2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 //#include <FShellNotificationManager.h>
31 #include "IntBookmarkData.h"
32 #include "IntBookmarkPresentationModel.h"
33 #include "IntCommonLib.h"
34 #include "IntFaviconManager.h"
35 #include "IntInternetApp.h"
36 #include "IntMainForm.h"
37 #include "IntSceneRegister.h"
38 #include "IntSettingPresentationModel.h"
40 using namespace Tizen::App;
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Base::Runtime;
44 using namespace Tizen::Base::Utility;
45 using namespace Tizen::Graphics;
46 using namespace Tizen::Io;
47 using namespace Tizen::Locales;
48 using namespace Tizen::Media;
49 using namespace Tizen::Shell;
50 using namespace Tizen::Ui;
51 using namespace Tizen::Ui::Controls;
52 using namespace Tizen::Content;
53 using namespace Tizen::Ui::Scenes;
54 using namespace Tizen::System;
55 using namespace Tizen::Web;
56 using namespace Tizen::Web::Controls;
58 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
60 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
61 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
66 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
67 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
68 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
69 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
70 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
71 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
73 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
74 static const wchar_t* IDS_APPID = L"AppID";
75 static const wchar_t* IDS_KEY = L"key";
76 static const wchar_t* IDS_VALUE = L"value";
77 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
78 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
79 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
81 const int IDA_BACKBTN_CLICKED = 101;
82 const int IDA_BOOKMARKBTN_CLICKED = 102;
83 const int IDA_MOREBTN_CLICKED = 103;
84 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
85 const int IDA_NEWWINDOWBTN_CLICKED = 105;
86 const int IDA_FORWARD_CLICKED = 106;
87 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
88 const int IDA_SHARE_CLICKED = 108;
89 const int IDA_FINDONPAGE_CLICKED = 109;
90 const int IDA_PRIVATEON_CLICKED = 110;
91 const int IDA_SETTINGS_CLICKED = 111;
92 const int IDA_READER_CLOSE_CLICKED = 112;
93 const int IDA_SMALLFONT_BTN_CLICKED = 113;
94 const int IDA_LARGEFONT_BTN_CLICKED = 114;
95 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
96 const int IDA_HISTORY_CLICKED = 116;
97 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
98 const int IDA_ADD_TO_HOME_CLICKED = 118;
99 const int IDA_SAVED_PAGES_CLICKED = 119;
100 const int IDA_DESKTOP_VIEW_CLICKED = 120;
101 const int IDA_SAVE_CLICKED = 121;
102 const int IDA_PRINT_CLICKED = 122;
104 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
105 const int IDA_FINDWORD_NEXT_CLICKED = 202;
106 const int IDA_FINDWORD_PREV_CLICKED = 203;
107 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
108 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
110 const int IDA_COPY_IMAGE_CLICKED = 206;
111 const int IDA_VIEW_IMAGE_CLICKED = 207;
112 const int IDA_SAVE_IMAGE_CLICKED = 208;
113 const int IDA_SHARE_IMAGE_CLICKED = 209;
115 const int IDA_COPY_TEXT_CLICKED = 210;
116 const int IDA_PASTE_TEXT_CLICKED = 211;
117 const int IDA_FIND_TEXT__CLICKED = 212;
118 const int IDA_SHARE_TEXT_CLICKED = 213;
120 const int IDA_GO_BACK = 214;
121 const int IDA_GO_FORWARD = 215;
122 const int IDA_REFRESH_BTN_CLICKED = 216;
123 const int IDA_STOP_BTN_CLICKED = 217;
124 const int IDA_CLEAR_URL = 218;
125 const int IDA_READER_BTN_CLICKED = 219;
128 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
129 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
130 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
131 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
133 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
135 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
137 const int MainForm::IDA_FORMAT_BITMAP = 500;
138 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
139 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
140 const int MainForm::IDA_FORMAT_URL_STRING = 503;
141 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
143 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
144 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
145 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
147 MainForm::MainForm(void)
149 //__isLongPressedDone = false;
151 __pAddressbar = null;
152 // __pMostVisitedSitesPanel = null;
153 __pMostVisitedListView = null;
154 __pFooterPanel = null;
155 __pHitElementResult = null;
156 __pWindowInfo = null;
159 __pOptionMenu = null;
160 __pFindWordControl = null;
161 __pFindWordPanelLeftToRight = null;
162 __pFindWordPanelRightToLeft = null;
163 __pFindWordBgLabel = null;
164 __pFindWordBgLabelRightToLeft = null;
165 __pFindWordEditField = null;
166 __pFindWordEditFieldRightToLeft = null;
167 __pFindWordClear = null;
168 __pFindWordClearRightToLeft = null;
169 __pFindWordCountLabel = null;
170 __pFindWordClearRightToLeft = null;
171 __pFindWordNext = null;
172 __pFindWordPrev = null;
173 __previousZoomLevel = 1.0;
175 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
178 __currentSearchStr = L"";
179 __currentSelectedStr = L"";
180 __maxOccurrances = 0;
181 __currentWordIndex = 0;
184 //__inputEventToBeSupressed = false;
185 __isLoadingData = false;
186 __isLoadingCompleted = false;
187 __progressPercentage = 0;
188 __touchPoint1 = Point(-1,-1);
189 __touchPoint2 = Point(-1,-1);
190 __longPressPoint = Point(-1,-1);
192 // __pReaderPopup = null;
193 __pReaderData = null;
195 __pReaderCloseBtn = null;
196 //__pNewWindowButton = null;
197 __pMoreButton = null;
198 __pMultiWindowButton = null;
199 __pArticleReaderPanel = null;
200 __pBlankPanel = null;
201 __pArticleReaderLabel = null;
202 __webControlHeight = 0;
203 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
204 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
205 __pMostVisitedSites = null;
206 __pFooterUrlField = null;
208 __pGoForwardBtn = null;
209 __pRefreshBtn = null;
210 __pProgressbarLabel = null;
211 __pFooterLabel = null;
215 __isWebKeypadOpened = false;
217 __pNotification = null;
220 MainForm::~MainForm(void)
222 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
226 __pAddressbar->SetAddressbarEventListener(null);
229 if(__pHistory != null)
235 if (__pReaderData != null)
237 delete __pReaderData;
238 __pReaderData = null;
241 if (__pPopUp != null)
247 if (__pHitElementResult != null)
249 delete __pHitElementResult;
250 __pHitElementResult = null;
254 delete __pOptionMenu;
255 __pOptionMenu = null;
258 String* pSelectedScene = NULL;
259 Object* pValue = NULL;
260 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
261 pSelectedScene = (String*) pValue;
263 /*if (pSelectedScene != null)
265 delete pSelectedScene;
267 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
271 MainForm::Initialize(void)
273 Construct(L"IDL_FORM");
275 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
280 MainForm::OnInitializing(void)
282 AppLog("get client area width = %d",GetClientAreaBounds().width);
283 AppLog("get client area height = %d",GetClientAreaBounds().height);
284 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
285 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
287 __fontSize = CommonUtil::GetFontSize();
288 Panel* pFooterPanel = null;
290 __pSaveImage = new Image();
291 __pSaveImage->Construct();
293 // Setup back event listener
294 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
295 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
296 AddOrientationEventListener(*this);
298 AppLogDebug(" MainForm::OnInitializing ended");
299 if (__pMostVisitedSites == null)
301 __pMostVisitedSites = new(std::nothrow) ArrayList();
302 __pMostVisitedSites->Construct();
304 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
306 __pItemContext= new(std::nothrow) ListContextItem();
307 __pItemContext->Construct();
309 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
312 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
313 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316 __pItemContextLandscape= new(std::nothrow) ListContextItem();
317 __pItemContextLandscape->Construct();
319 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
320 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
321 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
323 SetFormMenuEventListener(this);
324 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
329 MainForm::InitAddressbar(void)
331 AppLogDebug("MainForm::InitAddressbar entered");
333 result r = E_SUCCESS;
335 if (__pAddressbar != null)
339 __pAddressbar = new(std::nothrow) Addressbar();
340 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
341 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
344 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
347 __pAddressbar->SetAddressbarEventListener(this);
348 AddControl(__pAddressbar);
349 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
350 SetControlAlwaysOnTop(*__pAddressbar, true);
351 __adressPanelPosition = __pAddressbar->GetPosition();
353 AppLogDebug("MainForm::InitAddressbar exit");
359 MainForm::CreateReaderPanel(void)
361 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
362 result r = E_FAILURE;
364 Button *pSmallFontBtn = null;
365 Button *pLargeFontBtn = null;
367 __pBlankPanel = new (std::nothrow) Panel();
368 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
370 __pArticleReaderPanel = new (std::nothrow) Panel();
371 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
373 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
374 if (__pReaderCloseBtn)
376 AppLogDebug("CreateReaderPanel() 6");
377 __pReaderCloseBtn->AddActionEventListener(*this);
378 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
381 __pWebReader = new (std::nothrow) Web();
382 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
384 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
385 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
387 r = __pWebReader->SetSetting(settings);
389 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
392 __pArticleReaderLabel = new Label();
393 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
395 __pBlankPanel->AddControl(__pArticleReaderLabel);
396 __pBlankPanel->AddControl(__pArticleReaderPanel);
397 AddControl(__pBlankPanel);
399 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
400 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
401 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403 __pArticleReaderPanel->AddControl(__pWebReader);
404 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
405 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
406 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408 if (pBitmap != null && pSrcBitmap != null)
410 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
412 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
414 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
417 pSmallFontBtn->AddActionEventListener(*this);
418 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
421 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
424 pLargeFontBtn->AddActionEventListener(*this);
425 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
434 if (pSrcBitmap != null)
440 SetControlAlwaysOnTop(*__pBlankPanel, true);
441 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
448 MainForm::InitWebControl()
450 AppLogDebug("MainForm::InitWebControl enter");
451 result r = E_SUCCESS;
452 AppLogDebug("InitWebControl");
454 if (__pAddressbar == null || __pFooterPanel == null)
457 const int Y_WEBCONTROL_POSITION = 0;
459 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
461 if (__pMostVisitedListView)
463 __pMostVisitedListView->SetShowState(false);
465 if (__pWebViewer != null)
467 AppLogDebug("Already initialized");
470 __pWebViewer = new(std::nothrow) Web();
471 if(__pWebViewer == NULL)
473 AppLogDebug("Initialization failed");
476 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
480 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
487 r = AddControl(__pWebViewer);
493 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
496 __webControlPosition = __pWebViewer->GetPosition();
497 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
500 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
504 __pWebViewer->SetLoadingListener(this);
505 __pWebViewer->SetWebUiEventListenerF(this);
506 __pWebViewer->SetWebKeypadEventListener(this);
507 __pWebViewer->SetFocus();
508 __pWebViewer->AddTouchEventListener(*this);
510 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
511 __pWebViewer->SetTextSearchListener(this);
514 AppLogDebug("MainForm :before return");
516 AppLogDebug("MainForm::InitWebControl Exit");
522 MainForm::SetJavascriptEnabled()
524 WebSetting settings = __pWebViewer->GetSetting();
525 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
526 __pWebViewer->SetSetting(settings);
530 MainForm::SetImageLoadEnabled()
532 WebSetting settings = __pWebViewer->GetSetting();
533 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
534 __pWebViewer->SetSetting(settings);
538 MainForm::InitFooter(void)
540 AppLogDebug("MainForm::InitFooter entered");
541 Button* pBackButton = null;
542 Button* pBookmarkButton = null;
543 Button* pMultiWindowButton = null;
544 Bitmap *pIconBitmap = null;
545 Bitmap *pBGBitmap = null;
546 Label *pBGLabel = null;
548 if (__pFooterPanel == null)
550 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
553 if (__pFooterPanel == null)
558 SetControlAlwaysOnTop(*__pFooterPanel, true);
560 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
561 if ( __pFooterLabel == NULL )
565 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
566 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
569 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
573 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
575 if ( __pMultiWindowButton == NULL )
581 SetFormBackEventListener(this);
582 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
583 if (__pMultiWindowButton != null)
585 Bitmap* pBitmap = null;
586 Bitmap* pPressedBitmap = null;
587 String imagePath = "I01_toolbar_icon_windows_manager_0";
588 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
589 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
590 imagePath.Append(totalCount);
591 imagePath.Append(".png");
593 pressedImagePath.Append(totalCount);
594 pressedImagePath.Append("_press.png");
596 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
597 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
598 if ( pBitmap == null )
603 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
606 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
607 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
612 __pMultiWindowButton->AddActionEventListener(*this);
613 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
618 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
619 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
622 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
623 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
624 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
628 __pMoreButton->AddActionEventListener(*this);
629 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
632 //Add the editfield for url
633 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
634 if (__pFooterUrlField == NULL)
636 return E_INVALID_KEY;
639 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
640 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
641 __pFooterUrlField->AddKeypadEventListener(*this);
642 __pFooterUrlField->SetPropagatedTouchEventListener(this);
644 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
648 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
650 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
654 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
655 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
659 //Add the go Back Button
660 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
661 if (__pGoBackBtn == NULL)
663 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
664 return E_INVALID_KEY;
666 __pGoBackBtn->SetActionId(IDA_GO_BACK);
667 __pGoBackBtn->AddActionEventListener(*this);
669 //Add the go forward Button
670 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
671 if (__pGoForwardBtn == NULL)
673 AppLogDebug("Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
676 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
677 __pGoForwardBtn->AddActionEventListener(*this);
678 if (__pWebViewer && __pWebViewer->CanGoForward())
680 SetForwardButtonEnabled(true);
684 SetForwardButtonEnabled(false);
687 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
688 if (__pRefreshBtn == NULL)
690 AppLogDebug("Control not found returning E_INVALID_KEY");
691 return E_INVALID_KEY;
694 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
695 __pRefreshBtn->AddActionEventListener(*this);
696 __pRefreshBtn->SetShowState(true);
698 //Add the backround label for displaying progressbar
699 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
700 if (__pProgressbarLabel == NULL)
702 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
703 return E_INVALID_KEY;
705 __pProgressbarLabel->SetShowState(false);
707 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
708 if (__pStopBtn == NULL)
710 AppLogDebug("Control not found returning E_INVALID_KEY");
711 return E_INVALID_KEY;
713 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
714 __pStopBtn->AddActionEventListener(*this);
715 __pStopBtn->SetShowState(false);
717 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
718 if (__pClearBtn == NULL)
720 AppLogDebug("Control not found returning E_INVALID_KEY");
721 return E_INVALID_KEY;
723 __pClearBtn->SetActionId(IDA_CLEAR_URL);
724 __pClearBtn->AddActionEventListener(*this);
725 __pClearBtn->SetShowState(false);
727 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
728 if (__pReaderBtn == NULL)
730 AppLogDebug("Control not found returning E_INVALID_KEY");
731 return E_INVALID_KEY;
733 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
734 __pReaderBtn->AddActionEventListener(*this);
735 __pReaderBtn->SetShowState(false);
737 // __pFooterPanel->Invalidate(true);
738 AppLogDebug("MainForm::InitFooter exit");
743 MainForm::InitOptionMenu()
745 result r = E_SUCCESS;
746 bool isPrivateBrowsing = false;
747 Bitmap* pBitmap = null;
749 if (__pOptionMenu != null)
751 __pOptionMenu->Invalidate(true);
755 __pOptionMenu = new(std::nothrow) OptionMenu();
756 r = __pOptionMenu->Construct();
757 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
759 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
762 if (isPrivateBrowsing == true)
764 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
768 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
771 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
773 if ( pBitmap != NULL)
775 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
778 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
779 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
780 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
783 __pOptionMenu->SetMaxVisibleItemsCount(6);
784 __pOptionMenu->SetShowState(false);
785 __pOptionMenu->AddActionEventListener(*this);
786 SetControlAlwaysOnTop(*__pOptionMenu, true);
792 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
794 result r = E_SUCCESS;
795 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
797 AppLog("MainForm::InitImageContextMenu clicked on image");
798 if (__pImageMenu != null)
803 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
808 __pImageMenu = new (std::nothrow) ContextMenu();
809 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
810 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
812 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
813 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
814 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
815 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
816 __pImageMenu->SetMaxVisibleItemsCount(4);
817 __pImageMenu->AddActionEventListener(*this);
818 SetControlAlwaysOnTop(*__pImageMenu, true);
824 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
826 result r = E_SUCCESS;
827 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
829 AppLog("MainForm::InitImageContextMenu clicked on image");
830 if (__pImageMenu != null)
836 // if(__pAddressbar->GetShowState() == true)
837 // p.y = p.y + __pAddressbar->GetHeight();
838 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
843 __pImageMenu = new (std::nothrow) ContextMenu();
844 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
845 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
847 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
848 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
849 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
850 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
852 __pImageMenu->SetMaxVisibleItemsCount(3);
853 __pImageMenu->AddActionEventListener(*this);
854 SetControlAlwaysOnTop(*__pImageMenu, true);
861 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
863 result r = E_SUCCESS;
864 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
866 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
867 if (__pImageMenu != null)
876 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
880 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
882 __pImageMenu = new (std::nothrow) ContextMenu();
883 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
884 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
886 if(onlyPasteOption == false)
888 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
890 if (pasteOption || onlyPasteOption)
892 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
894 if(onlyPasteOption == false)
896 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
897 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
900 __pImageMenu->SetMaxVisibleItemsCount(3);
901 __pImageMenu->AddActionEventListener(*this);
902 SetControlAlwaysOnTop(*__pImageMenu, true);
909 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
911 result r = E_SUCCESS;
912 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
914 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
915 if (__pImageMenu != null)
924 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
928 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
930 __pImageMenu = new (std::nothrow) ContextMenu();
931 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
932 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
934 if(onlyPasteOption == false)
936 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
938 if (pasteOption || onlyPasteOption)
940 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
942 if(onlyPasteOption == false)
944 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
945 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
948 __pImageMenu->SetMaxVisibleItemsCount(3);
949 __pImageMenu->AddActionEventListener(*this);
950 SetControlAlwaysOnTop(*__pImageMenu, true);
957 MainForm::InitFindWordPanel(void)
959 result r = E_SUCCESS;
960 Bitmap *pIconBitmap = null;
962 if (__pFindWordControl != null)
964 AppLogDebug("Findword panel already initialized");
965 if (__pFindWordBgLabel != null)
967 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
970 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
974 if (__pFindWordBgLabelRightToLeft != null)
976 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
979 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
986 __pFindWordControl = new (std::nothrow) Panel();
987 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
990 AppLogException("There is some problem in the xml file. Please check.");
993 AddControl(__pFindWordControl);
994 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
995 SetControlAlwaysOnTop(*__pFindWordControl,true);
996 __pFindWordControl->SetShowState(false);
997 __pFindWordControl->Invalidate(false);
999 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1000 __pFindWordPanelLeftToRight->SetShowState(true);
1002 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1003 __pFindWordPanelRightToLeft->SetShowState(false);
1005 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1006 if (__pFindWordBgLabel != null)
1008 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1009 Rectangle pRect = pPanel1->GetBounds();
1010 pRect.x = pRect.y = 0;
1011 __pFindWordBgLabel->SetBounds(pRect);
1012 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1013 if (pBitmap != null)
1015 AppLogDebug("InitFindWordPanel: Coming here");
1016 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1021 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1025 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1026 if (__pFindWordBgLabelRightToLeft != null)
1028 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1029 Rectangle pRect = pPanel1->GetBounds();
1030 pRect.x = pRect.y = 0;
1031 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1032 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1033 if (pBitmap != null)
1035 AppLogDebug("InitFindWordPanel: Coming here");
1036 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1041 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1045 Button* pfindWordCancel = null;
1046 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1047 if (pfindWordCancel == null)
1049 AppLogException("There is some problem in the xml file. Please check.");
1052 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1053 pfindWordCancel->AddActionEventListener(*this);
1055 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1056 if (__pFindWordClear == null)
1058 AppLogException("There is some problem in the xml file. Please check.");
1062 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1063 if (__pFindWordClearRightToLeft == null)
1065 AppLogException("There is some problem in the xml file. Please check.");
1069 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1070 __pFindWordClear->AddActionEventListener(*this);
1072 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1073 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1075 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1076 if (__pFindWordNext == null)
1078 AppLogException("There is some problem in the xml file. Please check.");
1082 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1083 __pFindWordNext->AddActionEventListener(*this);
1085 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1086 if (__pFindWordPrev == null)
1088 AppLogException("There is some problem in the xml file. Please check.");
1092 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1093 __pFindWordPrev->AddActionEventListener(*this);
1095 __pFindWordNext->SetEnabled(false);
1096 __pFindWordPrev->SetEnabled(false);
1098 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1099 if (__pFindWordCountLabel == null)
1101 AppLogException("There is some problem in the xml file. Please check.");
1105 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1106 if (__pFindWordCountLabel == null)
1108 AppLogException("There is some problem in the xml file. Please check.");
1112 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1113 if (__pFindWordEditField == null)
1115 AppLogException("There is some problem in the xml file. Please check.");
1118 __pFindWordEditField->AddTextEventListener(*this);
1119 __pFindWordEditField->AddKeypadEventListener(*this);
1120 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1122 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1123 if (__pFindWordEditFieldRightToLeft == null)
1125 AppLogException("There is some problem in the xml file. Please check.");
1128 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1129 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1130 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1136 MainForm::CreateItem (int index, int itemWidth)
1138 Rectangle listImageRect;
1139 Rectangle pagetTitleRect;
1140 Rectangle pageURLRect;
1141 Rectangle deleteImageRect;
1142 String pageTitle(L"");
1143 String pageURL(L"");
1144 result r = E_SUCCESS;
1145 Bitmap* pListIconImage = null;
1148 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1149 if(pHistory == null)
1153 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1154 if ( pAppResource == NULL )
1158 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1160 CustomItem* pItem = new(std::nothrow) CustomItem();
1161 pageTitle = pHistory->GetHistoryTitle();
1162 pageURL = pHistory->GetHistoryUrl();
1164 if (pageURL.GetLength() == 0)
1167 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1168 pageURL = L"<"+ nourl +">";
1172 Rectangle screenBounds = GetBounds();
1175 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1184 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1186 if ( pBitmap != NULL)
1188 pListIconImage = new Bitmap();
1189 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1193 if(pListIconImage == null)
1195 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1198 if ( pListIconImage != NULL)
1200 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1201 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1202 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1205 if (pItem != null && pListIconImage != NULL)
1207 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1211 if (pageTitle.CompareTo(L"") != 0)
1215 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1219 if (pageURL.CompareTo(L"") != 0)
1223 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1228 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1230 if ( __pItemContext!= NULL)
1234 pItem->SetContextItem(__pItemContext);
1240 if ( __pItemContextLandscape!= NULL)
1244 pItem->SetContextItem(__pItemContextLandscape);
1248 if( pListIconImage != NULL)
1250 delete pListIconImage;
1251 pListIconImage = null;
1258 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1265 MainForm::GetItemCount (void)
1267 if(__pMostVisitedSites != null)
1269 __pMostVisitedSites->RemoveAll(true);
1271 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1272 if(__pMostVisitedSites != null)
1274 return __pMostVisitedSites->GetCount();
1281 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1283 if(__pMostVisitedSites != null)
1285 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1286 if (pHistory != null)
1288 String url = pHistory->GetHistoryUrl();
1290 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1291 __pMostVisitedListView->UpdateList();
1297 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1299 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1300 String url = pHistory->GetHistoryUrl();
1308 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1314 MainForm::OnTerminating(void)
1316 result r = E_SUCCESS;
1318 RemoveOrientationEventListener(*this);
1322 __pAddressbar->SetAddressbarEventListener(null);
1327 __pWebViewer->RemoveTouchEventListener(*this);
1332 delete __pItemContext;
1334 if(__pItemContextLandscape)
1336 delete __pItemContextLandscape;
1342 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1344 result r = E_SUCCESS;
1346 AppLogDebug("Clicked : %d", actionId);
1349 case IDA_BACKBTN_CLICKED:
1351 if (__pWebViewer && __pWebViewer->CanGoBack())
1353 __pWebViewer->GoBack();
1355 else if(__pWindowInfo->isJavascriptInitiated == false)
1358 pApp = UiApp::GetInstance();
1361 r = pApp->Terminate();
1364 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1372 WindowInfo* pWindowInfo = null;
1374 SceneManager* pSceneManager = SceneManager::GetInstance();
1375 if (pSceneManager == null)
1379 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1380 if (pAllWindowList == NULL)
1382 pApp = UiApp::GetInstance();
1385 r = pApp->Terminate();
1388 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1393 if (pAllWindowList != null)
1395 totalCount = pAllWindowList->GetCount();
1397 for (int count = 0; count < totalCount; count++)
1399 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1400 if (pWindowInfo == null)
1402 pApp = UiApp::GetInstance();
1405 r = pApp->Terminate();
1408 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1415 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1417 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1420 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1423 r = pAllWindowList->RemoveAt(count, true);
1424 __pWindowInfo = null;
1427 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1432 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1436 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1438 if (pWindowInfo == null)
1440 pApp = UiApp::GetInstance();
1443 r = pApp->Terminate();
1449 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1452 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1464 case IDA_FORWARD_CLICKED:
1465 if (__pWebViewer == null)
1468 if (__pWebViewer->CanGoForward())
1470 __pWebViewer->GoForward();
1472 __pOptionMenu->SetShowState(false);
1473 __pOptionMenu->Invalidate(false);
1476 case IDA_FINDONPAGE_CLICKED:
1478 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1479 __currentSearchStr.Clear();
1481 InitFindWordPanel();
1482 __pOptionMenu->SetShowState(false);
1483 __pOptionMenu->Invalidate(false);
1485 ShowFindWordPanel(true);
1487 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1489 __pFindWordEditField->SetFocus();
1490 __pFindWordCountLabel->SetShowState(false);
1494 __pFindWordEditFieldRightToLeft->SetFocus();
1495 __pFindWordCountLabelRightToLeft->SetShowState(false);
1499 case IDA_PRIVATEON_CLICKED:
1501 result r = E_SUCCESS;
1503 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1504 Bitmap* pBitmap = null;
1505 if (isPrivateBrowsing == true)
1507 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1510 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1514 if (__pWebViewer != NULL)
1516 __pWebViewer->SetPrivateBrowsingEnabled(false);
1519 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1521 if (__pAddressbar != null)
1523 __pAddressbar->UpdateFaviconBitmap(false);
1529 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1532 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1536 if (__pWebViewer != NULL)
1538 __pWebViewer->SetPrivateBrowsingEnabled(true);
1541 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1543 if (__pAddressbar != null)
1545 __pAddressbar->UpdateFaviconBitmap(true);
1549 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1550 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1551 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1552 __pOptionMenu->Invalidate(true);
1553 if ( pBitmap != NULL )
1560 case IDA_SETTINGS_CLICKED:
1563 ArrayList* pArgList = new(std::nothrow) ArrayList();
1566 pArgList->Construct();
1567 pArgList->Add(*__pWindowInfo);
1568 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1570 __pOptionMenu->SetShowState(false);
1571 __pOptionMenu->Invalidate(false);
1573 if (pArgList != null)
1582 case IDA_ADDTOBOOKMARK_CLICKED:
1585 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1587 int bookmarkCount=0;
1590 url=__pWindowInfo->pageUrl;
1591 result r = E_SUCCESS;
1592 Bitmap* pBitmap = null;
1593 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1601 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1602 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1603 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1605 if(__pNotification != null)
1607 RemoveControl(__pNotification);
1608 __pNotification = null;
1610 __pNotification = new (std::nothrow) NotificationPanel(*this);
1611 if (__pNotification != null)
1613 __pNotification->SetText(message);
1614 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1615 __pNotification->ShowNotification();
1620 String title=__pWindowInfo->pageTitle;
1621 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1622 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1624 pBookmark->SetBookmarkTitle(title);
1625 pBookmark->SetUrl(url);
1626 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1628 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1630 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1631 pBookmark->SetFaviconId(id);
1632 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1633 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1635 if(__pNotification != null)
1637 RemoveControl(__pNotification);
1638 __pNotification = null;
1640 __pNotification = new (std::nothrow) NotificationPanel(*this);
1641 if (__pNotification != null)
1643 __pNotification->SetText(message);
1644 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1645 __pNotification->ShowNotification();
1646 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1649 if (pBitmap != null)
1651 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1656 __pOptionMenu->Invalidate(true);
1661 case IDA_PRINT_CLICKED:
1663 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1664 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1666 AppLog("RequestPrint called!");
1667 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1668 result nResult = E_FAILURE;
1671 AppLog("TestPrint if (pAc) == true");
1676 String fileType = L"service_print_files_type";
1677 String typeVal = L"DOC";
1679 String fileCount = L"service_print_files_count";
1680 String countVal = L"1";
1681 String fileFolder= L"service_print_files_folder_name";
1682 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1684 map.Add(&fileCount, &countVal);
1685 map.Add(&fileFolder, &folderVal);
1686 map.Add(&fileType, &typeVal);
1688 String fileName = L"service_print_files_files_name";
1690 ArrayList fileNameList;
1691 fileNameList.Construct();
1692 String file1 = L"test.pdf";
1694 fileNameList.Add(&file1);
1695 map.Add(&fileName, &fileNameList);
1697 nResult = pAc->Start(NULL, NULL, &map, NULL);
1699 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1700 else if (nResult == E_MAX_EXCEEDED)
1701 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1702 else if (nResult == E_OBJ_NOT_FOUND)
1703 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1704 else if (nResult == E_IN_PROGRESS)
1705 AppLog("TestPrint ret == E_IN_PROGRESS");
1706 else if (nResult == E_PRIVILEGE_DENIED)
1707 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1708 else if(nResult == E_SYSTEM)
1709 AppLog("TestPrint ret == E_SYSTEM");
1715 int __modalMsgBoxResult;
1716 MessageBox* pMsgBox = new MessageBox();
1717 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1718 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1721 __modalMsgBoxResult = 0;
1725 case IDA_SHARE_CLICKED:
1727 if(__pPopUp != null)
1734 __pAddressbar->HideKeypad();
1736 __pPopUp = new(std::nothrow) SharePopup();
1737 __pPopUp->Initialize();
1738 if (__pWindowInfo != null)
1740 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1741 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1742 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1743 pShareInfo->SetImageAttached(false);
1744 __pPopUp->RemoveAllShareInfo();
1745 __pPopUp->AddShareInfo(pShareInfo);
1747 __pPopUp->SetShowState(true);
1751 case IDA_BOOKMARKBTN_CLICKED:
1753 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1754 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1757 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1762 case IDA_MOREBTN_CLICKED:
1764 AppLog("IDA_MOREBTN_CLICKED");
1766 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1768 int bookmarkCount=0;
1771 url=__pWindowInfo->pageUrl;
1772 result r = E_SUCCESS;
1773 Bitmap* pBitmap = null;
1775 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1778 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1783 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1787 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1789 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1791 if (__pOptionMenu->GetItemCount() == 9)
1793 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1797 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1802 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1806 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1807 if (__pOptionMenu->GetItemCount() != 9)
1809 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1810 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1811 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1812 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1813 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1814 __pOptionMenu->SetMaxVisibleItemsCount(6);
1816 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1818 AppLog(" Orientation landscape");
1819 __pOptionMenu->SetMaxVisibleItemsCount(5);
1823 AppLog(" Orientation potrait");
1824 __pOptionMenu->SetMaxVisibleItemsCount(6);
1827 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1830 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1831 __pOptionMenu->SetShowState(true);
1832 __pOptionMenu->Invalidate(true);
1833 __pOptionMenu->Show();
1837 case IDA_HISTORY_CLICKED:
1839 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1840 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1843 case IDA_SAVED_PAGES_CLICKED:
1848 case IDA_DESKTOP_VIEW_CLICKED:
1853 case IDA_SAVE_CLICKED:
1858 case IDA_MULTIWINDOWBTN_CLICKED:
1860 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1861 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1865 case IDA_NEWWINDOWBTN_CLICKED:
1867 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1869 if (pNewWindowInfo == null)
1873 result r = E_SUCCESS;
1874 SceneManager* pSceneManager = SceneManager::GetInstance();
1876 if (pSceneManager == NULL)
1880 ArrayList* pArgList = new(std::nothrow) ArrayList();
1881 if (pArgList == NULL)
1885 r = pArgList->Construct();
1888 pArgList->Add(*pNewWindowInfo);
1889 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1895 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1900 case IDA_SMALLFONT_BTN_CLICKED:
1902 WebSetting setting = __pWebReader->GetSetting();
1903 setting.SetFontSize(15);
1904 __pWebReader->SetSetting(setting);
1907 case IDA_LARGEFONT_BTN_CLICKED:
1909 WebSetting setting = __pWebReader->GetSetting();
1910 setting.SetFontSize(25);
1911 __pWebReader->SetSetting(setting);
1914 case IDA_READER_CLOSE_CLICKED:
1916 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1918 RemoveControl(__pBlankPanel);
1919 __pArticleReaderPanel = null;
1920 __pBlankPanel = null;
1921 __pArticleReaderLabel = null;
1923 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1926 case IDA_FINDWORD_CANCEL_CLICKED:
1928 __currentSearchStr = L"";
1929 __currentWordIndex = 0;
1930 __maxOccurrances = 0;
1932 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1934 __pFindWordEditField->SetText(L"");
1935 __pFindWordCountLabel->SetText(L"0/0");
1937 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1939 __pFindWordEditFieldRightToLeft->SetText(L"");
1940 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1943 __pFindWordNext->SetEnabled(false);
1944 __pFindWordPrev->SetEnabled(false);
1945 __pFindWordCountLabel->SetText(L"0/0");
1946 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1947 AppLog("akjshdasd 1");
1948 __pFooterPanel->SetShowState(true);
1949 ShowFindWordPanel(false);
1952 case IDA_FINDWORD_SEARCH_CLICKED:
1954 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1956 __currentSearchStr = __pFindWordEditField->GetText();
1958 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1960 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1963 if (__currentSearchStr.GetLength() > 0)
1969 AppLogDebug("Enter something");
1973 case IDA_FINDWORD_CLEAR_CLICKED:
1975 __pFindWordCountLabel->SetText(L"0/0");
1976 __pFindWordEditField->SetText(L"");
1977 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1979 __currentSearchStr = L"";
1980 __pFindWordNext->SetEnabled(false);
1981 __pFindWordPrev->SetEnabled(false);
1982 __pFindWordCountLabel->SetShowState(false);
1983 __pFindWordControl->Invalidate(true);
1986 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1988 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1989 __pFindWordEditFieldRightToLeft->SetText(L"");
1990 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1992 __currentSearchStr = L"";
1993 __pFindWordNext->SetEnabled(false);
1994 __pFindWordPrev->SetEnabled(false);
1995 __pFindWordCountLabelRightToLeft->SetShowState(false);
1996 __pFindWordControl->Invalidate(true);
1999 case IDA_FINDWORD_NEXT_CLICKED:
2004 case IDA_FINDWORD_PREV_CLICKED:
2006 FindNextWord(false);
2009 case IDA_BRIGHTNESS_BTN_CLICKED:
2011 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2012 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2015 case IDA_COPY_IMAGE_CLICKED:
2017 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2018 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2020 const Bitmap* pBitmap = null;
2021 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2023 pBitmap = __pHitElementResult->GetImage();
2026 String resourcePath = App::GetInstance()->GetAppResourcePath();
2027 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2028 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2029 // copying the item to clipboard
2030 Clipboard* pClipboard = Clipboard::GetInstance();
2031 if (pClipboard != null)
2033 r = pClipboard->CopyItem(item);
2034 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2038 case IDA_VIEW_IMAGE_CLICKED:
2040 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2041 WindowInfo* pNewWindowInfo = null;
2042 if (__pHitElementResult != null)
2044 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2045 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2051 case IDA_SAVE_IMAGE_CLICKED:
2053 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2054 const Bitmap* pSaveBitmap = null;
2055 String imageName = GetImagePath();
2056 AppLog("Content manager image name %ls",imageName.GetPointer());
2059 imagePath.Append(imageName);
2060 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2061 AppLog("Content manager image path %ls",imagePath.GetPointer());
2062 if (__pHitElementResult != null)
2064 pSaveBitmap = __pHitElementResult->GetImage();
2066 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2070 UpdateImageContent(pBuffer, imageName);
2072 if(__pNotification != null)
2074 RemoveControl(__pNotification);
2075 __pNotification = null;
2077 __pNotification = new NotificationPanel(*this);
2079 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2080 msg.Append(imagePath);
2081 if (__pNotification != null)
2083 __pNotification->SetText(msg);
2084 if (__pFooterPanel->GetShowState() == true)
2086 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2090 __pNotification->SetPositionDiff(0);
2093 __pNotification->ShowNotification();
2098 int __modalMsgBoxResult;
2099 MessageBox* pMsgBox = new MessageBox();
2100 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2101 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2104 __modalMsgBoxResult = 0;
2108 case IDA_SHARE_IMAGE_CLICKED:
2110 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2111 if (__pPopUp != null)
2118 __pAddressbar->HideKeypad();
2120 __pPopUp = new(std::nothrow) SharePopup();
2121 __pPopUp->Initialize();
2122 if (__pHitElementResult != null)
2124 const Bitmap* pSaveBitmap = null;
2125 String imageName = GetImagePath();
2126 AppLog("Content manager image name %ls",imageName.GetPointer());
2129 imagePath.Append(imageName);
2130 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2131 AppLog("Content manager image path %ls",imagePath.GetPointer());
2132 if (__pHitElementResult != null)
2134 pSaveBitmap = __pHitElementResult->GetImage();
2136 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2138 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2139 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2141 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2142 pShareInfo->SetPageTitle(L"");
2143 pShareInfo->SetPageUrl(srcUrl);
2144 pShareInfo->SetImageAttached(true);
2145 pShareInfo->SetImagePath(imagePath);
2146 __pPopUp->RemoveAllShareInfo();
2147 __pPopUp->AddShareInfo(pShareInfo);
2148 __pPopUp->SetShowState(true);
2153 case IDA_HYPERLINK_OPEN_CLICKED:
2155 if (__pHitElementResult != null)
2157 String srcUrl = __pHitElementResult->GetUrl();
2159 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2161 if (pNewWindowInfo == null)
2165 result r = E_SUCCESS;
2166 SceneManager* pSceneManager = SceneManager::GetInstance();
2167 if (pSceneManager == NULL)
2171 ArrayList* pArgList = new(std::nothrow) ArrayList();
2172 if (pArgList == NULL)
2176 pArgList->Construct();
2178 pArgList->Add(*pNewWindowInfo);
2179 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2180 if (pArgList != null)
2187 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2193 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2195 if (__pHitElementResult == null)
2200 if(__pPopUp != null)
2207 __pAddressbar->HideKeypad();
2209 __pPopUp = new(std::nothrow) SharePopup();
2210 __pPopUp->Initialize();
2212 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2213 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2214 pShareInfo->SetImageAttached(false);
2215 __pPopUp->RemoveAllShareInfo();
2216 __pPopUp->AddShareInfo(pShareInfo);
2218 __pPopUp->SetShowState(true);
2222 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2226 if (__pHitElementResult != null)
2228 url = __pHitElementResult->GetUrl();
2231 String resourcePath = App::GetInstance()->GetAppResourcePath();
2232 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2234 // copying the item to clipboard
2235 Clipboard* pClipboard = Clipboard::GetInstance();
2236 if (pClipboard != null)
2238 pClipboard->CopyItem(item);
2242 case IDA_FIND_TEXT__CLICKED:
2244 // AddressBarCancelledClicked(*__pAddressbar);
2245 RelayoutControls(false);
2246 // __pFooterPanel->SetShowState(false);
2247 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2248 __currentSearchStr.Clear();
2249 __currentSearchStr.Append(__currentSelectedStr);
2250 InitFindWordPanel();
2251 __pFindWordEditField->SetText(__currentSearchStr);
2253 if(__pOptionMenu != null)
2255 __pOptionMenu->SetShowState(false);
2256 __pOptionMenu->Invalidate(false);
2258 __adressPanelPosition.y = 0;
2260 if (__pAddressbar != null && __pWebViewer != NULL)
2262 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2263 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2265 if (__pFooterPanel->GetShowState() == false)
2266 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2268 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2269 __pWebViewer->Invalidate(true);
2272 ShowFindWordPanel(true);
2273 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2275 __pFindWordEditField->SetText(__currentSearchStr);
2276 __pFindWordEditField->SetFocus();
2278 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2280 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2281 __pFindWordEditFieldRightToLeft->SetFocus();
2284 if (__currentSearchStr.GetLength() > 0)
2290 AppLogDebug("Enter something");
2293 if (__pWebViewer != null)
2295 // releasing the set block
2296 __pWebViewer->ReleaseBlock();
2301 case IDA_SHARE_TEXT_CLICKED:
2303 __pWebViewer->ReleaseBlock();
2304 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2305 if(__pPopUp != null)
2312 __pAddressbar->HideKeypad();
2314 __pPopUp = new(std::nothrow) SharePopup();
2315 __pPopUp->Initialize();
2316 if (__pHitElementResult != null)
2318 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2319 pShareInfo->SetPageTitle(L"");
2320 pShareInfo->SetPageUrl(__currentSelectedStr);
2321 pShareInfo->SetImageAttached(false);
2322 __pPopUp->RemoveAllShareInfo();
2323 __pPopUp->AddShareInfo(pShareInfo);
2324 __pPopUp->SetShowState(true);
2329 case IDA_COPY_TEXT_CLICKED:
2331 __pWebViewer->ReleaseBlock();
2332 // need to implement
2333 //__currentSelectedStr
2334 // Sets data to a clip board item
2336 String resourcePath = App::GetInstance()->GetAppResourcePath();
2337 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2339 // copying the item to clipboard
2340 Clipboard* pClipboard = Clipboard::GetInstance();
2341 if (pClipboard != null)
2343 pClipboard->CopyItem(item);
2347 case IDA_PASTE_TEXT_CLICKED:
2349 Clipboard* pClipboard = Clipboard::GetInstance();
2351 if(pClipboard == null)
2355 // Retrieves a latest item
2356 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2362 //Gets data from the clipboard item
2363 String* pString = dynamic_cast<String*>(pItem->GetData());
2365 if (pString != null)
2367 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2368 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2369 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2372 if(idElement.GetLength() != 0)
2374 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } ";
2375 script.Append("insertAtCursor('");
2376 script.Append(idElement);
2377 script.Append("',");
2378 script.Append("\"");
2379 script.Append(*pString);
2380 script.Append("\");");
2382 else if (nameElement.GetLength() != 0)
2384 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementByName(myField)[0].value += myValue; } } ";
2385 script.Append("insertAtCursor(document.getElementsByName('");
2386 script.Append(nameElement);
2387 script.Append("')[0],");
2388 script.Append("\"");
2389 script.Append(*pString);
2390 script.Append("\");");
2392 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2393 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2404 case IDA_GO_FORWARD:
2409 case IDA_REFRESH_BTN_CLICKED:
2411 __isLoadingCompleted = false;
2412 __isLoadingData = true;
2413 __progressPercentage = 0;
2414 __displayUrl = __pFooterUrlField->GetText();
2416 String url = __pFooterUrlField->GetText();
2417 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2419 if (__pWebViewer != null && __pAddressbar != null)
2421 __pWebViewer->Reload();
2422 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2426 UpdateProgressBitmap();
2429 case IDA_STOP_BTN_CLICKED:
2431 __isLoadingCompleted = false;
2432 __isLoadingData = false;
2433 __progressPercentage = 0;
2434 __pFooterUrlField->HideKeypad();
2435 __displayUrl = __pFooterUrlField->GetText();
2439 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2440 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2441 __pWebViewer->StopLoading();
2442 RequestRedraw(true);
2445 UpdateProgressBitmap();
2450 if (__pFooterUrlField->GetText().IsEmpty() == false)
2452 //__displayUrl = __pUrlField->GetText();
2453 __pFooterUrlField->Clear();
2458 case IDA_READER_BTN_CLICKED:
2469 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2471 result r = E_FAILURE;
2472 if (__pWebViewer && __pWebViewer->CanGoBack())
2474 __pWebViewer->GoBack();
2476 else if(__pWindowInfo->isJavascriptInitiated == false)
2479 pApp = UiApp::GetInstance();
2482 r = pApp->Terminate();
2485 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2493 WindowInfo* pWindowInfo = null;
2495 SceneManager* pSceneManager = SceneManager::GetInstance();
2496 if (pSceneManager == null)
2500 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2501 if (pAllWindowList == NULL)
2503 pApp = UiApp::GetInstance();
2506 r = pApp->Terminate();
2509 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2514 if (pAllWindowList != null)
2516 totalCount = pAllWindowList->GetCount();
2518 for (int count = 0; count < totalCount; count++)
2520 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2521 if (pWindowInfo == null)
2523 pApp = UiApp::GetInstance();
2526 r = pApp->Terminate();
2529 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2536 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2538 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2541 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2544 r = pAllWindowList->RemoveAt(count, true);
2545 __pWindowInfo = null;
2548 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2553 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2557 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2559 if (pWindowInfo == null)
2561 pApp = UiApp::GetInstance();
2564 r = pApp->Terminate();
2570 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2573 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2585 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2586 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2589 AppLog("MainForm::OnSceneActivatedN called");
2590 String* pSelectedScene = NULL;
2591 Object* pValue = NULL;
2592 String* pUrl = null;
2593 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2594 pSelectedScene = (String*) pValue;
2596 if (pSelectedScene != null)
2598 delete pSelectedScene;
2600 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2601 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2602 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2603 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2605 // setting the current scene ID
2606 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2608 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2610 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2612 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2613 if(__pWindowInfo == null)
2615 // if(__pWindowInfo == null)
2617 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2620 else if ( pArgs != null && pArgs->GetCount() == 1)
2622 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2628 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2630 // hiding the address bar
2631 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2632 __pAddressbar->SetShowState(false);
2633 // if(__pWebViewer != null)
2635 // __pWebViewer->Resume();
2638 if(pUrl != null && pUrl->GetLength() > 0)
2642 else if(__pWindowInfo != null)
2644 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2646 LoadUrl(__pWindowInfo->pageUrl);
2648 else if (__pWindowInfo->isJavascriptInitiated == true)
2652 __pWindowInfo->pCurrentWeb = __pWebViewer;
2656 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2657 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2658 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2660 InitMostVisitedSitesView(GetOrientationStatus());
2662 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2664 if(__pMostVisitedListView != null)
2666 __pMostVisitedListView->SetShowState(false);
2670 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2672 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2674 if (pBookmarkUrl == null)
2676 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2677 //__pAddressbar->SetUrl(*pBookmarkUrl);
2678 SetUrl(*pBookmarkUrl);
2680 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2681 __pWebViewer->LoadUrl(*pBookmarkUrl);
2682 delete pBookmarkUrl;
2685 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2686 Bitmap* pBitmap = null;
2687 if (isPrivateBrowsing == true)
2689 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2691 if (__pWebViewer != null)
2693 __pWebViewer->SetPrivateBrowsingEnabled(true);
2696 if (__pAddressbar != null)
2698 // __pAddressbar->UpdateFaviconBitmap(true);
2704 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2706 if (__pWebViewer != null)
2708 __pWebViewer->SetPrivateBrowsingEnabled(false);
2711 if (__pAddressbar != null)
2713 // __pAddressbar->UpdateFaviconBitmap(false);
2717 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2719 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2721 else if (__pOptionMenu != null )
2723 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2726 if (pBitmap != null)
2731 AppLog("ABC: OnSceneActivatedN started exit");
2736 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2737 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2739 Canvas* pWebCanvas = null;
2740 if (__pWebViewer != null)
2742 pWebCanvas = __pWebViewer->GetCanvasN();
2745 if (pWebCanvas == null)
2749 if (__pWindowInfo != null)
2751 if (__pWindowInfo->pWebCanvasBitmap != null)
2753 delete __pWindowInfo->pWebCanvasBitmap;
2755 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2756 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2757 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2759 Bitmap* pBitmap = GetCapturedBitmapN();
2760 AppLog("Coming here");
2761 Canvas* pCanvas = new(std::nothrow) Canvas();
2762 pCanvas->Construct(GetClientAreaBounds());
2765 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2768 if(__pWebViewer != null && __pWindowInfo != null)
2769 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2771 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2772 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2774 AppLog("Coming here");
2778 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2779 const Tizen::Base::String& realm,
2780 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2786 MainForm::OnHttpAuthenticationCanceled(void)
2791 MainForm::OnLoadingStarted(void)
2793 AppLogDebug("MainForm::OnLoadingStarted entered");
2795 if(__pAddressbar == NULL || __pWebViewer == null)
2800 // this is added in case if menu is opened and user load the page
2801 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2803 __pOptionMenu->SetShowState(false);
2804 __pOptionMenu->Invalidate(true);
2809 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2811 __pImageMenu->SetShowState(false);
2812 __pImageMenu->Invalidate(true);
2814 String url = __pWebViewer->GetUrl();
2815 if(url.Contains(IDS_TIZEN_SERVICE))
2818 String delim(L":;,");
2820 // Creates a StringTokenizer instance
2821 StringTokenizer strTok(url, delim);
2823 int count = strTok.GetTokenCount(); // count == 4
2825 HashMap *pMap = new HashMap();
2830 while (strTok.HasMoreTokens())
2832 AppLog("Token: %ls", token.GetPointer());
2833 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2834 if(token.Contains(IDS_APPID))
2836 token.SubString(6, appId);
2837 AppLog("AppID:%ls", appId.GetPointer());
2839 else if(token.Contains(IDS_KEY))
2841 token.SubString(4, key);
2842 AppLog("key:%ls", key.GetPointer());
2844 else if(token.Contains(IDS_VALUE))
2846 token.SubString(6, value);
2847 AppLog("value:%ls", value.GetPointer());
2850 pMap->Add(key, value);
2854 AppControl *pAppControl = null;
2855 String operationId = L"http://tizen.org/appcontrol/operation/main";
2856 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2859 AppLog("Starting AppControl");
2860 result r = pAppControl->Start(null, null, pMap, null);
2861 AppLog("Result of Start %s", GetErrorMessage(r));
2865 AppLogException("AppControl not found");
2870 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2872 __pAddressbar->SetShowState(false);
2873 AddressBarCancelledClicked(*__pAddressbar);
2874 __pAddressbar->Invalidate(true);
2876 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2879 __pAddressbar->SetFaviconBitmap(*pBitmap);
2882 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2884 // updating the address bar position with respect to web control
2885 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2886 __distanceMoved = 0;
2890 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2891 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2892 if (__pWebViewer != null)
2894 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2895 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2896 SetUrl(__pWebViewer->GetUrl());
2897 if (__pWindowInfo != NULL)
2899 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2900 __pWindowInfo->pageTitle = L"";
2901 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2903 __pAddressbar->Invalidate(true);
2909 MainForm::OnLoadingCanceled(void)
2916 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2918 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2923 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2925 AppLog("XYZ::MainForm::OnKeypadOpened");
2926 __pFooterPanel->SetShowState(false);
2931 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2933 AppLog("XYZ::MainForm::OnKeypadClosed");
2934 __pFooterPanel->SetShowState(true);
2935 RelayoutControls(true);
2939 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2941 AppLog("XYZ::KeypadBoundsChanged");
2942 RelayoutControls(false);
2946 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2947 const Tizen::Base::String& reason)
2949 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2953 MainForm::OnLoadingCompleted(void)
2955 AppLog("MainForm::OnLoadingCompleted start");
2957 result r = E_SUCCESS;
2959 if (__pWebViewer == null)
2964 if (__pAddressbar == null)
2969 if(__pImageMenu && __pImageMenu->GetShowState())
2971 __pImageMenu->SetShowState(false);
2972 __pImageMenu->Invalidate(true);
2975 if (__pWebViewer->CanGoForward())
2977 //__pAddressbar->SetForwardButtonEnabled(true);
2978 SetForwardButtonEnabled(true);
2982 //__pAddressbar->SetForwardButtonEnabled(false);
2983 SetForwardButtonEnabled(false);
2986 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2988 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2990 //__pAddressbar->UpdateProgress(0);
2994 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2996 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3000 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3001 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3002 if (isPrivateBrowsing == false)
3004 if(__pHistory != null)
3010 __pHistory = new(std::nothrow) History;
3011 HistoryPresentationModel::GetCurrentDateTime(date);
3014 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3015 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3017 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3018 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3020 __pHistory->SetVisitedTime(date);
3022 if (__pWebViewer != null)
3024 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3026 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3027 if (pTempBitmap != null)
3029 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3030 __pHistory->SetFavIconBitmap(*pTempBitmap);
3033 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3036 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3037 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3038 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3040 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3041 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3042 __pHistory->SetThumbnail(pBitmap);
3044 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3047 __pHistory->SetFavIconBitmap(*pFavIcon);
3051 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3058 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3060 // temperary fixed (webpage can be not loaded)
3064 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3065 if (isReaderEnabled == true)
3069 delete __pReaderData;
3070 __pReaderData = null;
3072 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3073 filePath.Append(L"data/reader.js");
3079 result r = E_SUCCESS;
3080 FileAttributes attr;
3082 File::GetAttributes(filePath,attr);
3084 r = file.Construct(filePath, L"r+");
3087 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3090 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3093 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3096 // file.Read(pScript,attr.GetFileSize());
3098 // AppLogDebug("scipt length %d",strlen(pScript));
3099 String strScript = L"";
3100 // strScript.Append(pScript);
3101 // for(int i=0; i<25; i++)
3103 file.Read(pScript,attr.GetFileSize());
3104 // AppLog("xyzz tell %d",file.Tell());
3105 // r = strScript.Append(pScript);
3106 // AppLog("xyzz append result %s",GetErrorMessage(r));
3107 // AppLog("xyzz strScript length %d",strScript.GetLength());
3109 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3111 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3112 if (__pReaderData == null)
3114 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3115 __pReaderData = new String(L"<meta name=\"viewport\" content=\"width=0, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\"> <h1>Chinese PM Li Keqiang vows to open up markets to India</h1><div><span class=\"arttle\"><h1>Chinese PM Li Keqiang vows to open up markets to India</h1></span></div>");
3118 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3119 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3121 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3122 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3128 AppLog("MainForm::OnLoadingCompleted done");
3132 MainForm::OnEstimatedProgress(int progress)
3134 AppLogDebug("MainForm::OnEstimatedProgress entered");
3136 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3137 progress = DEFAULT_PROGRESS_PERCENTAGE;
3139 // __pAddressbar->UpdateProgress(progress);
3140 UpdateProgress(progress);
3143 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3145 AppLog("MainForm::OnFaviconReceived");
3146 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3148 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3151 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3158 MainForm::OnUrlValueChanged(Addressbar&)
3164 MainForm::OnUrlSubmitted(Addressbar& addBar)
3166 AppLog("MainForm::OnUrlSubmitted");
3167 String url = addBar.GetUrl();
3168 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3170 if(__pFooterUrlField)
3171 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3172 AddressBarCancelledClicked(*__pAddressbar);
3177 MainForm::LoadUrl(String& url)
3181 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3182 AppLogDebug("MainForm::LoadUrl enter");
3184 if (__pWebViewer != null)
3186 __pWebViewer->SetShowState(true);
3187 __pWebViewer->Invalidate(true);
3190 if (url.CompareTo(L"") == 0)
3194 if(__pFooterPanel != null)
3196 __pFooterPanel->SetShowState(true);
3197 __pFooterPanel->Invalidate(true);
3204 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3205 String secondPattern(L"^[A-Za-z0-9\.\+-:#@%/;$~?]+\\.[A-Za-z0-9!\+-=:#@%/;$~()_?\\\.&]{2,}$"); // URL of type abc.com (i.e without protocol in front of it)
3207 RegularExpression firstRegex;
3208 RegularExpression secondRegex;
3210 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3211 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3214 ret = firstRegex.Match(url, false); // This returns true value
3215 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3217 if (ret == true && __pWebViewer != null)
3220 __pWebViewer->LoadUrl(url);
3222 else if(__pWebViewer != null)
3224 String tempUrl = L"http://";
3225 tempUrl.Append(url);
3229 __pWebViewer->LoadUrl(tempUrl);
3233 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3234 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3237 if (__pAddressbar != null)
3239 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3240 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3243 AppLogDebug("MainForm::LoadUrl exit");
3250 MainForm::OnStopClicked(Addressbar& addBar)
3252 AppLogDebug("MainForm::OnStopClicked called");
3255 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3256 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3257 __pWebViewer->StopLoading();
3258 RequestRedraw(true);
3263 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3265 // AppLog("MainForm::OnBackClicked");
3266 result r = E_FAILURE;
3268 if (__pWebViewer && __pWebViewer->CanGoBack())
3270 __pWebViewer->GoBack();
3272 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3275 pApp = UiApp::GetInstance();
3278 r = pApp->Terminate();
3281 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3289 WindowInfo* pWindowInfo = null;
3291 SceneManager* pSceneManager = SceneManager::GetInstance();
3292 if (pSceneManager == null)
3296 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3297 if (pAllWindowList == NULL)
3299 pApp = UiApp::GetInstance();
3302 r = pApp->Terminate();
3305 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3310 if (pAllWindowList != null)
3312 totalCount = pAllWindowList->GetCount();
3314 for (int count = 0; count < totalCount; count++)
3316 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3317 if (pWindowInfo == null)
3319 pApp = UiApp::GetInstance();
3322 r = pApp->Terminate();
3325 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3330 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3332 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3335 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3338 r = pAllWindowList->RemoveAt(count, true);
3339 __pWindowInfo = null;
3342 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3347 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3349 else if(pAllWindowList->GetCount() > 0)
3351 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3355 pApp = UiApp::GetInstance();
3358 r = pApp->Terminate();
3363 if (pWindowInfo == null)
3365 pApp = UiApp::GetInstance();
3368 r = pApp->Terminate();
3374 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3377 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3391 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3393 AppLog("MainForm::OnForwardClicked");
3394 if (__pWebViewer == null)
3397 if (__pWebViewer->CanGoForward())
3399 __pWebViewer->GoForward();
3404 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3406 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3407 if(__pFooterPanel != null)
3409 __pFooterPanel->SetShowState(false);
3412 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3414 __pAddressbar->SetShowState(true);
3415 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3418 RelayoutControls(false);
3422 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3424 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3426 int Height = GetClientAreaBounds().height;
3427 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3430 __pAddressbar->SetShowState(false);
3432 if (__pFooterPanel != null && addressbarKeyPadState == false)
3434 AppLog("akjshdasd 3");
3435 __pFooterPanel->SetShowState(true);
3438 RelayoutControls(false);
3442 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3444 AddressBarCancelledClicked(addBar);
3448 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3450 __prevAddressBarMode = __curAddressBarMode;
3452 if (__pAddressbar != null)
3454 __curAddressBarMode = GetAddressbarMode();
3457 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3459 __adressPanelPosition.y = 0;
3460 if (__pAddressbar != null)
3462 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3463 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3464 __pAddressbar->Invalidate(true);
3466 if (__pWebViewer != null)
3468 __pWebViewer->StopLoading();
3471 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3473 __adressPanelPosition.y = 0;
3474 if (__pAddressbar != null)
3476 __webControlPosition.y = 0;
3477 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3478 __pAddressbar->Invalidate(true);
3484 MainForm::OnClipboardClosed(const Addressbar& addBar)
3486 AppLog("XYZ::MainForm::OnClipboardClosed");
3487 RelayoutControls(false);
3491 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3493 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3494 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3496 AppLog("akjshdasd 3");
3497 __pFooterPanel->SetShowState(true);
3500 RelayoutControls(false,footerState);
3504 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3506 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3507 RelayoutControls(false);
3511 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3513 __pFooterPanel->SetShowState(false);
3517 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3519 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3520 RelayoutControls(false);
3524 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3526 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3529 __pWindowInfo->pageTitle = title;
3530 if (__pWebViewer != null)
3532 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3535 if (__pAddressbar != null && __pWebViewer != null)
3537 SetUrl(__pWebViewer->GetUrl());
3538 __pAddressbar->Invalidate(true);
3543 MainForm::UpdateFavicon(void)
3545 bool urlImageType = false;
3546 String *tempPath = null;
3548 tempPath = __pWebViewer->EvaluateJavascriptN(L"var getFavicon = function() { var favicon = '/favicon.ico'; var nodeList = document.getElementsByTagName('link'); if(nodeList) { for (var i = 0; i < nodeList.length; i++) { if ((nodeList[i].getAttribute('rel') == 'icon')||(nodeList[i].getAttribute('rel') == 'shortcut icon')) { favicon = nodeList[i].getAttribute('href'); } } } return favicon; }; getFavicon();");
3549 Bitmap* pBitmap = null;
3551 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3553 if (__pWindowInfo != null)
3556 url.SetUri(*tempPath);
3557 if (url.GetHost().GetLength() == 0)
3560 webUrl.SetUri(__pWebViewer->GetUrl());
3561 result r = url.SetHost(webUrl.GetHost());
3568 if (url.GetScheme().GetLength() == 0)
3571 webUrl.SetUri(__pWebViewer->GetUrl());
3572 url.SetScheme(webUrl.GetScheme());
3574 __pWindowInfo->faviconUrl = url.ToString();
3576 pBitmap = __pWebViewer->GetFaviconN();
3578 if (pBitmap != null)
3580 if (__pWindowInfo->pFavicon != NULL)
3582 __pWindowInfo->pFavicon = null;
3584 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3585 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3587 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3589 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3591 else if(__pWindowInfo->pFavicon != null)
3593 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3597 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3598 if(pDefaultBmp != null)
3600 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3609 if(tempPath != null)
3613 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3619 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3620 Tizen::Web::Controls::WebNavigationType type)
3622 AppLog("urlk %ls",url.GetPointer());
3623 // when load new page if find word panel is open its show state is false
3624 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3626 __currentSearchStr = L"";
3627 __currentWordIndex = 0;
3628 __maxOccurrances = 0;
3629 __pFindWordEditField->SetText(L"");
3630 __pFindWordNext->SetEnabled(false);
3631 __pFindWordPrev->SetEnabled(false);
3632 __pFindWordCountLabel->SetText(L"0/0");
3633 __pFindWordControl->SetShowState(false);
3634 __pFindWordEditField->HideKeypad();
3635 RelayoutControls(false);
3638 __pFooterPanel->Invalidate(true);
3641 uriInfo.SetUri(url);
3643 if(url.Contains(IDS_TIZEN_SERVICE))
3646 String delim(L":;,");
3648 // Creates a StringTokenizer instance
3649 StringTokenizer strTok(url, delim);
3651 int count = strTok.GetTokenCount(); // count == 4
3653 HashMap *pMap = new HashMap();
3659 while (strTok.HasMoreTokens())
3661 AppLog("Token: %ls", token.GetPointer());
3662 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3663 if(token.Contains(IDS_APPID))
3665 token.SubString(6, appId);
3666 AppLog("AppID:%ls", appId.GetPointer());
3668 else if(token.Contains(IDS_KEY))
3670 token.SubString(4, key);
3671 AppLog("key:%ls", key.GetPointer());
3673 else if(token.Contains(IDS_VALUE))
3675 token.SubString(6, value);
3676 AppLog("value:%ls", value.GetPointer());
3679 pMap->Add(key, value);
3683 AppControl *pAppControl = null;
3684 String operationId = L"http://tizen.org/appcontrol/operation/main";
3685 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3688 result r = pAppControl->Start(null, null, pMap, null);
3692 AppLogException("AppControl not found");
3702 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3703 const Tizen::Net::Http::HttpHeader& httpHeader)
3705 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3709 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3711 AppLog("MainForm::OnWebPageBlockSelected");
3712 if (__pHitElementResult != null)
3714 delete __pHitElementResult;
3715 __pHitElementResult = null;
3718 if (__pWebViewer != null)
3720 AppLog("MainForm::OnWebPageBlockSelected web not null");
3721 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3723 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3725 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3726 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3727 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3729 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3731 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3735 if (__pHitElementResult == null)
3740 if (__pHitElementResult->HasImage() != true)
3742 String tagName = __pHitElementResult->GetTagName();
3743 String type = __pHitElementResult->GetAttributeValue("type");
3746 AppLog("TagName %ls",tagName.GetPointer());
3747 __currentSelectedStr.Clear();
3748 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3749 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3750 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3752 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3754 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3756 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
3757 __pImageMenu->SetShowState(true);
3758 __pImageMenu->Show();
3759 __pImageMenu->Invalidate(true);
3761 else /*if(__isLongPressedDone == true)*/
3763 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3765 if(__pHitElementResult->GetUrl().GetLength() > 0)
3767 __currentSelectedStr.Clear();
3768 __currentSelectedStr = __pHitElementResult->GetUrl();
3770 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
3771 __pImageMenu->SetShowState(true);
3772 __pImageMenu->Show();
3773 __pImageMenu->Invalidate(true);
3776 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3777 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3778 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3784 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3790 MainForm::OnWebWindowCreateRequested(void)
3792 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3794 if (pNewWindowInfo == null)
3798 result r = E_SUCCESS;
3799 SceneManager* pSceneManager = SceneManager::GetInstance();
3800 if (pSceneManager == NULL)
3804 ArrayList* pArgList = new(std::nothrow) ArrayList();
3805 if (pArgList == NULL)
3809 r = pArgList->Construct();
3812 pNewWindowInfo->isJavascriptInitiated = true;
3813 pArgList->Add(*pNewWindowInfo);
3814 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3818 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3825 return pNewWindowInfo->pCurrentWeb;
3829 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3831 AppLog("xyz:: MainForm::RelayoutControls called");
3832 __webControlPosition.y = 0;
3833 __webControlHeight = GetClientAreaBounds().height;
3834 AppLog("Client area height: %d", __webControlHeight);
3836 AppLog("Client area height: %d", __webControlHeight);
3837 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3839 __webControlPosition.y += __pAddressbar->GetHeight();
3840 __webControlHeight -= __pAddressbar->GetHeight();
3841 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3843 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3845 __webControlPosition.y += __pFindWordControl->GetHeight();
3846 __webControlHeight -= __pFindWordControl->GetHeight();
3847 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3850 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3852 __webControlHeight -= __pFooterPanel->GetHeight();
3854 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3856 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3858 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3863 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3864 __pWebViewer->Invalidate(false);
3867 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3869 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3876 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3878 if (__pFindWordControl == null)
3883 Tizen::Locales::LocaleManager localeManager;
3884 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3886 String languageCode;
3887 result r = SettingInfo::GetValue(L"Language", languageCode);
3888 // int languagecode = local.GetLanguageCode();
3889 AppLog("rahul language is %S", languageCode.GetPointer());
3893 InitFindWordPanel();
3895 if (languageCode.CompareTo("ara") == 0)
3897 AppLog("rahul language is arabic");
3899 __pFindWordPanelLeftToRight->SetShowState(false);
3900 __pFindWordPanelRightToLeft->SetShowState(true);
3902 __pFindWordClear->SetShowState(false);
3903 __pFindWordCountLabel->SetShowState(false);
3904 __pFindWordEditField->SetShowState(false);
3906 __pFindWordClearRightToLeft->SetShowState(true);
3907 __pFindWordCountLabelRightToLeft->SetShowState(true);
3908 __pFindWordEditFieldRightToLeft->SetShowState(true);
3912 AppLog("rahul language is not arabic");
3915 __pFindWordPanelLeftToRight->SetShowState(true);
3916 __pFindWordPanelRightToLeft->SetShowState(false);
3918 __pFindWordClear->SetShowState(true);
3919 __pFindWordCountLabel->SetShowState(true);
3920 __pFindWordEditField->SetShowState(true);
3922 __pFindWordClearRightToLeft->SetShowState(false);
3923 __pFindWordCountLabelRightToLeft->SetShowState(false);
3924 __pFindWordEditFieldRightToLeft->SetShowState(false);
3926 __pFindWordControl->SetShowState(true);
3930 if(__pFindWordControl != null)
3932 __pFindWordControl->SetShowState(false);
3936 AppLog("MainForm::ShowFindWordPanel %d",show);
3937 if (show && !isTouchPressed)
3939 if (languageCode.CompareTo("ara") == 0)
3941 if (__pFindWordEditFieldRightToLeft)
3943 __pFindWordEditFieldRightToLeft->SetFocus();
3944 __pFindWordEditFieldRightToLeft->ShowKeypad();
3949 if (__pFindWordEditField)
3951 __pFindWordEditField->SetFocus();
3952 __pFindWordEditField->ShowKeypad();
3958 if (languageCode.CompareTo("ara") == 0)
3960 if (__pFindWordEditFieldRightToLeft)
3961 __pFindWordEditFieldRightToLeft->HideKeypad();
3965 if (__pFindWordEditField)
3966 __pFindWordEditField->HideKeypad();
3970 RelayoutControls(false);
3974 MainForm::StartWordSearch()
3976 //Get the count of occurances of the word in the current page
3977 __maxOccurrances = 0;
3978 __currentWordIndex = 0;
3980 __pFindWordPrev->SetEnabled(false);
3981 String *pCountStr = null;
3982 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3983 AppLog("Search Result %s",GetErrorMessage(r));
3984 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3985 if (pCountStr != null)
3987 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3991 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3996 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3998 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3999 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4001 if(totalCount == -1 || totalCount == 0)
4003 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4004 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4007 else if(totalCount > 100)
4009 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4010 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4014 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4015 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4018 __maxOccurrances = totalCount;
4019 __currentWordIndex = currentOrdinal;
4021 //Reset the UI controls as per the maxOccurrance value
4022 if (totalCount <= 0)
4024 AppLog("Word not found");
4025 //Show error notification to user
4026 __pFindWordNext->SetEnabled(false);
4027 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4029 __pFindWordCountLabel->SetText(L"0/0");
4030 __pFindWordCountLabel->Invalidate(false);
4032 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4034 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4035 __pFindWordCountLabelRightToLeft->Invalidate(false);
4037 __pFindWordNext->Invalidate(false);
4038 __pFindWordPrev->Invalidate(false);
4043 if (totalCount == 1)
4045 __pFindWordNext->SetEnabled(false);
4049 __pFindWordNext->SetEnabled(true);
4052 String countStr = L"";
4053 countStr.Append(__currentWordIndex);
4054 countStr.Append(L"/");
4055 countStr.Append(__maxOccurrances);
4056 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4058 __pFindWordCountLabel->SetText(countStr);
4059 __pFindWordCountLabel->Invalidate(false);
4060 __pFindWordCountLabel->Invalidate(false);
4062 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4064 __pFindWordCountLabelRightToLeft->SetText(countStr);
4065 __pFindWordCountLabelRightToLeft->Invalidate(false);
4066 __pFindWordCountLabelRightToLeft->Invalidate(false);
4068 //FindNextWord(true);
4069 //Update the controls
4070 __pFindWordNext->Invalidate(false);
4071 __pFindWordPrev->Invalidate(false);
4076 MainForm::FindNextWord(bool next)
4080 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4081 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4083 if (__currentWordIndex < __maxOccurrances)
4085 __currentWordIndex++;
4091 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4092 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4094 if(__currentWordIndex > 1)
4096 __currentWordIndex--;
4101 String countStr = L"";
4102 countStr.Append(__currentWordIndex);
4103 countStr.Append(L"/");
4104 countStr.Append(__maxOccurrances);
4106 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4108 __pFindWordCountLabel->SetText(countStr);
4109 __pFindWordCountLabel->Invalidate(false);
4111 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4113 __pFindWordCountLabelRightToLeft->SetText(countStr);
4114 __pFindWordCountLabelRightToLeft->Invalidate(false);
4117 if (__currentWordIndex >= __maxOccurrances)
4119 __pFindWordNext->SetEnabled(false);
4123 __pFindWordNext->SetEnabled(true);
4125 if (__currentWordIndex <= 1)
4127 __pFindWordPrev->SetEnabled(false);
4131 __pFindWordPrev->SetEnabled(true);
4133 __pFindWordPrev->Invalidate(false);
4134 __pFindWordNext->Invalidate(false);
4136 __pFindWordControl->Invalidate(true);
4140 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4142 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4143 __isWebKeypadOpened = true;
4144 __pFooterPanel->SetShowState(false);
4145 // OnAddressBarKeypadOpened(*__pAddressbar);
4149 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4151 AppLog("xyz::MainForm::OnWebKeypadOpened");
4153 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4155 __currentSearchStr = L"";
4156 __currentWordIndex = 0;
4157 __maxOccurrances = 0;
4158 __pFindWordEditField->SetText(L"");
4159 __pFindWordNext->SetEnabled(false);
4160 __pFindWordPrev->SetEnabled(false);
4161 __pFindWordCountLabel->SetText(L"0/0");
4162 __pWebViewer->SearchTextAllAsync(L"",false);
4163 __pFindWordControl->SetShowState(false);
4164 __pFindWordEditField->HideKeypad();
4168 if (__pWebViewer != null && __pFooterPanel != null)
4170 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4171 if(__pAddressbar != null)
4173 __pAddressbar->SetShowState(false);
4175 if(__pFindWordControl != null)
4177 __pFindWordControl->SetShowState(false);
4179 __pFooterPanel->SetShowState(false);
4180 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4182 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4184 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4185 // AppLog("omgomgomg");
4191 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4193 AppLog("xyz::MainForm::OnWebKeypadClosed");
4194 AppLog("akjshdasd 4");
4195 __pFooterPanel->SetShowState(true);
4196 // OnAddressBarKeypadClosed(*__pAddressbar);
4197 RelayoutControls(false);
4198 __isWebKeypadOpened = false;
4202 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4204 // RelativeLayout(false);
4205 if(__pWebViewer != null)
4207 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4212 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4214 Control* temp = const_cast< Control* >(&source);
4215 Header* pHeader = dynamic_cast< Header* >(temp);
4216 if (pHeader != null)
4218 //Header double - clicked
4219 AppLog("Header double clicked");
4221 if(__pFindWordControl)
4223 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4224 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4228 AppLog("MainScene::OnTouchDoublePressed");
4232 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4234 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4235 __longPressPoint = currentPosition;
4237 if (__pHitElementResult != null)
4239 delete __pHitElementResult;
4240 __pHitElementResult = null;
4243 if (__pWebViewer != null)
4245 AppLog("MainForm::OnTouchLongPressed web not null");
4246 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4249 if (__pHitElementResult == null)
4254 if (__pHitElementResult->HasImage() == true)
4256 if(__pWebViewer != null)
4257 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4258 __pImageMenu->SetShowState(true);
4259 __pImageMenu->Show();
4260 __pImageMenu->Invalidate(true);
4262 else if(__pHitElementResult->HasUrl() == true)
4264 String tempURl = __pHitElementResult->GetUrl();
4265 AppLog("tempURl is %ls", tempURl.GetPointer());
4266 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4267 if (pBitmap != null)
4275 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4276 __pImageMenu->SetShowState(true);
4277 __pImageMenu->Show();
4278 __pImageMenu->Invalidate(true);
4282 String tagName = __pHitElementResult->GetTagName();
4283 String type = __pHitElementResult->GetAttributeValue("type");
4284 String value = __pHitElementResult->GetAttributeValue(L"value");
4285 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4287 __currentSelectedStr.Clear();
4288 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4290 AppLog("tag name is %ls", tagName.GetPointer());
4291 AppLog("type is %ls", type.GetPointer());
4295 //__isLongPressedDone = true;
4296 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4297 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4299 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4301 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4304 __pImageMenu->SetShowState(true);
4305 __pImageMenu->Show();
4306 __pImageMenu->Invalidate(true);
4309 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4312 // __inputEventToBeSupressed = true;
4316 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4318 AppLog("xyz:: MainForm::OnTouchReleased called");
4320 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4322 __pAddressbar->SetShowState(false);
4326 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4327 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4329 __pWebViewer->ConsumeInputEvent();
4331 if(pHitElement != null)
4335 __inputEventToBeSupressed = false;*/
4339 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4346 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4348 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4350 __currentSearchStr = L"";
4351 __currentWordIndex = 0;
4352 __maxOccurrances = 0;
4354 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4356 __pFindWordEditField->SetText(L"");
4357 __pFindWordEditField->HideKeypad();
4358 __pFindWordControl->SetShowState(false);
4359 __pFindWordCountLabel->SetText(L"0/0");
4361 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4363 __pFindWordEditFieldRightToLeft->SetText(L"");
4364 __pFindWordEditFieldRightToLeft->HideKeypad();
4365 __pFindWordControl->SetShowState(false);
4366 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4369 __pFindWordNext->SetEnabled(false);
4370 __pFindWordPrev->SetEnabled(false);
4372 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4373 __pFindWordControl->SetShowState(false);
4375 if(__pAddressbar->GetShowState() == false)
4377 __pAddressbar->SetAddressbarURLFocus();
4378 __pFooterPanel->SetShowState(false);
4385 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4391 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4397 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4403 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4409 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4415 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4417 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4418 int widthContextItem = 0;
4420 // As per the platform engineer comment removed this line
4421 /*if(__pWebViewer != null)
4423 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
4424 __pWebViewer->ReleaseBlock();
4427 // if(__pFindWordControl != null)
4428 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4429 if(__pNotification && __pNotification->GetShowState() == true)
4431 __pNotification->SetShowState(false);
4432 __pNotification->Invalidate(false);
4434 if ( __pFooterLabel != null)
4436 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4439 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4445 if (__pFindWordBgLabel != null)
4447 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4448 if (pBitmap != null)
4450 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4455 if (__pFindWordBgLabelRightToLeft != null)
4457 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4458 if (pBitmap != null)
4460 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4466 if(__pOptionMenu != null)
4467 __pOptionMenu->SetShowState(false);
4469 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4471 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4475 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4480 AppLog("__pFooterPanel->GetShowState() is true");
4482 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4483 __pFooterPanel->Invalidate(true);
4487 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4488 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4490 InitMostVisitedSitesView(orientationStatus);
4493 RelayoutControls(false);
4494 if (__pArticleReaderPanel != null)
4496 if (__pArticleReaderPanel->GetShowState() == true)
4498 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4500 if (__pBlankPanel != null)
4501 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4503 if (__pWebReader != null)
4505 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4507 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4508 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4510 if ( pBitmap != null && pSrcBitmap != null)
4512 AppLog("CreateReaderPanel ninepatchbitmap found");
4513 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4516 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4517 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4518 if (pBitmap != null)
4523 if (pSrcBitmap != null)
4532 if (__pAddressbar != null)
4534 int width = GetClientAreaBounds().width;
4535 __pAddressbar->OrientationChanged(width);
4540 MainForm::OnSettingsChange(int settingvalue)
4542 AppLogDebug("MainForm::OnSettingsChange entered");
4544 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4546 __pAddressbar->ResetGuideText();
4548 if (__pWebViewer == null)
4550 AppLogDebug("Webviewer is not initialized yet.");
4554 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4556 WebSetting settings = __pWebViewer->GetSetting();
4557 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4559 settings.SetAutoFittingEnabled(true);
4561 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4563 settings.SetAutoFittingEnabled(false);
4565 __pWebViewer->SetSetting(settings);
4567 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4569 WebSetting settings = __pWebViewer->GetSetting();
4570 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4571 __pWebViewer->SetSetting(settings);
4573 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4575 WebSetting settings = __pWebViewer->GetSetting();
4576 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4577 __pWebViewer->SetSetting(settings);
4578 __pWebViewer->Reload();
4580 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4582 WebSetting settings = __pWebViewer->GetSetting();
4583 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4584 __pWebViewer->SetSetting(settings);
4586 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4590 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4593 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4597 WebSetting settings = __pWebViewer->GetSetting();
4598 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4599 __pWebViewer->SetSetting(settings);
4602 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4606 WebSetting settings = __pWebViewer->GetSetting();
4607 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4608 __pWebViewer->SetSetting(settings);
4611 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4613 WebSetting settings = __pWebViewer->GetSetting();
4614 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4616 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4620 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4622 __pWebViewer->SetSetting(settings);
4624 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4628 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4629 WebSetting settings = __pWebReader->GetSetting();
4630 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4631 __pWebReader->SetSetting(settings);
4637 MainForm::OnSettingsReset()
4641 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4642 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4647 MainForm::OnClearCache()
4649 result r = E_SUCCESS;
4651 if (__pWebViewer != NULL)
4653 r = __pWebViewer->ClearCache();
4656 AppLogDebug("Cache cleared success");
4660 AppLogDebug("Cache cleared fail");
4666 MainForm::OnClearCookie()
4668 result r = E_SUCCESS;
4670 if (__pWebViewer != NULL)
4672 __pWebViewer->ClearCookie();
4676 AppLogDebug("Cookie cleared success");
4680 AppLogDebug("Cache cleared fail");
4685 MainForm::OnClearFormData()
4687 result r = E_SUCCESS;
4689 if (__pWebViewer != NULL)
4691 __pWebViewer->ClearFormData();
4695 AppLogDebug("Cookie cleared success");
4699 AppLogDebug("Cache cleared fail");
4704 MainForm::OnClearPasswords()
4706 result r = E_SUCCESS;
4708 if (__pWebViewer != NULL)
4710 __pWebViewer->ClearLoginFormData();
4714 AppLogDebug("Cookie cleared success");
4718 AppLogDebug("Cache cleared fail");
4724 MainForm::findDistance(int x1,int y1,int x2, int y2)
4726 int deltaX = Math::Abs(x2 - x1);
4727 int deltaY = Math::Abs(y2 - y1);
4728 double num = deltaX*deltaX + deltaY*deltaY;
4734 for (i = 0; i < 20; i++)
4736 x = (((x*x)+ num)/(2*x));
4747 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4749 AppLog("xyz:: MainForm::OnTouchPressed called");
4750 if(__pFindWordControl)
4752 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4753 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4755 //__isLongPressedDone = false;
4760 IList* pList = null;
4761 pList = touch.GetTouchInfoListN(source);
4765 int count = pList->GetCount();
4768 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4769 __touchPoint1 = pTouchInfo->position;
4771 /*if (__pAddressbar != null)
4773 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4775 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4777 __pAddressbar->SaveAddressbarEditText();
4779 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4782 __pAddressbar->Invalidate(true);
4784 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4786 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4788 //__pAddressbar->SaveAddressbarEditText();
4790 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4793 else if (count == 2)
4795 AppLogDebug("MainForm::OnTouchPressed count is two");
4796 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4797 __touchPoint1 = pTouchInfo->position;
4799 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4800 __touchPoint2 = pTouchInfo->position;
4805 pList->RemoveAll(true);
4809 __pAddressbar->SetShowState(false);
4810 RelayoutControls(false);
4815 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4817 // __currentWordIndex = 0;
4818 //__isLongPressedDone = false;
4823 MainForm::MoveUiControls()
4828 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4830 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4832 if(__pFooterUrlField->GetTextLength() == 0)
4834 __pFooterUrlField->SetKeypadActionEnabled(false);
4838 __pFooterUrlField->SetKeypadActionEnabled(true);
4841 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4843 __currentSearchStr = __pFindWordEditField->GetText();
4844 if (__currentSearchStr.GetLength() > 0)
4846 __pFindWordCountLabel->SetShowState(true);
4850 __pFindWordCountLabel->SetShowState(false);
4852 __pFindWordNext->SetEnabled(false);
4853 __pFindWordPrev->SetEnabled(false);
4854 __pFindWordNext->Invalidate(true);
4855 __pFindWordPrev->Invalidate(true);
4856 __pFindWordCountLabel->SetText(L"0/0");
4857 __pFindWordCountLabel->Invalidate(true);
4859 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4861 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4862 if (__currentSearchStr.GetLength() > 0)
4864 __pFindWordCountLabelRightToLeft->SetShowState(true);
4868 __pFindWordCountLabelRightToLeft->SetShowState(false);
4871 __pFindWordNext->SetEnabled(false);
4872 __pFindWordPrev->SetEnabled(false);
4873 __pFindWordNext->Invalidate(true);
4874 __pFindWordPrev->Invalidate(true);
4875 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4876 __pFindWordCountLabelRightToLeft->Invalidate(true);
4878 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4879 if (__currentSearchStr.GetLength() > 0)
4885 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4887 __currentSearchStr = L"";
4888 AppLogDebug("Enter something");
4893 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4900 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4902 if(__pWebViewer != null)
4905 AppLog("MainForm::InitMostVisitedSitesView");
4906 result r = E_SUCCESS;
4909 if (__pWebViewer != null && __pMostVisitedListView != null)
4914 if (__pMostVisitedListView != null)
4916 RemoveControl(__pMostVisitedListView);
4918 if(__pMostVisitedSites != null)
4920 __pMostVisitedSites->RemoveAll(true);
4923 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4925 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4926 __pMostVisitedListView = new(std::nothrow) ListView();
4928 int height = GetClientAreaBounds().height;
4930 if(__pFooterPanel->GetShowState() == true)
4932 height = height - __pFooterPanel->GetHeight();
4934 if(__pAddressbar->GetShowState() == true)
4936 height -= __pAddressbar->GetHeight();
4939 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4943 delete __pMostVisitedListView;
4944 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4947 __pMostVisitedListView->SetItemProvider(*this);
4948 __pMostVisitedListView->AddListViewItemEventListener(*this);
4949 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4950 AddControl(__pMostVisitedListView);
4951 __pMostVisitedListView->UpdateList();
4958 MainForm::GetImagePath(void)
4962 String formattedTime;
4963 DateTime currentTime;
4964 LocaleManager localManager;
4965 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4967 localManager.Construct();
4968 Locale locale = localManager.GetSystemLocale();
4969 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4971 // Get date formatter
4972 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4976 pTimeFormatter->Format(currentTime, formattedTime);
4979 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4980 String delim(L" :");
4981 StringTokenizer strTok(formattedTime, delim);
4984 String str1("GMT+00");
4985 while (strTok.HasMoreTokens())
4987 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4988 if(token.Equals(str1))
4990 AppLog("token is %ls", token.GetPointer());
4991 imageName.Append(token);
4997 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4999 result r = E_FAILURE;
5000 AppLog("Content manager 1");
5001 ContentId contentId;
5002 ContentManager contentManager;
5003 r = contentManager.Construct();
5006 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5009 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5010 Tizen::Io::Directory::Create(contentPath,true);
5011 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5013 AppLog("Already exists");
5015 else if(GetLastResult() == E_SUCCESS)
5017 AppLog("created success");
5019 contentPath.Append(imageName);
5020 contentPath.Append(".jpg");
5021 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5022 ShowIndicatorNotification(L"Download Complete");
5023 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5027 MainForm::ShowIndicatorNotification(const String& messageText)
5029 AppLogDebug("ENTER");
5031 NotificationRequest request;
5032 request.SetAlertText(messageText);
5033 request.SetTitleText(L"");
5034 request.SetAppMessage(L"AppMessage");
5036 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5037 String homePath = pApp->GetAppRootPath();
5038 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5039 AppLog("The iconPath is : %ls", homePath.GetPointer());
5040 request.SetIconFilePath(iconPath);
5042 Tizen::Shell::NotificationManager notiMgr;
5043 notiMgr.Construct();
5044 notiMgr.Notify(request);
5046 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5051 MainForm::SetForwardButtonEnabled(bool isEnabled)
5053 __pGoForwardBtn->SetEnabled(isEnabled);
5054 __pGoForwardBtn->Invalidate(true);
5058 MainForm::SetBackButtonEnabled(bool isEnabled)
5060 __pGoBackBtn->SetEnabled(isEnabled);
5061 __pGoBackBtn->Invalidate(true);
5065 MainForm::UpdateProgress(int percentage)
5067 __progressPercentage = percentage;
5068 if (percentage == 0 || percentage == 100)
5070 __isLoadingData = false;
5071 if (percentage == 100)
5073 __isLoadingCompleted = true;
5074 __progressPercentage = 0;
5078 __isLoadingCompleted = false;
5083 __isLoadingData = true;
5085 UpdateProgressBitmap();
5089 MainForm::GetProgress(void)
5091 return __progressPercentage;
5095 MainForm::UpdateProgressBitmap(void)
5097 result r = E_SUCCESS;
5098 if (__pProgressbarLabel == null)
5100 int w = __pProgressbarLabel->GetWidth();
5101 int h = __pProgressbarLabel->GetHeight();
5103 int progressWidth = 0;
5104 Bitmap* pRetBitmap = null;
5106 if (__progressPercentage == 0 || __progressPercentage == 100)
5108 __pProgressbarLabel->SetShowState(false);
5109 __pProgressbarLabel->Invalidate(false);
5114 __pProgressbarLabel->SetShowState(true);
5115 __pProgressbarLabel->Invalidate(false);
5118 r = canvas.Construct(Rectangle(0, 0, w, h));
5122 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5127 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5131 pBgBmp->Scale(Dimension(w, h));
5132 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5136 progressWidth = (double) (w) * __progressPercentage / 100;
5137 AppLogDebug("progressWidth: %d", progressWidth);
5138 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5140 if (pProgressBmp != null)
5142 pProgressBmp->Scale(Dimension(progressWidth, h));
5143 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5144 delete pProgressBmp;
5147 pRetBitmap = new (std::nothrow) Bitmap();
5149 if (pRetBitmap == null)
5151 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5155 pRetBitmap->Construct(canvas, canvas.GetBounds());
5157 if (__pProgressbarLabel != null && pRetBitmap != null)
5159 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5160 __pProgressbarLabel->Invalidate(false);
5163 if (pRetBitmap != null)
5172 MainForm::ReaderClicked()
5174 result r = E_SUCCESS;
5175 ArrayList* pArgList = new(std::nothrow) ArrayList();
5176 if (pArgList != null)
5178 r = pArgList->Construct();
5185 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5192 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5199 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5207 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5213 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5215 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5217 __currentAddMode = addMode;
5221 case ADDRESSBAR_MODE_INVALID:
5226 case ADDRESSBAR_MODE_READER:
5228 __pStopBtn->SetShowState(false);
5229 __pRefreshBtn->SetShowState(false);
5230 __pClearBtn->SetShowState(false);
5231 __pReaderBtn->SetShowState(false);
5234 case ADDRESSBAR_MODE_LOADING:
5236 __pRefreshBtn->SetShowState(false);
5237 __pStopBtn->SetShowState(true);
5238 __pClearBtn->SetShowState(false);
5239 __pReaderBtn->SetShowState(false);
5242 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5244 // SetUrl(__pAddressbar->GetUrl());
5246 __pRefreshBtn->SetShowState(true);
5247 __pStopBtn->SetShowState(false);
5248 __pClearBtn->SetShowState(false);
5249 __pReaderBtn->SetShowState(false);
5252 case ADDRESSBAR_MODE_EDIT:
5254 __pRefreshBtn->SetShowState(false);
5255 __pStopBtn->SetShowState(false);
5256 __pReaderBtn->SetShowState(false);
5257 __pClearBtn->SetShowState(true);
5264 OnAddressBarModeChanged();
5267 AddressBarMode MainForm::GetAddressbarMode(void)
5269 return __currentAddMode;
5272 void MainForm::SetUrl(const String& url)
5275 if(__displayUrl.GetLength() > 2048)
5276 __displayUrl.SubString(0,2048,__displayUrl);
5278 if (__pFooterUrlField != NULL)
5280 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5281 if (removedHttpUrl.IsEmpty() == false)
5283 __pFooterUrlField->SetText(removedHttpUrl);
5284 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5285 __pAddressbar->SetUrl(__displayUrl);
5289 __pFooterUrlField->SetText(__displayUrl);
5290 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5291 __pAddressbar->SetUrl(__displayUrl);
5293 if(__pFooterUrlField)
5294 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5295 __pFooterUrlField->Invalidate(false);
5296 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5297 __pAddressbar->Invalidate(true);
5298 // __pFooterUrlField->SetCursorPosition(0);
5303 MainForm::RemoveHttpTextFromDisplayURL(void)
5305 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5307 // bool isHttpText = __displayUrl.Contains(L"http://");
5308 String updatedDisplayUrl;
5309 updatedDisplayUrl.Clear();
5310 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5312 __displayUrl.SubString(7,updatedDisplayUrl);
5314 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5316 __displayUrl.SubString(8,updatedDisplayUrl);
5318 return updatedDisplayUrl;
5321 void MainForm::OnSharePopupControlStarted(void)
5323 __pWebViewer->AddTouchEventListener(*this);
5327 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5329 if (requestId == BACK_GROUND_APP_EVENT)
5331 if(__pWebViewer != null)
5333 __pWebViewer->Pause();
5335 if(__pAddressbar != null)
5337 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5340 else if(requestId == FORE_GROUND_APP_EVENT)
5342 if(__pWebViewer != null)
5344 __pWebViewer->Resume();
5346 if(__pAddressbar != null)
5348 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5354 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5356 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5357 result r = E_SUCCESS;
5360 __pAddressbar->SetShowState(false);
5362 //AppLog("akjshdasd 5");
5363 //__pFooterPanel->SetShowState(true);
5366 __pWebViewer->SetFocus();
5367 else if(__pMostVisitedListView)
5368 __pMostVisitedListView->SetFocus();
5369 else if(__pMultiWindowButton)
5370 __pMultiWindowButton->SetFocus();
5371 else if(__pMoreButton)
5372 __pMoreButton->SetFocus();
5374 __pAddressbar->SetShowState(false);
5376 RelayoutControls(false);
5380 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5382 AppLog("MainForm::OnFormMenuRequested called");
5384 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5386 int bookmarkCount=0;
5389 url=__pWindowInfo->pageUrl;
5390 result r = E_SUCCESS;
5391 Bitmap* pBitmap = null;
5393 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5396 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5401 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5405 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5407 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5409 if (__pOptionMenu->GetItemCount() == 9)
5411 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5415 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5420 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5424 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5425 if (__pOptionMenu->GetItemCount() != 9)
5427 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5428 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5429 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5430 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5431 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5432 __pOptionMenu->SetMaxVisibleItemsCount(6);
5434 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5436 AppLog(" Orientation landscape");
5437 __pOptionMenu->SetMaxVisibleItemsCount(5);
5441 AppLog(" Orientation potrait");
5442 __pOptionMenu->SetMaxVisibleItemsCount(6);
5445 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5448 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5449 __pOptionMenu->SetShowState(true);
5450 __pOptionMenu->Invalidate(true);
5451 __pOptionMenu->Show();