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.#.png";
59 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.#.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;
988 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
990 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
994 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
996 AppLog("asdasdafdsfdgfd");
999 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1003 Clipboard* pClipboard = Clipboard::GetInstance();
1005 if(pClipboard == null)
1007 clipboardAvailable = false;
1011 // Retrieves a latest item
1012 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1016 clipboardAvailable = false;
1020 //Gets data from the clipboard item
1021 String* pString = dynamic_cast<String*>(pItem->GetData());
1025 clipboardAvailable = false;
1029 if(clipboardAvailable == false && onlyPasteOption == true)
1033 __pImageMenu = new (std::nothrow) ContextMenu();
1034 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1035 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1041 if(onlyPasteOption == false)
1043 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1045 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1047 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1049 if(onlyPasteOption == false)
1051 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1052 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1055 __pImageMenu->SetMaxVisibleItemsCount(3);
1056 __pImageMenu->AddActionEventListener(*this);
1057 SetControlAlwaysOnTop(*__pImageMenu, true);
1058 __pImageMenu->SetFocusable(true);
1065 MainForm::InitFindWordPanel(void)
1067 result r = E_SUCCESS;
1068 Bitmap *pIconBitmap = null;
1070 if (__pFindWordControl != null)
1072 AppLogDebug("Findword panel already initialized");
1073 if (__pFindWordBgLabel != null)
1075 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1076 if (pBitmap != null)
1078 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1082 if (__pFindWordBgLabelRightToLeft != null)
1084 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1085 if (pBitmap != null)
1087 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1092 __pAddressbar->SetShowState(false);
1094 if(__isKeypadOpened == false)
1095 __pFooterPanel->SetShowState(true);
1099 __pFindWordControl = new (std::nothrow) Panel();
1100 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1103 AppLogException("There is some problem in the xml file. Please check.");
1106 AddControl(__pFindWordControl);
1107 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1108 SetControlAlwaysOnTop(*__pFindWordControl,true);
1109 __pFindWordControl->SetShowState(false);
1110 __pFindWordControl->Invalidate(false);
1112 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1113 __pFindWordPanelLeftToRight->SetShowState(true);
1115 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1116 __pFindWordPanelRightToLeft->SetShowState(false);
1118 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1119 if (__pFindWordBgLabel != null)
1121 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1122 Rectangle pRect = pPanel1->GetBounds();
1123 pRect.x = pRect.y = 0;
1124 __pFindWordBgLabel->SetBounds(pRect);
1125 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1126 if (pBitmap != null)
1128 AppLogDebug("InitFindWordPanel: Coming here");
1129 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1134 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1138 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1139 if (__pFindWordBgLabelRightToLeft != null)
1141 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1142 Rectangle pRect = pPanel1->GetBounds();
1143 pRect.x = pRect.y = 0;
1144 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1145 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1146 if (pBitmap != null)
1148 AppLogDebug("InitFindWordPanel: Coming here");
1149 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1154 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1158 Button* pfindWordCancel = null;
1159 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1160 if (pfindWordCancel == null)
1162 AppLogException("There is some problem in the xml file. Please check.");
1165 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1166 pfindWordCancel->AddActionEventListener(*this);
1168 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1169 if (__pFindWordClear == null)
1171 AppLogException("There is some problem in the xml file. Please check.");
1175 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1176 if (__pFindWordClearRightToLeft == null)
1178 AppLogException("There is some problem in the xml file. Please check.");
1182 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1183 __pFindWordClear->AddActionEventListener(*this);
1185 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1186 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1188 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1189 if (__pFindWordNext == null)
1191 AppLogException("There is some problem in the xml file. Please check.");
1195 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1196 __pFindWordNext->AddActionEventListener(*this);
1198 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1199 if (__pFindWordPrev == null)
1201 AppLogException("There is some problem in the xml file. Please check.");
1205 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1206 __pFindWordPrev->AddActionEventListener(*this);
1208 __pFindWordNext->SetEnabled(false);
1209 __pFindWordPrev->SetEnabled(false);
1211 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1212 if (__pFindWordCountLabel == null)
1214 AppLogException("There is some problem in the xml file. Please check.");
1218 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1219 if (__pFindWordCountLabelRightToLeft == null)
1221 AppLogException("There is some problem in the xml file. Please check.");
1225 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1226 if (__pFindWordEditField == null)
1228 AppLogException("There is some problem in the xml file. Please check.");
1231 __pFindWordEditField->AddTextEventListener(*this);
1232 __pFindWordEditField->AddKeypadEventListener(*this);
1233 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1234 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1236 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1237 if (__pFindWordEditFieldRightToLeft == null)
1239 AppLogException("There is some problem in the xml file. Please check.");
1242 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1243 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1244 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1245 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1248 __pAddressbar->SetShowState(false);
1250 if(__isKeypadOpened == false)
1251 __pFooterPanel->SetShowState(true);
1256 MainForm::CreateItem (int index, int itemWidth)
1258 Rectangle listImageRect;
1259 Rectangle pagetTitleRect;
1260 Rectangle pageURLRect;
1261 Rectangle deleteImageRect;
1262 String pageTitle(L"");
1263 String pageURL(L"");
1264 result r = E_SUCCESS;
1265 Bitmap* pListIconImage = null;
1268 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1269 if(pHistory == null)
1273 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1274 if ( pAppResource == NULL )
1278 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1280 CustomItem* pItem = new(std::nothrow) CustomItem();
1281 pageTitle = pHistory->GetHistoryTitle();
1282 pageURL = pHistory->GetHistoryUrl();
1284 if (pageURL.GetLength() == 0)
1287 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1288 pageURL = L"<"+ nourl +">";
1292 Rectangle screenBounds = GetBounds();
1295 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1304 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1306 if ( pBitmap != NULL)
1308 pListIconImage = new Bitmap();
1309 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1313 if(pListIconImage == null)
1315 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1318 if ( pListIconImage != NULL)
1320 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1321 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1322 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1325 if (pItem != null && pListIconImage != NULL)
1327 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1331 if (pageTitle.CompareTo(L"") != 0)
1335 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1339 if (pageURL.CompareTo(L"") != 0)
1343 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1348 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1350 if ( __pItemContext!= NULL)
1354 pItem->SetContextItem(__pItemContext);
1360 if ( __pItemContextLandscape!= NULL)
1364 pItem->SetContextItem(__pItemContextLandscape);
1368 if( pListIconImage != NULL)
1370 delete pListIconImage;
1371 pListIconImage = null;
1378 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1385 MainForm::GetItemCount (void)
1387 if(__pMostVisitedSites != null)
1389 __pMostVisitedSites->RemoveAll(true);
1391 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1392 if(__pMostVisitedSites != null)
1394 return __pMostVisitedSites->GetCount();
1401 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1403 AppLog("MainForm::OnListViewContextItemStateChanged called");
1404 if(__pMostVisitedSites != null)
1406 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1407 if (pHistory != null)
1409 String url = pHistory->GetHistoryUrl();
1411 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1412 __pMostVisitedListView->UpdateList();
1418 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1420 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1421 String url = pHistory->GetHistoryUrl();
1429 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1435 MainForm::OnTerminating(void)
1437 result r = E_SUCCESS;
1439 RemoveOrientationEventListener(*this);
1443 __pAddressbar->SetAddressbarEventListener(null);
1448 __pWebViewer->RemoveTouchEventListener(*this);
1449 __pWebViewer->SetWebUiEventListenerF(null);
1450 __pWebViewer->SetWebKeypadEventListener(null);
1451 __pWebViewer->SetTextSearchListener(null);
1457 delete __pItemContext;
1459 if (__pItemContextLandscape)
1461 delete __pItemContextLandscape;
1465 delete __pSaveImage;
1467 if (__pMostVisitedSites)
1469 __pMostVisitedSites->RemoveAll(true);
1470 delete __pMostVisitedSites;
1476 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1478 result r = E_SUCCESS;
1480 AppLogDebug("Clicked : %d", actionId);
1483 case IDA_BACKBTN_CLICKED:
1485 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1487 AppLog("Hiding the menu");
1488 __pImageMenu->SetShowState(false);
1490 if (__pWebViewer && __pWebViewer->CanGoBack())
1492 __pWebViewer->GoBack();
1494 else if(__pWindowInfo->isJavascriptInitiated == false)
1497 pApp = UiApp::GetInstance();
1500 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1503 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1511 WindowInfo* pWindowInfo = null;
1513 SceneManager* pSceneManager = SceneManager::GetInstance();
1514 if (pSceneManager == null)
1518 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1519 if (pAllWindowList == NULL)
1521 pApp = UiApp::GetInstance();
1524 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1527 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1532 if (pAllWindowList != null)
1534 totalCount = pAllWindowList->GetCount();
1536 for (int count = 0; count < totalCount; count++)
1538 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1539 if (pWindowInfo == null)
1541 pApp = UiApp::GetInstance();
1544 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1547 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1554 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1556 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1559 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1562 r = pAllWindowList->RemoveAt(count, true);
1563 __pWindowInfo = null;
1566 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1571 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1575 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1577 if (pWindowInfo == null)
1579 pApp = UiApp::GetInstance();
1582 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1588 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1589 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1592 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1604 case IDA_FORWARD_CLICKED:
1605 if (__pWebViewer == null)
1608 if (__pWebViewer->CanGoForward())
1610 __pWebViewer->GoForward();
1612 __pOptionMenu->SetShowState(false);
1613 __pOptionMenu->Invalidate(false);
1616 case IDA_FINDONPAGE_CLICKED:
1618 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1619 __currentSearchStr.Clear();
1621 InitFindWordPanel();
1622 __pOptionMenu->SetShowState(false);
1623 __pOptionMenu->Invalidate(false);
1625 ShowFindWordPanel(true);
1627 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1629 __pFindWordEditField->SetFocus();
1630 // __pFindWordCountLabel->SetShowState(false);
1634 __pFindWordEditFieldRightToLeft->SetFocus();
1635 __pFindWordCountLabelRightToLeft->SetShowState(false);
1639 case IDA_PRIVATEON_CLICKED:
1641 result r = E_SUCCESS;
1643 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1644 Bitmap* pBitmap = null;
1645 if (isPrivateBrowsing == true)
1647 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1650 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1654 if (__pWebViewer != NULL)
1656 __pWebViewer->SetPrivateBrowsingEnabled(false);
1659 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1661 if (__pAddressbar != null)
1663 __pAddressbar->UpdateFaviconBitmap(false);
1669 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1672 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1676 if (__pWebViewer != NULL)
1678 __pWebViewer->SetPrivateBrowsingEnabled(true);
1681 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1683 if (__pAddressbar != null)
1685 __pAddressbar->UpdateFaviconBitmap(true);
1689 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1690 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1691 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1692 __pOptionMenu->Invalidate(true);
1693 if ( pBitmap != NULL )
1700 case IDA_SETTINGS_CLICKED:
1703 ArrayList* pArgList = new(std::nothrow) ArrayList();
1706 pArgList->Construct();
1707 pArgList->Add(*__pWindowInfo);
1708 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1710 __pOptionMenu->SetShowState(false);
1711 __pOptionMenu->Invalidate(false);
1713 if (pArgList != null)
1722 case IDA_ADDTOBOOKMARK_CLICKED:
1725 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1727 int bookmarkCount=0;
1730 url=__pWindowInfo->pageUrl;
1731 result r = E_SUCCESS;
1732 Bitmap* pBitmap = null;
1733 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1741 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1742 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1743 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1745 if(__pNotification != null)
1747 RemoveControl(__pNotification);
1748 __pNotification = null;
1750 __pNotification = new (std::nothrow) NotificationPanel(*this);
1751 if (__pNotification != null)
1753 __pNotification->SetText(message);
1754 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1755 __pNotification->ShowNotification();
1760 String title=__pWindowInfo->pageTitle;
1761 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1762 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1764 pBookmark->SetBookmarkTitle(title);
1765 pBookmark->SetUrl(url);
1766 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1768 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1770 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1771 pBookmark->SetFaviconId(id);
1772 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1773 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1775 if(__pNotification != null)
1777 RemoveControl(__pNotification);
1778 __pNotification = null;
1780 __pNotification = new (std::nothrow) NotificationPanel(*this);
1781 if (__pNotification != null)
1783 __pNotification->SetText(message);
1784 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1785 __pNotification->ShowNotification();
1786 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1789 if (pBitmap != null)
1791 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1796 __pOptionMenu->Invalidate(true);
1801 case IDA_PRINT_CLICKED:
1803 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1804 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1806 AppLog("RequestPrint called!");
1807 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1808 result nResult = E_FAILURE;
1811 AppLog("TestPrint if (pAc) == true");
1816 String fileType = L"service_print_files_type";
1817 String typeVal = L"DOC";
1819 String fileCount = L"service_print_files_count";
1820 String countVal = L"1";
1821 String fileFolder= L"service_print_files_folder_name";
1822 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1824 map.Add(&fileCount, &countVal);
1825 map.Add(&fileFolder, &folderVal);
1826 map.Add(&fileType, &typeVal);
1828 String fileName = L"service_print_files_files_name";
1830 ArrayList fileNameList;
1831 fileNameList.Construct();
1832 String file1 = L"test.pdf";
1834 fileNameList.Add(&file1);
1835 map.Add(&fileName, &fileNameList);
1837 nResult = pAc->Start(NULL, NULL, &map, NULL);
1839 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1840 else if (nResult == E_MAX_EXCEEDED)
1841 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1842 else if (nResult == E_OBJ_NOT_FOUND)
1843 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1844 else if (nResult == E_IN_PROGRESS)
1845 AppLog("TestPrint ret == E_IN_PROGRESS");
1846 else if (nResult == E_PRIVILEGE_DENIED)
1847 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1848 else if(nResult == E_SYSTEM)
1849 AppLog("TestPrint ret == E_SYSTEM");
1855 int __modalMsgBoxResult;
1856 MessageBox* pMsgBox = new MessageBox();
1857 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1858 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1861 __modalMsgBoxResult = 0;
1865 case IDA_SHARE_CLICKED:
1867 if(__pPopUp != null)
1874 __pAddressbar->HideKeypad();
1876 __pPopUp = new(std::nothrow) SharePopup();
1877 __pPopUp->Initialize();
1878 if (__pWindowInfo != null)
1880 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1881 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1882 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1883 pShareInfo->SetImageAttached(false);
1884 __pPopUp->RemoveAllShareInfo();
1885 __pPopUp->AddShareInfo(pShareInfo);
1887 __pPopUp->SetShowState(true);
1891 case IDA_BOOKMARKBTN_CLICKED:
1893 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1894 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1897 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1902 case IDA_MOREBTN_CLICKED:
1904 AppLog("IDA_MOREBTN_CLICKED");
1906 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1908 int bookmarkCount=0;
1911 url=__pWindowInfo->pageUrl;
1912 result r = E_SUCCESS;
1913 Bitmap* pBitmap = null;
1915 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1918 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1923 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1927 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1929 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1931 if (__pOptionMenu->GetItemCount() == 9)
1933 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1937 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1942 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1946 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1947 if (__pOptionMenu->GetItemCount() != 9)
1949 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1950 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1951 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1952 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1953 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1954 __pOptionMenu->SetMaxVisibleItemsCount(6);
1956 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1958 AppLog(" Orientation landscape");
1959 __pOptionMenu->SetMaxVisibleItemsCount(5);
1963 AppLog(" Orientation potrait");
1964 __pOptionMenu->SetMaxVisibleItemsCount(6);
1967 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1970 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1971 __pOptionMenu->SetShowState(true);
1972 __pOptionMenu->Invalidate(true);
1973 __pOptionMenu->Show();
1977 case IDA_HISTORY_CLICKED:
1979 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1980 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1983 case IDA_SAVED_PAGES_CLICKED:
1988 case IDA_DESKTOP_VIEW_CLICKED:
1993 case IDA_SAVE_CLICKED:
1998 case IDA_MULTIWINDOWBTN_CLICKED:
2000 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2001 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2005 case IDA_NEWWINDOWBTN_CLICKED:
2007 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2009 if (pNewWindowInfo == null)
2013 result r = E_SUCCESS;
2014 SceneManager* pSceneManager = SceneManager::GetInstance();
2016 if (pSceneManager == NULL)
2020 ArrayList* pArgList = new(std::nothrow) ArrayList();
2021 if (pArgList == NULL)
2025 r = pArgList->Construct();
2028 pArgList->Add(*pNewWindowInfo);
2029 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2035 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2040 case IDA_SMALLFONT_BTN_CLICKED:
2042 WebSetting setting = __pWebReader->GetSetting();
2043 setting.SetFontSize(15);
2044 __pWebReader->SetSetting(setting);
2047 case IDA_LARGEFONT_BTN_CLICKED:
2049 WebSetting setting = __pWebReader->GetSetting();
2050 setting.SetFontSize(25);
2051 __pWebReader->SetSetting(setting);
2054 case IDA_READER_CLOSE_CLICKED:
2056 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2058 RemoveControl(__pBlankPanel);
2059 __pArticleReaderPanel = null;
2060 __pBlankPanel = null;
2061 __pArticleReaderLabel = null;
2063 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2066 case IDA_FINDWORD_CANCEL_CLICKED:
2068 __currentSearchStr = L"";
2069 __currentWordIndex = 0;
2070 __maxOccurrances = 0;
2072 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2074 __pFindWordEditField->SetText(L"");
2075 __pFindWordCountLabel->SetText(L"0/0");
2077 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2079 __pFindWordEditFieldRightToLeft->SetText(L"");
2080 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2083 __pFindWordNext->SetEnabled(false);
2084 __pFindWordPrev->SetEnabled(false);
2085 __pFindWordCountLabel->SetText(L"0/0");
2086 __pWebViewer->SearchTextAllAsync(L"",true);
2087 AppLog("akjshdasd 1");
2088 if(__isKeypadOpened == false)
2089 __pFooterPanel->SetShowState(true);
2090 ShowFindWordPanel(false);
2093 case IDA_FINDWORD_SEARCH_CLICKED:
2095 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2097 __currentSearchStr = __pFindWordEditField->GetText();
2099 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2101 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2104 if (__currentSearchStr.GetLength() > 0)
2110 AppLogDebug("Enter something");
2114 case IDA_FINDWORD_CLEAR_CLICKED:
2116 __pFindWordCountLabel->SetText(L"0/0");
2117 __pFindWordEditField->SetText(L"");
2118 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2120 __currentSearchStr = L"";
2121 __pFindWordNext->SetEnabled(false);
2122 __pFindWordPrev->SetEnabled(false);
2123 // __pFindWordCountLabel->SetShowState(false);
2124 __pFindWordControl->Invalidate(true);
2127 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2129 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2130 __pFindWordEditFieldRightToLeft->SetText(L"");
2131 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2133 __currentSearchStr = L"";
2134 __pFindWordNext->SetEnabled(false);
2135 __pFindWordPrev->SetEnabled(false);
2136 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2137 __pFindWordControl->Invalidate(true);
2140 case IDA_FINDWORD_NEXT_CLICKED:
2145 case IDA_FINDWORD_PREV_CLICKED:
2147 FindNextWord(false);
2150 case IDA_BRIGHTNESS_BTN_CLICKED:
2152 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2153 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2156 case IDA_COPY_IMAGE_CLICKED:
2158 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2159 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2161 const Bitmap* pBitmap = null;
2162 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2164 pBitmap = __pHitElementResult->GetImage();
2167 String resourcePath = App::GetInstance()->GetAppResourcePath();
2168 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2169 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2170 // copying the item to clipboard
2171 Clipboard* pClipboard = Clipboard::GetInstance();
2172 if (pClipboard != null)
2174 r = pClipboard->CopyItem(item);
2175 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2179 case IDA_VIEW_IMAGE_CLICKED:
2181 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2182 WindowInfo* pNewWindowInfo = null;
2183 if (__pHitElementResult != null)
2185 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2186 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2192 case IDA_SAVE_IMAGE_CLICKED:
2194 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2195 const Bitmap* pSaveBitmap = null;
2196 String imageName = GetImagePath();
2197 AppLog("Content manager image name %ls",imageName.GetPointer());
2200 imagePath.Append(imageName);
2201 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2202 AppLog("Content manager image path %ls",imagePath.GetPointer());
2203 if (__pHitElementResult != null)
2205 pSaveBitmap = __pHitElementResult->GetImage();
2207 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2211 UpdateImageContent(pBuffer, imageName);
2213 if(__pNotification != null)
2215 RemoveControl(__pNotification);
2216 __pNotification = null;
2218 __pNotification = new NotificationPanel(*this);
2220 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2221 msg.Append(imagePath);
2222 if (__pNotification != null)
2224 __pNotification->SetText(msg);
2225 if (__pFooterPanel->GetShowState() == true)
2227 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2231 __pNotification->SetPositionDiff(0);
2233 __pNotification->ShowNotification();
2238 int __modalMsgBoxResult;
2239 MessageBox* pMsgBox = new MessageBox();
2240 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);
2241 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2244 __modalMsgBoxResult = 0;
2248 case IDA_SHARE_IMAGE_CLICKED:
2250 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2251 if (__pPopUp != null)
2258 __pAddressbar->HideKeypad();
2260 __pPopUp = new(std::nothrow) SharePopup();
2261 __pPopUp->Initialize();
2262 if (__pHitElementResult != null)
2264 const Bitmap* pSaveBitmap = null;
2265 String imageName = GetImagePath();
2266 AppLog("Content manager image name %ls",imageName.GetPointer());
2269 imagePath.Append(imageName);
2270 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2271 AppLog("Content manager image path %ls",imagePath.GetPointer());
2272 if (__pHitElementResult != null)
2274 pSaveBitmap = __pHitElementResult->GetImage();
2276 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2278 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2279 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2281 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2282 pShareInfo->SetPageTitle(L"");
2283 pShareInfo->SetPageUrl(srcUrl);
2284 pShareInfo->SetImageAttached(true);
2285 pShareInfo->SetImagePath(imagePath);
2286 __pPopUp->RemoveAllShareInfo();
2287 __pPopUp->AddShareInfo(pShareInfo);
2288 __pPopUp->SetShowState(true);
2293 case IDA_HYPERLINK_OPEN_CLICKED:
2295 if (__pHitElementResult != null)
2297 String srcUrl = __pHitElementResult->GetUrl();
2299 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2301 if (pNewWindowInfo == null)
2305 pNewWindowInfo->isJavascriptInitiated = true;
2306 result r = E_SUCCESS;
2307 SceneManager* pSceneManager = SceneManager::GetInstance();
2308 if (pSceneManager == NULL)
2312 ArrayList* pArgList = new(std::nothrow) ArrayList();
2313 if (pArgList == NULL)
2317 pArgList->Construct();
2319 pArgList->Add(*pNewWindowInfo);
2320 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2321 if (pArgList != null)
2328 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2334 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2336 if (__pHitElementResult == null)
2341 if(__pPopUp != null)
2348 __pAddressbar->HideKeypad();
2350 __pPopUp = new(std::nothrow) SharePopup();
2351 __pPopUp->Initialize();
2353 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2354 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2355 pShareInfo->SetImageAttached(false);
2356 __pPopUp->RemoveAllShareInfo();
2357 __pPopUp->AddShareInfo(pShareInfo);
2359 __pPopUp->SetShowState(true);
2363 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2367 if (__pHitElementResult != null)
2369 url = __pHitElementResult->GetUrl();
2372 String resourcePath = App::GetInstance()->GetAppResourcePath();
2373 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2375 // copying the item to clipboard
2376 Clipboard* pClipboard = Clipboard::GetInstance();
2377 if (pClipboard != null)
2379 pClipboard->CopyItem(item);
2383 case IDA_FIND_TEXT__CLICKED:
2385 // AddressBarCancelledClicked(*__pAddressbar);
2386 RelayoutControls(false);
2387 // __pFooterPanel->SetShowState(false);
2388 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2389 __currentSearchStr.Clear();
2390 __currentSearchStr.Append(__currentSelectedStr);
2391 InitFindWordPanel();
2392 __pFindWordEditField->SetText(__currentSearchStr);
2394 if(__pOptionMenu != null)
2396 __pOptionMenu->SetShowState(false);
2397 __pOptionMenu->Invalidate(false);
2399 __adressPanelPosition.y = 0;
2401 if (__pAddressbar != null && __pWebViewer != NULL)
2403 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2404 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2406 if (__pFooterPanel->GetShowState() == false)
2407 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2409 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2410 __pWebViewer->Invalidate(true);
2413 ShowFindWordPanel(true);
2414 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2416 __pFindWordEditField->SetText(__currentSearchStr);
2417 __pFindWordEditField->SetFocus();
2419 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2421 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2422 __pFindWordEditFieldRightToLeft->SetFocus();
2425 if (__currentSearchStr.GetLength() > 0)
2431 AppLogDebug("Enter something");
2434 if (__pWebViewer != null)
2436 // releasing the set block
2437 __pWebViewer->ReleaseBlock();
2442 case IDA_SHARE_TEXT_CLICKED:
2444 __pWebViewer->ReleaseBlock();
2445 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2446 if(__pPopUp != null)
2453 __pAddressbar->HideKeypad();
2455 __pPopUp = new(std::nothrow) SharePopup();
2456 __pPopUp->Initialize();
2457 if (__pHitElementResult != null)
2459 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2460 pShareInfo->SetPageTitle(L"");
2461 pShareInfo->SetPageUrl(__currentSelectedStr);
2462 pShareInfo->SetImageAttached(false);
2463 __pPopUp->RemoveAllShareInfo();
2464 __pPopUp->AddShareInfo(pShareInfo);
2465 __pPopUp->SetShowState(true);
2470 case IDA_COPY_TEXT_CLICKED:
2472 __pWebViewer->ReleaseBlock();
2473 // need to implement
2474 //__currentSelectedStr
2475 // Sets data to a clip board item
2477 String resourcePath = App::GetInstance()->GetAppResourcePath();
2478 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2480 // copying the item to clipboard
2481 Clipboard* pClipboard = Clipboard::GetInstance();
2482 if (pClipboard != null)
2484 pClipboard->CopyItem(item);
2488 case IDA_PASTE_TEXT_CLICKED:
2490 __pWebViewer->ReleaseBlock();
2491 Clipboard* pClipboard = Clipboard::GetInstance();
2493 if(pClipboard == null)
2497 // Retrieves a latest item
2498 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2504 //Gets data from the clipboard item
2505 String* pString = dynamic_cast<String*>(pItem->GetData());
2507 if (pString != null)
2509 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2510 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2511 String tagElement = __pHitElementResult->GetTagName();
2512 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2513 String str = L"document.getElementsByName('";
2514 str.Append(nameElement);
2515 str.Append("').length");
2516 String* pCount = __pWebViewer->EvaluateJavascriptN(str);
2519 if(idElement.GetLength() != 0)
2521 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; } } ";
2522 script.Append("insertAtCursor('");
2523 script.Append(idElement);
2524 script.Append("',");
2525 script.Append("\"");
2526 script.Append(*pString);
2527 script.Append("\");");
2529 else if (nameElement.GetLength() != 0 && pCount->Equals("1",false) == true)
2531 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; } } ";
2532 script.Append("insertAtCursor(document.getElementsByName('");
2533 script.Append(nameElement);
2534 script.Append("')[0],");
2535 script.Append("\"");
2536 script.Append(*pString);
2537 script.Append("\");");
2539 else if(tagElement.GetLength() != 0) //adding for twitter post page
2541 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; } } ";
2543 script.Append("insertAtCursor(document.activeElement,");
2544 script.Append("\"");
2545 script.Append(*pString);
2546 script.Append("\");");
2548 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2549 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2561 case IDA_GO_FORWARD:
2566 case IDA_REFRESH_BTN_CLICKED:
2568 __isLoadingCompleted = false;
2569 __isLoadingData = true;
2570 __progressPercentage = 0;
2571 __displayUrl = __pFooterUrlField->GetText();
2573 String url = __pFooterUrlField->GetText();
2574 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2576 if (__pWebViewer != null && __pAddressbar != null)
2579 //__pWebViewer->Reload();
2580 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2584 UpdateProgressBitmap();
2587 case IDA_STOP_BTN_CLICKED:
2589 __isLoadingCompleted = false;
2590 __isLoadingData = false;
2591 __progressPercentage = 0;
2592 __pFooterUrlField->HideKeypad();
2593 __displayUrl = __pFooterUrlField->GetText();
2597 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2598 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2599 __pWebViewer->StopLoading();
2600 RequestRedraw(true);
2603 UpdateProgressBitmap();
2608 if (__pFooterUrlField->GetText().IsEmpty() == false)
2610 //__displayUrl = __pUrlField->GetText();
2611 __pFooterUrlField->Clear();
2616 case IDA_READER_BTN_CLICKED:
2627 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2629 AppLog("MainForm::OnFormBackRequested entered");
2630 result r = E_FAILURE;
2631 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2633 AppLog("Hiding the menu");
2634 __pImageMenu->SetShowState(false);
2636 if (__pWebViewer && __pWebViewer->CanGoBack())
2638 __pWebViewer->GoBack();
2640 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2643 pApp = UiApp::GetInstance();
2646 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2649 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2657 WindowInfo* pWindowInfo = null;
2659 SceneManager* pSceneManager = SceneManager::GetInstance();
2660 if (pSceneManager == null)
2664 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2665 if (pAllWindowList == NULL)
2667 pApp = UiApp::GetInstance();
2670 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2673 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2678 if (pAllWindowList != null)
2680 totalCount = pAllWindowList->GetCount();
2682 for (int count = 0; count < totalCount; count++)
2684 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2685 if (pWindowInfo == null)
2687 pApp = UiApp::GetInstance();
2690 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2693 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2700 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2702 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2705 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2708 r = pAllWindowList->RemoveAt(count, true);
2709 __pWindowInfo = null;
2712 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2717 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2721 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2723 if (pWindowInfo == null)
2725 pApp = UiApp::GetInstance();
2728 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2734 if(pWindowInfo != null)
2735 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2738 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2744 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2746 // UiApp* pApp = null;
2747 // pApp = UiApp::GetInstance();
2748 // if (pApp != null)
2750 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2753 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2761 AppLog("MainForm::OnFormBackRequested exit");
2765 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2766 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2769 AppLog("MainForm::OnSceneActivatedN called");
2770 String* pSelectedScene = NULL;
2771 Object* pValue = NULL;
2772 String* pUrl = null;
2773 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2774 pSelectedScene = (String*) pValue;
2776 if (pSelectedScene != null)
2778 delete pSelectedScene;
2780 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2781 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2782 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2783 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2785 // setting the current scene ID
2786 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2788 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2790 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2792 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2793 if(__pWindowInfo == null)
2795 // if(__pWindowInfo == null)
2797 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2800 else if ( pArgs != null && pArgs->GetCount() == 1)
2802 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2808 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2810 // hiding the address bar
2811 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2812 __pAddressbar->SetShowState(false);
2813 // if(__pWebViewer != null)
2815 // __pWebViewer->Resume();
2818 if(pUrl != null && pUrl->GetLength() > 0)
2822 else if(__pWindowInfo != null)
2824 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)
2826 LoadUrl(__pWindowInfo->pageUrl);
2828 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2830 LoadUrl(__pWindowInfo->pageUrl);
2831 __pWindowInfo->isAppcontrolTriggered = false;
2833 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2835 __pWindowInfo->isFirstLaunch = false;
2838 __pWindowInfo->pCurrentWeb = __pWebViewer;
2839 if(__pWindowInfo->pageUrl.GetLength() > 0)
2840 LoadUrl(__pWindowInfo->pageUrl);
2844 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2845 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2846 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2848 InitMostVisitedSitesView(GetOrientationStatus());
2850 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2852 if(__pMostVisitedListView != null)
2854 __pMostVisitedListView->SetShowState(false);
2858 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2860 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2862 if (pBookmarkUrl == null)
2864 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2865 //__pAddressbar->SetUrl(*pBookmarkUrl);
2866 SetUrl(*pBookmarkUrl);
2868 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2869 __pWebViewer->LoadUrl(*pBookmarkUrl);
2870 delete pBookmarkUrl;
2873 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2874 Bitmap* pBitmap = null;
2875 if (isPrivateBrowsing == true)
2877 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2879 if (__pWebViewer != null)
2881 __pWebViewer->SetPrivateBrowsingEnabled(true);
2884 if (__pAddressbar != null)
2886 // __pAddressbar->UpdateFaviconBitmap(true);
2892 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2894 if (__pWebViewer != null)
2896 __pWebViewer->SetPrivateBrowsingEnabled(false);
2899 if (__pAddressbar != null)
2901 // __pAddressbar->UpdateFaviconBitmap(false);
2905 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2907 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2909 else if (__pOptionMenu != null )
2911 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2914 if (pBitmap != null)
2919 RelayoutControls(false);
2920 AppLog("ABC: OnSceneActivatedN started exit");
2925 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2926 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2928 Canvas* pWebCanvas = null;
2929 if (__pWebViewer != null)
2931 pWebCanvas = __pWebViewer->GetCanvasN();
2934 if (pWebCanvas == null)
2938 if (__pWindowInfo != null)
2940 if (__pWindowInfo->pWebCanvasBitmap != null)
2942 delete __pWindowInfo->pWebCanvasBitmap;
2944 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2945 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2946 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2948 Bitmap* pBitmap = GetCapturedBitmapN();
2949 AppLog("Coming here");
2950 Canvas* pCanvas = new(std::nothrow) Canvas();
2951 pCanvas->Construct(GetClientAreaBounds());
2954 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2957 if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
2958 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2960 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2963 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2968 __pAddressbar->SetShowState(false);
2969 AppLog("Coming here");
2973 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2974 const Tizen::Base::String& realm,
2975 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2981 MainForm::OnHttpAuthenticationCanceled(void)
2986 MainForm::OnLoadingStarted(void)
2988 AppLogDebug("MainForm::OnLoadingStarted entered");
2990 if(__pAddressbar == NULL || __pWebViewer == null)
2995 // this is added in case if menu is opened and user load the page
2996 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2998 __pOptionMenu->SetShowState(false);
2999 __pOptionMenu->Invalidate(true);
3004 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3006 __pImageMenu->SetShowState(false);
3007 __pImageMenu->Invalidate(true);
3009 String url = __pWebViewer->GetUrl();
3010 if(url.Contains(IDS_TIZEN_SERVICE))
3013 String delim(L":;,");
3015 // Creates a StringTokenizer instance
3016 StringTokenizer strTok(url, delim);
3018 int count = strTok.GetTokenCount(); // count == 4
3020 HashMap *pMap = new HashMap();
3025 while (strTok.HasMoreTokens())
3027 AppLog("Token: %ls", token.GetPointer());
3028 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3029 if(token.Contains(IDS_APPID))
3031 token.SubString(6, appId);
3032 AppLog("AppID:%ls", appId.GetPointer());
3034 else if(token.Contains(IDS_KEY))
3036 token.SubString(4, key);
3037 AppLog("key:%ls", key.GetPointer());
3039 else if(token.Contains(IDS_VALUE))
3041 token.SubString(6, value);
3042 AppLog("value:%ls", value.GetPointer());
3045 pMap->Add(key, value);
3049 AppControl *pAppControl = null;
3050 String operationId = L"http://tizen.org/appcontrol/operation/main";
3051 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3054 AppLog("Starting AppControl");
3055 result r = pAppControl->Start(null, null, pMap, null);
3056 AppLog("Result of Start %s", GetErrorMessage(r));
3060 AppLogException("AppControl not found");
3065 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3067 __pAddressbar->SetShowState(false);
3068 AddressBarCancelledClicked(*__pAddressbar);
3069 __pAddressbar->Invalidate(true);
3071 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3074 __pAddressbar->SetFaviconBitmap(*pBitmap);
3077 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3079 // updating the address bar position with respect to web control
3080 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3081 __distanceMoved = 0;
3085 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3086 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3087 if (__pWebViewer != null)
3089 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3090 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3091 SetUrl(__pWebViewer->GetUrl());
3092 if (__pWindowInfo != NULL)
3094 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3095 __pWindowInfo->pageTitle = L"";
3096 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3098 __pAddressbar->Invalidate(true);
3104 MainForm::OnLoadingCanceled(void)
3110 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3112 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3117 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3119 AppLog("XYZ::MainForm::OnKeypadOpened");
3120 __isKeypadOpened = true;
3121 __pFooterPanel->SetShowState(false);
3122 RelayoutControls(false);
3126 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3128 AppLog("XYZ::MainForm::OnKeypadClosed");
3129 __isKeypadOpened = false;
3130 __pFooterPanel->SetShowState(true);
3131 RelayoutControls(true);
3135 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3137 AppLog("XYZ::KeypadBoundsChanged");
3138 RelayoutControls(false);
3142 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3143 const Tizen::Base::String& reason)
3145 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3149 MainForm::OnLoadingCompleted(void)
3151 AppLog("MainForm::OnLoadingCompleted start");
3153 result r = E_SUCCESS;
3155 if (__pWebViewer == null)
3160 if (__pAddressbar == null)
3165 if(__pImageMenu && __pImageMenu->GetShowState())
3167 __pImageMenu->SetShowState(false);
3168 __pImageMenu->Invalidate(true);
3171 if (__pWebViewer->CanGoForward())
3173 //__pAddressbar->SetForwardButtonEnabled(true);
3174 SetForwardButtonEnabled(true);
3178 //__pAddressbar->SetForwardButtonEnabled(false);
3179 SetForwardButtonEnabled(false);
3182 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3184 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3186 //__pAddressbar->UpdateProgress(0);
3190 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3192 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3196 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3197 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3198 if (isPrivateBrowsing == false)
3200 if(__pHistory != null)
3206 __pHistory = new(std::nothrow) History;
3207 HistoryPresentationModel::GetCurrentDateTime(date);
3210 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3211 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3213 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3214 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3216 __pHistory->SetVisitedTime(date);
3218 if (__pWebViewer != null)
3220 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3222 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3223 if (pTempBitmap != null)
3225 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3226 __pHistory->SetFavIconBitmap(*pTempBitmap);
3229 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3232 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3233 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3234 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3236 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3237 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3238 __pHistory->SetThumbnail(pBitmap);
3240 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3243 __pHistory->SetFavIconBitmap(*pFavIcon);
3247 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3254 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3256 // temperary fixed (webpage can be not loaded)
3260 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3261 if (isReaderEnabled == true)
3265 delete __pReaderData;
3266 __pReaderData = null;
3268 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3269 filePath.Append(L"data/reader.js");
3275 result r = E_SUCCESS;
3276 FileAttributes attr;
3278 File::GetAttributes(filePath,attr);
3280 r = file.Construct(filePath, L"r+");
3283 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3286 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3289 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3292 // file.Read(pScript,attr.GetFileSize());
3294 // AppLogDebug("scipt length %d",strlen(pScript));
3295 String strScript = L"";
3296 // strScript.Append(pScript);
3297 // for(int i=0; i<25; i++)
3299 file.Read(pScript,attr.GetFileSize());
3300 // AppLog("xyzz tell %d",file.Tell());
3301 // r = strScript.Append(pScript);
3302 // AppLog("xyzz append result %s",GetErrorMessage(r));
3303 // AppLog("xyzz strScript length %d",strScript.GetLength());
3305 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3307 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3308 if (__pReaderData == null)
3310 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3311 __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>");
3314 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3315 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3317 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3318 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3324 AppLog("MainForm::OnLoadingCompleted done");
3328 MainForm::OnEstimatedProgress(int progress)
3330 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3332 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3333 progress = DEFAULT_PROGRESS_PERCENTAGE;
3335 // __pAddressbar->UpdateProgress(progress);
3336 UpdateProgress(progress);
3339 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3341 AppLog("MainForm::OnFaviconReceived");
3342 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3344 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3347 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3354 MainForm::OnUrlValueChanged(Addressbar&)
3360 MainForm::OnUrlSubmitted(Addressbar& addBar)
3362 AppLog("MainForm::OnUrlSubmitted");
3363 String url = addBar.GetUrl();
3364 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3366 if(__pFooterUrlField)
3367 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3368 AddressBarCancelledClicked(*__pAddressbar);
3373 MainForm::LoadUrl(String& url)
3377 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3378 AppLogDebug("MainForm::LoadUrl enter");
3380 if (__pWebViewer != null)
3382 __pWebViewer->SetShowState(true);
3383 __pWebViewer->Invalidate(true);
3386 if (url.CompareTo(L"") == 0)
3390 if(__pFooterPanel != null)
3392 __pFooterPanel->SetShowState(true);
3393 __pFooterPanel->Invalidate(true);
3400 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3401 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)
3403 RegularExpression firstRegex;
3404 RegularExpression secondRegex;
3406 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3407 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3410 ret = firstRegex.Match(url, false); // This returns true value
3411 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3413 if (ret == true && __pWebViewer != null)
3416 __pWebViewer->LoadUrl(url);
3418 else if(__pWebViewer != null)
3420 String tempUrl = L"http://";
3421 tempUrl.Append(url);
3425 __pWebViewer->LoadUrl(tempUrl);
3429 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3430 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3433 if (__pAddressbar != null)
3435 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3436 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3439 AppLogDebug("MainForm::LoadUrl exit");
3446 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3448 AppLog("MainForm::OnFocusGained");
3451 __pFooterPanel->SetShowState(false);
3456 __pAddressbar->SetShowState(true);
3457 __pAddressbar->SetAddressbarURLFocus();
3459 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3461 __currentSearchStr = L"";
3462 __currentWordIndex = 0;
3463 __maxOccurrances = 0;
3465 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3467 __pFindWordEditField->SetText(L"");
3468 __pFindWordEditField->HideKeypad();
3469 __pFindWordControl->SetShowState(false);
3470 __pFindWordCountLabel->SetText(L"0/0");
3472 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3474 __pFindWordEditFieldRightToLeft->SetText(L"");
3475 __pFindWordEditFieldRightToLeft->HideKeypad();
3476 __pFindWordControl->SetShowState(false);
3477 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3480 __pFindWordNext->SetEnabled(false);
3481 __pFindWordPrev->SetEnabled(false);
3483 __pWebViewer->SearchTextAllAsync(L"",true);
3484 __pFindWordControl->SetShowState(false);
3486 RelayoutControls(false);
3490 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3492 AppLog("MainForm::OnFocusLost called");
3496 MainForm::OnStopClicked(Addressbar& addBar)
3498 AppLogDebug("MainForm::OnStopClicked called");
3501 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3502 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3503 __pWebViewer->StopLoading();
3504 RequestRedraw(true);
3509 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3511 // AppLog("MainForm::OnBackClicked");
3512 result r = E_FAILURE;
3513 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3515 AppLog("Hiding the menu");
3516 __pImageMenu->SetShowState(false);
3519 if (__pWebViewer && __pWebViewer->CanGoBack())
3521 __pWebViewer->GoBack();
3523 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3526 pApp = UiApp::GetInstance();
3529 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3532 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3540 WindowInfo* pWindowInfo = null;
3542 SceneManager* pSceneManager = SceneManager::GetInstance();
3543 if (pSceneManager == null)
3547 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3548 if (pAllWindowList == NULL)
3550 pApp = UiApp::GetInstance();
3553 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3556 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3561 if (pAllWindowList != null)
3563 totalCount = pAllWindowList->GetCount();
3565 for (int count = 0; count < totalCount; count++)
3567 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3568 if (pWindowInfo == null)
3570 pApp = UiApp::GetInstance();
3573 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3576 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3581 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3583 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3586 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3589 r = pAllWindowList->RemoveAt(count, true);
3590 __pWindowInfo = null;
3593 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3598 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3600 else if(pAllWindowList->GetCount() > 0)
3602 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3606 pApp = UiApp::GetInstance();
3609 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3614 if (pWindowInfo == null)
3616 pApp = UiApp::GetInstance();
3619 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3625 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3626 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3629 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3643 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3645 AppLog("MainForm::OnForwardClicked");
3646 if (__pWebViewer == null)
3649 if (__pWebViewer->CanGoForward())
3651 __pWebViewer->GoForward();
3656 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3658 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3659 if(__pFooterPanel != null)
3661 __pFooterPanel->SetShowState(false);
3664 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3666 __pAddressbar->SetShowState(true);
3667 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3670 RelayoutControls(false);
3674 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3676 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3678 int Height = GetClientAreaBounds().height;
3679 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3681 RelayoutControls(false);
3685 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3687 AddressBarCancelledClicked(addBar);
3691 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3693 __prevAddressBarMode = __curAddressBarMode;
3695 if (__pAddressbar != null)
3697 __curAddressBarMode = GetAddressbarMode();
3700 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3702 __adressPanelPosition.y = 0;
3703 if (__pAddressbar != null)
3705 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3706 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3707 __pAddressbar->Invalidate(true);
3709 if (__pWebViewer != null)
3711 __pWebViewer->StopLoading();
3714 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3716 __adressPanelPosition.y = 0;
3717 if (__pAddressbar != null)
3719 __webControlPosition.y = 0;
3720 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3721 __pAddressbar->Invalidate(true);
3727 MainForm::OnClipboardClosed(const Addressbar& addBar)
3729 AppLog("XYZ::MainForm::OnClipboardClosed");
3730 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3732 AppLog("akjshdasd 3");
3733 __pFooterPanel->SetShowState(true);
3735 __isKeypadOpened = false;
3736 RelayoutControls(false);
3740 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3742 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3743 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3745 AppLog("akjshdasd 3");
3746 __pFooterPanel->SetShowState(true);
3748 __isKeypadOpened = false;
3749 if(__pNotification && __pNotification->GetShowState())
3751 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3754 RelayoutControls(false,footerState);
3758 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3760 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3761 __isKeypadOpened = true;
3762 if(__pNotification && __pNotification->GetShowState())
3764 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3766 RelayoutControls(false);
3770 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3772 __isKeypadOpened = true;
3773 __pFooterPanel->SetShowState(false);
3777 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3779 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3780 RelayoutControls(false);
3784 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3786 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3789 __pWindowInfo->pageTitle = title;
3790 if (__pWebViewer != null)
3792 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3793 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3796 if (__pAddressbar != null && __pWebViewer != null)
3798 SetUrl(__pWebViewer->GetUrl());
3799 __pAddressbar->Invalidate(true);
3804 MainForm::UpdateFavicon(void)
3806 bool urlImageType = false;
3807 String *tempPath = null;
3809 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();");
3810 Bitmap* pBitmap = null;
3812 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3814 if (__pWindowInfo != null)
3817 url.SetUri(*tempPath);
3818 if (url.GetHost().GetLength() == 0)
3822 webUrl.SetUri(__pWebViewer->GetUrl());
3823 result r = url.SetHost(webUrl.GetHost());
3830 if (url.GetScheme().GetLength() == 0)
3834 webUrl.SetUri(__pWebViewer->GetUrl());
3835 url.SetScheme(webUrl.GetScheme());
3837 __pWindowInfo->faviconUrl = url.ToString();
3839 pBitmap = __pWebViewer->GetFaviconN();
3841 if (pBitmap != null)
3843 if (__pWindowInfo->pFavicon != NULL)
3845 __pWindowInfo->pFavicon = null;
3847 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3848 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3850 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3852 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3854 else if(__pWindowInfo->pFavicon != null)
3856 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3860 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3861 if(pDefaultBmp != null)
3863 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3877 if(tempPath != null)
3881 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3887 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3888 Tizen::Web::Controls::WebNavigationType type)
3890 AppLog("urlk %ls",url.GetPointer());
3891 // when load new page if find word panel is open its show state is false
3892 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3894 __currentSearchStr = L"";
3895 __currentWordIndex = 0;
3896 __maxOccurrances = 0;
3897 __pFindWordEditField->SetText(L"");
3898 __pFindWordNext->SetEnabled(false);
3899 __pFindWordPrev->SetEnabled(false);
3900 __pFindWordCountLabel->SetText(L"0/0");
3901 __pFindWordControl->SetShowState(false);
3902 __pFindWordEditField->HideKeypad();
3903 RelayoutControls(false);
3906 __pFooterPanel->Invalidate(true);
3909 uriInfo.SetUri(url);
3911 if(url.Contains(IDS_TIZEN_SERVICE))
3914 String delim(L":;,");
3916 // Creates a StringTokenizer instance
3917 StringTokenizer strTok(url, delim);
3919 int count = strTok.GetTokenCount(); // count == 4
3921 HashMap *pMap = new HashMap();
3927 while (strTok.HasMoreTokens())
3929 AppLog("Token: %ls", token.GetPointer());
3930 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3931 if(token.Contains(IDS_APPID))
3933 token.SubString(6, appId);
3934 AppLog("AppID:%ls", appId.GetPointer());
3936 else if(token.Contains(IDS_KEY))
3938 token.SubString(4, key);
3939 AppLog("key:%ls", key.GetPointer());
3941 else if(token.Contains(IDS_VALUE))
3943 token.SubString(6, value);
3944 AppLog("value:%ls", value.GetPointer());
3947 pMap->Add(key, value);
3951 AppControl *pAppControl = null;
3952 String operationId = L"http://tizen.org/appcontrol/operation/main";
3953 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3956 result r = pAppControl->Start(null, null, pMap, null);
3960 AppLogException("AppControl not found");
3970 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3971 const Tizen::Net::Http::HttpHeader& httpHeader)
3973 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3977 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3979 AppLog("MainForm::OnWebPageBlockSelected");
3980 // if(__isLongPressedDone == false)
3983 if (__pHitElementResult != null)
3985 delete __pHitElementResult;
3986 __pHitElementResult = null;
3989 if (__pWebViewer != null)
3991 AppLog("MainForm::OnWebPageBlockSelected web not null");
3992 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3994 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
3996 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3997 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3998 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4000 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4002 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4006 if (__pHitElementResult == null)
4011 if (__pHitElementResult->HasImage() != true)
4013 String tagName = __pHitElementResult->GetTagName();
4014 String type = __pHitElementResult->GetAttributeValue("type");
4017 AppLog("TagName %ls",tagName.GetPointer());
4018 __currentSelectedStr.Clear();
4019 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4020 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4021 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4022 if(tagName.Equals(L"TEXTAREA",false) == true)
4024 AppLog("Tagnameseemstobe TEXTAREA");
4026 else if(tagName.Equals(L"INPUT",false) == true)
4028 AppLog("Tagnameseemstobe INPUT");
4031 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
4033 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4035 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
4038 __pImageMenu->SetShowState(true);
4039 __pImageMenu->Show();
4040 __pImageMenu->Invalidate(true);
4043 else /*if(__isLongPressedDone == true)*/
4045 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4047 if(__pHitElementResult->GetUrl().GetLength() > 0)
4049 __currentSelectedStr.Clear();
4050 __currentSelectedStr = __pHitElementResult->GetUrl();
4052 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
4055 __pImageMenu->SetShowState(true);
4056 __pImageMenu->Show();
4057 __pImageMenu->Invalidate(true);
4061 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4062 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4063 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4069 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4075 MainForm::OnWebWindowCreateRequested(void)
4077 AppLog("MainForm::OnWebWindowCreateRequested entered");
4078 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4080 if (pNewWindowInfo == null)
4084 result r = E_SUCCESS;
4085 SceneManager* pSceneManager = SceneManager::GetInstance();
4086 if (pSceneManager == NULL)
4090 ArrayList* pArgList = new(std::nothrow) ArrayList();
4091 if (pArgList == NULL)
4095 r = pArgList->Construct();
4098 pNewWindowInfo->isJavascriptInitiated = true;
4099 pArgList->Add(*pNewWindowInfo);
4100 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4104 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4111 return pNewWindowInfo->pCurrentWeb;
4114 void MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4116 AppLog("OnWebWindowCloseRequested");
4117 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4118 SceneManager* pSceneManager = SceneManager::GetInstance();
4119 WindowInfo* pWindowInfo = null;
4120 WindowInfo* pNewWindowInfo = null;
4123 result r = E_FAILURE;
4125 if (pAllWindowList != null)
4127 totalCount = pAllWindowList->GetCount();
4130 for (int count = 0; count < totalCount; count++)
4132 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4133 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID)
4135 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
4138 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
4142 r = pAllWindowList->RemoveAt(count, true);
4146 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
4148 else if(pAllWindowList->GetCount() > 0)
4150 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4154 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4156 if (pNewWindowInfo == null)
4160 result r = E_SUCCESS;
4161 SceneManager* pSceneManager = SceneManager::GetInstance();
4162 if (pSceneManager == NULL)
4166 ArrayList* pArgList = new(std::nothrow) ArrayList();
4167 if (pArgList == NULL)
4171 r = pArgList->Construct();
4174 pArgList->Add(*pNewWindowInfo);
4175 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4176 if (pArgList != null)
4183 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4188 pApp = UiApp::GetInstance();
4191 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4196 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4198 __pWindowInfo = null;
4206 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4208 AppLog("xyz:: MainForm::RelayoutControls called");
4209 __webControlPosition.y = 0;
4210 __webControlHeight = GetClientAreaBounds().height;
4211 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4213 AppLog("Client area height: %d", __webControlHeight);
4214 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4216 __webControlPosition.y += __pAddressbar->GetHeight();
4217 __webControlHeight -= __pAddressbar->GetHeight();
4218 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4220 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4222 __webControlPosition.y += __pFindWordControl->GetHeight();
4223 __webControlHeight -= __pFindWordControl->GetHeight();
4224 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4227 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4229 __webControlHeight -= __pFooterPanel->GetHeight();
4231 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
4232 __webControlHeight = __webControlHeight + 12;
4234 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4236 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4241 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4242 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4243 __pWebViewer->Invalidate(false);
4246 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4248 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4255 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4257 if (__pFindWordControl == null)
4262 Tizen::Locales::LocaleManager localeManager;
4263 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4265 String languageCode;
4266 result r = SettingInfo::GetValue(L"Language", languageCode);
4267 // int languagecode = local.GetLanguageCode();
4268 AppLog("rahul language is %S", languageCode.GetPointer());
4272 InitFindWordPanel();
4274 if (languageCode.CompareTo("ara") == 0)
4276 AppLog("rahul language is arabic");
4278 __pFindWordPanelLeftToRight->SetShowState(false);
4279 __pFindWordPanelRightToLeft->SetShowState(true);
4281 __pFindWordClear->SetShowState(false);
4282 __pFindWordCountLabel->SetShowState(false);
4283 __pFindWordEditField->SetShowState(false);
4285 __pFindWordClearRightToLeft->SetShowState(true);
4286 __pFindWordCountLabelRightToLeft->SetShowState(true);
4287 __pFindWordEditFieldRightToLeft->SetShowState(true);
4291 AppLog("rahul language is not arabic");
4294 __pFindWordPanelLeftToRight->SetShowState(true);
4295 __pFindWordPanelRightToLeft->SetShowState(false);
4297 __pFindWordClear->SetShowState(true);
4298 __pFindWordCountLabel->SetShowState(true);
4299 __pFindWordEditField->SetShowState(true);
4301 __pFindWordClearRightToLeft->SetShowState(false);
4302 __pFindWordCountLabelRightToLeft->SetShowState(false);
4303 __pFindWordEditFieldRightToLeft->SetShowState(false);
4305 __pFindWordControl->SetShowState(true);
4309 if(__pFindWordControl != null)
4311 __pFindWordControl->SetShowState(false);
4315 AppLog("MainForm::ShowFindWordPanel %d",show);
4316 if (show && !isTouchPressed)
4318 if (languageCode.CompareTo("ara") == 0)
4320 if (__pFindWordEditFieldRightToLeft)
4322 __pFindWordEditFieldRightToLeft->SetFocus();
4323 __pFindWordEditFieldRightToLeft->ShowKeypad();
4328 if (__pFindWordEditField)
4330 __pFindWordEditField->SetFocus();
4331 __pFindWordEditField->ShowKeypad();
4337 if (languageCode.CompareTo("ara") == 0)
4339 if (__pFindWordEditFieldRightToLeft)
4340 __pFindWordEditFieldRightToLeft->HideKeypad();
4344 if (__pFindWordEditField)
4345 __pFindWordEditField->HideKeypad();
4349 RelayoutControls(false);
4353 MainForm::StartWordSearch()
4355 //Get the count of occurances of the word in the current page
4356 __maxOccurrances = 0;
4357 __currentWordIndex = 0;
4359 __pFindWordPrev->SetEnabled(false);
4360 String *pCountStr = null;
4363 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4364 AppLog("Search Result %s",GetErrorMessage(r));
4367 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4368 if (pCountStr != null)
4370 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4374 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4379 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4381 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4382 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4386 if (__pFindWordCountLabel)
4388 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4390 if (__pFindWordEditField)
4392 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4395 else if(totalCount >= 100)
4397 if (__pFindWordCountLabel)
4399 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4401 if (__pFindWordEditField)
4403 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4408 if (__pFindWordCountLabel)
4410 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4412 if (__pFindWordEditField)
4414 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4418 __maxOccurrances = totalCount;
4419 __currentWordIndex = currentOrdinal;
4421 //Reset the UI controls as per the maxOccurrance value
4422 if (totalCount <= 0)
4424 AppLog("Word not found");
4425 //Show error notification to user
4426 __pFindWordNext->SetEnabled(false);
4427 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4429 __pFindWordCountLabel->SetText(L"0/0");
4430 __pFindWordCountLabel->Invalidate(false);
4432 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4434 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4435 __pFindWordCountLabelRightToLeft->Invalidate(false);
4437 __pFindWordNext->Invalidate(false);
4438 __pFindWordPrev->Invalidate(false);
4443 if (totalCount == 1 || totalCount == currentOrdinal)
4445 __pFindWordNext->SetEnabled(false);
4449 __pFindWordNext->SetEnabled(true);
4452 String countStr = L"";
4453 countStr.Append(__currentWordIndex);
4454 countStr.Append(L"/");
4455 countStr.Append(__maxOccurrances);
4456 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4458 __pFindWordCountLabel->SetText(countStr);
4459 __pFindWordCountLabel->Invalidate(false);
4460 __pFindWordCountLabel->Invalidate(false);
4462 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4464 __pFindWordCountLabelRightToLeft->SetText(countStr);
4465 __pFindWordCountLabelRightToLeft->Invalidate(false);
4466 __pFindWordCountLabelRightToLeft->Invalidate(false);
4468 if (__pFindWordNext)
4470 __pFindWordNext->Invalidate(false);
4472 if (__pFindWordPrev)
4474 __pFindWordPrev->Invalidate(false);
4480 MainForm::FindNextWord(bool next)
4484 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4485 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4487 if (__currentWordIndex < __maxOccurrances)
4489 __currentWordIndex++;
4495 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4496 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4498 if(__currentWordIndex > 1)
4500 __currentWordIndex--;
4505 String countStr = L"";
4506 countStr.Append(__currentWordIndex);
4507 countStr.Append(L"/");
4508 countStr.Append(__maxOccurrances);
4510 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4512 __pFindWordCountLabel->SetText(countStr);
4513 __pFindWordCountLabel->Invalidate(false);
4515 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4517 __pFindWordCountLabelRightToLeft->SetText(countStr);
4518 __pFindWordCountLabelRightToLeft->Invalidate(false);
4521 if (__currentWordIndex >= __maxOccurrances)
4523 __pFindWordNext->SetEnabled(false);
4527 __pFindWordNext->SetEnabled(true);
4529 if (__currentWordIndex <= 1)
4531 __pFindWordPrev->SetEnabled(false);
4535 __pFindWordPrev->SetEnabled(true);
4537 __pFindWordPrev->Invalidate(false);
4538 __pFindWordNext->Invalidate(false);
4540 __pFindWordControl->Invalidate(true);
4544 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4546 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4547 __isKeypadOpened = true;
4548 __pFooterPanel->SetShowState(false);
4549 // OnAddressBarKeypadOpened(*__pAddressbar);
4553 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4555 __isKeypadOpened = true;
4556 AppLog("xyz::MainForm::OnWebKeypadOpened");
4558 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4560 __currentSearchStr = L"";
4561 __currentWordIndex = 0;
4562 __maxOccurrances = 0;
4563 __pFindWordEditField->SetText(L"");
4564 __pFindWordNext->SetEnabled(false);
4565 __pFindWordPrev->SetEnabled(false);
4566 __pFindWordCountLabel->SetText(L"0/0");
4567 __pWebViewer->SearchTextAllAsync(L"",false);
4568 __pFindWordControl->SetShowState(false);
4569 __pFindWordEditField->HideKeypad();
4573 if (__pWebViewer != null && __pFooterPanel != null)
4575 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4576 if(__pAddressbar != null)
4578 __pAddressbar->SetShowState(false);
4580 if(__pFindWordControl != null)
4582 __pFindWordControl->SetShowState(false);
4584 __pFooterPanel->SetShowState(false);
4585 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4587 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4589 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4590 // AppLog("omgomgomg");
4596 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4598 AppLog("abcde::MainForm::OnWebKeypadClosed");
4599 AppLog("xyz::MainForm::OnWebKeypadClosed");
4600 AppLog("akjshdasd 4");
4601 __pFooterPanel->SetShowState(true);
4602 // OnAddressBarKeypadClosed(*__pAddressbar);
4603 RelayoutControls(false);
4604 __isKeypadOpened = false;
4607 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4609 AppLog("abcde: imagemenu visible.");
4612 __pWebViewer->GetBlockRange(p,q);
4613 if (p == Point(0,0) && q == Point(0,0))
4616 __pImageMenu->SetAnchorPosition(p);
4617 __pImageMenu->Show();
4623 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4625 // RelativeLayout(false);
4626 if(__pWebViewer != null)
4628 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4633 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4635 Control* temp = const_cast< Control* >(&source);
4636 Header* pHeader = dynamic_cast< Header* >(temp);
4637 if (pHeader != null)
4639 //Header double - clicked
4640 AppLog("Header double clicked");
4642 if(__pFindWordControl)
4644 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4645 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4649 AppLog("MainScene::OnTouchDoublePressed");
4653 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4655 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4656 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4658 AppLog("Returning because of more than one touch point.");
4662 __pWebViewer->ReleaseBlock();
4663 __longPressPoint = currentPosition;
4665 if (__pHitElementResult != null)
4667 delete __pHitElementResult;
4668 __pHitElementResult = null;
4671 if (__pWebViewer != null)
4673 AppLog("MainForm::OnTouchLongPressed web not null");
4674 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4677 if (__pHitElementResult == null)
4682 if (__pHitElementResult->HasImage() == true)
4684 if(__pWebViewer != null)
4685 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4686 __pImageMenu->SetShowState(true);
4687 __pImageMenu->Show();
4688 __pImageMenu->Invalidate(true);
4690 else if(__pHitElementResult->HasUrl() == true)
4692 String tempURl = __pHitElementResult->GetUrl();
4693 AppLog("tempURl is %ls", tempURl.GetPointer());
4694 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4695 if (pBitmap != null)
4703 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4704 __pImageMenu->SetShowState(true);
4705 __pImageMenu->Show();
4706 __pImageMenu->Invalidate(true);
4710 String tagName = __pHitElementResult->GetTagName();
4711 String type = __pHitElementResult->GetAttributeValue("type");
4712 String value = __pHitElementResult->GetAttributeValue(L"value");
4713 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4715 __currentSelectedStr.Clear();
4716 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4718 AppLog("tag name is %ls", tagName.GetPointer());
4719 AppLog("type is %ls", type.GetPointer());
4723 __isLongPressedDone = true;
4724 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4725 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)
4727 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4729 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4732 __pImageMenu->SetShowState(true);
4733 __pImageMenu->Show();
4734 __pImageMenu->Invalidate(true);
4737 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4740 // __inputEventToBeSupressed = true;
4744 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4746 AppLog("xyz:: MainForm::OnTouchReleased called");
4748 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4750 __pAddressbar->SetShowState(false);
4752 if(__pFooterPanel && __isKeypadOpened == false)
4754 __pFooterPanel->SetShowState(true);
4758 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4759 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4761 __pWebViewer->ConsumeInputEvent();
4763 if(pHitElement != null)
4767 __inputEventToBeSupressed = false;*/
4771 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4778 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4780 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4782 __currentSearchStr = L"";
4783 __currentWordIndex = 0;
4784 __maxOccurrances = 0;
4786 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4788 __pFindWordEditField->SetText(L"");
4789 __pFindWordEditField->HideKeypad();
4790 __pFindWordControl->SetShowState(false);
4791 __pFindWordCountLabel->SetText(L"0/0");
4793 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4795 __pFindWordEditFieldRightToLeft->SetText(L"");
4796 __pFindWordEditFieldRightToLeft->HideKeypad();
4797 __pFindWordControl->SetShowState(false);
4798 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4801 __pFindWordNext->SetEnabled(false);
4802 __pFindWordPrev->SetEnabled(false);
4804 __pWebViewer->SearchTextAllAsync(L"",true);
4805 __pFindWordControl->SetShowState(false);
4807 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4808 if(__pAddressbar->GetShowState() == false)
4810 __pAddressbar->SetAddressbarURLFocus();
4811 __pFooterPanel->SetShowState(false);
4818 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4824 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4830 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4836 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4842 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4848 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4850 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4851 int widthContextItem = 0;
4852 if(__pFindWordCountLabel)
4853 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4854 // As per the platform engineer comment removed this line
4855 /*if(__pWebViewer != null)
4857 // 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
4858 __pWebViewer->ReleaseBlock();
4861 // if(__pFindWordControl != null)
4862 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4864 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4866 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4868 AppLog(" Orientation landscape");
4869 __pOptionMenu->SetMaxVisibleItemsCount(5);
4873 AppLog(" Orientation potrait");
4874 __pOptionMenu->SetMaxVisibleItemsCount(6);
4877 if(__pNotification && __pNotification->GetShowState() == true)
4879 __pNotification->SetShowState(false);
4880 __pNotification->Invalidate(false);
4882 if ( __pFooterLabel != null)
4884 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4887 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4893 if (__pFindWordBgLabel != null)
4895 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4896 if (pBitmap != null)
4898 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4903 if (__pFindWordBgLabelRightToLeft != null)
4905 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4906 if (pBitmap != null)
4908 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4914 // if(__pOptionMenu != null)
4915 // __pOptionMenu->SetShowState(false);
4917 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4919 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4923 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4928 AppLog("__pFooterPanel->GetShowState() is true");
4930 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4931 __pFooterPanel->Invalidate(true);
4935 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4936 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4938 InitMostVisitedSitesView(orientationStatus);
4941 RelayoutControls(false);
4942 if (__pArticleReaderPanel != null)
4944 if (__pArticleReaderPanel->GetShowState() == true)
4946 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4948 if (__pBlankPanel != null)
4949 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4951 if (__pWebReader != null)
4953 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4955 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4956 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4958 if ( pBitmap != null && pSrcBitmap != null)
4960 AppLog("CreateReaderPanel ninepatchbitmap found");
4961 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4964 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4965 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4966 if (pBitmap != null)
4971 if (pSrcBitmap != null)
4980 if (__pAddressbar != null)
4982 int width = GetClientAreaBounds().width;
4983 __pAddressbar->OrientationChanged(width);
4988 MainForm::OnSettingsChange(int settingvalue)
4990 AppLogDebug("MainForm::OnSettingsChange entered");
4992 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4994 __pAddressbar->ResetGuideText();
4996 if (__pWebViewer == null)
4998 AppLogDebug("Webviewer is not initialized yet.");
5002 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5004 WebSetting settings = __pWebViewer->GetSetting();
5005 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5007 settings.SetAutoFittingEnabled(true);
5009 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5011 settings.SetAutoFittingEnabled(false);
5013 __pWebViewer->SetSetting(settings);
5016 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5018 WebSetting settings = __pWebViewer->GetSetting();
5019 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5020 __pWebViewer->SetSetting(settings);
5022 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5024 WebSetting settings = __pWebViewer->GetSetting();
5025 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5026 __pWebViewer->SetSetting(settings);
5027 __pWebViewer->Reload();
5029 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5031 WebSetting settings = __pWebViewer->GetSetting();
5032 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5033 __pWebViewer->SetSetting(settings);
5035 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5039 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5042 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5046 WebSetting settings = __pWebViewer->GetSetting();
5047 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5048 __pWebViewer->SetSetting(settings);
5051 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5055 WebSetting settings = __pWebViewer->GetSetting();
5056 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5057 __pWebViewer->SetSetting(settings);
5060 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5062 WebSetting settings = __pWebViewer->GetSetting();
5063 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5065 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5069 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5071 __pWebViewer->SetSetting(settings);
5073 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5077 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5078 WebSetting settings = __pWebReader->GetSetting();
5079 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5080 __pWebReader->SetSetting(settings);
5086 MainForm::OnSettingsReset()
5090 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5091 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5096 MainForm::OnClearCache()
5098 result r = E_SUCCESS;
5100 if (__pWebViewer != NULL)
5102 r = __pWebViewer->ClearCache();
5105 AppLogDebug("Cache cleared success");
5109 AppLogDebug("Cache cleared fail");
5115 MainForm::OnClearCookie()
5117 result r = E_SUCCESS;
5119 if (__pWebViewer != NULL)
5121 __pWebViewer->ClearCookie();
5125 AppLogDebug("Cookie cleared success");
5129 AppLogDebug("Cache cleared fail");
5134 MainForm::OnClearFormData()
5136 result r = E_SUCCESS;
5138 if (__pWebViewer != NULL)
5140 __pWebViewer->ClearFormData();
5144 AppLogDebug("Cookie cleared success");
5148 AppLogDebug("Cache cleared fail");
5153 MainForm::OnClearPasswords()
5155 result r = E_SUCCESS;
5157 if (__pWebViewer != NULL)
5159 __pWebViewer->ClearLoginFormData();
5163 AppLogDebug("Cookie cleared success");
5167 AppLogDebug("Cache cleared fail");
5173 MainForm::findDistance(int x1,int y1,int x2, int y2)
5175 int deltaX = Math::Abs(x2 - x1);
5176 int deltaY = Math::Abs(y2 - y1);
5177 double num = deltaX*deltaX + deltaY*deltaY;
5183 for (i = 0; i < 20; i++)
5185 x = (((x*x)+ num)/(2*x));
5196 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5198 AppLog("xyz:: MainForm::OnTouchPressed called");
5199 if(__pFindWordControl)
5201 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5202 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5204 __isLongPressedDone = false;
5209 IList* pList = null;
5210 pList = touch.GetTouchInfoListN(source);
5214 int count = pList->GetCount();
5217 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5218 __touchPoint1 = pTouchInfo->position;
5220 /*if (__pAddressbar != null)
5222 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5224 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5226 __pAddressbar->SaveAddressbarEditText();
5228 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5231 __pAddressbar->Invalidate(true);
5233 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5235 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5237 //__pAddressbar->SaveAddressbarEditText();
5239 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5242 else if (count == 2)
5244 AppLogDebug("MainForm::OnTouchPressed count is two");
5245 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5246 __touchPoint1 = pTouchInfo->position;
5248 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5249 __touchPoint2 = pTouchInfo->position;
5254 pList->RemoveAll(true);
5259 __pAddressbar->SetShowState(false);
5261 if(__pFooterPanel && __isKeypadOpened == false)
5263 __pFooterPanel->SetShowState(true);
5265 RelayoutControls(false);
5270 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5272 // __currentWordIndex = 0;
5273 __isLongPressedDone = false;
5278 MainForm::MoveUiControls()
5283 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5285 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5287 if(__pFooterUrlField->GetTextLength() == 0)
5289 __pFooterUrlField->SetKeypadActionEnabled(false);
5293 __pFooterUrlField->SetKeypadActionEnabled(true);
5296 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5298 __currentSearchStr = __pFindWordEditField->GetText();
5299 if (__currentSearchStr.GetLength() > 0)
5301 __pFindWordCountLabel->SetShowState(true);
5305 // __pFindWordCountLabel->SetShowState(false);
5306 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5307 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5310 __pFindWordNext->SetEnabled(false);
5311 __pFindWordPrev->SetEnabled(false);
5312 __pFindWordNext->Invalidate(true);
5313 __pFindWordPrev->Invalidate(true);
5314 __pFindWordCountLabel->SetText(L"0/0");
5315 __pFindWordCountLabel->Invalidate(true);
5317 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5319 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5320 if (__currentSearchStr.GetLength() > 0)
5322 __pFindWordCountLabelRightToLeft->SetShowState(true);
5326 __pFindWordCountLabelRightToLeft->SetShowState(false);
5329 __pFindWordNext->SetEnabled(false);
5330 __pFindWordPrev->SetEnabled(false);
5331 __pFindWordNext->Invalidate(true);
5332 __pFindWordPrev->Invalidate(true);
5333 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5334 __pFindWordCountLabelRightToLeft->Invalidate(true);
5336 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5337 if (__currentSearchStr.GetLength() > 0)
5343 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5345 __currentSearchStr = L"";
5346 AppLogDebug("Enter something");
5351 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5358 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5360 if(__pWebViewer != null)
5363 AppLog("MainForm::InitMostVisitedSitesView");
5364 result r = E_SUCCESS;
5367 if (__pWebViewer != null && __pMostVisitedListView != null)
5372 if (__pMostVisitedListView != null)
5374 RemoveControl(__pMostVisitedListView);
5376 if(__pMostVisitedSites != null)
5378 __pMostVisitedSites->RemoveAll(true);
5381 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5383 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5384 __pMostVisitedListView = new(std::nothrow) ListView();
5386 int height = GetClientAreaBounds().height;
5388 if(__pFooterPanel->GetShowState() == true)
5390 height = height - __pFooterPanel->GetHeight();
5392 if(__pAddressbar->GetShowState() == true)
5394 height -= __pAddressbar->GetHeight();
5397 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5401 delete __pMostVisitedListView;
5402 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5405 __pMostVisitedListView->SetItemProvider(*this);
5406 __pMostVisitedListView->AddListViewItemEventListener(*this);
5407 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5408 AddControl(__pMostVisitedListView);
5409 __pMostVisitedListView->UpdateList();
5416 MainForm::GetImagePath(void)
5420 String formattedTime;
5421 DateTime currentTime;
5422 LocaleManager localManager;
5423 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5425 localManager.Construct();
5426 Locale locale = localManager.GetSystemLocale();
5427 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5429 // Get date formatter
5430 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5434 pTimeFormatter->Format(currentTime, formattedTime);
5437 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5438 String delim(L" :");
5439 StringTokenizer strTok(formattedTime, delim);
5442 String str1("GMT+00");
5443 while (strTok.HasMoreTokens())
5445 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5446 if(token.Equals(str1))
5448 AppLog("token is %ls", token.GetPointer());
5449 imageName.Append(token);
5455 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5457 result r = E_FAILURE;
5458 AppLog("Content manager 1");
5459 ContentId contentId;
5460 ContentManager contentManager;
5461 r = contentManager.Construct();
5464 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5467 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5468 Tizen::Io::Directory::Create(contentPath,true);
5469 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5471 AppLog("Already exists");
5473 else if(GetLastResult() == E_SUCCESS)
5475 AppLog("created success");
5477 contentPath.Append(imageName);
5478 contentPath.Append(".jpg");
5479 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5480 ShowIndicatorNotification(L"Download Complete",contentPath);
5481 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5485 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5487 AppLogDebug("ENTER");
5489 NotificationRequest request;
5490 request.SetAlertText(messageText);
5491 request.SetTitleText(L"");
5492 request.SetAppMessage(contentPath);
5493 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5494 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5495 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5496 String homePath = pApp->GetAppRootPath();
5497 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5498 AppLog("The iconPath is : %ls", homePath.GetPointer());
5499 request.SetIconFilePath(iconPath);
5501 Tizen::Shell::NotificationManager notiMgr;
5502 notiMgr.Construct();
5503 notiMgr.NotifyOngoingActivity(request);
5504 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5509 MainForm::SetForwardButtonEnabled(bool isEnabled)
5511 __pGoForwardBtn->SetEnabled(isEnabled);
5512 __pGoForwardBtn->Invalidate(true);
5516 MainForm::SetBackButtonEnabled(bool isEnabled)
5518 __pGoBackBtn->SetEnabled(isEnabled);
5519 __pGoBackBtn->Invalidate(true);
5523 MainForm::UpdateProgress(int percentage)
5525 __progressPercentage = percentage;
5526 if (percentage == 0 || percentage == 100)
5528 __isLoadingData = false;
5529 if (percentage == 100)
5531 __isLoadingCompleted = true;
5532 __progressPercentage = 0;
5536 __isLoadingCompleted = false;
5541 __isLoadingData = true;
5543 UpdateProgressBitmap();
5547 MainForm::GetProgress(void)
5549 return __progressPercentage;
5553 MainForm::UpdateProgressBitmap(void)
5555 result r = E_SUCCESS;
5556 if (__pProgressbarLabel == null)
5558 int w = __pProgressbarLabel->GetWidth();
5559 int h = __pProgressbarLabel->GetHeight();
5561 int progressWidth = 0;
5562 Bitmap* pRetBitmap = null;
5564 if (__progressPercentage == 0 || __progressPercentage == 100)
5566 __pProgressbarLabel->SetShowState(false);
5567 __pProgressbarLabel->Invalidate(false);
5572 __pProgressbarLabel->SetShowState(true);
5573 __pProgressbarLabel->Invalidate(false);
5576 r = canvas.Construct(Rectangle(0, 0, w, h));
5580 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5585 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5589 pBgBmp->Scale(Dimension(w, h));
5590 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5594 progressWidth = (double) (w) * __progressPercentage / 100;
5595 AppLogDebug("progressWidth: %d", progressWidth);
5596 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5598 if (pProgressBmp != null)
5600 pProgressBmp->Scale(Dimension(progressWidth, h));
5601 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5602 delete pProgressBmp;
5605 pRetBitmap = new (std::nothrow) Bitmap();
5607 if (pRetBitmap == null)
5609 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5613 pRetBitmap->Construct(canvas, canvas.GetBounds());
5615 if (__pProgressbarLabel != null && pRetBitmap != null)
5617 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5618 __pProgressbarLabel->Invalidate(false);
5621 if (pRetBitmap != null)
5630 MainForm::ReaderClicked()
5632 result r = E_SUCCESS;
5633 ArrayList* pArgList = new(std::nothrow) ArrayList();
5634 if (pArgList != null)
5636 r = pArgList->Construct();
5643 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5650 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5657 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5665 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5671 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5673 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5675 __currentAddMode = addMode;
5679 case ADDRESSBAR_MODE_INVALID:
5684 case ADDRESSBAR_MODE_READER:
5686 __pStopBtn->SetShowState(false);
5687 __pRefreshBtn->SetShowState(false);
5688 __pClearBtn->SetShowState(false);
5689 __pReaderBtn->SetShowState(false);
5692 case ADDRESSBAR_MODE_LOADING:
5694 __pRefreshBtn->SetShowState(false);
5695 __pStopBtn->SetShowState(true);
5696 __pClearBtn->SetShowState(false);
5697 __pReaderBtn->SetShowState(false);
5700 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5702 // SetUrl(__pAddressbar->GetUrl());
5704 __pRefreshBtn->SetShowState(true);
5705 __pStopBtn->SetShowState(false);
5706 __pClearBtn->SetShowState(false);
5707 __pReaderBtn->SetShowState(false);
5710 case ADDRESSBAR_MODE_EDIT:
5712 __pRefreshBtn->SetShowState(false);
5713 __pStopBtn->SetShowState(false);
5714 __pReaderBtn->SetShowState(false);
5715 __pClearBtn->SetShowState(true);
5722 OnAddressBarModeChanged();
5725 AddressBarMode MainForm::GetAddressbarMode(void)
5727 return __currentAddMode;
5730 void MainForm::SetUrl(const String& url)
5733 if(__displayUrl.GetLength() > 2048)
5734 __displayUrl.SubString(0,2048,__displayUrl);
5736 if (__pFooterUrlField != NULL)
5738 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5739 if (removedHttpUrl.IsEmpty() == false)
5741 __pFooterUrlField->SetText(removedHttpUrl);
5742 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5743 __pAddressbar->SetUrl(__displayUrl);
5747 __pFooterUrlField->SetText(__displayUrl);
5748 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5749 __pAddressbar->SetUrl(__displayUrl);
5751 if(__pFooterUrlField)
5752 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5753 __pFooterUrlField->Invalidate(false);
5754 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5755 __pAddressbar->Invalidate(true);
5756 // __pFooterUrlField->SetCursorPosition(0);
5761 MainForm::RemoveHttpTextFromDisplayURL(void)
5763 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5765 // bool isHttpText = __displayUrl.Contains(L"http://");
5766 String updatedDisplayUrl;
5767 updatedDisplayUrl.Clear();
5768 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5770 __displayUrl.SubString(7,updatedDisplayUrl);
5772 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5774 __displayUrl.SubString(8,updatedDisplayUrl);
5776 return updatedDisplayUrl;
5779 void MainForm::OnSharePopupControlStarted(void)
5781 __pWebViewer->AddTouchEventListener(*this);
5785 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5787 if (requestId == BACK_GROUND_APP_EVENT)
5789 if(__pWebViewer != null)
5791 __pWebViewer->Pause();
5795 __pImageMenu->SetShowState(false);
5797 if(__pAddressbar != null)
5799 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5802 else if(requestId == FORE_GROUND_APP_EVENT)
5804 if(__pWebViewer != null)
5806 __pWebViewer->Resume();
5808 if(__pAddressbar != null)
5810 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5816 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5818 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5819 result r = E_SUCCESS;
5822 __pAddressbar->SetShowState(false);
5824 AppLog("akjshdasd 5");
5825 __pFooterPanel->SetShowState(true);
5828 __pWebViewer->SetFocus();
5829 else if(__pMostVisitedListView)
5830 __pMostVisitedListView->SetFocus();
5831 else if(__pMultiWindowButton)
5832 __pMultiWindowButton->SetFocus();
5833 else if(__pMoreButton)
5834 __pMoreButton->SetFocus();
5836 __pAddressbar->SetShowState(false);
5838 RelayoutControls(false);
5842 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5844 AppLog("MainForm::OnFormMenuRequested called");
5846 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5848 int bookmarkCount=0;
5851 url=__pWindowInfo->pageUrl;
5852 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5853 result r = E_SUCCESS;
5854 Bitmap* pBitmap = null;
5855 String lastChar = L"";
5856 // if(url.SubString(url.GetLength()-1,lastChar));
5857 // if(lastChar == L"/")
5859 // bool exist1 = false;
5860 // bool exist2 = false;
5861 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5862 // url.SubString(0,url.GetLength() - 1,url);
5863 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5864 // exist = exist1 | exist2;
5868 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5871 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5877 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5881 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5883 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5885 if (__pOptionMenu->GetItemCount() == 9)
5887 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5891 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5896 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5900 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5901 if (__pOptionMenu->GetItemCount() != 9)
5903 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5904 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5905 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5906 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5907 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5908 __pOptionMenu->SetMaxVisibleItemsCount(6);
5910 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5912 AppLog(" Orientation landscape");
5913 __pOptionMenu->SetMaxVisibleItemsCount(5);
5917 AppLog(" Orientation potrait");
5918 __pOptionMenu->SetMaxVisibleItemsCount(6);
5921 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5924 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5926 __pAddressbar->SetShowState(false);
5928 __pFooterPanel->SetShowState(true);
5929 result r = __pOptionMenu->SetShowState(true);
5930 AppLog("ajsghd %s",GetErrorMessage(r));
5931 RelayoutControls(false);
5932 __pOptionMenu->Invalidate(true);
5933 __pOptionMenu->Show();