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"00_icon_favorite_off_74x74.png";
72 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"00_icon_favorite_on_74x74.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 static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/view";
148 MainForm::MainForm(void)
150 __isLongPressedDone = false;
152 __pAddressbar = null;
153 // __pMostVisitedSitesPanel = null;
154 __pMostVisitedListView = null;
155 __pFooterPanel = null;
156 __pHitElementResult = null;
157 __pWindowInfo = null;
160 __pOptionMenu = null;
161 __pFindWordControl = null;
162 __pFindWordPanelLeftToRight = null;
163 __pFindWordPanelRightToLeft = null;
164 __pFindWordBgLabel = null;
165 __pFindWordBgLabelRightToLeft = null;
166 __pFindWordEditField = null;
167 __pFindWordEditFieldRightToLeft = null;
168 __pFindWordClear = null;
169 __pFindWordClearRightToLeft = null;
170 __pFindWordCountLabel = null;
171 __pFindWordClearRightToLeft = null;
172 __pFindWordNext = null;
173 __pFindWordPrev = null;
174 __previousZoomLevel = 1.0;
176 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
179 __currentSearchStr = L"";
180 __currentSelectedStr = L"";
181 __maxOccurrances = 0;
182 __currentWordIndex = 0;
185 //__inputEventToBeSupressed = false;
186 __isLoadingData = false;
187 __isLoadingCompleted = false;
188 __progressPercentage = 0;
189 __touchPoint1 = Point(-1,-1);
190 __touchPoint2 = Point(-1,-1);
191 __longPressPoint = Point(-1,-1);
193 // __pReaderPopup = null;
194 __pReaderData = null;
196 __pReaderCloseBtn = null;
197 //__pNewWindowButton = null;
198 __pMoreButton = null;
199 __pMultiWindowButton = null;
200 __pArticleReaderPanel = null;
201 __pBlankPanel = null;
202 __pArticleReaderLabel = null;
203 __webControlHeight = 0;
204 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
205 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
206 __pMostVisitedSites = null;
207 __pFooterUrlField = null;
209 __pGoForwardBtn = null;
210 __pRefreshBtn = null;
211 __pProgressbarLabel = null;
212 __pFooterLabel = null;
216 __isKeypadOpened = false;
218 __pNotification = null;
221 MainForm::~MainForm(void)
223 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
227 __pAddressbar->SetAddressbarEventListener(null);
230 if(__pHistory != null)
236 if (__pReaderData != null)
238 delete __pReaderData;
239 __pReaderData = null;
242 if (__pPopUp != null)
248 if (__pHitElementResult != null)
250 delete __pHitElementResult;
251 __pHitElementResult = null;
255 delete __pOptionMenu;
256 __pOptionMenu = null;
259 String* pSelectedScene = NULL;
260 Object* pValue = NULL;
261 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
262 pSelectedScene = (String*) pValue;
264 /*if (pSelectedScene != null)
266 delete pSelectedScene;
268 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
272 MainForm::Initialize(void)
274 Construct(L"IDL_FORM");
276 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
281 MainForm::OnInitializing(void)
283 AppLog("get client area width = %d",GetClientAreaBounds().width);
284 AppLog("get client area height = %d",GetClientAreaBounds().height);
285 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
286 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
288 __fontSize = CommonUtil::GetFontSize();
289 Panel* pFooterPanel = null;
291 __pSaveImage = new Image();
292 __pSaveImage->Construct();
294 // Setup back event listener
295 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
296 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
297 AddOrientationEventListener(*this);
299 AppLogDebug(" MainForm::OnInitializing ended");
300 if (__pMostVisitedSites == null)
302 __pMostVisitedSites = new(std::nothrow) ArrayList();
303 __pMostVisitedSites->Construct();
305 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
307 __pItemContext= new(std::nothrow) ListContextItem();
308 __pItemContext->Construct();
310 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
313 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
317 __pItemContextLandscape= new(std::nothrow) ListContextItem();
318 __pItemContextLandscape->Construct();
320 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
321 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
323 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
324 SetFormMenuEventListener(this);
325 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
330 MainForm::InitAddressbar(void)
332 AppLogDebug("MainForm::InitAddressbar entered");
334 result r = E_SUCCESS;
336 if (__pAddressbar != null)
340 __pAddressbar = new(std::nothrow) Addressbar();
341 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
342 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
345 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
348 __pAddressbar->SetAddressbarEventListener(this);
349 AddControl(__pAddressbar);
350 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
351 SetControlAlwaysOnTop(*__pAddressbar, true);
352 __adressPanelPosition = __pAddressbar->GetPosition();
354 AppLogDebug("MainForm::InitAddressbar exit");
360 MainForm::CreateReaderPanel(void)
362 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
363 result r = E_FAILURE;
365 Button *pSmallFontBtn = null;
366 Button *pLargeFontBtn = null;
368 __pBlankPanel = new (std::nothrow) Panel();
369 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
371 __pArticleReaderPanel = new (std::nothrow) Panel();
372 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
374 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
375 if (__pReaderCloseBtn)
377 AppLogDebug("CreateReaderPanel() 6");
378 __pReaderCloseBtn->AddActionEventListener(*this);
379 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
382 __pWebReader = new (std::nothrow) Web();
383 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
385 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
386 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
388 r = __pWebReader->SetSetting(settings);
390 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
393 __pArticleReaderLabel = new Label();
394 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
396 __pBlankPanel->AddControl(__pArticleReaderLabel);
397 __pBlankPanel->AddControl(__pArticleReaderPanel);
398 AddControl(__pBlankPanel);
400 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
401 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
402 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
404 __pArticleReaderPanel->AddControl(__pWebReader);
405 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
406 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
407 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
409 if (pBitmap != null && pSrcBitmap != null)
411 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
413 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
415 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
418 pSmallFontBtn->AddActionEventListener(*this);
419 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
422 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
425 pLargeFontBtn->AddActionEventListener(*this);
426 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
435 if (pSrcBitmap != null)
441 SetControlAlwaysOnTop(*__pBlankPanel, true);
442 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
449 MainForm::InitWebControl()
451 AppLogDebug("MainForm::InitWebControl enter");
452 result r = E_SUCCESS;
453 AppLogDebug("InitWebControl");
455 if (__pAddressbar == null || __pFooterPanel == null)
458 const int Y_WEBCONTROL_POSITION = 0;
460 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
462 if (__pMostVisitedListView)
464 __pMostVisitedListView->SetShowState(false);
466 if (__pWebViewer != null)
468 AppLogDebug("Already initialized");
471 __pWebViewer = new(std::nothrow) Web();
472 if(__pWebViewer == NULL)
474 AppLogDebug("Initialization failed");
477 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
481 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
488 r = AddControl(__pWebViewer);
491 __pWebViewer->Destroy();
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);
616 delete pPressedBitmap;
617 pPressedBitmap = null;
623 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
624 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
627 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
628 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
629 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
633 __pMoreButton->AddActionEventListener(*this);
634 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
637 //Add the editfield for url
638 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
639 if (__pFooterUrlField == NULL)
641 return E_INVALID_KEY;
644 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
645 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
646 __pFooterUrlField->AddKeypadEventListener(*this);
647 __pFooterUrlField->SetPropagatedTouchEventListener(this);
648 __pFooterUrlField->AddFocusEventListener(*this);
650 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
652 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
654 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
656 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
660 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
661 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
665 //Add the go Back Button
666 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
667 if (__pGoBackBtn == NULL)
669 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
670 return E_INVALID_KEY;
672 __pGoBackBtn->SetActionId(IDA_GO_BACK);
673 __pGoBackBtn->AddActionEventListener(*this);
675 //Add the go forward Button
676 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
677 if (__pGoForwardBtn == NULL)
679 AppLogDebug("Control not found returning E_INVALID_KEY");
680 return E_INVALID_KEY;
682 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
683 __pGoForwardBtn->AddActionEventListener(*this);
684 if (__pWebViewer && __pWebViewer->CanGoForward())
686 SetForwardButtonEnabled(true);
690 SetForwardButtonEnabled(false);
693 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
694 if (__pRefreshBtn == NULL)
696 AppLogDebug("Control not found returning E_INVALID_KEY");
697 return E_INVALID_KEY;
700 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
701 __pRefreshBtn->AddActionEventListener(*this);
702 __pRefreshBtn->SetShowState(true);
704 //Add the backround label for displaying progressbar
705 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
706 if (__pProgressbarLabel == NULL)
708 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
709 return E_INVALID_KEY;
711 __pProgressbarLabel->SetShowState(false);
713 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
714 if (__pStopBtn == NULL)
716 AppLogDebug("Control not found returning E_INVALID_KEY");
717 return E_INVALID_KEY;
719 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
720 __pStopBtn->AddActionEventListener(*this);
721 __pStopBtn->SetShowState(false);
723 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
724 if (__pClearBtn == NULL)
726 AppLogDebug("Control not found returning E_INVALID_KEY");
727 return E_INVALID_KEY;
729 __pClearBtn->SetActionId(IDA_CLEAR_URL);
730 __pClearBtn->AddActionEventListener(*this);
731 __pClearBtn->SetShowState(false);
733 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
734 if (__pReaderBtn == NULL)
736 AppLogDebug("Control not found returning E_INVALID_KEY");
737 return E_INVALID_KEY;
739 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
740 __pReaderBtn->AddActionEventListener(*this);
741 __pReaderBtn->SetShowState(false);
743 // __pFooterPanel->Invalidate(true);
744 if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
746 // AppLog("asdasdasdasda");
747 __pFooterPanel->SetShowState(true);
749 else if(__pAddressbar == null)
751 __pFooterPanel->SetShowState(true);
754 __pFooterPanel->SetShowState(false);
756 SetAddressbarMode(GetAddressbarMode());
757 AppLogDebug("MainForm::InitFooter exit");
762 MainForm::InitOptionMenu()
764 result r = E_SUCCESS;
765 bool isPrivateBrowsing = false;
766 Bitmap* pBitmap = null;
768 if (__pOptionMenu != null)
770 __pOptionMenu->SetFocusable(true);
771 __pOptionMenu->Invalidate(true);
775 __pOptionMenu = new(std::nothrow) OptionMenu();
776 r = __pOptionMenu->Construct();
777 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
779 __pOptionMenu->SetFocusable(true);
780 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
783 if (isPrivateBrowsing == true)
785 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
789 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
792 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
794 if ( pBitmap != NULL)
796 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
799 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
800 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
801 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
804 __pOptionMenu->SetMaxVisibleItemsCount(6);
805 __pOptionMenu->SetShowState(false);
806 __pOptionMenu->AddActionEventListener(*this);
807 SetControlAlwaysOnTop(*__pOptionMenu, true);
813 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
815 result r = E_SUCCESS;
816 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
818 AppLog("MainForm::InitImageContextMenu clicked on image");
819 if (__pImageMenu != null)
824 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
829 __pImageMenu = new (std::nothrow) ContextMenu();
830 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
831 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
835 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
836 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
837 __pImageMenu->SetMaxVisibleItemsCount(4);
838 __pImageMenu->AddActionEventListener(*this);
839 SetControlAlwaysOnTop(*__pImageMenu, true);
840 __pImageMenu->SetFocusable(true);
846 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
848 result r = E_SUCCESS;
849 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
851 AppLog("MainForm::InitImageContextMenu clicked on image");
852 if (__pImageMenu != null)
858 // if(__pAddressbar->GetShowState() == true)
859 // p.y = p.y + __pAddressbar->GetHeight();
860 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
865 __pImageMenu = new (std::nothrow) ContextMenu();
866 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
867 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
869 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
870 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
871 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
872 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
874 __pImageMenu->SetMaxVisibleItemsCount(3);
875 __pImageMenu->AddActionEventListener(*this);
876 SetControlAlwaysOnTop(*__pImageMenu, true);
877 __pImageMenu->SetFocusable(true);
884 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
886 result r = E_SUCCESS;
887 bool clipboardAvailable = true;
888 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
890 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
891 if (__pImageMenu != null)
897 // __pWebViewer->GetBlockRange(p,q);
902 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
906 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
910 Clipboard* pClipboard = Clipboard::GetInstance();
912 if(pClipboard == null)
914 clipboardAvailable = false;
918 // Retrieves a latest item
919 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
923 clipboardAvailable = false;
927 //Gets data from the clipboard item
928 String* pString = dynamic_cast<String*>(pItem->GetData());
932 clipboardAvailable = false;
936 if(clipboardAvailable == false && onlyPasteOption == true)
941 __pImageMenu = new (std::nothrow) ContextMenu();
942 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
943 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
945 if(onlyPasteOption == false)
947 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
949 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
951 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
953 if(onlyPasteOption == false)
955 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
956 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
959 __pImageMenu->SetMaxVisibleItemsCount(3);
960 __pImageMenu->AddActionEventListener(*this);
961 SetControlAlwaysOnTop(*__pImageMenu, true);
962 __pImageMenu->SetFocusable(true);
969 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
971 result r = E_SUCCESS;
972 bool clipboardAvailable = true;
973 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
975 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
976 if (__pImageMenu != null)
981 // FloatPoint q(0.0,0.0);
982 // __pWebViewer->GetBlockRange(p,q);
986 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
990 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
992 AppLog("asdasdafdsfdgfd");
995 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
999 Clipboard* pClipboard = Clipboard::GetInstance();
1001 if(pClipboard == null)
1003 clipboardAvailable = false;
1007 // Retrieves a latest item
1008 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1012 clipboardAvailable = false;
1016 //Gets data from the clipboard item
1017 String* pString = dynamic_cast<String*>(pItem->GetData());
1021 clipboardAvailable = false;
1025 if(clipboardAvailable == false && onlyPasteOption == true)
1029 __pImageMenu = new (std::nothrow) ContextMenu();
1030 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1031 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1037 if(onlyPasteOption == false)
1039 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1041 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1043 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1045 if(onlyPasteOption == false)
1047 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1048 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1051 __pImageMenu->SetMaxVisibleItemsCount(3);
1052 __pImageMenu->AddActionEventListener(*this);
1053 SetControlAlwaysOnTop(*__pImageMenu, true);
1054 __pImageMenu->SetFocusable(true);
1061 MainForm::InitFindWordPanel(void)
1063 result r = E_SUCCESS;
1064 Bitmap *pIconBitmap = null;
1066 if (__pFindWordControl != null)
1068 AppLogDebug("Findword panel already initialized");
1069 if (__pFindWordBgLabel != null)
1071 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1072 if (pBitmap != null)
1074 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1078 if (__pFindWordBgLabelRightToLeft != null)
1080 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1081 if (pBitmap != null)
1083 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1088 __pAddressbar->SetShowState(false);
1090 if(__isKeypadOpened == false)
1091 __pFooterPanel->SetShowState(true);
1095 __pFindWordControl = new (std::nothrow) Panel();
1096 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1099 AppLogException("There is some problem in the xml file. Please check.");
1102 AddControl(__pFindWordControl);
1103 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1104 SetControlAlwaysOnTop(*__pFindWordControl,true);
1105 __pFindWordControl->SetShowState(false);
1106 __pFindWordControl->Invalidate(false);
1108 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1109 __pFindWordPanelLeftToRight->SetShowState(true);
1111 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1112 __pFindWordPanelRightToLeft->SetShowState(false);
1114 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1115 if (__pFindWordBgLabel != null)
1117 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1118 Rectangle pRect = pPanel1->GetBounds();
1119 pRect.x = pRect.y = 0;
1120 __pFindWordBgLabel->SetBounds(pRect);
1121 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1122 if (pBitmap != null)
1124 AppLogDebug("InitFindWordPanel: Coming here");
1125 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1130 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1134 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1135 if (__pFindWordBgLabelRightToLeft != null)
1137 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1138 Rectangle pRect = pPanel1->GetBounds();
1139 pRect.x = pRect.y = 0;
1140 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1141 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1142 if (pBitmap != null)
1144 AppLogDebug("InitFindWordPanel: Coming here");
1145 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1150 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1154 Button* pfindWordCancel = null;
1155 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1156 if (pfindWordCancel == null)
1158 AppLogException("There is some problem in the xml file. Please check.");
1161 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1162 pfindWordCancel->AddActionEventListener(*this);
1164 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1165 if (__pFindWordClear == null)
1167 AppLogException("There is some problem in the xml file. Please check.");
1171 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1172 if (__pFindWordClearRightToLeft == null)
1174 AppLogException("There is some problem in the xml file. Please check.");
1178 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1179 __pFindWordClear->AddActionEventListener(*this);
1181 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1182 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1184 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1185 if (__pFindWordNext == null)
1187 AppLogException("There is some problem in the xml file. Please check.");
1191 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1192 __pFindWordNext->AddActionEventListener(*this);
1194 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1195 if (__pFindWordPrev == null)
1197 AppLogException("There is some problem in the xml file. Please check.");
1201 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1202 __pFindWordPrev->AddActionEventListener(*this);
1204 __pFindWordNext->SetEnabled(false);
1205 __pFindWordPrev->SetEnabled(false);
1207 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1208 if (__pFindWordCountLabel == null)
1210 AppLogException("There is some problem in the xml file. Please check.");
1214 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1215 if (__pFindWordCountLabelRightToLeft == null)
1217 AppLogException("There is some problem in the xml file. Please check.");
1221 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1222 if (__pFindWordEditField == null)
1224 AppLogException("There is some problem in the xml file. Please check.");
1227 __pFindWordEditField->AddTextEventListener(*this);
1228 __pFindWordEditField->AddKeypadEventListener(*this);
1229 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1230 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1232 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1233 if (__pFindWordEditFieldRightToLeft == null)
1235 AppLogException("There is some problem in the xml file. Please check.");
1238 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1239 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1240 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1241 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1244 __pAddressbar->SetShowState(false);
1246 if(__isKeypadOpened == false)
1247 __pFooterPanel->SetShowState(true);
1252 MainForm::CreateItem (int index, int itemWidth)
1254 Rectangle listImageRect;
1255 Rectangle pagetTitleRect;
1256 Rectangle pageURLRect;
1257 Rectangle deleteImageRect;
1258 String pageTitle(L"");
1259 String pageURL(L"");
1260 result r = E_SUCCESS;
1261 Bitmap* pListIconImage = null;
1264 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1265 if(pHistory == null)
1269 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1270 if ( pAppResource == NULL )
1274 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1276 CustomItem* pItem = new(std::nothrow) CustomItem();
1277 pageTitle = pHistory->GetHistoryTitle();
1278 pageURL = pHistory->GetHistoryUrl();
1280 if (pageURL.GetLength() == 0)
1283 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1284 pageURL = L"<"+ nourl +">";
1288 Rectangle screenBounds = GetBounds();
1291 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1300 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1302 if ( pBitmap != NULL)
1304 pListIconImage = new Bitmap();
1305 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1309 if(pListIconImage == null)
1311 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1314 if ( pListIconImage != NULL)
1316 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1317 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1318 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1321 if (pItem != null && pListIconImage != NULL)
1323 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1327 if (pageTitle.CompareTo(L"") != 0)
1331 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1335 if (pageURL.CompareTo(L"") != 0)
1339 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1344 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1346 if ( __pItemContext!= NULL)
1350 pItem->SetContextItem(__pItemContext);
1356 if ( __pItemContextLandscape!= NULL)
1360 pItem->SetContextItem(__pItemContextLandscape);
1364 if( pListIconImage != NULL)
1366 delete pListIconImage;
1367 pListIconImage = null;
1374 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1381 MainForm::GetItemCount (void)
1383 if(__pMostVisitedSites != null)
1385 __pMostVisitedSites->RemoveAll(true);
1387 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1388 if(__pMostVisitedSites != null)
1390 return __pMostVisitedSites->GetCount();
1397 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1399 AppLog("MainForm::OnListViewContextItemStateChanged called");
1400 if(__pMostVisitedSites != null)
1402 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1403 if (pHistory != null)
1405 String url = pHistory->GetHistoryUrl();
1407 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1408 __pMostVisitedListView->UpdateList();
1414 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1416 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1417 String url = pHistory->GetHistoryUrl();
1425 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1431 MainForm::OnTerminating(void)
1433 result r = E_SUCCESS;
1435 RemoveOrientationEventListener(*this);
1439 __pAddressbar->SetAddressbarEventListener(null);
1444 __pWebViewer->RemoveTouchEventListener(*this);
1445 __pWebViewer->SetWebUiEventListenerF(null);
1446 __pWebViewer->SetWebKeypadEventListener(null);
1447 __pWebViewer->SetTextSearchListener(null);
1453 delete __pItemContext;
1455 if (__pItemContextLandscape)
1457 delete __pItemContextLandscape;
1461 delete __pSaveImage;
1463 if (__pMostVisitedSites)
1465 __pMostVisitedSites->RemoveAll(true);
1466 delete __pMostVisitedSites;
1472 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1474 result r = E_SUCCESS;
1476 AppLogDebug("Clicked : %d", actionId);
1479 case IDA_BACKBTN_CLICKED:
1481 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1483 AppLog("Hiding the menu");
1484 __pImageMenu->SetShowState(false);
1486 if (__pWebViewer && __pWebViewer->CanGoBack())
1488 __pWebViewer->GoBack();
1490 else if(__pWindowInfo->isJavascriptInitiated == false)
1493 pApp = UiApp::GetInstance();
1496 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1499 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1507 WindowInfo* pWindowInfo = null;
1509 SceneManager* pSceneManager = SceneManager::GetInstance();
1510 if (pSceneManager == null)
1514 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1515 if (pAllWindowList == NULL)
1517 pApp = UiApp::GetInstance();
1520 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1523 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1528 if (pAllWindowList != null)
1530 totalCount = pAllWindowList->GetCount();
1532 for (int count = 0; count < totalCount; count++)
1534 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1535 if (pWindowInfo == null)
1537 pApp = UiApp::GetInstance();
1540 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1543 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1550 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1552 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1555 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1558 r = pAllWindowList->RemoveAt(count, true);
1559 __pWindowInfo = null;
1562 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1567 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1571 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1573 if (pWindowInfo == null)
1575 pApp = UiApp::GetInstance();
1578 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1584 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1585 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1588 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1600 case IDA_FORWARD_CLICKED:
1601 if (__pWebViewer == null)
1604 if (__pWebViewer->CanGoForward())
1606 __pWebViewer->GoForward();
1608 __pOptionMenu->SetShowState(false);
1609 __pOptionMenu->Invalidate(false);
1612 case IDA_FINDONPAGE_CLICKED:
1614 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1615 __currentSearchStr.Clear();
1617 InitFindWordPanel();
1618 __pOptionMenu->SetShowState(false);
1619 __pOptionMenu->Invalidate(false);
1621 ShowFindWordPanel(true);
1623 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1625 __pFindWordEditField->SetFocus();
1626 // __pFindWordCountLabel->SetShowState(false);
1630 __pFindWordEditFieldRightToLeft->SetFocus();
1631 __pFindWordCountLabelRightToLeft->SetShowState(false);
1635 case IDA_PRIVATEON_CLICKED:
1637 result r = E_SUCCESS;
1639 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1640 Bitmap* pBitmap = null;
1641 if (isPrivateBrowsing == true)
1643 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1646 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1650 if (__pWebViewer != NULL)
1652 __pWebViewer->SetPrivateBrowsingEnabled(false);
1655 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1657 if (__pAddressbar != null)
1659 __pAddressbar->UpdateFaviconBitmap(false);
1665 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1668 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1672 if (__pWebViewer != NULL)
1674 __pWebViewer->SetPrivateBrowsingEnabled(true);
1677 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1679 if (__pAddressbar != null)
1681 __pAddressbar->UpdateFaviconBitmap(true);
1685 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1686 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1687 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1688 __pOptionMenu->Invalidate(true);
1689 if ( pBitmap != NULL )
1696 case IDA_SETTINGS_CLICKED:
1699 ArrayList* pArgList = new(std::nothrow) ArrayList();
1702 pArgList->Construct();
1703 pArgList->Add(*__pWindowInfo);
1704 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1706 __pOptionMenu->SetShowState(false);
1707 __pOptionMenu->Invalidate(false);
1709 if (pArgList != null)
1718 case IDA_ADDTOBOOKMARK_CLICKED:
1721 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1723 int bookmarkCount=0;
1726 url=__pWindowInfo->pageUrl;
1727 result r = E_SUCCESS;
1728 Bitmap* pBitmap = null;
1729 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1737 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1738 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1739 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1741 if(__pNotification != null)
1743 RemoveControl(__pNotification);
1744 __pNotification = null;
1746 __pNotification = new (std::nothrow) NotificationPanel(*this);
1747 if (__pNotification != null)
1749 __pNotification->SetText(message);
1750 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1751 __pNotification->ShowNotification();
1756 String title=__pWindowInfo->pageTitle;
1757 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1758 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1760 pBookmark->SetBookmarkTitle(title);
1761 pBookmark->SetUrl(url);
1762 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1764 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1766 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1767 pBookmark->SetFaviconId(id);
1768 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1769 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1771 if(__pNotification != null)
1773 RemoveControl(__pNotification);
1774 __pNotification = null;
1776 __pNotification = new (std::nothrow) NotificationPanel(*this);
1777 if (__pNotification != null)
1779 __pNotification->SetText(message);
1780 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1781 __pNotification->ShowNotification();
1782 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1785 if (pBitmap != null)
1787 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1792 __pOptionMenu->Invalidate(true);
1797 case IDA_PRINT_CLICKED:
1799 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1800 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1802 AppLog("RequestPrint called!");
1803 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1804 result nResult = E_FAILURE;
1807 AppLog("TestPrint if (pAc) == true");
1812 String fileType = L"service_print_files_type";
1813 String typeVal = L"DOC";
1815 String fileCount = L"service_print_files_count";
1816 String countVal = L"1";
1817 String fileFolder= L"service_print_files_folder_name";
1818 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1820 map.Add(&fileCount, &countVal);
1821 map.Add(&fileFolder, &folderVal);
1822 map.Add(&fileType, &typeVal);
1824 String fileName = L"service_print_files_files_name";
1826 ArrayList fileNameList;
1827 fileNameList.Construct();
1828 String file1 = L"test.pdf";
1830 fileNameList.Add(&file1);
1831 map.Add(&fileName, &fileNameList);
1833 nResult = pAc->Start(NULL, NULL, &map, NULL);
1835 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1836 else if (nResult == E_MAX_EXCEEDED)
1837 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1838 else if (nResult == E_OBJ_NOT_FOUND)
1839 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1840 else if (nResult == E_IN_PROGRESS)
1841 AppLog("TestPrint ret == E_IN_PROGRESS");
1842 else if (nResult == E_PRIVILEGE_DENIED)
1843 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1844 else if(nResult == E_SYSTEM)
1845 AppLog("TestPrint ret == E_SYSTEM");
1851 int __modalMsgBoxResult;
1852 MessageBox* pMsgBox = new MessageBox();
1853 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1854 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1857 __modalMsgBoxResult = 0;
1861 case IDA_SHARE_CLICKED:
1863 if(__pPopUp != null)
1870 __pAddressbar->HideKeypad();
1872 __pPopUp = new(std::nothrow) SharePopup();
1873 __pPopUp->Initialize();
1874 if (__pWindowInfo != null)
1876 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1877 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1878 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1879 pShareInfo->SetImageAttached(false);
1880 __pPopUp->RemoveAllShareInfo();
1881 __pPopUp->AddShareInfo(pShareInfo);
1883 __pPopUp->SetShowState(true);
1887 case IDA_BOOKMARKBTN_CLICKED:
1889 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1890 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1893 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1898 case IDA_MOREBTN_CLICKED:
1900 AppLog("IDA_MOREBTN_CLICKED");
1902 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1904 int bookmarkCount=0;
1907 url=__pWindowInfo->pageUrl;
1908 result r = E_SUCCESS;
1909 Bitmap* pBitmap = null;
1911 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1914 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1919 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1923 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1925 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1927 if (__pOptionMenu->GetItemCount() == 9)
1929 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1933 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1938 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1942 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1943 if (__pOptionMenu->GetItemCount() != 9)
1945 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1946 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1947 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1948 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1949 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1950 __pOptionMenu->SetMaxVisibleItemsCount(6);
1952 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1954 AppLog(" Orientation landscape");
1955 __pOptionMenu->SetMaxVisibleItemsCount(5);
1959 AppLog(" Orientation potrait");
1960 __pOptionMenu->SetMaxVisibleItemsCount(6);
1963 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1966 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1967 __pOptionMenu->SetShowState(true);
1968 __pOptionMenu->Invalidate(true);
1969 __pOptionMenu->Show();
1973 case IDA_HISTORY_CLICKED:
1975 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1976 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1979 case IDA_SAVED_PAGES_CLICKED:
1984 case IDA_DESKTOP_VIEW_CLICKED:
1989 case IDA_SAVE_CLICKED:
1994 case IDA_MULTIWINDOWBTN_CLICKED:
1996 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1997 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2001 case IDA_NEWWINDOWBTN_CLICKED:
2003 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2005 if (pNewWindowInfo == null)
2009 result r = E_SUCCESS;
2010 SceneManager* pSceneManager = SceneManager::GetInstance();
2012 if (pSceneManager == NULL)
2016 ArrayList* pArgList = new(std::nothrow) ArrayList();
2017 if (pArgList == NULL)
2021 r = pArgList->Construct();
2024 pArgList->Add(*pNewWindowInfo);
2025 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2031 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2036 case IDA_SMALLFONT_BTN_CLICKED:
2038 WebSetting setting = __pWebReader->GetSetting();
2039 setting.SetFontSize(15);
2040 __pWebReader->SetSetting(setting);
2043 case IDA_LARGEFONT_BTN_CLICKED:
2045 WebSetting setting = __pWebReader->GetSetting();
2046 setting.SetFontSize(25);
2047 __pWebReader->SetSetting(setting);
2050 case IDA_READER_CLOSE_CLICKED:
2052 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2054 RemoveControl(__pBlankPanel);
2055 __pArticleReaderPanel = null;
2056 __pBlankPanel = null;
2057 __pArticleReaderLabel = null;
2059 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2062 case IDA_FINDWORD_CANCEL_CLICKED:
2064 __currentSearchStr = L"";
2065 __currentWordIndex = 0;
2066 __maxOccurrances = 0;
2068 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2070 __pFindWordEditField->SetText(L"");
2071 __pFindWordCountLabel->SetText(L"0/0");
2073 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2075 __pFindWordEditFieldRightToLeft->SetText(L"");
2076 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2079 __pFindWordNext->SetEnabled(false);
2080 __pFindWordPrev->SetEnabled(false);
2081 __pFindWordCountLabel->SetText(L"0/0");
2082 __pWebViewer->SearchTextAllAsync(L"",true);
2083 AppLog("akjshdasd 1");
2084 if(__isKeypadOpened == false)
2085 __pFooterPanel->SetShowState(true);
2086 ShowFindWordPanel(false);
2089 case IDA_FINDWORD_SEARCH_CLICKED:
2091 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2093 __currentSearchStr = __pFindWordEditField->GetText();
2095 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2097 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2100 if (__currentSearchStr.GetLength() > 0)
2106 AppLogDebug("Enter something");
2110 case IDA_FINDWORD_CLEAR_CLICKED:
2112 __pFindWordCountLabel->SetText(L"0/0");
2113 __pFindWordEditField->SetText(L"");
2114 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2116 __currentSearchStr = L"";
2117 __pFindWordNext->SetEnabled(false);
2118 __pFindWordPrev->SetEnabled(false);
2119 // __pFindWordCountLabel->SetShowState(false);
2120 __pFindWordControl->Invalidate(true);
2123 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2125 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2126 __pFindWordEditFieldRightToLeft->SetText(L"");
2127 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2129 __currentSearchStr = L"";
2130 __pFindWordNext->SetEnabled(false);
2131 __pFindWordPrev->SetEnabled(false);
2132 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2133 __pFindWordControl->Invalidate(true);
2136 case IDA_FINDWORD_NEXT_CLICKED:
2141 case IDA_FINDWORD_PREV_CLICKED:
2143 FindNextWord(false);
2146 case IDA_BRIGHTNESS_BTN_CLICKED:
2148 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2149 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2152 case IDA_COPY_IMAGE_CLICKED:
2154 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2155 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2157 const Bitmap* pBitmap = null;
2158 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2160 pBitmap = __pHitElementResult->GetImage();
2163 String resourcePath = App::GetInstance()->GetAppResourcePath();
2164 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2165 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2166 // copying the item to clipboard
2167 Clipboard* pClipboard = Clipboard::GetInstance();
2168 if (pClipboard != null)
2170 r = pClipboard->CopyItem(item);
2171 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2175 case IDA_VIEW_IMAGE_CLICKED:
2177 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2178 WindowInfo* pNewWindowInfo = null;
2179 if (__pHitElementResult != null)
2181 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2182 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2188 case IDA_SAVE_IMAGE_CLICKED:
2190 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2191 const Bitmap* pSaveBitmap = null;
2192 String imageName = GetImagePath();
2193 AppLog("Content manager image name %ls",imageName.GetPointer());
2196 imagePath.Append(imageName);
2197 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2198 AppLog("Content manager image path %ls",imagePath.GetPointer());
2199 if (__pHitElementResult != null)
2201 pSaveBitmap = __pHitElementResult->GetImage();
2203 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2207 UpdateImageContent(pBuffer, imageName);
2209 if(__pNotification != null)
2211 RemoveControl(__pNotification);
2212 __pNotification = null;
2214 __pNotification = new NotificationPanel(*this);
2216 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2217 msg.Append(imagePath);
2218 if (__pNotification != null)
2220 __pNotification->SetText(msg);
2221 if (__pFooterPanel->GetShowState() == true)
2223 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2227 __pNotification->SetPositionDiff(0);
2229 __pNotification->ShowNotification();
2234 int __modalMsgBoxResult;
2235 MessageBox* pMsgBox = new MessageBox();
2236 pMsgBox->Construct(CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_IMGE_POP_UNABLE_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2237 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2240 __modalMsgBoxResult = 0;
2244 case IDA_SHARE_IMAGE_CLICKED:
2246 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2247 if (__pPopUp != null)
2254 __pAddressbar->HideKeypad();
2256 __pPopUp = new(std::nothrow) SharePopup();
2257 __pPopUp->Initialize();
2258 if (__pHitElementResult != null)
2260 const Bitmap* pSaveBitmap = null;
2261 String imageName = GetImagePath();
2262 AppLog("Content manager image name %ls",imageName.GetPointer());
2265 imagePath.Append(imageName);
2266 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2267 AppLog("Content manager image path %ls",imagePath.GetPointer());
2268 if (__pHitElementResult != null)
2270 pSaveBitmap = __pHitElementResult->GetImage();
2272 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2274 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2275 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2277 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2278 pShareInfo->SetPageTitle(L"");
2279 pShareInfo->SetPageUrl(srcUrl);
2280 pShareInfo->SetImageAttached(true);
2281 pShareInfo->SetImagePath(imagePath);
2282 __pPopUp->RemoveAllShareInfo();
2283 __pPopUp->AddShareInfo(pShareInfo);
2284 __pPopUp->SetShowState(true);
2289 case IDA_HYPERLINK_OPEN_CLICKED:
2291 if (__pHitElementResult != null)
2293 String srcUrl = __pHitElementResult->GetUrl();
2295 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2297 if (pNewWindowInfo == null)
2301 pNewWindowInfo->isJavascriptInitiated = true;
2302 result r = E_SUCCESS;
2303 SceneManager* pSceneManager = SceneManager::GetInstance();
2304 if (pSceneManager == NULL)
2308 ArrayList* pArgList = new(std::nothrow) ArrayList();
2309 if (pArgList == NULL)
2313 pArgList->Construct();
2315 pArgList->Add(*pNewWindowInfo);
2316 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2317 if (pArgList != null)
2324 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2330 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2332 if (__pHitElementResult == null)
2337 if(__pPopUp != null)
2344 __pAddressbar->HideKeypad();
2346 __pPopUp = new(std::nothrow) SharePopup();
2347 __pPopUp->Initialize();
2349 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2350 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2351 pShareInfo->SetImageAttached(false);
2352 __pPopUp->RemoveAllShareInfo();
2353 __pPopUp->AddShareInfo(pShareInfo);
2355 __pPopUp->SetShowState(true);
2359 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2363 if (__pHitElementResult != null)
2365 url = __pHitElementResult->GetUrl();
2368 String resourcePath = App::GetInstance()->GetAppResourcePath();
2369 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2371 // copying the item to clipboard
2372 Clipboard* pClipboard = Clipboard::GetInstance();
2373 if (pClipboard != null)
2375 pClipboard->CopyItem(item);
2379 case IDA_FIND_TEXT__CLICKED:
2381 // AddressBarCancelledClicked(*__pAddressbar);
2382 RelayoutControls(false);
2383 // __pFooterPanel->SetShowState(false);
2384 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2385 __currentSearchStr.Clear();
2386 __currentSearchStr.Append(__currentSelectedStr);
2387 InitFindWordPanel();
2388 __pFindWordEditField->SetText(__currentSearchStr);
2390 if(__pOptionMenu != null)
2392 __pOptionMenu->SetShowState(false);
2393 __pOptionMenu->Invalidate(false);
2395 __adressPanelPosition.y = 0;
2397 if (__pAddressbar != null && __pWebViewer != NULL)
2399 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2400 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2402 if (__pFooterPanel->GetShowState() == false)
2403 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2405 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2406 __pWebViewer->Invalidate(true);
2409 ShowFindWordPanel(true);
2410 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2412 __pFindWordEditField->SetText(__currentSearchStr);
2413 __pFindWordEditField->SetFocus();
2415 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2417 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2418 __pFindWordEditFieldRightToLeft->SetFocus();
2421 if (__currentSearchStr.GetLength() > 0)
2427 AppLogDebug("Enter something");
2430 if (__pWebViewer != null)
2432 // releasing the set block
2433 __pWebViewer->ReleaseBlock();
2438 case IDA_SHARE_TEXT_CLICKED:
2440 __pWebViewer->ReleaseBlock();
2441 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2442 if(__pPopUp != null)
2449 __pAddressbar->HideKeypad();
2451 __pPopUp = new(std::nothrow) SharePopup();
2452 __pPopUp->Initialize();
2453 if (__pHitElementResult != null)
2455 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2456 pShareInfo->SetPageTitle(L"");
2457 pShareInfo->SetPageUrl(__currentSelectedStr);
2458 pShareInfo->SetImageAttached(false);
2459 __pPopUp->RemoveAllShareInfo();
2460 __pPopUp->AddShareInfo(pShareInfo);
2461 __pPopUp->SetShowState(true);
2466 case IDA_COPY_TEXT_CLICKED:
2468 __pWebViewer->ReleaseBlock();
2469 // need to implement
2470 //__currentSelectedStr
2471 // Sets data to a clip board item
2473 String resourcePath = App::GetInstance()->GetAppResourcePath();
2474 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2476 // copying the item to clipboard
2477 Clipboard* pClipboard = Clipboard::GetInstance();
2478 if (pClipboard != null)
2480 pClipboard->CopyItem(item);
2484 case IDA_PASTE_TEXT_CLICKED:
2486 Clipboard* pClipboard = Clipboard::GetInstance();
2488 if(pClipboard == null)
2492 // Retrieves a latest item
2493 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2499 //Gets data from the clipboard item
2500 String* pString = dynamic_cast<String*>(pItem->GetData());
2502 if (pString != null)
2504 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2505 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2506 String tagElement = __pHitElementResult->GetTagName();
2507 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2508 String str = L"document.getElementsByName('";
2509 str.Append(nameElement);
2510 str.Append("').length");
2511 String* pCount = __pWebViewer->EvaluateJavascriptN(str);
2514 if(idElement.GetLength() != 0)
2516 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; } } ";
2517 script.Append("insertAtCursor('");
2518 script.Append(idElement);
2519 script.Append("',");
2520 script.Append("\"");
2521 script.Append(*pString);
2522 script.Append("\");");
2524 else if (nameElement.GetLength() != 0 && pCount->Equals("1",false) == true)
2526 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.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 { myField.value += myValue; } } ";
2527 script.Append("insertAtCursor(document.getElementsByName('");
2528 script.Append(nameElement);
2529 script.Append("')[0],");
2530 script.Append("\"");
2531 script.Append(*pString);
2532 script.Append("\");");
2534 else if(tagElement.GetLength() != 0) //adding for twitter post page
2536 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementsByTagName(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.getElementsByTagName(myField)[0].value += myValue; } } ";
2537 script.Append("insertAtCursor(document.getElementsByTagName('");
2538 script.Append(tagElement);
2539 script.Append("')[0],");
2540 script.Append("\"");
2541 script.Append(*pString);
2542 script.Append("\");");
2544 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2545 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2557 case IDA_GO_FORWARD:
2562 case IDA_REFRESH_BTN_CLICKED:
2564 __isLoadingCompleted = false;
2565 __isLoadingData = true;
2566 __progressPercentage = 0;
2567 __displayUrl = __pFooterUrlField->GetText();
2569 String url = __pFooterUrlField->GetText();
2570 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2572 if (__pWebViewer != null && __pAddressbar != null)
2574 __pWebViewer->Reload();
2575 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2579 UpdateProgressBitmap();
2582 case IDA_STOP_BTN_CLICKED:
2584 __isLoadingCompleted = false;
2585 __isLoadingData = false;
2586 __progressPercentage = 0;
2587 __pFooterUrlField->HideKeypad();
2588 __displayUrl = __pFooterUrlField->GetText();
2592 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2593 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2594 __pWebViewer->StopLoading();
2595 RequestRedraw(true);
2598 UpdateProgressBitmap();
2603 if (__pFooterUrlField->GetText().IsEmpty() == false)
2605 //__displayUrl = __pUrlField->GetText();
2606 __pFooterUrlField->Clear();
2611 case IDA_READER_BTN_CLICKED:
2622 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2624 AppLog("MainForm::OnFormBackRequested entered");
2625 result r = E_FAILURE;
2626 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2628 AppLog("Hiding the menu");
2629 __pImageMenu->SetShowState(false);
2631 if (__pWebViewer && __pWebViewer->CanGoBack())
2633 __pWebViewer->GoBack();
2635 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2638 pApp = UiApp::GetInstance();
2641 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2644 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2652 WindowInfo* pWindowInfo = null;
2654 SceneManager* pSceneManager = SceneManager::GetInstance();
2655 if (pSceneManager == null)
2659 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2660 if (pAllWindowList == NULL)
2662 pApp = UiApp::GetInstance();
2665 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2668 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2673 if (pAllWindowList != null)
2675 totalCount = pAllWindowList->GetCount();
2677 for (int count = 0; count < totalCount; count++)
2679 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2680 if (pWindowInfo == null)
2682 pApp = UiApp::GetInstance();
2685 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2688 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2695 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2697 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2700 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2703 r = pAllWindowList->RemoveAt(count, true);
2704 __pWindowInfo = null;
2707 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2712 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2716 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2718 if (pWindowInfo == null)
2720 pApp = UiApp::GetInstance();
2723 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2729 if(pWindowInfo != null)
2730 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2733 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2739 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2741 // UiApp* pApp = null;
2742 // pApp = UiApp::GetInstance();
2743 // if (pApp != null)
2745 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2748 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2756 AppLog("MainForm::OnFormBackRequested exit");
2760 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2761 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2764 AppLog("MainForm::OnSceneActivatedN called");
2765 String* pSelectedScene = NULL;
2766 Object* pValue = NULL;
2767 String* pUrl = null;
2768 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2769 pSelectedScene = (String*) pValue;
2771 if (pSelectedScene != null)
2773 delete pSelectedScene;
2775 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2776 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2777 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2778 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2780 // setting the current scene ID
2781 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2783 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2785 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2787 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2788 if(__pWindowInfo == null)
2790 // if(__pWindowInfo == null)
2792 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2795 else if ( pArgs != null && pArgs->GetCount() == 1)
2797 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2803 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2805 // hiding the address bar
2806 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2807 __pAddressbar->SetShowState(false);
2808 // if(__pWebViewer != null)
2810 // __pWebViewer->Resume();
2813 if(pUrl != null && pUrl->GetLength() > 0)
2817 else if(__pWindowInfo != null)
2819 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.Contains(IDSCN_MAIN_VIEW) == false)
2821 LoadUrl(__pWindowInfo->pageUrl);
2823 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2825 LoadUrl(__pWindowInfo->pageUrl);
2826 __pWindowInfo->isAppcontrolTriggered = false;
2828 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2830 __pWindowInfo->isFirstLaunch = false;
2833 __pWindowInfo->pCurrentWeb = __pWebViewer;
2834 if(__pWindowInfo->pageUrl.GetLength() > 0)
2835 LoadUrl(__pWindowInfo->pageUrl);
2839 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2840 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2841 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2843 InitMostVisitedSitesView(GetOrientationStatus());
2845 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2847 if(__pMostVisitedListView != null)
2849 __pMostVisitedListView->SetShowState(false);
2853 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2855 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2857 if (pBookmarkUrl == null)
2859 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2860 //__pAddressbar->SetUrl(*pBookmarkUrl);
2861 SetUrl(*pBookmarkUrl);
2863 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2864 __pWebViewer->LoadUrl(*pBookmarkUrl);
2865 delete pBookmarkUrl;
2868 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2869 Bitmap* pBitmap = null;
2870 if (isPrivateBrowsing == true)
2872 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2874 if (__pWebViewer != null)
2876 __pWebViewer->SetPrivateBrowsingEnabled(true);
2879 if (__pAddressbar != null)
2881 // __pAddressbar->UpdateFaviconBitmap(true);
2887 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2889 if (__pWebViewer != null)
2891 __pWebViewer->SetPrivateBrowsingEnabled(false);
2894 if (__pAddressbar != null)
2896 // __pAddressbar->UpdateFaviconBitmap(false);
2900 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2902 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2904 else if (__pOptionMenu != null )
2906 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2909 if (pBitmap != null)
2914 RelayoutControls(false);
2915 AppLog("ABC: OnSceneActivatedN started exit");
2920 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2921 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2923 Canvas* pWebCanvas = null;
2924 if (__pWebViewer != null)
2926 pWebCanvas = __pWebViewer->GetCanvasN();
2929 if (pWebCanvas == null)
2933 if (__pWindowInfo != null)
2935 if (__pWindowInfo->pWebCanvasBitmap != null)
2937 delete __pWindowInfo->pWebCanvasBitmap;
2939 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2940 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2941 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2943 Bitmap* pBitmap = GetCapturedBitmapN();
2944 AppLog("Coming here");
2945 Canvas* pCanvas = new(std::nothrow) Canvas();
2946 pCanvas->Construct(GetClientAreaBounds());
2949 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2952 if(__pWebViewer != null && __pWindowInfo != null)
2953 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2955 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2956 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2960 __pAddressbar->SetShowState(false);
2961 AppLog("Coming here");
2965 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2966 const Tizen::Base::String& realm,
2967 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2973 MainForm::OnHttpAuthenticationCanceled(void)
2978 MainForm::OnLoadingStarted(void)
2980 AppLogDebug("MainForm::OnLoadingStarted entered");
2982 if(__pAddressbar == NULL || __pWebViewer == null)
2987 // this is added in case if menu is opened and user load the page
2988 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2990 __pOptionMenu->SetShowState(false);
2991 __pOptionMenu->Invalidate(true);
2996 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2998 __pImageMenu->SetShowState(false);
2999 __pImageMenu->Invalidate(true);
3001 String url = __pWebViewer->GetUrl();
3002 if(url.Contains(IDS_TIZEN_SERVICE))
3005 String delim(L":;,");
3007 // Creates a StringTokenizer instance
3008 StringTokenizer strTok(url, delim);
3010 int count = strTok.GetTokenCount(); // count == 4
3012 HashMap *pMap = new HashMap();
3017 while (strTok.HasMoreTokens())
3019 AppLog("Token: %ls", token.GetPointer());
3020 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3021 if(token.Contains(IDS_APPID))
3023 token.SubString(6, appId);
3024 AppLog("AppID:%ls", appId.GetPointer());
3026 else if(token.Contains(IDS_KEY))
3028 token.SubString(4, key);
3029 AppLog("key:%ls", key.GetPointer());
3031 else if(token.Contains(IDS_VALUE))
3033 token.SubString(6, value);
3034 AppLog("value:%ls", value.GetPointer());
3037 pMap->Add(key, value);
3041 AppControl *pAppControl = null;
3042 String operationId = L"http://tizen.org/appcontrol/operation/main";
3043 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3046 AppLog("Starting AppControl");
3047 result r = pAppControl->Start(null, null, pMap, null);
3048 AppLog("Result of Start %s", GetErrorMessage(r));
3052 AppLogException("AppControl not found");
3057 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3059 __pAddressbar->SetShowState(false);
3060 AddressBarCancelledClicked(*__pAddressbar);
3061 __pAddressbar->Invalidate(true);
3063 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3066 __pAddressbar->SetFaviconBitmap(*pBitmap);
3069 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3071 // updating the address bar position with respect to web control
3072 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3073 __distanceMoved = 0;
3077 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3078 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3079 if (__pWebViewer != null)
3081 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3082 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3083 SetUrl(__pWebViewer->GetUrl());
3084 if (__pWindowInfo != NULL)
3086 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3087 __pWindowInfo->pageTitle = L"";
3088 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3090 __pAddressbar->Invalidate(true);
3096 MainForm::OnLoadingCanceled(void)
3103 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3105 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3110 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3112 AppLog("XYZ::MainForm::OnKeypadOpened");
3113 __isKeypadOpened = true;
3114 __pFooterPanel->SetShowState(false);
3119 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3121 AppLog("XYZ::MainForm::OnKeypadClosed");
3122 __isKeypadOpened = false;
3123 __pFooterPanel->SetShowState(true);
3124 RelayoutControls(true);
3128 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3130 AppLog("XYZ::KeypadBoundsChanged");
3131 RelayoutControls(false);
3135 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3136 const Tizen::Base::String& reason)
3138 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3142 MainForm::OnLoadingCompleted(void)
3144 AppLog("MainForm::OnLoadingCompleted start");
3146 result r = E_SUCCESS;
3148 if (__pWebViewer == null)
3153 if (__pAddressbar == null)
3158 if(__pImageMenu && __pImageMenu->GetShowState())
3160 __pImageMenu->SetShowState(false);
3161 __pImageMenu->Invalidate(true);
3164 if (__pWebViewer->CanGoForward())
3166 //__pAddressbar->SetForwardButtonEnabled(true);
3167 SetForwardButtonEnabled(true);
3171 //__pAddressbar->SetForwardButtonEnabled(false);
3172 SetForwardButtonEnabled(false);
3175 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3177 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3179 //__pAddressbar->UpdateProgress(0);
3183 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3185 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3189 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3190 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3191 if (isPrivateBrowsing == false)
3193 if(__pHistory != null)
3199 __pHistory = new(std::nothrow) History;
3200 HistoryPresentationModel::GetCurrentDateTime(date);
3203 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3204 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3206 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3207 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3209 __pHistory->SetVisitedTime(date);
3211 if (__pWebViewer != null)
3213 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3215 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3216 if (pTempBitmap != null)
3218 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3219 __pHistory->SetFavIconBitmap(*pTempBitmap);
3222 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3225 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3226 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3227 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3229 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3230 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3231 __pHistory->SetThumbnail(pBitmap);
3233 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3236 __pHistory->SetFavIconBitmap(*pFavIcon);
3240 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3247 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3249 // temperary fixed (webpage can be not loaded)
3253 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3254 if (isReaderEnabled == true)
3258 delete __pReaderData;
3259 __pReaderData = null;
3261 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3262 filePath.Append(L"data/reader.js");
3268 result r = E_SUCCESS;
3269 FileAttributes attr;
3271 File::GetAttributes(filePath,attr);
3273 r = file.Construct(filePath, L"r+");
3276 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3279 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3282 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3285 // file.Read(pScript,attr.GetFileSize());
3287 // AppLogDebug("scipt length %d",strlen(pScript));
3288 String strScript = L"";
3289 // strScript.Append(pScript);
3290 // for(int i=0; i<25; i++)
3292 file.Read(pScript,attr.GetFileSize());
3293 // AppLog("xyzz tell %d",file.Tell());
3294 // r = strScript.Append(pScript);
3295 // AppLog("xyzz append result %s",GetErrorMessage(r));
3296 // AppLog("xyzz strScript length %d",strScript.GetLength());
3298 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3300 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3301 if (__pReaderData == null)
3303 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3304 __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>");
3307 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3308 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3310 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3311 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3317 AppLog("MainForm::OnLoadingCompleted done");
3321 MainForm::OnEstimatedProgress(int progress)
3323 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3325 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3326 progress = DEFAULT_PROGRESS_PERCENTAGE;
3328 // __pAddressbar->UpdateProgress(progress);
3329 UpdateProgress(progress);
3332 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3334 AppLog("MainForm::OnFaviconReceived");
3335 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3337 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3340 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3347 MainForm::OnUrlValueChanged(Addressbar&)
3353 MainForm::OnUrlSubmitted(Addressbar& addBar)
3355 AppLog("MainForm::OnUrlSubmitted");
3356 String url = addBar.GetUrl();
3357 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3359 if(__pFooterUrlField)
3360 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3361 AddressBarCancelledClicked(*__pAddressbar);
3366 MainForm::LoadUrl(String& url)
3370 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3371 AppLogDebug("MainForm::LoadUrl enter");
3373 if (__pWebViewer != null)
3375 __pWebViewer->SetShowState(true);
3376 __pWebViewer->Invalidate(true);
3379 if (url.CompareTo(L"") == 0)
3383 if(__pFooterPanel != null)
3385 __pFooterPanel->SetShowState(true);
3386 __pFooterPanel->Invalidate(true);
3393 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3394 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)
3396 RegularExpression firstRegex;
3397 RegularExpression secondRegex;
3399 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3400 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3403 ret = firstRegex.Match(url, false); // This returns true value
3404 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3406 if (ret == true && __pWebViewer != null)
3409 __pWebViewer->LoadUrl(url);
3411 else if(__pWebViewer != null)
3413 String tempUrl = L"http://";
3414 tempUrl.Append(url);
3418 __pWebViewer->LoadUrl(tempUrl);
3422 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3423 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3426 if (__pAddressbar != null)
3428 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3429 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3432 AppLogDebug("MainForm::LoadUrl exit");
3439 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3441 AppLog("MainForm::OnFocusGained");
3444 __pFooterPanel->SetShowState(false);
3449 __pAddressbar->SetShowState(true);
3450 __pAddressbar->SetAddressbarURLFocus();
3452 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3454 __currentSearchStr = L"";
3455 __currentWordIndex = 0;
3456 __maxOccurrances = 0;
3458 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3460 __pFindWordEditField->SetText(L"");
3461 __pFindWordEditField->HideKeypad();
3462 __pFindWordControl->SetShowState(false);
3463 __pFindWordCountLabel->SetText(L"0/0");
3465 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3467 __pFindWordEditFieldRightToLeft->SetText(L"");
3468 __pFindWordEditFieldRightToLeft->HideKeypad();
3469 __pFindWordControl->SetShowState(false);
3470 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3473 __pFindWordNext->SetEnabled(false);
3474 __pFindWordPrev->SetEnabled(false);
3476 __pWebViewer->SearchTextAllAsync(L"",true);
3477 __pFindWordControl->SetShowState(false);
3479 RelayoutControls(false);
3483 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3485 AppLog("MainForm::OnFocusLost called");
3489 MainForm::OnStopClicked(Addressbar& addBar)
3491 AppLogDebug("MainForm::OnStopClicked called");
3494 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3495 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3496 __pWebViewer->StopLoading();
3497 RequestRedraw(true);
3502 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3504 // AppLog("MainForm::OnBackClicked");
3505 result r = E_FAILURE;
3506 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3508 AppLog("Hiding the menu");
3509 __pImageMenu->SetShowState(false);
3512 if (__pWebViewer && __pWebViewer->CanGoBack())
3514 __pWebViewer->GoBack();
3516 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3519 pApp = UiApp::GetInstance();
3522 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3525 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3533 WindowInfo* pWindowInfo = null;
3535 SceneManager* pSceneManager = SceneManager::GetInstance();
3536 if (pSceneManager == null)
3540 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3541 if (pAllWindowList == NULL)
3543 pApp = UiApp::GetInstance();
3546 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3549 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3554 if (pAllWindowList != null)
3556 totalCount = pAllWindowList->GetCount();
3558 for (int count = 0; count < totalCount; count++)
3560 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3561 if (pWindowInfo == null)
3563 pApp = UiApp::GetInstance();
3566 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3569 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3574 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3576 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3579 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3582 r = pAllWindowList->RemoveAt(count, true);
3583 __pWindowInfo = null;
3586 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3591 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3593 else if(pAllWindowList->GetCount() > 0)
3595 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3599 pApp = UiApp::GetInstance();
3602 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3607 if (pWindowInfo == null)
3609 pApp = UiApp::GetInstance();
3612 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3618 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3619 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3622 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3636 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3638 AppLog("MainForm::OnForwardClicked");
3639 if (__pWebViewer == null)
3642 if (__pWebViewer->CanGoForward())
3644 __pWebViewer->GoForward();
3649 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3651 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3652 if(__pFooterPanel != null)
3654 __pFooterPanel->SetShowState(false);
3657 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3659 __pAddressbar->SetShowState(true);
3660 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3663 RelayoutControls(false);
3667 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3669 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3671 int Height = GetClientAreaBounds().height;
3672 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3674 RelayoutControls(false);
3678 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3680 AddressBarCancelledClicked(addBar);
3684 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3686 __prevAddressBarMode = __curAddressBarMode;
3688 if (__pAddressbar != null)
3690 __curAddressBarMode = GetAddressbarMode();
3693 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3695 __adressPanelPosition.y = 0;
3696 if (__pAddressbar != null)
3698 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3699 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3700 __pAddressbar->Invalidate(true);
3702 if (__pWebViewer != null)
3704 __pWebViewer->StopLoading();
3707 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3709 __adressPanelPosition.y = 0;
3710 if (__pAddressbar != null)
3712 __webControlPosition.y = 0;
3713 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3714 __pAddressbar->Invalidate(true);
3720 MainForm::OnClipboardClosed(const Addressbar& addBar)
3722 AppLog("XYZ::MainForm::OnClipboardClosed");
3723 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3725 AppLog("akjshdasd 3");
3726 __pFooterPanel->SetShowState(true);
3728 __isKeypadOpened = false;
3729 RelayoutControls(false);
3733 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3735 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3736 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3738 AppLog("akjshdasd 3");
3739 __pFooterPanel->SetShowState(true);
3741 __isKeypadOpened = false;
3742 if(__pNotification && __pNotification->GetShowState())
3744 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3747 RelayoutControls(false,footerState);
3751 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3753 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3754 __isKeypadOpened = true;
3755 if(__pNotification && __pNotification->GetShowState())
3757 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3759 RelayoutControls(false);
3763 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3765 __isKeypadOpened = true;
3766 __pFooterPanel->SetShowState(false);
3770 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3772 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3773 RelayoutControls(false);
3777 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3779 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3782 __pWindowInfo->pageTitle = title;
3783 if (__pWebViewer != null)
3785 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3786 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3789 if (__pAddressbar != null && __pWebViewer != null)
3791 SetUrl(__pWebViewer->GetUrl());
3792 __pAddressbar->Invalidate(true);
3797 MainForm::UpdateFavicon(void)
3799 bool urlImageType = false;
3800 String *tempPath = null;
3802 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();");
3803 Bitmap* pBitmap = null;
3805 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3807 if (__pWindowInfo != null)
3810 url.SetUri(*tempPath);
3811 if (url.GetHost().GetLength() == 0)
3815 webUrl.SetUri(__pWebViewer->GetUrl());
3816 result r = url.SetHost(webUrl.GetHost());
3823 if (url.GetScheme().GetLength() == 0)
3827 webUrl.SetUri(__pWebViewer->GetUrl());
3828 url.SetScheme(webUrl.GetScheme());
3830 __pWindowInfo->faviconUrl = url.ToString();
3832 pBitmap = __pWebViewer->GetFaviconN();
3834 if (pBitmap != null)
3836 if (__pWindowInfo->pFavicon != NULL)
3838 __pWindowInfo->pFavicon = null;
3840 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3841 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3843 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3845 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3847 else if(__pWindowInfo->pFavicon != null)
3849 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3853 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3854 if(pDefaultBmp != null)
3856 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3870 if(tempPath != null)
3874 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3880 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3881 Tizen::Web::Controls::WebNavigationType type)
3883 AppLog("urlk %ls",url.GetPointer());
3884 // when load new page if find word panel is open its show state is false
3885 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3887 __currentSearchStr = L"";
3888 __currentWordIndex = 0;
3889 __maxOccurrances = 0;
3890 __pFindWordEditField->SetText(L"");
3891 __pFindWordNext->SetEnabled(false);
3892 __pFindWordPrev->SetEnabled(false);
3893 __pFindWordCountLabel->SetText(L"0/0");
3894 __pFindWordControl->SetShowState(false);
3895 __pFindWordEditField->HideKeypad();
3896 RelayoutControls(false);
3899 __pFooterPanel->Invalidate(true);
3902 uriInfo.SetUri(url);
3904 if(url.Contains(IDS_TIZEN_SERVICE))
3907 String delim(L":;,");
3909 // Creates a StringTokenizer instance
3910 StringTokenizer strTok(url, delim);
3912 int count = strTok.GetTokenCount(); // count == 4
3914 HashMap *pMap = new HashMap();
3920 while (strTok.HasMoreTokens())
3922 AppLog("Token: %ls", token.GetPointer());
3923 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3924 if(token.Contains(IDS_APPID))
3926 token.SubString(6, appId);
3927 AppLog("AppID:%ls", appId.GetPointer());
3929 else if(token.Contains(IDS_KEY))
3931 token.SubString(4, key);
3932 AppLog("key:%ls", key.GetPointer());
3934 else if(token.Contains(IDS_VALUE))
3936 token.SubString(6, value);
3937 AppLog("value:%ls", value.GetPointer());
3940 pMap->Add(key, value);
3944 AppControl *pAppControl = null;
3945 String operationId = L"http://tizen.org/appcontrol/operation/main";
3946 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3949 result r = pAppControl->Start(null, null, pMap, null);
3953 AppLogException("AppControl not found");
3963 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3964 const Tizen::Net::Http::HttpHeader& httpHeader)
3966 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3970 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3972 AppLog("MainForm::OnWebPageBlockSelected");
3973 // if(__isLongPressedDone == false)
3976 if (__pHitElementResult != null)
3978 delete __pHitElementResult;
3979 __pHitElementResult = null;
3982 if (__pWebViewer != null)
3984 AppLog("MainForm::OnWebPageBlockSelected web not null");
3985 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3987 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
3989 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3990 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3991 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
3993 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3995 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3999 if (__pHitElementResult == null)
4004 if (__pHitElementResult->HasImage() != true)
4006 String tagName = __pHitElementResult->GetTagName();
4007 String type = __pHitElementResult->GetAttributeValue("type");
4010 AppLog("TagName %ls",tagName.GetPointer());
4011 __currentSelectedStr.Clear();
4012 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4013 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4014 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4015 if(tagName.Equals(L"TEXTAREA",false) == true)
4017 AppLog("Tagnameseemstobe TEXTAREA");
4019 else if(tagName.Equals(L"INPUT",false) == true)
4021 AppLog("Tagnameseemstobe INPUT");
4024 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4026 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4028 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4031 __pImageMenu->SetShowState(true);
4032 __pImageMenu->Show();
4033 __pImageMenu->Invalidate(true);
4036 else /*if(__isLongPressedDone == true)*/
4038 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4040 if(__pHitElementResult->GetUrl().GetLength() > 0)
4042 __currentSelectedStr.Clear();
4043 __currentSelectedStr = __pHitElementResult->GetUrl();
4045 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4048 __pImageMenu->SetShowState(true);
4049 __pImageMenu->Show();
4050 __pImageMenu->Invalidate(true);
4054 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4055 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4056 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4062 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4068 MainForm::OnWebWindowCreateRequested(void)
4070 AppLog("MainForm::OnWebWindowCreateRequested entered");
4071 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4073 if (pNewWindowInfo == null)
4077 result r = E_SUCCESS;
4078 SceneManager* pSceneManager = SceneManager::GetInstance();
4079 if (pSceneManager == NULL)
4083 ArrayList* pArgList = new(std::nothrow) ArrayList();
4084 if (pArgList == NULL)
4088 r = pArgList->Construct();
4091 pNewWindowInfo->isJavascriptInitiated = true;
4092 pArgList->Add(*pNewWindowInfo);
4093 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4097 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4104 return pNewWindowInfo->pCurrentWeb;
4107 void MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4109 AppLog("OnWebWindowCloseRequested");
4110 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4111 SceneManager* pSceneManager = SceneManager::GetInstance();
4112 WindowInfo* pWindowInfo = null;
4113 WindowInfo* pNewWindowInfo = null;
4116 result r = E_FAILURE;
4118 if (pAllWindowList != null)
4120 totalCount = pAllWindowList->GetCount();
4123 for (int count = 0; count < totalCount; count++)
4125 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4126 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID)
4128 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
4131 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
4135 r = pAllWindowList->RemoveAt(count, true);
4139 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
4141 else if(pAllWindowList->GetCount() > 0)
4143 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4147 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4149 if (pNewWindowInfo == null)
4153 result r = E_SUCCESS;
4154 SceneManager* pSceneManager = SceneManager::GetInstance();
4155 if (pSceneManager == NULL)
4159 ArrayList* pArgList = new(std::nothrow) ArrayList();
4160 if (pArgList == NULL)
4164 r = pArgList->Construct();
4167 pArgList->Add(*pNewWindowInfo);
4168 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4169 if (pArgList != null)
4176 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4181 pApp = UiApp::GetInstance();
4184 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4189 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4191 __pWindowInfo = null;
4199 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4201 AppLog("xyz:: MainForm::RelayoutControls called");
4202 __webControlPosition.y = 0;
4203 __webControlHeight = GetClientAreaBounds().height;
4204 AppLog("Client area height: %d", __webControlHeight);
4206 AppLog("Client area height: %d", __webControlHeight);
4207 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4209 __webControlPosition.y += __pAddressbar->GetHeight();
4210 __webControlHeight -= __pAddressbar->GetHeight();
4211 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4213 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4215 __webControlPosition.y += __pFindWordControl->GetHeight();
4216 __webControlHeight -= __pFindWordControl->GetHeight();
4217 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4220 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4222 __webControlHeight -= __pFooterPanel->GetHeight();
4224 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4225 __webControlHeight = __webControlHeight + 12;
4227 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4229 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4234 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4235 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4236 __pWebViewer->Invalidate(false);
4239 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4241 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4248 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4250 if (__pFindWordControl == null)
4255 Tizen::Locales::LocaleManager localeManager;
4256 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4258 String languageCode;
4259 result r = SettingInfo::GetValue(L"Language", languageCode);
4260 // int languagecode = local.GetLanguageCode();
4261 AppLog("rahul language is %S", languageCode.GetPointer());
4265 InitFindWordPanel();
4267 if (languageCode.CompareTo("ara") == 0)
4269 AppLog("rahul language is arabic");
4271 __pFindWordPanelLeftToRight->SetShowState(false);
4272 __pFindWordPanelRightToLeft->SetShowState(true);
4274 __pFindWordClear->SetShowState(false);
4275 __pFindWordCountLabel->SetShowState(false);
4276 __pFindWordEditField->SetShowState(false);
4278 __pFindWordClearRightToLeft->SetShowState(true);
4279 __pFindWordCountLabelRightToLeft->SetShowState(true);
4280 __pFindWordEditFieldRightToLeft->SetShowState(true);
4284 AppLog("rahul language is not arabic");
4287 __pFindWordPanelLeftToRight->SetShowState(true);
4288 __pFindWordPanelRightToLeft->SetShowState(false);
4290 __pFindWordClear->SetShowState(true);
4291 __pFindWordCountLabel->SetShowState(true);
4292 __pFindWordEditField->SetShowState(true);
4294 __pFindWordClearRightToLeft->SetShowState(false);
4295 __pFindWordCountLabelRightToLeft->SetShowState(false);
4296 __pFindWordEditFieldRightToLeft->SetShowState(false);
4298 __pFindWordControl->SetShowState(true);
4302 if(__pFindWordControl != null)
4304 __pFindWordControl->SetShowState(false);
4308 AppLog("MainForm::ShowFindWordPanel %d",show);
4309 if (show && !isTouchPressed)
4311 if (languageCode.CompareTo("ara") == 0)
4313 if (__pFindWordEditFieldRightToLeft)
4315 __pFindWordEditFieldRightToLeft->SetFocus();
4316 __pFindWordEditFieldRightToLeft->ShowKeypad();
4321 if (__pFindWordEditField)
4323 __pFindWordEditField->SetFocus();
4324 __pFindWordEditField->ShowKeypad();
4330 if (languageCode.CompareTo("ara") == 0)
4332 if (__pFindWordEditFieldRightToLeft)
4333 __pFindWordEditFieldRightToLeft->HideKeypad();
4337 if (__pFindWordEditField)
4338 __pFindWordEditField->HideKeypad();
4342 RelayoutControls(false);
4346 MainForm::StartWordSearch()
4348 //Get the count of occurances of the word in the current page
4349 __maxOccurrances = 0;
4350 __currentWordIndex = 0;
4352 __pFindWordPrev->SetEnabled(false);
4353 String *pCountStr = null;
4356 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4357 AppLog("Search Result %s",GetErrorMessage(r));
4360 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4361 if (pCountStr != null)
4363 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4367 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4372 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4374 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4375 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4379 if (__pFindWordCountLabel)
4381 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4383 if (__pFindWordEditField)
4385 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4388 else if(totalCount >= 100)
4390 if (__pFindWordCountLabel)
4392 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4394 if (__pFindWordEditField)
4396 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4401 if (__pFindWordCountLabel)
4403 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4405 if (__pFindWordEditField)
4407 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4411 __maxOccurrances = totalCount;
4412 __currentWordIndex = currentOrdinal;
4414 //Reset the UI controls as per the maxOccurrance value
4415 if (totalCount <= 0)
4417 AppLog("Word not found");
4418 //Show error notification to user
4419 __pFindWordNext->SetEnabled(false);
4420 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4422 __pFindWordCountLabel->SetText(L"0/0");
4423 __pFindWordCountLabel->Invalidate(false);
4425 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4427 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4428 __pFindWordCountLabelRightToLeft->Invalidate(false);
4430 __pFindWordNext->Invalidate(false);
4431 __pFindWordPrev->Invalidate(false);
4436 if (totalCount == 1 || totalCount == currentOrdinal)
4438 __pFindWordNext->SetEnabled(false);
4442 __pFindWordNext->SetEnabled(true);
4445 String countStr = L"";
4446 countStr.Append(__currentWordIndex);
4447 countStr.Append(L"/");
4448 countStr.Append(__maxOccurrances);
4449 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4451 __pFindWordCountLabel->SetText(countStr);
4452 __pFindWordCountLabel->Invalidate(false);
4453 __pFindWordCountLabel->Invalidate(false);
4455 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4457 __pFindWordCountLabelRightToLeft->SetText(countStr);
4458 __pFindWordCountLabelRightToLeft->Invalidate(false);
4459 __pFindWordCountLabelRightToLeft->Invalidate(false);
4461 if (__pFindWordNext)
4463 __pFindWordNext->Invalidate(false);
4465 if (__pFindWordPrev)
4467 __pFindWordPrev->Invalidate(false);
4473 MainForm::FindNextWord(bool next)
4477 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4478 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4480 if (__currentWordIndex < __maxOccurrances)
4482 __currentWordIndex++;
4488 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4489 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4491 if(__currentWordIndex > 1)
4493 __currentWordIndex--;
4498 String countStr = L"";
4499 countStr.Append(__currentWordIndex);
4500 countStr.Append(L"/");
4501 countStr.Append(__maxOccurrances);
4503 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4505 __pFindWordCountLabel->SetText(countStr);
4506 __pFindWordCountLabel->Invalidate(false);
4508 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4510 __pFindWordCountLabelRightToLeft->SetText(countStr);
4511 __pFindWordCountLabelRightToLeft->Invalidate(false);
4514 if (__currentWordIndex >= __maxOccurrances)
4516 __pFindWordNext->SetEnabled(false);
4520 __pFindWordNext->SetEnabled(true);
4522 if (__currentWordIndex <= 1)
4524 __pFindWordPrev->SetEnabled(false);
4528 __pFindWordPrev->SetEnabled(true);
4530 __pFindWordPrev->Invalidate(false);
4531 __pFindWordNext->Invalidate(false);
4533 __pFindWordControl->Invalidate(true);
4537 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4539 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4540 __isKeypadOpened = true;
4541 __pFooterPanel->SetShowState(false);
4542 // OnAddressBarKeypadOpened(*__pAddressbar);
4546 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4548 __isKeypadOpened = true;
4549 AppLog("xyz::MainForm::OnWebKeypadOpened");
4551 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4553 __currentSearchStr = L"";
4554 __currentWordIndex = 0;
4555 __maxOccurrances = 0;
4556 __pFindWordEditField->SetText(L"");
4557 __pFindWordNext->SetEnabled(false);
4558 __pFindWordPrev->SetEnabled(false);
4559 __pFindWordCountLabel->SetText(L"0/0");
4560 __pWebViewer->SearchTextAllAsync(L"",false);
4561 __pFindWordControl->SetShowState(false);
4562 __pFindWordEditField->HideKeypad();
4566 if (__pWebViewer != null && __pFooterPanel != null)
4568 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4569 if(__pAddressbar != null)
4571 __pAddressbar->SetShowState(false);
4573 if(__pFindWordControl != null)
4575 __pFindWordControl->SetShowState(false);
4577 __pFooterPanel->SetShowState(false);
4578 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4580 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4582 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4583 // AppLog("omgomgomg");
4589 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4591 AppLog("abcde::MainForm::OnWebKeypadClosed");
4592 AppLog("xyz::MainForm::OnWebKeypadClosed");
4593 AppLog("akjshdasd 4");
4594 __pFooterPanel->SetShowState(true);
4595 // OnAddressBarKeypadClosed(*__pAddressbar);
4596 RelayoutControls(false);
4597 __isKeypadOpened = false;
4600 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4602 AppLog("abcde: imagemenu visible.");
4605 __pWebViewer->GetBlockRange(p,q);
4606 if (p == Point(0,0) && q == Point(0,0))
4609 __pImageMenu->SetAnchorPosition(p);
4610 __pImageMenu->Show();
4616 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4618 // RelativeLayout(false);
4619 if(__pWebViewer != null)
4621 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4626 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4628 Control* temp = const_cast< Control* >(&source);
4629 Header* pHeader = dynamic_cast< Header* >(temp);
4630 if (pHeader != null)
4632 //Header double - clicked
4633 AppLog("Header double clicked");
4635 if(__pFindWordControl)
4637 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4638 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4642 AppLog("MainScene::OnTouchDoublePressed");
4646 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4648 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4649 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4651 AppLog("Returning because of more than one touch point.");
4654 __longPressPoint = currentPosition;
4656 if (__pHitElementResult != null)
4658 delete __pHitElementResult;
4659 __pHitElementResult = null;
4662 if (__pWebViewer != null)
4664 AppLog("MainForm::OnTouchLongPressed web not null");
4665 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4668 if (__pHitElementResult == null)
4673 if (__pHitElementResult->HasImage() == true)
4675 if(__pWebViewer != null)
4676 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4677 __pImageMenu->SetShowState(true);
4678 __pImageMenu->Show();
4679 __pImageMenu->Invalidate(true);
4681 else if(__pHitElementResult->HasUrl() == true)
4683 String tempURl = __pHitElementResult->GetUrl();
4684 AppLog("tempURl is %ls", tempURl.GetPointer());
4685 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4686 if (pBitmap != null)
4694 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4695 __pImageMenu->SetShowState(true);
4696 __pImageMenu->Show();
4697 __pImageMenu->Invalidate(true);
4701 String tagName = __pHitElementResult->GetTagName();
4702 String type = __pHitElementResult->GetAttributeValue("type");
4703 String value = __pHitElementResult->GetAttributeValue(L"value");
4704 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4706 __currentSelectedStr.Clear();
4707 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4709 AppLog("tag name is %ls", tagName.GetPointer());
4710 AppLog("type is %ls", type.GetPointer());
4714 __isLongPressedDone = true;
4715 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4716 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) && innerHtml.GetLength() == 0 && type.Equals(L"submit",false) !=true && type.Equals(L"range",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG)
4718 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4720 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4723 __pImageMenu->SetShowState(true);
4724 __pImageMenu->Show();
4725 __pImageMenu->Invalidate(true);
4728 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4731 // __inputEventToBeSupressed = true;
4735 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4737 AppLog("xyz:: MainForm::OnTouchReleased called");
4739 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4741 __pAddressbar->SetShowState(false);
4743 if(__pFooterPanel && __isKeypadOpened == false)
4745 __pFooterPanel->SetShowState(true);
4749 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4750 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4752 __pWebViewer->ConsumeInputEvent();
4754 if(pHitElement != null)
4758 __inputEventToBeSupressed = false;*/
4762 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4769 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4771 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4773 __currentSearchStr = L"";
4774 __currentWordIndex = 0;
4775 __maxOccurrances = 0;
4777 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4779 __pFindWordEditField->SetText(L"");
4780 __pFindWordEditField->HideKeypad();
4781 __pFindWordControl->SetShowState(false);
4782 __pFindWordCountLabel->SetText(L"0/0");
4784 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4786 __pFindWordEditFieldRightToLeft->SetText(L"");
4787 __pFindWordEditFieldRightToLeft->HideKeypad();
4788 __pFindWordControl->SetShowState(false);
4789 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4792 __pFindWordNext->SetEnabled(false);
4793 __pFindWordPrev->SetEnabled(false);
4795 __pWebViewer->SearchTextAllAsync(L"",true);
4796 __pFindWordControl->SetShowState(false);
4798 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4799 if(__pAddressbar->GetShowState() == false)
4801 __pAddressbar->SetAddressbarURLFocus();
4802 __pFooterPanel->SetShowState(false);
4809 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4815 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4821 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4827 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4833 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4839 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4841 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4842 int widthContextItem = 0;
4843 if(__pFindWordCountLabel)
4844 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4845 // As per the platform engineer comment removed this line
4846 /*if(__pWebViewer != null)
4848 // 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
4849 __pWebViewer->ReleaseBlock();
4852 // if(__pFindWordControl != null)
4853 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4855 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4857 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4859 AppLog(" Orientation landscape");
4860 __pOptionMenu->SetMaxVisibleItemsCount(5);
4864 AppLog(" Orientation potrait");
4865 __pOptionMenu->SetMaxVisibleItemsCount(6);
4868 if(__pNotification && __pNotification->GetShowState() == true)
4870 __pNotification->SetShowState(false);
4871 __pNotification->Invalidate(false);
4873 if ( __pFooterLabel != null)
4875 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4878 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4884 if (__pFindWordBgLabel != null)
4886 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4887 if (pBitmap != null)
4889 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4894 if (__pFindWordBgLabelRightToLeft != null)
4896 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4897 if (pBitmap != null)
4899 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4905 // if(__pOptionMenu != null)
4906 // __pOptionMenu->SetShowState(false);
4908 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4910 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4914 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4919 AppLog("__pFooterPanel->GetShowState() is true");
4921 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4922 __pFooterPanel->Invalidate(true);
4926 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4927 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4929 InitMostVisitedSitesView(orientationStatus);
4932 RelayoutControls(false);
4933 if (__pArticleReaderPanel != null)
4935 if (__pArticleReaderPanel->GetShowState() == true)
4937 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4939 if (__pBlankPanel != null)
4940 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4942 if (__pWebReader != null)
4944 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4946 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4947 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4949 if ( pBitmap != null && pSrcBitmap != null)
4951 AppLog("CreateReaderPanel ninepatchbitmap found");
4952 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4955 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4956 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4957 if (pBitmap != null)
4962 if (pSrcBitmap != null)
4971 if (__pAddressbar != null)
4973 int width = GetClientAreaBounds().width;
4974 __pAddressbar->OrientationChanged(width);
4979 MainForm::OnSettingsChange(int settingvalue)
4981 AppLogDebug("MainForm::OnSettingsChange entered");
4983 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4985 __pAddressbar->ResetGuideText();
4987 if (__pWebViewer == null)
4989 AppLogDebug("Webviewer is not initialized yet.");
4993 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4995 WebSetting settings = __pWebViewer->GetSetting();
4996 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4998 settings.SetAutoFittingEnabled(true);
5000 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5002 settings.SetAutoFittingEnabled(false);
5004 __pWebViewer->SetSetting(settings);
5006 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5008 WebSetting settings = __pWebViewer->GetSetting();
5009 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5010 __pWebViewer->SetSetting(settings);
5012 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5014 WebSetting settings = __pWebViewer->GetSetting();
5015 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5016 __pWebViewer->SetSetting(settings);
5017 __pWebViewer->Reload();
5019 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5021 WebSetting settings = __pWebViewer->GetSetting();
5022 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5023 __pWebViewer->SetSetting(settings);
5025 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5029 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5032 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5036 WebSetting settings = __pWebViewer->GetSetting();
5037 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5038 __pWebViewer->SetSetting(settings);
5041 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5045 WebSetting settings = __pWebViewer->GetSetting();
5046 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5047 __pWebViewer->SetSetting(settings);
5050 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5052 WebSetting settings = __pWebViewer->GetSetting();
5053 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5055 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5059 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5061 __pWebViewer->SetSetting(settings);
5063 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5067 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5068 WebSetting settings = __pWebReader->GetSetting();
5069 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5070 __pWebReader->SetSetting(settings);
5076 MainForm::OnSettingsReset()
5080 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5081 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5086 MainForm::OnClearCache()
5088 result r = E_SUCCESS;
5090 if (__pWebViewer != NULL)
5092 r = __pWebViewer->ClearCache();
5095 AppLogDebug("Cache cleared success");
5099 AppLogDebug("Cache cleared fail");
5105 MainForm::OnClearCookie()
5107 result r = E_SUCCESS;
5109 if (__pWebViewer != NULL)
5111 __pWebViewer->ClearCookie();
5115 AppLogDebug("Cookie cleared success");
5119 AppLogDebug("Cache cleared fail");
5124 MainForm::OnClearFormData()
5126 result r = E_SUCCESS;
5128 if (__pWebViewer != NULL)
5130 __pWebViewer->ClearFormData();
5134 AppLogDebug("Cookie cleared success");
5138 AppLogDebug("Cache cleared fail");
5143 MainForm::OnClearPasswords()
5145 result r = E_SUCCESS;
5147 if (__pWebViewer != NULL)
5149 __pWebViewer->ClearLoginFormData();
5153 AppLogDebug("Cookie cleared success");
5157 AppLogDebug("Cache cleared fail");
5163 MainForm::findDistance(int x1,int y1,int x2, int y2)
5165 int deltaX = Math::Abs(x2 - x1);
5166 int deltaY = Math::Abs(y2 - y1);
5167 double num = deltaX*deltaX + deltaY*deltaY;
5173 for (i = 0; i < 20; i++)
5175 x = (((x*x)+ num)/(2*x));
5186 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5188 AppLog("xyz:: MainForm::OnTouchPressed called");
5189 if(__pFindWordControl)
5191 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5192 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5194 __isLongPressedDone = false;
5199 IList* pList = null;
5200 pList = touch.GetTouchInfoListN(source);
5204 int count = pList->GetCount();
5207 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5208 __touchPoint1 = pTouchInfo->position;
5210 /*if (__pAddressbar != null)
5212 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5214 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5216 __pAddressbar->SaveAddressbarEditText();
5218 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5221 __pAddressbar->Invalidate(true);
5223 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5225 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5227 //__pAddressbar->SaveAddressbarEditText();
5229 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5232 else if (count == 2)
5234 AppLogDebug("MainForm::OnTouchPressed count is two");
5235 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5236 __touchPoint1 = pTouchInfo->position;
5238 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5239 __touchPoint2 = pTouchInfo->position;
5244 pList->RemoveAll(true);
5249 __pAddressbar->SetShowState(false);
5251 if(__pFooterPanel && __isKeypadOpened == false)
5253 __pFooterPanel->SetShowState(true);
5255 RelayoutControls(false);
5260 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5262 // __currentWordIndex = 0;
5263 __isLongPressedDone = false;
5268 MainForm::MoveUiControls()
5273 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5275 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5277 if(__pFooterUrlField->GetTextLength() == 0)
5279 __pFooterUrlField->SetKeypadActionEnabled(false);
5283 __pFooterUrlField->SetKeypadActionEnabled(true);
5286 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5288 __currentSearchStr = __pFindWordEditField->GetText();
5289 if (__currentSearchStr.GetLength() > 0)
5291 __pFindWordCountLabel->SetShowState(true);
5295 // __pFindWordCountLabel->SetShowState(false);
5296 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5297 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5300 __pFindWordNext->SetEnabled(false);
5301 __pFindWordPrev->SetEnabled(false);
5302 __pFindWordNext->Invalidate(true);
5303 __pFindWordPrev->Invalidate(true);
5304 __pFindWordCountLabel->SetText(L"0/0");
5305 __pFindWordCountLabel->Invalidate(true);
5307 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5309 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5310 if (__currentSearchStr.GetLength() > 0)
5312 __pFindWordCountLabelRightToLeft->SetShowState(true);
5316 __pFindWordCountLabelRightToLeft->SetShowState(false);
5319 __pFindWordNext->SetEnabled(false);
5320 __pFindWordPrev->SetEnabled(false);
5321 __pFindWordNext->Invalidate(true);
5322 __pFindWordPrev->Invalidate(true);
5323 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5324 __pFindWordCountLabelRightToLeft->Invalidate(true);
5326 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5327 if (__currentSearchStr.GetLength() > 0)
5333 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5335 __currentSearchStr = L"";
5336 AppLogDebug("Enter something");
5341 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5348 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5350 if(__pWebViewer != null)
5353 AppLog("MainForm::InitMostVisitedSitesView");
5354 result r = E_SUCCESS;
5357 if (__pWebViewer != null && __pMostVisitedListView != null)
5362 if (__pMostVisitedListView != null)
5364 RemoveControl(__pMostVisitedListView);
5366 if(__pMostVisitedSites != null)
5368 __pMostVisitedSites->RemoveAll(true);
5371 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5373 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5374 __pMostVisitedListView = new(std::nothrow) ListView();
5376 int height = GetClientAreaBounds().height;
5378 if(__pFooterPanel->GetShowState() == true)
5380 height = height - __pFooterPanel->GetHeight();
5382 if(__pAddressbar->GetShowState() == true)
5384 height -= __pAddressbar->GetHeight();
5387 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5391 delete __pMostVisitedListView;
5392 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5395 __pMostVisitedListView->SetItemProvider(*this);
5396 __pMostVisitedListView->AddListViewItemEventListener(*this);
5397 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5398 AddControl(__pMostVisitedListView);
5399 __pMostVisitedListView->UpdateList();
5406 MainForm::GetImagePath(void)
5410 String formattedTime;
5411 DateTime currentTime;
5412 LocaleManager localManager;
5413 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5415 localManager.Construct();
5416 Locale locale = localManager.GetSystemLocale();
5417 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5419 // Get date formatter
5420 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5424 pTimeFormatter->Format(currentTime, formattedTime);
5427 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5428 String delim(L" :");
5429 StringTokenizer strTok(formattedTime, delim);
5432 String str1("GMT+00");
5433 while (strTok.HasMoreTokens())
5435 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5436 if(token.Equals(str1))
5438 AppLog("token is %ls", token.GetPointer());
5439 imageName.Append(token);
5445 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5447 result r = E_FAILURE;
5448 AppLog("Content manager 1");
5449 ContentId contentId;
5450 ContentManager contentManager;
5451 r = contentManager.Construct();
5454 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5457 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5458 Tizen::Io::Directory::Create(contentPath,true);
5459 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5461 AppLog("Already exists");
5463 else if(GetLastResult() == E_SUCCESS)
5465 AppLog("created success");
5467 contentPath.Append(imageName);
5468 contentPath.Append(".jpg");
5469 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5470 ShowIndicatorNotification(L"Download Complete",contentPath);
5471 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5475 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5477 AppLogDebug("ENTER");
5479 NotificationRequest request;
5480 request.SetAlertText(messageText);
5481 request.SetTitleText(L"");
5482 request.SetAppMessage(contentPath);
5483 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5484 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5485 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5486 String homePath = pApp->GetAppRootPath();
5487 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5488 AppLog("The iconPath is : %ls", homePath.GetPointer());
5489 request.SetIconFilePath(iconPath);
5491 Tizen::Shell::NotificationManager notiMgr;
5492 notiMgr.Construct();
5493 notiMgr.NotifyOngoingActivity(request);
5494 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5499 MainForm::SetForwardButtonEnabled(bool isEnabled)
5501 __pGoForwardBtn->SetEnabled(isEnabled);
5502 __pGoForwardBtn->Invalidate(true);
5506 MainForm::SetBackButtonEnabled(bool isEnabled)
5508 __pGoBackBtn->SetEnabled(isEnabled);
5509 __pGoBackBtn->Invalidate(true);
5513 MainForm::UpdateProgress(int percentage)
5515 __progressPercentage = percentage;
5516 if (percentage == 0 || percentage == 100)
5518 __isLoadingData = false;
5519 if (percentage == 100)
5521 __isLoadingCompleted = true;
5522 __progressPercentage = 0;
5526 __isLoadingCompleted = false;
5531 __isLoadingData = true;
5533 UpdateProgressBitmap();
5537 MainForm::GetProgress(void)
5539 return __progressPercentage;
5543 MainForm::UpdateProgressBitmap(void)
5545 result r = E_SUCCESS;
5546 if (__pProgressbarLabel == null)
5548 int w = __pProgressbarLabel->GetWidth();
5549 int h = __pProgressbarLabel->GetHeight();
5551 int progressWidth = 0;
5552 Bitmap* pRetBitmap = null;
5554 if (__progressPercentage == 0 || __progressPercentage == 100)
5556 __pProgressbarLabel->SetShowState(false);
5557 __pProgressbarLabel->Invalidate(false);
5562 __pProgressbarLabel->SetShowState(true);
5563 __pProgressbarLabel->Invalidate(false);
5566 r = canvas.Construct(Rectangle(0, 0, w, h));
5570 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5575 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5579 pBgBmp->Scale(Dimension(w, h));
5580 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5584 progressWidth = (double) (w) * __progressPercentage / 100;
5585 AppLogDebug("progressWidth: %d", progressWidth);
5586 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5588 if (pProgressBmp != null)
5590 pProgressBmp->Scale(Dimension(progressWidth, h));
5591 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5592 delete pProgressBmp;
5595 pRetBitmap = new (std::nothrow) Bitmap();
5597 if (pRetBitmap == null)
5599 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5603 pRetBitmap->Construct(canvas, canvas.GetBounds());
5605 if (__pProgressbarLabel != null && pRetBitmap != null)
5607 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5608 __pProgressbarLabel->Invalidate(false);
5611 if (pRetBitmap != null)
5620 MainForm::ReaderClicked()
5622 result r = E_SUCCESS;
5623 ArrayList* pArgList = new(std::nothrow) ArrayList();
5624 if (pArgList != null)
5626 r = pArgList->Construct();
5633 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5640 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5647 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5655 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5661 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5663 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5665 __currentAddMode = addMode;
5669 case ADDRESSBAR_MODE_INVALID:
5674 case ADDRESSBAR_MODE_READER:
5676 __pStopBtn->SetShowState(false);
5677 __pRefreshBtn->SetShowState(false);
5678 __pClearBtn->SetShowState(false);
5679 __pReaderBtn->SetShowState(false);
5682 case ADDRESSBAR_MODE_LOADING:
5684 __pRefreshBtn->SetShowState(false);
5685 __pStopBtn->SetShowState(true);
5686 __pClearBtn->SetShowState(false);
5687 __pReaderBtn->SetShowState(false);
5690 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5692 // SetUrl(__pAddressbar->GetUrl());
5694 __pRefreshBtn->SetShowState(true);
5695 __pStopBtn->SetShowState(false);
5696 __pClearBtn->SetShowState(false);
5697 __pReaderBtn->SetShowState(false);
5700 case ADDRESSBAR_MODE_EDIT:
5702 __pRefreshBtn->SetShowState(false);
5703 __pStopBtn->SetShowState(false);
5704 __pReaderBtn->SetShowState(false);
5705 __pClearBtn->SetShowState(true);
5712 OnAddressBarModeChanged();
5715 AddressBarMode MainForm::GetAddressbarMode(void)
5717 return __currentAddMode;
5720 void MainForm::SetUrl(const String& url)
5723 if(__displayUrl.GetLength() > 2048)
5724 __displayUrl.SubString(0,2048,__displayUrl);
5726 if (__pFooterUrlField != NULL)
5728 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5729 if (removedHttpUrl.IsEmpty() == false)
5731 __pFooterUrlField->SetText(removedHttpUrl);
5732 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5733 __pAddressbar->SetUrl(__displayUrl);
5737 __pFooterUrlField->SetText(__displayUrl);
5738 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5739 __pAddressbar->SetUrl(__displayUrl);
5741 if(__pFooterUrlField)
5742 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5743 __pFooterUrlField->Invalidate(false);
5744 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5745 __pAddressbar->Invalidate(true);
5746 // __pFooterUrlField->SetCursorPosition(0);
5751 MainForm::RemoveHttpTextFromDisplayURL(void)
5753 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5755 // bool isHttpText = __displayUrl.Contains(L"http://");
5756 String updatedDisplayUrl;
5757 updatedDisplayUrl.Clear();
5758 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5760 __displayUrl.SubString(7,updatedDisplayUrl);
5762 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5764 __displayUrl.SubString(8,updatedDisplayUrl);
5766 return updatedDisplayUrl;
5769 void MainForm::OnSharePopupControlStarted(void)
5771 __pWebViewer->AddTouchEventListener(*this);
5775 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5777 if (requestId == BACK_GROUND_APP_EVENT)
5779 if(__pWebViewer != null)
5781 __pWebViewer->Pause();
5785 __pImageMenu->SetShowState(false);
5787 if(__pAddressbar != null)
5789 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5792 else if(requestId == FORE_GROUND_APP_EVENT)
5794 if(__pWebViewer != null)
5796 __pWebViewer->Resume();
5798 if(__pAddressbar != null)
5800 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5806 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5808 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5809 result r = E_SUCCESS;
5812 __pAddressbar->SetShowState(false);
5814 AppLog("akjshdasd 5");
5815 __pFooterPanel->SetShowState(true);
5818 __pWebViewer->SetFocus();
5819 else if(__pMostVisitedListView)
5820 __pMostVisitedListView->SetFocus();
5821 else if(__pMultiWindowButton)
5822 __pMultiWindowButton->SetFocus();
5823 else if(__pMoreButton)
5824 __pMoreButton->SetFocus();
5826 __pAddressbar->SetShowState(false);
5828 RelayoutControls(false);
5832 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5834 AppLog("MainForm::OnFormMenuRequested called");
5836 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5838 int bookmarkCount=0;
5841 url=__pWindowInfo->pageUrl;
5842 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5843 result r = E_SUCCESS;
5844 Bitmap* pBitmap = null;
5845 String lastChar = L"";
5846 // if(url.SubString(url.GetLength()-1,lastChar));
5847 // if(lastChar == L"/")
5849 // bool exist1 = false;
5850 // bool exist2 = false;
5851 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5852 // url.SubString(0,url.GetLength() - 1,url);
5853 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5854 // exist = exist1 | exist2;
5858 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5861 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5867 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5871 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5873 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5875 if (__pOptionMenu->GetItemCount() == 9)
5877 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5881 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5886 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5890 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5891 if (__pOptionMenu->GetItemCount() != 9)
5893 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5894 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5895 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5896 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5897 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5898 __pOptionMenu->SetMaxVisibleItemsCount(6);
5900 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5902 AppLog(" Orientation landscape");
5903 __pOptionMenu->SetMaxVisibleItemsCount(5);
5907 AppLog(" Orientation potrait");
5908 __pOptionMenu->SetMaxVisibleItemsCount(6);
5911 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5914 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5916 __pAddressbar->SetShowState(false);
5918 __pFooterPanel->SetShowState(true);
5919 result r = __pOptionMenu->SetShowState(true);
5920 AppLog("ajsghd %s",GetErrorMessage(r));
5921 RelayoutControls(false);
5922 __pOptionMenu->Invalidate(true);
5923 __pOptionMenu->Show();