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 __webControlHeightF = 0;
205 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
206 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
207 __pMostVisitedSites = null;
208 __pFooterUrlField = null;
210 __pGoForwardBtn = null;
211 __pRefreshBtn = null;
212 __pProgressbarLabel = null;
213 __pFooterLabel = null;
217 __isKeypadOpened = false;
219 __pNotification = null;
222 MainForm::~MainForm(void)
224 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
228 __pAddressbar->SetAddressbarEventListener(null);
231 if(__pHistory != null)
237 if (__pReaderData != null)
239 delete __pReaderData;
240 __pReaderData = null;
243 if (__pPopUp != null)
249 if (__pHitElementResult != null)
251 delete __pHitElementResult;
252 __pHitElementResult = null;
256 delete __pOptionMenu;
257 __pOptionMenu = null;
260 String* pSelectedScene = NULL;
261 Object* pValue = NULL;
262 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
263 pSelectedScene = (String*) pValue;
265 /*if (pSelectedScene != null)
267 delete pSelectedScene;
269 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
273 MainForm::Initialize(void)
275 Construct(L"IDL_FORM");
277 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
282 MainForm::OnInitializing(void)
284 AppLog("get client area width = %d",GetClientAreaBounds().width);
285 AppLog("get client area height = %d",GetClientAreaBounds().height);
286 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
287 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
289 __fontSize = CommonUtil::GetFontSize();
290 Panel* pFooterPanel = null;
292 __pSaveImage = new Image();
293 __pSaveImage->Construct();
295 // Setup back event listener
296 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
297 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
298 AddOrientationEventListener(*this);
300 AppLogDebug(" MainForm::OnInitializing ended");
301 if (__pMostVisitedSites == null)
303 __pMostVisitedSites = new(std::nothrow) ArrayList();
304 __pMostVisitedSites->Construct();
306 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
308 __pItemContext= new(std::nothrow) ListContextItem();
309 __pItemContext->Construct();
311 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
314 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
315 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
316 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
318 __pItemContextLandscape= new(std::nothrow) ListContextItem();
319 __pItemContextLandscape->Construct();
321 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
322 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
323 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
324 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
325 SetFormMenuEventListener(this);
326 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
331 MainForm::InitAddressbar(void)
333 AppLogDebug("MainForm::InitAddressbar entered");
335 result r = E_SUCCESS;
337 if (__pAddressbar != null)
341 __pAddressbar = new(std::nothrow) Addressbar();
342 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
343 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
346 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
349 __pAddressbar->SetAddressbarEventListener(this);
350 AddControl(__pAddressbar);
351 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
352 SetControlAlwaysOnTop(*__pAddressbar, true);
353 __adressPanelPosition = __pAddressbar->GetPosition();
355 AppLogDebug("MainForm::InitAddressbar exit");
361 MainForm::CreateReaderPanel(void)
363 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
364 result r = E_FAILURE;
366 Button *pSmallFontBtn = null;
367 Button *pLargeFontBtn = null;
369 __pBlankPanel = new (std::nothrow) Panel();
370 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
372 __pArticleReaderPanel = new (std::nothrow) Panel();
373 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
375 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
376 if (__pReaderCloseBtn)
378 AppLogDebug("CreateReaderPanel() 6");
379 __pReaderCloseBtn->AddActionEventListener(*this);
380 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
383 __pWebReader = new (std::nothrow) Web();
384 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
386 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
387 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
389 r = __pWebReader->SetSetting(settings);
391 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
394 __pArticleReaderLabel = new Label();
395 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
397 __pBlankPanel->AddControl(__pArticleReaderLabel);
398 __pBlankPanel->AddControl(__pArticleReaderPanel);
399 AddControl(__pBlankPanel);
401 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
402 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
403 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
405 __pArticleReaderPanel->AddControl(__pWebReader);
406 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
407 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
410 if (pBitmap != null && pSrcBitmap != null)
412 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
414 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
416 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
419 pSmallFontBtn->AddActionEventListener(*this);
420 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
423 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
426 pLargeFontBtn->AddActionEventListener(*this);
427 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
436 if (pSrcBitmap != null)
442 SetControlAlwaysOnTop(*__pBlankPanel, true);
443 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
450 MainForm::InitWebControl()
452 AppLogDebug("MainForm::InitWebControl enter");
453 result r = E_SUCCESS;
454 AppLogDebug("InitWebControl");
456 if (__pAddressbar == null || __pFooterPanel == null)
459 const int Y_WEBCONTROL_POSITION = 0;
461 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
462 __webControlHeightF = GetHeightF() - __pFooterPanel->GetHeightF();
464 if (__pMostVisitedListView)
466 __pMostVisitedListView->SetShowState(false);
468 if (__pWebViewer != null)
470 AppLogDebug("Already initialized");
473 __pWebViewer = new(std::nothrow) Web();
474 if(__pWebViewer == NULL)
476 AppLogDebug("Initialization failed");
479 AppLog("GetClientAreaBounds().width %d",GetClientAreaBounds().width);
480 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
484 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
491 r = AddControl(__pWebViewer);
494 __pWebViewer->Destroy();
496 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
499 __webControlPosition = __pWebViewer->GetPosition();
500 __webControlPositionF = __pWebViewer->GetPositionF();
501 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
504 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
508 __pWebViewer->SetLoadingListener(this);
509 __pWebViewer->SetWebUiEventListenerF(this);
510 __pWebViewer->SetWebKeypadEventListener(this);
511 __pWebViewer->SetFocus();
512 __pWebViewer->AddTouchEventListener(*this);
514 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
515 __pWebViewer->SetTextSearchListener(this);
518 AppLogDebug("MainForm :before return");
520 AppLogDebug("MainForm::InitWebControl Exit");
526 MainForm::SetJavascriptEnabled()
528 WebSetting settings = __pWebViewer->GetSetting();
529 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
530 __pWebViewer->SetSetting(settings);
534 MainForm::SetImageLoadEnabled()
536 WebSetting settings = __pWebViewer->GetSetting();
537 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
538 __pWebViewer->SetSetting(settings);
542 MainForm::InitFooter(void)
544 AppLogDebug("MainForm::InitFooter entered");
545 Button* pBackButton = null;
546 Button* pBookmarkButton = null;
547 Button* pMultiWindowButton = null;
548 Bitmap *pIconBitmap = null;
549 Bitmap *pBGBitmap = null;
550 Label *pBGLabel = null;
552 if (__pFooterPanel == null)
554 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
557 if (__pFooterPanel == null)
562 SetControlAlwaysOnTop(*__pFooterPanel, true);
564 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
565 if ( __pFooterLabel == NULL )
569 // __pFooterPanel->SetBackgroundColor(Color(255,0,0));
570 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
571 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
574 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
578 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
580 if ( __pMultiWindowButton == NULL )
586 SetFormBackEventListener(this);
587 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
588 if (__pMultiWindowButton != null)
590 Bitmap* pBitmap = null;
591 Bitmap* pPressedBitmap = null;
592 String imagePath = "I01_toolbar_icon_windows_manager_0";
593 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
594 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
595 imagePath.Append(totalCount);
596 imagePath.Append(".png");
598 pressedImagePath.Append(totalCount);
599 pressedImagePath.Append("_press.png");
601 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
602 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
603 if ( pBitmap == null )
608 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
611 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
612 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
617 __pMultiWindowButton->AddActionEventListener(*this);
618 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
621 delete pPressedBitmap;
622 pPressedBitmap = null;
628 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
629 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
632 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
633 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
634 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
638 __pMoreButton->AddActionEventListener(*this);
639 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
642 //Add the editfield for url
643 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
644 if (__pFooterUrlField == NULL)
646 return E_INVALID_KEY;
649 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
650 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
651 __pFooterUrlField->AddKeypadEventListener(*this);
652 __pFooterUrlField->SetPropagatedTouchEventListener(this);
653 __pFooterUrlField->AddFocusEventListener(*this);
655 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
657 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
659 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
661 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE"));
665 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
666 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
670 //Add the go Back Button
671 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
672 if (__pGoBackBtn == NULL)
674 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
675 return E_INVALID_KEY;
677 __pGoBackBtn->SetActionId(IDA_GO_BACK);
678 __pGoBackBtn->AddActionEventListener(*this);
680 //Add the go forward Button
681 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
682 if (__pGoForwardBtn == NULL)
684 AppLogDebug("Control not found returning E_INVALID_KEY");
685 return E_INVALID_KEY;
687 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
688 __pGoForwardBtn->AddActionEventListener(*this);
689 if (__pWebViewer && __pWebViewer->CanGoForward())
691 SetForwardButtonEnabled(true);
695 SetForwardButtonEnabled(false);
698 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
699 if (__pRefreshBtn == NULL)
701 AppLogDebug("Control not found returning E_INVALID_KEY");
702 return E_INVALID_KEY;
705 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
706 __pRefreshBtn->AddActionEventListener(*this);
707 __pRefreshBtn->SetShowState(true);
709 //Add the backround label for displaying progressbar
710 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
711 if (__pProgressbarLabel == NULL)
713 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
716 __pProgressbarLabel->SetShowState(false);
718 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
719 if (__pStopBtn == NULL)
721 AppLogDebug("Control not found returning E_INVALID_KEY");
722 return E_INVALID_KEY;
724 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
725 __pStopBtn->AddActionEventListener(*this);
726 __pStopBtn->SetShowState(false);
728 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
729 if (__pClearBtn == NULL)
731 AppLogDebug("Control not found returning E_INVALID_KEY");
732 return E_INVALID_KEY;
734 __pClearBtn->SetActionId(IDA_CLEAR_URL);
735 __pClearBtn->AddActionEventListener(*this);
736 __pClearBtn->SetShowState(false);
738 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
739 if (__pReaderBtn == NULL)
741 AppLogDebug("Control not found returning E_INVALID_KEY");
742 return E_INVALID_KEY;
744 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
745 __pReaderBtn->AddActionEventListener(*this);
746 __pReaderBtn->SetShowState(false);
748 // __pFooterPanel->Invalidate(true);
749 if(__isKeypadOpened == false && __pAddressbar && __pAddressbar->GetShowState() == false)
751 // AppLog("asdasdasdasda");
752 __pFooterPanel->SetShowState(true);
754 else if(__pAddressbar == null)
756 __pFooterPanel->SetShowState(true);
759 __pFooterPanel->SetShowState(false);
761 SetAddressbarMode(GetAddressbarMode());
762 AppLogDebug("MainForm::InitFooter exit");
767 MainForm::InitOptionMenu()
769 result r = E_SUCCESS;
770 bool isPrivateBrowsing = false;
771 Bitmap* pBitmap = null;
773 if (__pOptionMenu != null)
775 __pOptionMenu->SetFocusable(true);
776 __pOptionMenu->Invalidate(true);
780 __pOptionMenu = new(std::nothrow) OptionMenu();
781 r = __pOptionMenu->Construct();
782 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
784 __pOptionMenu->SetFocusable(true);
785 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
788 if (isPrivateBrowsing == true)
790 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
794 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
797 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
799 if ( pBitmap != NULL)
801 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
804 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
805 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
806 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
809 __pOptionMenu->SetMaxVisibleItemsCount(6);
810 __pOptionMenu->SetShowState(false);
811 __pOptionMenu->AddActionEventListener(*this);
812 SetControlAlwaysOnTop(*__pOptionMenu, true);
818 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
820 result r = E_SUCCESS;
821 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
823 AppLog("MainForm::InitImageContextMenu clicked on image");
824 if (__pImageMenu != null)
829 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
834 __pImageMenu = new (std::nothrow) ContextMenu();
835 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
836 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
838 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
839 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
840 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
841 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
842 __pImageMenu->SetMaxVisibleItemsCount(4);
843 __pImageMenu->AddActionEventListener(*this);
844 SetControlAlwaysOnTop(*__pImageMenu, true);
845 __pImageMenu->SetFocusable(true);
851 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
853 result r = E_SUCCESS;
854 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
856 AppLog("MainForm::InitImageContextMenu clicked on image");
857 if (__pImageMenu != null)
863 // if(__pAddressbar->GetShowState() == true)
864 // p.y = p.y + __pAddressbar->GetHeight();
865 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
870 __pImageMenu = new (std::nothrow) ContextMenu();
871 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
872 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
874 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
875 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
876 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
877 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
879 __pImageMenu->SetMaxVisibleItemsCount(3);
880 __pImageMenu->AddActionEventListener(*this);
881 SetControlAlwaysOnTop(*__pImageMenu, true);
882 __pImageMenu->SetFocusable(true);
889 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
891 result r = E_SUCCESS;
892 bool clipboardAvailable = true;
893 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
895 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
896 if (__pImageMenu != null)
902 // __pWebViewer->GetBlockRange(p,q);
907 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
911 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
915 Clipboard* pClipboard = Clipboard::GetInstance();
917 if(pClipboard == null)
919 clipboardAvailable = false;
923 // Retrieves a latest item
924 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
928 clipboardAvailable = false;
932 //Gets data from the clipboard item
933 String* pString = dynamic_cast<String*>(pItem->GetData());
937 clipboardAvailable = false;
941 if(clipboardAvailable == false && onlyPasteOption == true)
946 __pImageMenu = new (std::nothrow) ContextMenu();
947 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
948 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
950 if(onlyPasteOption == false)
952 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
954 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
956 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
958 if(onlyPasteOption == false)
960 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
961 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
964 __pImageMenu->SetMaxVisibleItemsCount(3);
965 __pImageMenu->AddActionEventListener(*this);
966 SetControlAlwaysOnTop(*__pImageMenu, true);
967 __pImageMenu->SetFocusable(true);
974 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
976 result r = E_SUCCESS;
977 bool clipboardAvailable = true;
978 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
980 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
981 if (__pImageMenu != null)
986 // FloatPoint q(0.0,0.0);
987 // __pWebViewer->GetBlockRange(p,q);
991 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
993 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
995 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
999 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
1001 AppLog("asdasdafdsfdgfd");
1004 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1008 Clipboard* pClipboard = Clipboard::GetInstance();
1010 if(pClipboard == null)
1012 clipboardAvailable = false;
1016 // Retrieves a latest item
1017 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1021 clipboardAvailable = false;
1025 //Gets data from the clipboard item
1026 String* pString = dynamic_cast<String*>(pItem->GetData());
1030 clipboardAvailable = false;
1034 if(clipboardAvailable == false && (onlyPasteOption == true || __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
1038 __pImageMenu = new (std::nothrow) ContextMenu();
1039 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1040 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1046 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1048 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1050 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1052 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1054 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1056 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1057 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1060 __pImageMenu->SetMaxVisibleItemsCount(3);
1061 __pImageMenu->AddActionEventListener(*this);
1062 SetControlAlwaysOnTop(*__pImageMenu, true);
1063 __pImageMenu->SetFocusable(true);
1070 MainForm::InitFindWordPanel(void)
1072 result r = E_SUCCESS;
1073 Bitmap *pIconBitmap = null;
1075 if (__pFindWordControl != null)
1077 AppLogDebug("Findword panel already initialized");
1078 if (__pFindWordBgLabel != null)
1080 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1081 if (pBitmap != null)
1083 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1087 if (__pFindWordBgLabelRightToLeft != null)
1089 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1090 if (pBitmap != null)
1092 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1097 __pAddressbar->SetShowState(false);
1099 if(__isKeypadOpened == false)
1100 __pFooterPanel->SetShowState(true);
1104 __pFindWordControl = new (std::nothrow) Panel();
1105 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1108 AppLogException("There is some problem in the xml file. Please check.");
1111 AddControl(__pFindWordControl);
1112 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1113 SetControlAlwaysOnTop(*__pFindWordControl,true);
1114 __pFindWordControl->SetShowState(false);
1115 __pFindWordControl->Invalidate(false);
1117 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1118 __pFindWordPanelLeftToRight->SetShowState(true);
1120 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1121 __pFindWordPanelRightToLeft->SetShowState(false);
1123 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1124 if (__pFindWordBgLabel != null)
1126 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1127 Rectangle pRect = pPanel1->GetBounds();
1128 pRect.x = pRect.y = 0;
1129 __pFindWordBgLabel->SetBounds(pRect);
1130 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1131 if (pBitmap != null)
1133 AppLogDebug("InitFindWordPanel: Coming here");
1134 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1139 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1143 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1144 if (__pFindWordBgLabelRightToLeft != null)
1146 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1147 Rectangle pRect = pPanel1->GetBounds();
1148 pRect.x = pRect.y = 0;
1149 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1150 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1151 if (pBitmap != null)
1153 AppLogDebug("InitFindWordPanel: Coming here");
1154 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1159 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1163 Button* pfindWordCancel = null;
1164 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1165 if (pfindWordCancel == null)
1167 AppLogException("There is some problem in the xml file. Please check.");
1170 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1171 pfindWordCancel->AddActionEventListener(*this);
1173 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1174 if (__pFindWordClear == null)
1176 AppLogException("There is some problem in the xml file. Please check.");
1180 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1181 if (__pFindWordClearRightToLeft == null)
1183 AppLogException("There is some problem in the xml file. Please check.");
1187 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1188 __pFindWordClear->AddActionEventListener(*this);
1190 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1191 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1193 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1194 if (__pFindWordNext == null)
1196 AppLogException("There is some problem in the xml file. Please check.");
1200 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1201 __pFindWordNext->AddActionEventListener(*this);
1203 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1204 if (__pFindWordPrev == null)
1206 AppLogException("There is some problem in the xml file. Please check.");
1210 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1211 __pFindWordPrev->AddActionEventListener(*this);
1213 __pFindWordNext->SetEnabled(false);
1214 __pFindWordPrev->SetEnabled(false);
1216 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1217 if (__pFindWordCountLabel == null)
1219 AppLogException("There is some problem in the xml file. Please check.");
1223 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1224 if (__pFindWordCountLabelRightToLeft == null)
1226 AppLogException("There is some problem in the xml file. Please check.");
1230 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1231 if (__pFindWordEditField == null)
1233 AppLogException("There is some problem in the xml file. Please check.");
1236 __pFindWordEditField->AddTextEventListener(*this);
1237 __pFindWordEditField->AddKeypadEventListener(*this);
1238 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1239 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1241 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1242 if (__pFindWordEditFieldRightToLeft == null)
1244 AppLogException("There is some problem in the xml file. Please check.");
1247 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1248 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1249 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1250 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1253 __pAddressbar->SetShowState(false);
1255 if(__isKeypadOpened == false)
1256 __pFooterPanel->SetShowState(true);
1261 MainForm::CreateItem (int index, int itemWidth)
1263 Rectangle listImageRect;
1264 Rectangle pagetTitleRect;
1265 Rectangle pageURLRect;
1266 Rectangle deleteImageRect;
1267 String pageTitle(L"");
1268 String pageURL(L"");
1269 result r = E_SUCCESS;
1270 Bitmap* pListIconImage = null;
1273 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1274 if(pHistory == null)
1278 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1279 if ( pAppResource == NULL )
1283 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1285 CustomItem* pItem = new(std::nothrow) CustomItem();
1286 pageTitle = pHistory->GetHistoryTitle();
1287 pageURL = pHistory->GetHistoryUrl();
1289 if (pageURL.GetLength() == 0)
1292 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1293 pageURL = L"<"+ nourl +">";
1297 Rectangle screenBounds = GetBounds();
1300 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1309 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1311 if ( pBitmap != NULL)
1313 pListIconImage = new Bitmap();
1314 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1318 if(pListIconImage == null)
1320 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1323 if ( pListIconImage != NULL)
1325 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1326 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1327 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1330 if (pItem != null && pListIconImage != NULL)
1332 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1336 if (pageTitle.CompareTo(L"") != 0)
1340 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1344 if (pageURL.CompareTo(L"") != 0)
1348 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
1353 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1355 if ( __pItemContext!= NULL)
1359 pItem->SetContextItem(__pItemContext);
1365 if ( __pItemContextLandscape!= NULL)
1369 pItem->SetContextItem(__pItemContextLandscape);
1373 if( pListIconImage != NULL)
1375 delete pListIconImage;
1376 pListIconImage = null;
1383 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1390 MainForm::GetItemCount (void)
1392 if(__pMostVisitedSites != null)
1394 __pMostVisitedSites->RemoveAll(true);
1396 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1397 if(__pMostVisitedSites != null)
1399 return __pMostVisitedSites->GetCount();
1406 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1408 AppLog("MainForm::OnListViewContextItemStateChanged called");
1409 if(__pMostVisitedSites != null)
1411 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1412 if (pHistory != null)
1414 String url = pHistory->GetHistoryUrl();
1416 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1417 __pMostVisitedListView->UpdateList();
1423 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1425 AppLog("MainForm::OnListViewItemStateChanged called");
1426 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1427 String url = pHistory->GetHistoryUrl();
1435 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1441 MainForm::OnTerminating(void)
1443 result r = E_SUCCESS;
1445 RemoveOrientationEventListener(*this);
1449 __pAddressbar->SetAddressbarEventListener(null);
1454 __pWebViewer->RemoveTouchEventListener(*this);
1455 __pWebViewer->SetWebUiEventListenerF(null);
1456 __pWebViewer->SetWebKeypadEventListener(null);
1457 __pWebViewer->SetTextSearchListener(null);
1463 delete __pItemContext;
1465 if (__pItemContextLandscape)
1467 delete __pItemContextLandscape;
1471 delete __pSaveImage;
1473 if (__pMostVisitedSites)
1475 __pMostVisitedSites->RemoveAll(true);
1476 delete __pMostVisitedSites;
1482 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1484 result r = E_SUCCESS;
1486 AppLogDebug("Clicked : %d", actionId);
1489 case IDA_BACKBTN_CLICKED:
1491 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1493 AppLog("Hiding the menu");
1494 __pImageMenu->SetShowState(false);
1496 if (__pWebViewer && __pWebViewer->CanGoBack())
1498 __pWebViewer->GoBack();
1500 else if(__pWindowInfo->isJavascriptInitiated == false)
1503 pApp = UiApp::GetInstance();
1506 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1509 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1517 WindowInfo* pWindowInfo = null;
1519 SceneManager* pSceneManager = SceneManager::GetInstance();
1520 if (pSceneManager == null)
1524 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1525 if (pAllWindowList == NULL)
1527 pApp = UiApp::GetInstance();
1530 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1533 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1538 if (pAllWindowList != null)
1540 totalCount = pAllWindowList->GetCount();
1542 for (int count = 0; count < totalCount; count++)
1544 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1545 if (pWindowInfo == null)
1547 pApp = UiApp::GetInstance();
1550 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1553 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1560 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1562 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1565 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1568 r = pAllWindowList->RemoveAt(count, true);
1569 __pWindowInfo = null;
1572 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1577 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1581 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1583 if (pWindowInfo == null)
1585 pApp = UiApp::GetInstance();
1588 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1594 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1595 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1598 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1610 case IDA_FORWARD_CLICKED:
1611 if (__pWebViewer == null)
1614 if (__pWebViewer->CanGoForward())
1616 __pWebViewer->GoForward();
1618 __pOptionMenu->SetShowState(false);
1619 __pOptionMenu->Invalidate(false);
1622 case IDA_FINDONPAGE_CLICKED:
1624 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1625 __currentSearchStr.Clear();
1627 InitFindWordPanel();
1628 __pOptionMenu->SetShowState(false);
1629 __pOptionMenu->Invalidate(false);
1631 ShowFindWordPanel(true);
1633 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1635 __pFindWordEditField->SetFocus();
1636 // __pFindWordCountLabel->SetShowState(false);
1640 __pFindWordEditFieldRightToLeft->SetFocus();
1641 __pFindWordCountLabelRightToLeft->SetShowState(false);
1645 case IDA_PRIVATEON_CLICKED:
1647 result r = E_SUCCESS;
1649 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1650 Bitmap* pBitmap = null;
1651 if (isPrivateBrowsing == true)
1653 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1656 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1660 if (__pWebViewer != NULL)
1662 __pWebViewer->SetPrivateBrowsingEnabled(false);
1665 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1667 if (__pAddressbar != null)
1669 __pAddressbar->UpdateFaviconBitmap(false);
1675 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1678 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1682 if (__pWebViewer != NULL)
1684 __pWebViewer->SetPrivateBrowsingEnabled(true);
1687 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1689 if (__pAddressbar != null)
1691 __pAddressbar->UpdateFaviconBitmap(true);
1695 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1696 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1697 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1698 __pOptionMenu->Invalidate(true);
1699 if ( pBitmap != NULL )
1706 case IDA_SETTINGS_CLICKED:
1709 ArrayList* pArgList = new(std::nothrow) ArrayList();
1712 pArgList->Construct();
1713 pArgList->Add(*__pWindowInfo);
1714 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1716 __pOptionMenu->SetShowState(false);
1717 __pOptionMenu->Invalidate(false);
1719 if (pArgList != null)
1728 case IDA_ADDTOBOOKMARK_CLICKED:
1731 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1733 int bookmarkCount=0;
1736 url=__pWindowInfo->pageUrl;
1737 result r = E_SUCCESS;
1738 Bitmap* pBitmap = null;
1739 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1747 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1748 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1749 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1751 if(__pNotification != null)
1753 RemoveControl(__pNotification);
1754 __pNotification = null;
1756 __pNotification = new (std::nothrow) NotificationPanel(*this);
1757 if (__pNotification != null)
1759 __pNotification->SetText(message);
1760 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1761 __pNotification->ShowNotification();
1766 String title=__pWindowInfo->pageTitle;
1767 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1768 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1770 pBookmark->SetBookmarkTitle(title);
1771 pBookmark->SetUrl(url);
1772 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1774 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1776 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1777 pBookmark->SetFaviconId(id);
1778 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1779 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1781 if(__pNotification != null)
1783 RemoveControl(__pNotification);
1784 __pNotification = null;
1786 __pNotification = new (std::nothrow) NotificationPanel(*this);
1787 if (__pNotification != null)
1789 __pNotification->SetText(message);
1790 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1791 __pNotification->ShowNotification();
1792 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1795 if (pBitmap != null)
1797 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1802 __pOptionMenu->Invalidate(true);
1807 case IDA_PRINT_CLICKED:
1809 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1810 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1812 AppLog("RequestPrint called!");
1813 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1814 result nResult = E_FAILURE;
1817 AppLog("TestPrint if (pAc) == true");
1822 String fileType = L"service_print_files_type";
1823 String typeVal = L"DOC";
1825 String fileCount = L"service_print_files_count";
1826 String countVal = L"1";
1827 String fileFolder= L"service_print_files_folder_name";
1828 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1830 map.Add(&fileCount, &countVal);
1831 map.Add(&fileFolder, &folderVal);
1832 map.Add(&fileType, &typeVal);
1834 String fileName = L"service_print_files_files_name";
1836 ArrayList fileNameList;
1837 fileNameList.Construct();
1838 String file1 = L"test.pdf";
1840 fileNameList.Add(&file1);
1841 map.Add(&fileName, &fileNameList);
1843 nResult = pAc->Start(NULL, NULL, &map, NULL);
1845 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1846 else if (nResult == E_MAX_EXCEEDED)
1847 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1848 else if (nResult == E_OBJ_NOT_FOUND)
1849 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1850 else if (nResult == E_IN_PROGRESS)
1851 AppLog("TestPrint ret == E_IN_PROGRESS");
1852 else if (nResult == E_PRIVILEGE_DENIED)
1853 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1854 else if(nResult == E_SYSTEM)
1855 AppLog("TestPrint ret == E_SYSTEM");
1861 int __modalMsgBoxResult;
1862 MessageBox* pMsgBox = new MessageBox();
1863 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1864 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1867 __modalMsgBoxResult = 0;
1871 case IDA_SHARE_CLICKED:
1873 if(__pPopUp != null)
1880 __pAddressbar->HideKeypad();
1882 __pPopUp = new(std::nothrow) SharePopup();
1883 __pPopUp->Initialize();
1884 if (__pWindowInfo != null)
1886 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1887 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1888 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1889 pShareInfo->SetImageAttached(false);
1890 __pPopUp->RemoveAllShareInfo();
1891 __pPopUp->AddShareInfo(pShareInfo);
1893 __pPopUp->SetShowState(true);
1897 case IDA_BOOKMARKBTN_CLICKED:
1899 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1900 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1903 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1908 case IDA_MOREBTN_CLICKED:
1910 AppLog("IDA_MOREBTN_CLICKED");
1912 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1914 int bookmarkCount=0;
1917 url=__pWindowInfo->pageUrl;
1918 result r = E_SUCCESS;
1919 Bitmap* pBitmap = null;
1921 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1924 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1929 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1933 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1935 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1937 if (__pOptionMenu->GetItemCount() == 9)
1939 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1943 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1948 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1952 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1953 if (__pOptionMenu->GetItemCount() != 9)
1955 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1956 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1957 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1958 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1959 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1960 __pOptionMenu->SetMaxVisibleItemsCount(6);
1962 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1964 AppLog(" Orientation landscape");
1965 __pOptionMenu->SetMaxVisibleItemsCount(5);
1969 AppLog(" Orientation potrait");
1970 __pOptionMenu->SetMaxVisibleItemsCount(6);
1973 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1976 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1977 __pOptionMenu->SetShowState(true);
1978 __pOptionMenu->Invalidate(true);
1979 __pOptionMenu->Show();
1983 case IDA_HISTORY_CLICKED:
1985 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1986 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1989 case IDA_SAVED_PAGES_CLICKED:
1994 case IDA_DESKTOP_VIEW_CLICKED:
1999 case IDA_SAVE_CLICKED:
2004 case IDA_MULTIWINDOWBTN_CLICKED:
2006 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2007 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2011 case IDA_NEWWINDOWBTN_CLICKED:
2013 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2015 if (pNewWindowInfo == null)
2019 result r = E_SUCCESS;
2020 SceneManager* pSceneManager = SceneManager::GetInstance();
2022 if (pSceneManager == NULL)
2026 ArrayList* pArgList = new(std::nothrow) ArrayList();
2027 if (pArgList == NULL)
2031 r = pArgList->Construct();
2034 pArgList->Add(*pNewWindowInfo);
2035 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2041 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2046 case IDA_SMALLFONT_BTN_CLICKED:
2048 WebSetting setting = __pWebReader->GetSetting();
2049 setting.SetFontSize(15);
2050 __pWebReader->SetSetting(setting);
2053 case IDA_LARGEFONT_BTN_CLICKED:
2055 WebSetting setting = __pWebReader->GetSetting();
2056 setting.SetFontSize(25);
2057 __pWebReader->SetSetting(setting);
2060 case IDA_READER_CLOSE_CLICKED:
2062 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2064 RemoveControl(__pBlankPanel);
2065 __pArticleReaderPanel = null;
2066 __pBlankPanel = null;
2067 __pArticleReaderLabel = null;
2069 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2072 case IDA_FINDWORD_CANCEL_CLICKED:
2074 __currentSearchStr = L"";
2075 __currentWordIndex = 0;
2076 __maxOccurrances = 0;
2078 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2080 __pFindWordEditField->SetText(L"");
2081 __pFindWordCountLabel->SetText(L"0/0");
2083 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2085 __pFindWordEditFieldRightToLeft->SetText(L"");
2086 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2089 __pFindWordNext->SetEnabled(false);
2090 __pFindWordPrev->SetEnabled(false);
2091 __pFindWordCountLabel->SetText(L"0/0");
2092 __pWebViewer->SearchTextAllAsync(L"",true);
2093 AppLog("akjshdasd 1");
2094 if(__isKeypadOpened == false)
2095 __pFooterPanel->SetShowState(true);
2096 ShowFindWordPanel(false);
2099 case IDA_FINDWORD_SEARCH_CLICKED:
2101 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2103 __currentSearchStr = __pFindWordEditField->GetText();
2105 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2107 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2110 if (__currentSearchStr.GetLength() > 0)
2116 AppLogDebug("Enter something");
2120 case IDA_FINDWORD_CLEAR_CLICKED:
2122 __pFindWordCountLabel->SetText(L"0/0");
2123 __pFindWordEditField->SetText(L"");
2124 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2126 __currentSearchStr = L"";
2127 __pFindWordNext->SetEnabled(false);
2128 __pFindWordPrev->SetEnabled(false);
2129 // __pFindWordCountLabel->SetShowState(false);
2130 __pFindWordControl->Invalidate(true);
2133 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2135 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2136 __pFindWordEditFieldRightToLeft->SetText(L"");
2137 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2139 __currentSearchStr = L"";
2140 __pFindWordNext->SetEnabled(false);
2141 __pFindWordPrev->SetEnabled(false);
2142 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2143 __pFindWordControl->Invalidate(true);
2146 case IDA_FINDWORD_NEXT_CLICKED:
2151 case IDA_FINDWORD_PREV_CLICKED:
2153 FindNextWord(false);
2156 case IDA_BRIGHTNESS_BTN_CLICKED:
2158 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2159 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2162 case IDA_COPY_IMAGE_CLICKED:
2164 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2165 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2167 const Bitmap* pBitmap = null;
2168 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2170 pBitmap = __pHitElementResult->GetImage();
2173 String resourcePath = App::GetInstance()->GetAppResourcePath();
2174 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2175 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2176 // copying the item to clipboard
2177 Clipboard* pClipboard = Clipboard::GetInstance();
2178 if (pClipboard != null)
2180 r = pClipboard->CopyItem(item);
2181 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2185 case IDA_VIEW_IMAGE_CLICKED:
2187 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2188 WindowInfo* pNewWindowInfo = null;
2189 if (__pHitElementResult != null)
2191 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2192 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2198 case IDA_SAVE_IMAGE_CLICKED:
2200 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2201 const Bitmap* pSaveBitmap = null;
2202 String imageName = GetImagePath();
2203 AppLog("Content manager image name %ls",imageName.GetPointer());
2206 imagePath.Append(imageName);
2207 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2208 AppLog("Content manager image path %ls",imagePath.GetPointer());
2209 if (__pHitElementResult != null)
2211 pSaveBitmap = __pHitElementResult->GetImage();
2213 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2217 UpdateImageContent(pBuffer, imageName);
2219 if(__pNotification != null)
2221 RemoveControl(__pNotification);
2222 __pNotification = null;
2224 __pNotification = new NotificationPanel(*this);
2226 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2227 msg.Append(imagePath);
2228 if (__pNotification != null)
2230 __pNotification->SetText(msg);
2231 if (__pFooterPanel->GetShowState() == true)
2233 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2237 __pNotification->SetPositionDiff(0);
2239 __pNotification->ShowNotification();
2244 int __modalMsgBoxResult;
2245 MessageBox* pMsgBox = new MessageBox();
2246 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);
2247 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2250 __modalMsgBoxResult = 0;
2254 case IDA_SHARE_IMAGE_CLICKED:
2256 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2257 if (__pPopUp != null)
2264 __pAddressbar->HideKeypad();
2266 __pPopUp = new(std::nothrow) SharePopup();
2267 __pPopUp->Initialize();
2268 if (__pHitElementResult != null)
2270 const Bitmap* pSaveBitmap = null;
2271 String imageName = GetImagePath();
2272 AppLog("Content manager image name %ls",imageName.GetPointer());
2275 imagePath.Append(imageName);
2276 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2277 AppLog("Content manager image path %ls",imagePath.GetPointer());
2278 if (__pHitElementResult != null)
2280 pSaveBitmap = __pHitElementResult->GetImage();
2282 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2284 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2285 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2287 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2288 pShareInfo->SetPageTitle(L"");
2289 pShareInfo->SetPageUrl(srcUrl);
2290 pShareInfo->SetImageAttached(true);
2291 pShareInfo->SetImagePath(imagePath);
2292 __pPopUp->RemoveAllShareInfo();
2293 __pPopUp->AddShareInfo(pShareInfo);
2294 __pPopUp->SetShowState(true);
2299 case IDA_HYPERLINK_OPEN_CLICKED:
2301 if (__pHitElementResult != null)
2303 String srcUrl = __pHitElementResult->GetUrl();
2305 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2307 if (pNewWindowInfo == null)
2311 pNewWindowInfo->isJavascriptInitiated = true;
2312 result r = E_SUCCESS;
2313 SceneManager* pSceneManager = SceneManager::GetInstance();
2314 if (pSceneManager == NULL)
2318 ArrayList* pArgList = new(std::nothrow) ArrayList();
2319 if (pArgList == NULL)
2323 pArgList->Construct();
2325 pArgList->Add(*pNewWindowInfo);
2326 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2327 if (pArgList != null)
2334 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2340 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2342 if (__pHitElementResult == null)
2347 if(__pPopUp != null)
2354 __pAddressbar->HideKeypad();
2356 __pPopUp = new(std::nothrow) SharePopup();
2357 __pPopUp->Initialize();
2359 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2360 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2361 pShareInfo->SetImageAttached(false);
2362 __pPopUp->RemoveAllShareInfo();
2363 __pPopUp->AddShareInfo(pShareInfo);
2365 __pPopUp->SetShowState(true);
2369 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2373 if (__pHitElementResult != null)
2375 url = __pHitElementResult->GetUrl();
2378 String resourcePath = App::GetInstance()->GetAppResourcePath();
2379 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2381 // copying the item to clipboard
2382 Clipboard* pClipboard = Clipboard::GetInstance();
2383 if (pClipboard != null)
2385 pClipboard->CopyItem(item);
2389 case IDA_FIND_TEXT__CLICKED:
2391 // AddressBarCancelledClicked(*__pAddressbar);
2392 RelayoutControls(false);
2393 // __pFooterPanel->SetShowState(false);
2394 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2395 __currentSearchStr.Clear();
2396 __currentSearchStr.Append(__currentSelectedStr);
2397 InitFindWordPanel();
2398 __pFindWordEditField->SetText(__currentSearchStr);
2400 if(__pOptionMenu != null)
2402 __pOptionMenu->SetShowState(false);
2403 __pOptionMenu->Invalidate(false);
2405 __adressPanelPosition.y = 0;
2407 if (__pAddressbar != null && __pWebViewer != NULL)
2409 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2410 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
2411 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2412 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeightF() - 12.0f);
2414 if (__pFooterPanel->GetShowState() == false)
2415 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2417 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2418 __pWebViewer->Invalidate(true);
2421 ShowFindWordPanel(true);
2422 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2424 __pFindWordEditField->SetText(__currentSearchStr);
2425 __pFindWordEditField->SetFocus();
2427 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2429 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2430 __pFindWordEditFieldRightToLeft->SetFocus();
2433 if (__currentSearchStr.GetLength() > 0)
2439 AppLogDebug("Enter something");
2442 if (__pWebViewer != null)
2444 // releasing the set block
2445 __pWebViewer->ReleaseBlock();
2450 case IDA_SHARE_TEXT_CLICKED:
2452 __pWebViewer->ReleaseBlock();
2453 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2454 if(__pPopUp != null)
2461 __pAddressbar->HideKeypad();
2463 __pPopUp = new(std::nothrow) SharePopup();
2464 __pPopUp->Initialize();
2465 if (__pHitElementResult != null)
2467 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2468 pShareInfo->SetPageTitle(L"");
2469 pShareInfo->SetPageUrl(__currentSelectedStr);
2470 pShareInfo->SetImageAttached(false);
2471 __pPopUp->RemoveAllShareInfo();
2472 __pPopUp->AddShareInfo(pShareInfo);
2473 __pPopUp->SetShowState(true);
2478 case IDA_COPY_TEXT_CLICKED:
2480 // __pWebViewer->ReleaseBlock();//as per hyunn lee request for issue 53500
2481 // need to implement
2482 //__currentSelectedStr
2483 // Sets data to a clip board item
2485 String resourcePath = App::GetInstance()->GetAppResourcePath();
2486 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2488 // copying the item to clipboard
2489 Clipboard* pClipboard = Clipboard::GetInstance();
2490 if (pClipboard != null)
2492 pClipboard->CopyItem(item);
2496 case IDA_PASTE_TEXT_CLICKED:
2498 Clipboard* pClipboard = Clipboard::GetInstance();
2500 if(pClipboard == null)
2504 // Retrieves a latest item
2505 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2511 //Gets data from the clipboard item
2512 String* pString = dynamic_cast<String*>(pItem->GetData());
2514 if (pString != null)
2516 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2517 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2518 String classElement = __pHitElementResult->GetAttributeValue(L"class");
2519 String tagElement = __pHitElementResult->GetTagName();
2520 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
2521 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2522 String str = L"document.getElementsByName('";
2523 str.Append(nameElement);
2524 str.Append("').length");
2525 String* pNameCount = __pWebViewer->EvaluateJavascriptN(str);
2528 str = L"document.getElementsByClassName('";
2529 str.Append(classElement);
2530 str.Append("').length");
2531 String* pClassCount = __pWebViewer->EvaluateJavascriptN(str);
2534 if(contenteditable.Equals(L"true",false) == true)
2536 AppLog("gmail paste need to support");
2538 script = L"function replaceSelectedText(replacementText) { var sel, range; if (window.getSelection) { sel = window.getSelection(); if (sel.rangeCount) { range = sel.getRangeAt(0); range.deleteContents(); range.insertNode(document.createTextNode(replacementText)); } } else if (document.selection && document.selection.createRange) { range = document.selection.createRange(); range.text = replacementText; } }";
2539 script.Append("replaceSelectedText(");
2540 script.Append("\"");
2541 script.Append(*pString);
2542 script.Append("\");");
2544 else if(idElement.GetLength() != 0)
2546 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; } } ";
2547 script.Append("insertAtCursor(");
2548 script.Append(L"document.activeElement");
2550 script.Append("\"");
2551 script.Append(*pString);
2552 script.Append("\");");
2554 else if (classElement.GetLength() != 0 && pClassCount->Equals("1",false) == true)
2556 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; } } ";
2557 script.Append("insertAtCursor(document.getElementsByClassName('");
2558 script.Append(classElement);
2559 script.Append("')[0],");
2560 script.Append("\"");
2561 script.Append(*pString);
2562 script.Append("\");");
2564 else if (nameElement.GetLength() != 0 && pNameCount->Equals("1",false) == true)
2566 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; } } ";
2567 script.Append("insertAtCursor(document.getElementsByName('");
2568 script.Append(nameElement);
2569 script.Append("')[0],");
2570 script.Append("\"");
2571 script.Append(*pString);
2572 script.Append("\");");
2574 else if(tagElement.GetLength() != 0) //adding for twitter post page
2576 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; } } ";
2578 script.Append("insertAtCursor(document.activeElement,");
2579 script.Append("\"");
2580 script.Append(*pString);
2581 script.Append("\");");
2583 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2584 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2591 __pWebViewer->ReleaseBlock();
2599 case IDA_GO_FORWARD:
2604 case IDA_REFRESH_BTN_CLICKED:
2606 __isLoadingCompleted = false;
2607 __isLoadingData = true;
2608 __progressPercentage = 0;
2609 __displayUrl = __pFooterUrlField->GetText();
2611 String url = __pFooterUrlField->GetText();
2612 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2614 if (__pWebViewer != null && __pAddressbar != null)
2617 //__pWebViewer->Reload();
2618 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2622 UpdateProgressBitmap();
2625 case IDA_STOP_BTN_CLICKED:
2627 __isLoadingCompleted = false;
2628 __isLoadingData = false;
2629 __progressPercentage = 0;
2630 __pFooterUrlField->HideKeypad();
2631 __displayUrl = __pFooterUrlField->GetText();
2635 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2636 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2637 __pWebViewer->StopLoading();
2638 RequestRedraw(true);
2641 UpdateProgressBitmap();
2646 if (__pFooterUrlField->GetText().IsEmpty() == false)
2648 //__displayUrl = __pUrlField->GetText();
2649 __pFooterUrlField->Clear();
2654 case IDA_READER_BTN_CLICKED:
2665 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2667 AppLog("MainForm::OnFormBackRequested entered");
2668 result r = E_FAILURE;
2669 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2671 AppLog("Hiding the menu");
2672 __pImageMenu->SetShowState(false);
2674 if (__pWebViewer && __pWebViewer->CanGoBack())
2676 __pWebViewer->GoBack();
2678 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2681 pApp = UiApp::GetInstance();
2684 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2687 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2695 WindowInfo* pWindowInfo = null;
2697 SceneManager* pSceneManager = SceneManager::GetInstance();
2698 if (pSceneManager == null)
2702 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2703 if (pAllWindowList == NULL)
2705 pApp = UiApp::GetInstance();
2708 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2711 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2716 if (pAllWindowList != null)
2718 totalCount = pAllWindowList->GetCount();
2720 for (int count = 0; count < totalCount; count++)
2722 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2723 if (pWindowInfo == null)
2725 pApp = UiApp::GetInstance();
2728 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2731 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2738 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2740 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2743 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2746 r = pAllWindowList->RemoveAt(count, true);
2747 __pWindowInfo = null;
2750 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2755 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2759 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2761 if (pWindowInfo == null)
2763 pApp = UiApp::GetInstance();
2766 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2772 if(pWindowInfo != null)
2773 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2776 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2782 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2784 // UiApp* pApp = null;
2785 // pApp = UiApp::GetInstance();
2786 // if (pApp != null)
2788 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2791 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2799 AppLog("MainForm::OnFormBackRequested exit");
2803 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2804 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2807 AppLog("MainForm::OnSceneActivatedN called");
2808 String* pSelectedScene = NULL;
2809 Object* pValue = NULL;
2810 String* pUrl = null;
2811 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2812 pSelectedScene = (String*) pValue;
2814 if (pSelectedScene != null)
2816 delete pSelectedScene;
2818 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2819 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2820 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2821 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2823 // setting the current scene ID
2824 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2826 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2828 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2830 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2831 if(__pWindowInfo == null)
2833 // if(__pWindowInfo == null)
2835 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2838 else if ( pArgs != null && pArgs->GetCount() == 1)
2840 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2846 FloatRectangle footerPanelBounds = FloatRectangle(0.0f, (GetClientAreaBoundsF().height) - __pFooterPanel->GetHeightF(), GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF());
2847 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(footerPanelBounds));
2849 // hiding the address bar
2850 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2851 __pAddressbar->SetShowState(false);
2852 // if(__pWebViewer != null)
2854 // __pWebViewer->Resume();
2857 if(pUrl != null && pUrl->GetLength() > 0)
2861 else if(__pWindowInfo != null)
2863 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)
2865 LoadUrl(__pWindowInfo->pageUrl);
2867 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2869 LoadUrl(__pWindowInfo->pageUrl);
2870 __pWindowInfo->isAppcontrolTriggered = false;
2872 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2874 __pWindowInfo->isFirstLaunch = false;
2877 __pWindowInfo->pCurrentWeb = __pWebViewer;
2878 if(__pWindowInfo->pageUrl.GetLength() > 0)
2879 LoadUrl(__pWindowInfo->pageUrl);
2883 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2884 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2885 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2887 InitMostVisitedSitesView(GetOrientationStatus());
2889 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2891 if(__pMostVisitedListView != null)
2893 __pMostVisitedListView->SetShowState(false);
2897 if(__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2899 __pMostVisitedListView->UpdateList();
2901 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2903 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2905 if (pBookmarkUrl == null)
2907 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2908 //__pAddressbar->SetUrl(*pBookmarkUrl);
2909 SetUrl(*pBookmarkUrl);
2911 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2912 __pWebViewer->LoadUrl(*pBookmarkUrl);
2913 delete pBookmarkUrl;
2916 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2917 Bitmap* pBitmap = null;
2918 if (isPrivateBrowsing == true)
2920 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2922 if (__pWebViewer != null)
2924 __pWebViewer->SetPrivateBrowsingEnabled(true);
2927 if (__pAddressbar != null)
2929 // __pAddressbar->UpdateFaviconBitmap(true);
2935 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2937 if (__pWebViewer != null)
2939 __pWebViewer->SetPrivateBrowsingEnabled(false);
2942 if (__pAddressbar != null)
2944 // __pAddressbar->UpdateFaviconBitmap(false);
2948 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2950 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2952 else if (__pOptionMenu != null )
2954 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2957 if (pBitmap != null)
2962 RelayoutControls(false);
2963 AppLog("ABC: OnSceneActivatedN started exit");
2965 AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight());
2970 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2971 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2973 Canvas* pWebCanvas = null;
2974 if (__pWebViewer != null)
2976 pWebCanvas = __pWebViewer->GetCanvasN();
2979 if (pWebCanvas == null)
2983 if (__pWindowInfo != null)
2985 if (__pWindowInfo->pWebCanvasBitmap != null)
2987 delete __pWindowInfo->pWebCanvasBitmap;
2989 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2990 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2991 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2993 Bitmap* pBitmap = GetCapturedBitmapN();
2994 AppLog("Coming here");
2995 Canvas* pCanvas = new(std::nothrow) Canvas();
2996 pCanvas->Construct(GetClientAreaBounds());
2999 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
3002 if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
3003 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
3005 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
3008 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
3013 __pAddressbar->SetShowState(false);
3014 AppLog("Coming here");
3018 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
3019 const Tizen::Base::String& realm,
3020 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
3026 MainForm::OnHttpAuthenticationCanceled(void)
3031 MainForm::OnLoadingStarted(void)
3033 AppLogDebug("MainForm::OnLoadingStarted entered");
3035 if(__pAddressbar == NULL || __pWebViewer == null)
3040 // this is added in case if menu is opened and user load the page
3041 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
3043 __pOptionMenu->SetShowState(false);
3044 __pOptionMenu->Invalidate(true);
3049 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3051 __pImageMenu->SetShowState(false);
3052 __pImageMenu->Invalidate(true);
3054 String url = __pWebViewer->GetUrl();
3055 if(url.Contains(IDS_TIZEN_SERVICE))
3058 String delim(L":;,");
3060 // Creates a StringTokenizer instance
3061 StringTokenizer strTok(url, delim);
3063 int count = strTok.GetTokenCount(); // count == 4
3065 HashMap *pMap = new HashMap();
3070 while (strTok.HasMoreTokens())
3072 AppLog("Token: %ls", token.GetPointer());
3073 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3074 if(token.Contains(IDS_APPID))
3076 token.SubString(6, appId);
3077 AppLog("AppID:%ls", appId.GetPointer());
3079 else if(token.Contains(IDS_KEY))
3081 token.SubString(4, key);
3082 AppLog("key:%ls", key.GetPointer());
3084 else if(token.Contains(IDS_VALUE))
3086 token.SubString(6, value);
3087 AppLog("value:%ls", value.GetPointer());
3090 pMap->Add(key, value);
3094 AppControl *pAppControl = null;
3095 String operationId = L"http://tizen.org/appcontrol/operation/main";
3096 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3099 AppLog("Starting AppControl");
3100 result r = pAppControl->Start(null, null, pMap, null);
3101 AppLog("Result of Start %s", GetErrorMessage(r));
3105 AppLogException("AppControl not found");
3110 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3112 __pAddressbar->SetShowState(false);
3113 AddressBarCancelledClicked(*__pAddressbar);
3114 __pAddressbar->Invalidate(true);
3116 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3119 __pAddressbar->SetFaviconBitmap(*pBitmap);
3122 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3124 // updating the address bar position with respect to web control
3125 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3126 __distanceMoved = 0;
3130 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3131 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3132 if (__pWebViewer != null)
3134 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3135 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3136 SetUrl(__pWebViewer->GetUrl());
3137 if (__pWindowInfo != NULL)
3139 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3140 // __pWindowInfo->pageTitle = L"";
3141 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3143 __pAddressbar->Invalidate(true);
3149 MainForm::OnLoadingCanceled(void)
3155 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3157 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3162 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3164 AppLog("XYZ::MainForm::OnKeypadOpened");
3165 __isKeypadOpened = true;
3166 __pFooterPanel->SetShowState(false);
3167 RelayoutControls(false);
3171 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3173 AppLog("XYZ::MainForm::OnKeypadClosed");
3174 __isKeypadOpened = false;
3175 __pFooterPanel->SetShowState(true);
3176 RelayoutControls(true);
3180 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3182 AppLog("XYZ::KeypadBoundsChanged");
3183 RelayoutControls(false);
3187 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3188 const Tizen::Base::String& reason)
3190 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3194 MainForm::OnLoadingCompleted(void)
3196 AppLog("MainForm::OnLoadingCompleted start");
3198 result r = E_SUCCESS;
3200 if (__pWebViewer == null)
3205 if (__pAddressbar == null)
3210 if(__pWindowInfo && __pWebViewer)
3211 __pWindowInfo->pageTitle = __pWebViewer->GetTitle();
3212 if(__pImageMenu && __pImageMenu->GetShowState())
3214 __pImageMenu->SetShowState(false);
3215 __pImageMenu->Invalidate(true);
3218 if (__pWebViewer->CanGoForward())
3220 //__pAddressbar->SetForwardButtonEnabled(true);
3221 SetForwardButtonEnabled(true);
3225 //__pAddressbar->SetForwardButtonEnabled(false);
3226 SetForwardButtonEnabled(false);
3229 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3231 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3233 //__pAddressbar->UpdateProgress(0);
3237 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3239 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3243 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3244 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3245 if (isPrivateBrowsing == false)
3247 if(__pHistory != null)
3253 __pHistory = new(std::nothrow) History;
3254 HistoryPresentationModel::GetCurrentDateTime(date);
3257 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3258 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3260 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3261 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3263 __pHistory->SetVisitedTime(date);
3265 if (__pWebViewer != null)
3267 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3269 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3270 if (pTempBitmap != null)
3272 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3273 __pHistory->SetFavIconBitmap(*pTempBitmap);
3278 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3279 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3280 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3282 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3283 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3284 __pHistory->SetThumbnail(pBitmap);
3286 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3289 Tizen::Graphics::BufferInfo bmpInfo;
3290 pFavIcon->Lock(bmpInfo);
3291 AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height);
3293 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3295 AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight());
3296 __pHistory->SetFavIconBitmap(*pFavIcon);
3300 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3307 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3309 // temperary fixed (webpage can be not loaded)
3313 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3314 if (isReaderEnabled == true)
3318 delete __pReaderData;
3319 __pReaderData = null;
3321 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3322 filePath.Append(L"data/reader.js");
3328 result r = E_SUCCESS;
3329 FileAttributes attr;
3331 File::GetAttributes(filePath,attr);
3333 r = file.Construct(filePath, L"r+");
3336 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3339 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3342 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3345 // file.Read(pScript,attr.GetFileSize());
3347 // AppLogDebug("scipt length %d",strlen(pScript));
3348 String strScript = L"";
3349 // strScript.Append(pScript);
3350 // for(int i=0; i<25; i++)
3352 file.Read(pScript,attr.GetFileSize());
3353 // AppLog("xyzz tell %d",file.Tell());
3354 // r = strScript.Append(pScript);
3355 // AppLog("xyzz append result %s",GetErrorMessage(r));
3356 // AppLog("xyzz strScript length %d",strScript.GetLength());
3358 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3360 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3361 if (__pReaderData == null)
3363 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3364 __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>");
3367 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3368 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3370 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3371 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3377 AppLog("MainForm::OnLoadingCompleted done");
3381 MainForm::OnEstimatedProgress(int progress)
3383 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3385 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3386 progress = DEFAULT_PROGRESS_PERCENTAGE;
3388 // __pAddressbar->UpdateProgress(progress);
3389 UpdateProgress(progress);
3392 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3394 AppLog("MainForm::OnFaviconReceived");
3395 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3397 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3400 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3407 MainForm::OnUrlValueChanged(Addressbar&)
3413 MainForm::OnUrlSubmitted(Addressbar& addBar)
3415 AppLog("MainForm::OnUrlSubmitted");
3416 String url = addBar.GetUrl();
3417 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3419 if(__pFooterUrlField)
3420 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3421 AddressBarCancelledClicked(*__pAddressbar);
3426 MainForm::LoadUrl(String& url)
3430 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3431 AppLogDebug("MainForm::LoadUrl enter");
3433 if (__pWebViewer != null)
3435 __pWebViewer->SetShowState(true);
3436 __pWebViewer->Invalidate(true);
3439 if (url.CompareTo(L"") == 0)
3443 if(__pFooterPanel != null)
3445 __pFooterPanel->SetShowState(true);
3446 __pFooterPanel->Invalidate(true);
3453 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3454 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)
3456 RegularExpression firstRegex;
3457 RegularExpression secondRegex;
3459 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3460 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3463 ret = firstRegex.Match(url, false); // This returns true value
3464 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3466 if (ret == true && __pWebViewer != null)
3469 __pWebViewer->LoadUrl(url);
3471 else if(__pWebViewer != null)
3473 String tempUrl = L"http://";
3474 tempUrl.Append(url);
3478 __pWebViewer->LoadUrl(tempUrl);
3482 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3483 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3486 if (__pAddressbar != null)
3488 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3489 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3492 AppLogDebug("MainForm::LoadUrl exit");
3499 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3501 AppLog("MainForm::OnFocusGained");
3504 __pFooterPanel->SetShowState(false);
3509 __pWebViewer->ReleaseBlock();
3514 __pAddressbar->SetShowState(true);
3515 __pAddressbar->SetAddressbarURLFocus();
3517 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3519 __currentSearchStr = L"";
3520 __currentWordIndex = 0;
3521 __maxOccurrances = 0;
3523 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3525 __pFindWordEditField->SetText(L"");
3526 __pFindWordEditField->HideKeypad();
3527 __pFindWordControl->SetShowState(false);
3528 __pFindWordCountLabel->SetText(L"0/0");
3530 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3532 __pFindWordEditFieldRightToLeft->SetText(L"");
3533 __pFindWordEditFieldRightToLeft->HideKeypad();
3534 __pFindWordControl->SetShowState(false);
3535 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3538 __pFindWordNext->SetEnabled(false);
3539 __pFindWordPrev->SetEnabled(false);
3541 __pWebViewer->SearchTextAllAsync(L"",true);
3542 __pFindWordControl->SetShowState(false);
3544 RelayoutControls(false);
3548 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3550 AppLog("MainForm::OnFocusLost called");
3554 MainForm::OnStopClicked(Addressbar& addBar)
3556 AppLogDebug("MainForm::OnStopClicked called");
3559 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3560 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3561 __pWebViewer->StopLoading();
3562 RequestRedraw(true);
3567 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3569 // AppLog("MainForm::OnBackClicked");
3570 result r = E_FAILURE;
3571 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3573 AppLog("Hiding the menu");
3574 __pImageMenu->SetShowState(false);
3577 if (__pWebViewer && __pWebViewer->CanGoBack())
3579 __pWebViewer->GoBack();
3581 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3584 pApp = UiApp::GetInstance();
3587 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3590 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3598 WindowInfo* pWindowInfo = null;
3600 SceneManager* pSceneManager = SceneManager::GetInstance();
3601 if (pSceneManager == null)
3605 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3606 if (pAllWindowList == NULL)
3608 pApp = UiApp::GetInstance();
3611 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3614 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3619 if (pAllWindowList != null)
3621 totalCount = pAllWindowList->GetCount();
3623 for (int count = 0; count < totalCount; count++)
3625 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3626 if (pWindowInfo == null)
3628 pApp = UiApp::GetInstance();
3631 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3634 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3639 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3641 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3644 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3647 r = pAllWindowList->RemoveAt(count, true);
3648 __pWindowInfo = null;
3651 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3656 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3658 else if(pAllWindowList->GetCount() > 0)
3660 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3664 pApp = UiApp::GetInstance();
3667 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3672 if (pWindowInfo == null)
3674 pApp = UiApp::GetInstance();
3677 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3683 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3684 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3687 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3701 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3703 AppLog("MainForm::OnForwardClicked");
3704 if (__pWebViewer == null)
3707 if (__pWebViewer->CanGoForward())
3709 __pWebViewer->GoForward();
3714 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3716 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3717 if(__pFooterPanel != null)
3719 __pFooterPanel->SetShowState(false);
3722 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3724 __pAddressbar->SetShowState(true);
3725 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3728 RelayoutControls(false);
3732 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3734 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3736 int Height = GetClientAreaBounds().height;
3737 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3739 RelayoutControls(false);
3743 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3745 AddressBarCancelledClicked(addBar);
3749 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3751 __prevAddressBarMode = __curAddressBarMode;
3753 if (__pAddressbar != null)
3755 __curAddressBarMode = GetAddressbarMode();
3758 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3760 __adressPanelPosition.y = 0;
3761 if (__pAddressbar != null)
3763 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3764 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
3765 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3766 __pAddressbar->Invalidate(true);
3768 if (__pWebViewer != null)
3770 __pWebViewer->StopLoading();
3773 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3775 __adressPanelPosition.y = 0;
3776 if (__pAddressbar != null)
3778 __webControlPosition.y = 0;
3779 __webControlPositionF.y = 0.0f;
3780 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3781 __pAddressbar->Invalidate(true);
3787 MainForm::OnClipboardClosed(const Addressbar& addBar)
3789 AppLog("XYZ::MainForm::OnClipboardClosed");
3790 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3792 AppLog("akjshdasd 3");
3793 __pFooterPanel->SetShowState(true);
3795 __isKeypadOpened = false;
3796 RelayoutControls(false);
3800 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3802 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3803 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3805 AppLog("akjshdasd 3");
3806 __pFooterPanel->SetShowState(true);
3808 __isKeypadOpened = false;
3809 if(__pNotification && __pNotification->GetShowState())
3811 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3814 RelayoutControls(false,footerState);
3818 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3820 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3821 __isKeypadOpened = true;
3822 if(__pNotification && __pNotification->GetShowState())
3824 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3826 RelayoutControls(false);
3830 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3832 __isKeypadOpened = true;
3833 __pFooterPanel->SetShowState(false);
3837 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3839 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3840 RelayoutControls(false);
3844 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3846 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3849 __pWindowInfo->pageTitle = title;
3850 if (__pWebViewer != null)
3852 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3853 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3856 if (__pAddressbar != null && __pWebViewer != null)
3858 SetUrl(__pWebViewer->GetUrl());
3859 __pAddressbar->Invalidate(true);
3864 MainForm::UpdateFavicon(void)
3866 bool urlImageType = false;
3867 String *tempPath = null;
3869 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();");
3870 Bitmap* pBitmap = null;
3872 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3874 if (__pWindowInfo != null)
3877 url.SetUri(*tempPath);
3878 if (url.GetHost().GetLength() == 0)
3882 webUrl.SetUri(__pWebViewer->GetUrl());
3883 result r = url.SetHost(webUrl.GetHost());
3890 if (url.GetScheme().GetLength() == 0)
3894 webUrl.SetUri(__pWebViewer->GetUrl());
3895 url.SetScheme(webUrl.GetScheme());
3897 __pWindowInfo->faviconUrl = url.ToString();
3899 pBitmap = __pWebViewer->GetFaviconN();
3901 if (pBitmap != null)
3903 if (__pWindowInfo->pFavicon != NULL)
3905 __pWindowInfo->pFavicon = null;
3907 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3908 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3910 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3912 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3914 else if(__pWindowInfo->pFavicon != null)
3916 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3920 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3921 if(pDefaultBmp != null)
3923 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3937 if(tempPath != null)
3941 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3947 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3948 Tizen::Web::Controls::WebNavigationType type)
3950 AppLog("urlk %ls",url.GetPointer());
3951 // when load new page if find word panel is open its show state is false
3952 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3954 __currentSearchStr = L"";
3955 __currentWordIndex = 0;
3956 __maxOccurrances = 0;
3957 __pFindWordEditField->SetText(L"");
3958 __pFindWordNext->SetEnabled(false);
3959 __pFindWordPrev->SetEnabled(false);
3960 __pFindWordCountLabel->SetText(L"0/0");
3961 __pFindWordControl->SetShowState(false);
3962 __pFindWordEditField->HideKeypad();
3963 RelayoutControls(false);
3966 __pFooterPanel->Invalidate(true);
3969 uriInfo.SetUri(url);
3971 if(url.Contains(IDS_TIZEN_SERVICE))
3974 String delim(L":;,");
3976 // Creates a StringTokenizer instance
3977 StringTokenizer strTok(url, delim);
3979 int count = strTok.GetTokenCount(); // count == 4
3981 HashMap *pMap = new HashMap();
3987 while (strTok.HasMoreTokens())
3989 AppLog("Token: %ls", token.GetPointer());
3990 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3991 if(token.Contains(IDS_APPID))
3993 token.SubString(6, appId);
3994 AppLog("AppID:%ls", appId.GetPointer());
3996 else if(token.Contains(IDS_KEY))
3998 token.SubString(4, key);
3999 AppLog("key:%ls", key.GetPointer());
4001 else if(token.Contains(IDS_VALUE))
4003 token.SubString(6, value);
4004 AppLog("value:%ls", value.GetPointer());
4007 pMap->Add(key, value);
4011 AppControl *pAppControl = null;
4012 String operationId = L"http://tizen.org/appcontrol/operation/main";
4013 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
4016 result r = pAppControl->Start(null, null, pMap, null);
4020 AppLogException("AppControl not found");
4030 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
4031 const Tizen::Net::Http::HttpHeader& httpHeader)
4033 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
4037 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4039 AppLog("LMN::MainForm::OnWebPageBlockSelected");
4040 // if(__isLongPressedDone == false)
4043 if (__pHitElementResult != null)
4045 delete __pHitElementResult;
4046 __pHitElementResult = null;
4049 if (__pWebViewer != null)
4051 AppLog("MainForm::OnWebPageBlockSelected web not null");
4052 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4054 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4056 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4057 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4058 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4060 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4061 if(__pHitElementResult == null)
4063 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4066 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4070 if (__pHitElementResult == null)
4075 if (__pHitElementResult->HasImage() != true)
4077 String tagName = __pHitElementResult->GetTagName();
4078 String type = __pHitElementResult->GetAttributeValue("type");
4079 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
4082 AppLog("TagName %ls",tagName.GetPointer());
4083 __currentSelectedStr.Clear();
4084 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4085 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4086 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4087 if(tagName.Equals(L"TEXTAREA",false) == true)
4089 AppLog("Tagnameseemstobe TEXTAREA");
4091 else if(tagName.Equals(L"INPUT",false) == true)
4093 AppLog("Tagnameseemstobe INPUT");
4096 if (((tagName.Equals(L"INPUT",false) == true) || tagName.Equals(L"TEXTAREA",false) == true) || contenteditable.Equals(L"true",false) == true/*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0 )
4098 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4100 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true);
4103 __pImageMenu->SetShowState(true);
4104 __pImageMenu->Show();
4105 __pImageMenu->Invalidate(true);
4108 else /*if(__isLongPressedDone == true)*/
4110 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4112 if(__pHitElementResult->GetUrl().GetLength() > 0)
4114 __currentSelectedStr.Clear();
4115 __currentSelectedStr = __pHitElementResult->GetUrl();
4117 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false);
4120 __pImageMenu->SetShowState(true);
4121 __pImageMenu->Show();
4122 __pImageMenu->Invalidate(true);
4126 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4127 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4128 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4134 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4140 MainForm::OnWebWindowCreateRequested(void)
4142 AppLog("MainForm::OnWebWindowCreateRequested entered");
4143 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4145 if (pNewWindowInfo == null)
4149 result r = E_SUCCESS;
4150 SceneManager* pSceneManager = SceneManager::GetInstance();
4151 if (pSceneManager == NULL)
4155 ArrayList* pArgList = new(std::nothrow) ArrayList();
4156 if (pArgList == NULL)
4160 r = pArgList->Construct();
4163 pNewWindowInfo->isJavascriptInitiated = true;
4164 pArgList->Add(*pNewWindowInfo);
4165 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4169 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4176 return pNewWindowInfo->pCurrentWeb;
4180 MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4182 AppLog("OnWebWindowCloseRequested");
4183 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4184 SceneManager* pSceneManager = SceneManager::GetInstance();
4185 WindowInfo* pWindowInfo = null;
4186 WindowInfo* pNewWindowInfo = null;
4189 result r = E_FAILURE;
4191 if (pAllWindowList != null)
4193 totalCount = pAllWindowList->GetCount();
4196 for (int count = 0; count < totalCount; count++)
4198 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4200 if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID)
4202 r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID);
4203 r = pAllWindowList->RemoveAt(count, true);
4205 Form* pCurrentForm = null;
4206 if(SceneManager::GetInstance()->GetCurrentScene() != null)
4207 pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
4210 pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null);
4213 if (pAllWindowList->GetCount() > 0)
4215 pNewWindowInfo = null;
4216 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4220 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4222 if (pNewWindowInfo == null)
4226 result r = E_SUCCESS;
4227 SceneManager* pSceneManager = SceneManager::GetInstance();
4228 if (pSceneManager == NULL)
4232 ArrayList* pArgList = new(std::nothrow) ArrayList();
4233 if (pArgList == NULL)
4237 r = pArgList->Construct();
4240 pArgList->Add(*pNewWindowInfo);
4241 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4242 if (pArgList != null)
4249 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4254 pApp = UiApp::GetInstance();
4257 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4261 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4272 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4274 AppLog("xyz:: MainForm::RelayoutControls called");
4275 __webControlPosition.y = 0;
4276 __webControlPositionF.y = 0.0f;
4277 __webControlHeight = GetClientAreaBounds().height;
4278 __webControlHeightF = GetClientAreaBoundsF().height;
4279 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4281 AppLog("Client area height: %d", __webControlHeight);
4282 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4284 __webControlPosition.y += __pAddressbar->GetHeight();
4285 __webControlPositionF.y += __pAddressbar->GetHeightF();
4286 __webControlHeight -= __pAddressbar->GetHeight();
4287 __webControlHeightF -= __pAddressbar->GetHeightF();
4288 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4290 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4292 __webControlPosition.y += __pFindWordControl->GetHeight();
4293 __webControlPositionF.y += __pFindWordControl->GetHeightF();
4294 __webControlHeight -= __pFindWordControl->GetHeight();
4295 __webControlHeightF -= __pFindWordControl->GetHeightF();
4296 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4299 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4301 __webControlHeight -= __pFooterPanel->GetHeight();
4302 __webControlHeightF -= __pFooterPanel->GetHeightF();
4304 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0F, __webControlPositionF.y + __webControlHeightF, GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF())));
4305 __webControlHeight = __webControlHeight + 12;
4306 __webControlHeightF = __webControlHeightF + 12.0f;
4308 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4310 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4315 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4316 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4317 __pWebViewer->Invalidate(false);
4320 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4322 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4329 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4331 if (__pFindWordControl == null)
4336 Tizen::Locales::LocaleManager localeManager;
4337 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4339 String languageCode;
4340 result r = SettingInfo::GetValue(L"Language", languageCode);
4341 // int languagecode = local.GetLanguageCode();
4342 AppLog("rahul language is %S", languageCode.GetPointer());
4346 InitFindWordPanel();
4348 if (languageCode.CompareTo("ara") == 0)
4350 AppLog("rahul language is arabic");
4352 __pFindWordPanelLeftToRight->SetShowState(false);
4353 __pFindWordPanelRightToLeft->SetShowState(true);
4355 __pFindWordClear->SetShowState(false);
4356 __pFindWordCountLabel->SetShowState(false);
4357 __pFindWordEditField->SetShowState(false);
4359 __pFindWordClearRightToLeft->SetShowState(true);
4360 __pFindWordCountLabelRightToLeft->SetShowState(true);
4361 __pFindWordEditFieldRightToLeft->SetShowState(true);
4365 AppLog("rahul language is not arabic");
4368 __pFindWordPanelLeftToRight->SetShowState(true);
4369 __pFindWordPanelRightToLeft->SetShowState(false);
4371 __pFindWordClear->SetShowState(true);
4372 __pFindWordCountLabel->SetShowState(true);
4373 __pFindWordEditField->SetShowState(true);
4375 __pFindWordClearRightToLeft->SetShowState(false);
4376 __pFindWordCountLabelRightToLeft->SetShowState(false);
4377 __pFindWordEditFieldRightToLeft->SetShowState(false);
4379 __pFindWordControl->SetShowState(true);
4383 if(__pFindWordControl != null)
4385 __pFindWordControl->SetShowState(false);
4389 AppLog("MainForm::ShowFindWordPanel %d",show);
4390 if (show && !isTouchPressed)
4392 if (languageCode.CompareTo("ara") == 0)
4394 if (__pFindWordEditFieldRightToLeft)
4396 __pFindWordEditFieldRightToLeft->SetFocus();
4397 __pFindWordEditFieldRightToLeft->ShowKeypad();
4402 if (__pFindWordEditField)
4404 __pFindWordEditField->SetFocus();
4405 __pFindWordEditField->ShowKeypad();
4411 if (languageCode.CompareTo("ara") == 0)
4413 if (__pFindWordEditFieldRightToLeft)
4414 __pFindWordEditFieldRightToLeft->HideKeypad();
4418 if (__pFindWordEditField)
4419 __pFindWordEditField->HideKeypad();
4423 RelayoutControls(false);
4427 MainForm::StartWordSearch()
4429 //Get the count of occurances of the word in the current page
4430 __maxOccurrances = 0;
4431 __currentWordIndex = 0;
4433 __pFindWordPrev->SetEnabled(false);
4434 String *pCountStr = null;
4437 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4438 AppLog("Search Result %s",GetErrorMessage(r));
4441 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4442 if (pCountStr != null)
4444 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4448 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4453 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4455 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4456 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4460 if (__pFindWordCountLabel)
4462 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4464 if (__pFindWordEditField)
4466 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4469 else if(totalCount >= 100)
4471 if (__pFindWordCountLabel)
4473 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4475 if (__pFindWordEditField)
4477 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4482 if (__pFindWordCountLabel)
4484 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4486 if (__pFindWordEditField)
4488 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4492 __maxOccurrances = totalCount;
4493 __currentWordIndex = currentOrdinal;
4495 //Reset the UI controls as per the maxOccurrance value
4496 if (totalCount <= 0)
4498 AppLog("Word not found");
4499 //Show error notification to user
4500 __pFindWordNext->SetEnabled(false);
4501 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4503 __pFindWordCountLabel->SetText(L"0/0");
4504 __pFindWordCountLabel->Invalidate(false);
4506 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4508 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4509 __pFindWordCountLabelRightToLeft->Invalidate(false);
4511 __pFindWordNext->Invalidate(false);
4512 __pFindWordPrev->Invalidate(false);
4517 if (totalCount == 1 || totalCount == currentOrdinal)
4519 __pFindWordNext->SetEnabled(false);
4523 __pFindWordNext->SetEnabled(true);
4526 String countStr = L"";
4527 countStr.Append(__currentWordIndex);
4528 countStr.Append(L"/");
4529 countStr.Append(__maxOccurrances);
4530 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4532 __pFindWordCountLabel->SetText(countStr);
4533 __pFindWordCountLabel->Invalidate(false);
4534 __pFindWordCountLabel->Invalidate(false);
4536 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4538 __pFindWordCountLabelRightToLeft->SetText(countStr);
4539 __pFindWordCountLabelRightToLeft->Invalidate(false);
4540 __pFindWordCountLabelRightToLeft->Invalidate(false);
4542 if (__pFindWordNext)
4544 __pFindWordNext->Invalidate(false);
4546 if (__pFindWordPrev)
4548 __pFindWordPrev->Invalidate(false);
4554 MainForm::FindNextWord(bool next)
4558 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4559 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4561 if (__currentWordIndex < __maxOccurrances)
4563 __currentWordIndex++;
4569 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4570 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4572 if(__currentWordIndex > 1)
4574 __currentWordIndex--;
4579 String countStr = L"";
4580 countStr.Append(__currentWordIndex);
4581 countStr.Append(L"/");
4582 countStr.Append(__maxOccurrances);
4584 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4586 __pFindWordCountLabel->SetText(countStr);
4587 __pFindWordCountLabel->Invalidate(false);
4589 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4591 __pFindWordCountLabelRightToLeft->SetText(countStr);
4592 __pFindWordCountLabelRightToLeft->Invalidate(false);
4595 if (__currentWordIndex >= __maxOccurrances)
4597 __pFindWordNext->SetEnabled(false);
4601 __pFindWordNext->SetEnabled(true);
4603 if (__currentWordIndex <= 1)
4605 __pFindWordPrev->SetEnabled(false);
4609 __pFindWordPrev->SetEnabled(true);
4611 __pFindWordPrev->Invalidate(false);
4612 __pFindWordNext->Invalidate(false);
4614 __pFindWordControl->Invalidate(true);
4618 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4620 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4621 __isKeypadOpened = true;
4622 __pFooterPanel->SetShowState(false);
4623 // OnAddressBarKeypadOpened(*__pAddressbar);
4627 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4629 __isKeypadOpened = true;
4630 AppLog("xyz::MainForm::OnWebKeypadOpened");
4632 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4634 __currentSearchStr = L"";
4635 __currentWordIndex = 0;
4636 __maxOccurrances = 0;
4637 __pFindWordEditField->SetText(L"");
4638 __pFindWordNext->SetEnabled(false);
4639 __pFindWordPrev->SetEnabled(false);
4640 __pFindWordCountLabel->SetText(L"0/0");
4641 __pWebViewer->SearchTextAllAsync(L"",false);
4642 __pFindWordControl->SetShowState(false);
4643 __pFindWordEditField->HideKeypad();
4647 if (__pWebViewer != null && __pFooterPanel != null)
4649 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4650 if(__pAddressbar != null)
4652 __pAddressbar->SetShowState(false);
4654 if(__pFindWordControl != null)
4656 __pFindWordControl->SetShowState(false);
4658 __pFooterPanel->SetShowState(false);
4659 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4661 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4663 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4664 // AppLog("omgomgomg");
4670 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4672 AppLog("abcde::MainForm::OnWebKeypadClosed");
4673 AppLog("xyz::MainForm::OnWebKeypadClosed");
4674 AppLog("akjshdasd 4");
4675 __pFooterPanel->SetShowState(true);
4676 // OnAddressBarKeypadClosed(*__pAddressbar);
4677 RelayoutControls(false);
4678 __isKeypadOpened = false;
4681 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4683 AppLog("abcde: imagemenu visible.");
4686 __pWebViewer->GetBlockRange(p,q);
4687 if (p == Point(0,0) && q == Point(0,0))
4695 __pImageMenu->SetAnchorPosition(p);
4696 __pImageMenu->Show();
4702 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4704 // RelativeLayout(false);
4705 if(__pWebViewer != null)
4707 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4712 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4714 Control* temp = const_cast< Control* >(&source);
4715 Header* pHeader = dynamic_cast< Header* >(temp);
4716 if (pHeader != null)
4718 //Header double - clicked
4719 AppLog("Header double clicked");
4721 if(__pFindWordControl)
4723 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4724 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4728 AppLog("MainScene::OnTouchDoublePressed");
4732 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4734 AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4735 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4737 AppLog("Returning because of more than one touch point.");
4741 // __pWebViewer->ReleaseBlock();
4743 __pWebViewer->SetFocus();
4744 __longPressPoint = currentPosition;
4746 if (__pHitElementResult != null)
4748 delete __pHitElementResult;
4749 __pHitElementResult = null;
4752 if (__pWebViewer != null)
4754 AppLog("MainForm::OnTouchLongPressed web not null");
4755 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4758 if (__pHitElementResult == null)
4763 if (__pHitElementResult->HasImage() == true)
4765 if(__pWebViewer != null)
4767 __pWebViewer->ReleaseBlock();//N_SE-52389
4768 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4770 __pImageMenu->SetShowState(true);
4771 __pImageMenu->Show();
4772 __pImageMenu->Invalidate(true);
4774 else if(__pHitElementResult->HasUrl() == true)
4776 if(__pWebViewer != null)
4777 __pWebViewer->ReleaseBlock();//N_SE-52389
4778 String tempURl = __pHitElementResult->GetUrl();
4779 AppLog("tempURl is %ls", tempURl.GetPointer());
4780 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4781 if (pBitmap != null)
4789 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4790 __pImageMenu->SetShowState(true);
4791 __pImageMenu->Show();
4792 __pImageMenu->Invalidate(true);
4796 String tagName = __pHitElementResult->GetTagName();
4797 String type = __pHitElementResult->GetAttributeValue("type");
4798 String value = __pHitElementResult->GetAttributeValue(L"value");
4799 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4800 result r = E_FAILURE;
4801 __currentSelectedStr.Clear();
4802 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4804 AppLog("tag name is %ls", tagName.GetPointer());
4805 AppLog("type is %ls", type.GetPointer());
4809 __isLongPressedDone = true;
4810 if( type.Equals(L"submit",false) !=true && type.Equals(L"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true)
4811 r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4812 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"checkbox",false) !=true && type.Equals(L"range",false) !=true && type.Equals(L"file",false) !=true/*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.Equals(L"",false) == true && r == E_INVALID_ARG)
4814 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4816 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4819 __pImageMenu->SetShowState(true);
4820 __pImageMenu->Show();
4821 __pImageMenu->Invalidate(true);
4824 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4827 // __inputEventToBeSupressed = true;
4831 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4833 AppLog("xyz:: MainForm::OnTouchReleased called");
4835 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4837 __pAddressbar->SetShowState(false);
4839 if(__pFooterPanel && __isKeypadOpened == false)
4841 __pFooterPanel->SetShowState(true);
4845 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4846 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4848 __pWebViewer->ConsumeInputEvent();
4850 if(pHitElement != null)
4854 __inputEventToBeSupressed = false;*/
4858 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4865 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4867 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4869 __currentSearchStr = L"";
4870 __currentWordIndex = 0;
4871 __maxOccurrances = 0;
4873 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4875 __pFindWordEditField->SetText(L"");
4876 __pFindWordEditField->HideKeypad();
4877 __pFindWordControl->SetShowState(false);
4878 __pFindWordCountLabel->SetText(L"0/0");
4880 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4882 __pFindWordEditFieldRightToLeft->SetText(L"");
4883 __pFindWordEditFieldRightToLeft->HideKeypad();
4884 __pFindWordControl->SetShowState(false);
4885 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4888 __pFindWordNext->SetEnabled(false);
4889 __pFindWordPrev->SetEnabled(false);
4891 __pWebViewer->SearchTextAllAsync(L"",true);
4892 __pFindWordControl->SetShowState(false);
4894 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4895 if(__pAddressbar->GetShowState() == false)
4897 __pAddressbar->SetAddressbarURLFocus();
4898 __pFooterPanel->SetShowState(false);
4905 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4911 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4917 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4923 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4929 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4935 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4937 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4938 int widthContextItem = 0;
4939 //if(__pFindWordCountLabel)
4940 // __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4941 // As per the platform engineer comment removed this line
4942 /*if(__pWebViewer != null)
4944 // 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
4945 __pWebViewer->ReleaseBlock();
4948 // if(__pFindWordControl != null)
4949 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4951 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4953 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4955 AppLog(" Orientation landscape");
4956 __pOptionMenu->SetMaxVisibleItemsCount(5);
4960 AppLog(" Orientation potrait");
4961 __pOptionMenu->SetMaxVisibleItemsCount(6);
4964 if(__pNotification && __pNotification->GetShowState() == true)
4966 __pNotification->SetShowState(false);
4967 __pNotification->Invalidate(false);
4969 if ( __pFooterLabel != null)
4971 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4974 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4980 if (__pFindWordBgLabel != null)
4982 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4983 if (pBitmap != null)
4985 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4990 if (__pFindWordBgLabelRightToLeft != null)
4992 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4993 if (pBitmap != null)
4995 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
5001 // if(__pOptionMenu != null)
5002 // __pOptionMenu->SetShowState(false);
5004 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5006 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
5010 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
5015 AppLog("__pFooterPanel->GetShowState() is true");
5017 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0, GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(), __pFooterPanel->GetWidthF(), __pFooterPanel->GetHeightF())));
5018 __pFooterPanel->Invalidate(true);
5022 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
5023 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
5025 InitMostVisitedSitesView(orientationStatus);
5028 RelayoutControls(false);
5029 if (__pArticleReaderPanel != null)
5031 if (__pArticleReaderPanel->GetShowState() == true)
5033 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
5035 if (__pBlankPanel != null)
5036 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
5038 if (__pWebReader != null)
5040 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
5042 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5043 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5045 if ( pBitmap != null && pSrcBitmap != null)
5047 AppLog("CreateReaderPanel ninepatchbitmap found");
5048 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
5051 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
5052 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
5053 if (pBitmap != null)
5058 if (pSrcBitmap != null)
5067 if (__pAddressbar != null)
5069 int width = GetClientAreaBounds().width;
5070 __pAddressbar->OrientationChanged(width);
5075 MainForm::OnSettingsChange(int settingvalue)
5077 AppLogDebug("MainForm::OnSettingsChange entered");
5079 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
5081 __pAddressbar->ResetGuideText();
5083 if (__pWebViewer == null)
5085 AppLogDebug("Webviewer is not initialized yet.");
5089 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5091 WebSetting settings = __pWebViewer->GetSetting();
5092 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5094 settings.SetAutoFittingEnabled(true);
5096 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5098 settings.SetAutoFittingEnabled(false);
5100 __pWebViewer->SetSetting(settings);
5103 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5105 WebSetting settings = __pWebViewer->GetSetting();
5106 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5107 __pWebViewer->SetSetting(settings);
5109 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5111 WebSetting settings = __pWebViewer->GetSetting();
5112 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5113 __pWebViewer->SetSetting(settings);
5114 __pWebViewer->Reload();
5116 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5118 WebSetting settings = __pWebViewer->GetSetting();
5119 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5120 __pWebViewer->SetSetting(settings);
5122 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5126 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5129 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5133 WebSetting settings = __pWebViewer->GetSetting();
5134 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5135 __pWebViewer->SetSetting(settings);
5138 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5142 WebSetting settings = __pWebViewer->GetSetting();
5143 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5144 __pWebViewer->SetSetting(settings);
5147 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5149 WebSetting settings = __pWebViewer->GetSetting();
5150 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5152 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5156 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5158 __pWebViewer->SetSetting(settings);
5160 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5164 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5165 WebSetting settings = __pWebReader->GetSetting();
5166 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5167 __pWebReader->SetSetting(settings);
5173 MainForm::OnSettingsReset()
5177 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5178 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5183 MainForm::OnClearCache()
5185 result r = E_SUCCESS;
5187 if (__pWebViewer != NULL)
5189 r = __pWebViewer->ClearCache();
5192 AppLogDebug("Cache cleared success");
5196 AppLogDebug("Cache cleared fail");
5202 MainForm::OnClearCookie()
5204 result r = E_SUCCESS;
5206 if (__pWebViewer != NULL)
5208 __pWebViewer->ClearCookie();
5212 AppLogDebug("Cookie cleared success");
5216 AppLogDebug("Cache cleared fail");
5221 MainForm::OnClearFormData()
5223 result r = E_SUCCESS;
5225 if (__pWebViewer != NULL)
5227 __pWebViewer->ClearFormData();
5231 AppLogDebug("Cookie cleared success");
5235 AppLogDebug("Cache cleared fail");
5240 MainForm::OnClearPasswords()
5242 result r = E_SUCCESS;
5244 if (__pWebViewer != NULL)
5246 __pWebViewer->ClearLoginFormData();
5250 AppLogDebug("Cookie cleared success");
5254 AppLogDebug("Cache cleared fail");
5260 MainForm::findDistance(int x1,int y1,int x2, int y2)
5262 int deltaX = Math::Abs(x2 - x1);
5263 int deltaY = Math::Abs(y2 - y1);
5264 double num = deltaX*deltaX + deltaY*deltaY;
5270 for (i = 0; i < 20; i++)
5272 x = (((x*x)+ num)/(2*x));
5283 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5285 AppLog("xyz:: MainForm::OnTouchPressed called");
5286 if(__pFindWordControl)
5288 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5289 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5291 __isLongPressedDone = false;
5296 IList* pList = null;
5297 pList = touch.GetTouchInfoListN(source);
5301 int count = pList->GetCount();
5304 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5305 __touchPoint1 = pTouchInfo->position;
5307 /*if (__pAddressbar != null)
5309 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5311 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5313 __pAddressbar->SaveAddressbarEditText();
5315 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5318 __pAddressbar->Invalidate(true);
5320 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5322 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5324 //__pAddressbar->SaveAddressbarEditText();
5326 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5329 else if (count == 2)
5331 AppLogDebug("MainForm::OnTouchPressed count is two");
5332 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5333 __touchPoint1 = pTouchInfo->position;
5335 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5336 __touchPoint2 = pTouchInfo->position;
5341 pList->RemoveAll(true);
5346 __pAddressbar->SetShowState(false);
5348 if(__pFooterPanel && __isKeypadOpened == false)
5350 __pFooterPanel->SetShowState(true);
5352 RelayoutControls(false);
5357 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5359 AppLog("LMN::MainForm::OnTouchMoved entered");
5360 // __currentWordIndex = 0;
5361 __isLongPressedDone = false;
5366 MainForm::MoveUiControls()
5371 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5373 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5375 if(__pFooterUrlField->GetTextLength() == 0)
5377 __pFooterUrlField->SetKeypadActionEnabled(false);
5381 __pFooterUrlField->SetKeypadActionEnabled(true);
5384 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5386 __currentSearchStr = __pFindWordEditField->GetText();
5387 if (__currentSearchStr.GetLength() > 0)
5389 __pFindWordCountLabel->SetShowState(true);
5393 // __pFindWordCountLabel->SetShowState(false);
5394 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5395 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5398 __pFindWordNext->SetEnabled(false);
5399 __pFindWordPrev->SetEnabled(false);
5400 __pFindWordNext->Invalidate(true);
5401 __pFindWordPrev->Invalidate(true);
5402 __pFindWordCountLabel->SetText(L"0/0");
5403 __pFindWordCountLabel->Invalidate(true);
5405 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5407 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5408 if (__currentSearchStr.GetLength() > 0)
5410 __pFindWordCountLabelRightToLeft->SetShowState(true);
5414 __pFindWordCountLabelRightToLeft->SetShowState(false);
5417 __pFindWordNext->SetEnabled(false);
5418 __pFindWordPrev->SetEnabled(false);
5419 __pFindWordNext->Invalidate(true);
5420 __pFindWordPrev->Invalidate(true);
5421 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5422 __pFindWordCountLabelRightToLeft->Invalidate(true);
5424 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5425 if (__currentSearchStr.GetLength() > 0)
5431 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5433 __currentSearchStr = L"";
5434 AppLogDebug("Enter something");
5439 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5446 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5448 if(__pWebViewer != null)
5451 AppLog("MainForm::InitMostVisitedSitesView");
5452 result r = E_SUCCESS;
5455 if (__pMostVisitedListView != null)
5460 if (__pMostVisitedListView != null)
5462 RemoveControl(__pMostVisitedListView);
5464 if(__pMostVisitedSites != null)
5466 __pMostVisitedSites->RemoveAll(true);
5469 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5471 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5472 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF();
5473 __pMostVisitedListView = new(std::nothrow) ListView();
5475 int height = GetClientAreaBounds().height;
5477 if(__pFooterPanel->GetShowState() == true)
5479 height = height - __pFooterPanel->GetHeight();
5481 if(__pAddressbar->GetShowState() == true)
5483 height -= __pAddressbar->GetHeight();
5486 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5490 delete __pMostVisitedListView;
5491 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5494 __pMostVisitedListView->SetItemProvider(*this);
5495 __pMostVisitedListView->AddListViewItemEventListener(*this);
5496 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5497 AddControl(__pMostVisitedListView);
5498 __pMostVisitedListView->UpdateList();
5505 MainForm::GetImagePath(void)
5509 String formattedTime;
5510 DateTime currentTime;
5511 LocaleManager localManager;
5512 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5514 localManager.Construct();
5515 Locale locale = localManager.GetSystemLocale();
5516 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5518 // Get date formatter
5519 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5523 pTimeFormatter->Format(currentTime, formattedTime);
5526 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5527 String delim(L" :");
5528 StringTokenizer strTok(formattedTime, delim);
5531 String str1("GMT+00");
5532 while (strTok.HasMoreTokens())
5534 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5535 if(token.Equals(str1))
5537 AppLog("token is %ls", token.GetPointer());
5538 imageName.Append(token);
5544 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5546 result r = E_FAILURE;
5547 AppLog("Content manager 1");
5548 ContentId contentId;
5549 ContentManager contentManager;
5550 r = contentManager.Construct();
5553 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5556 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5557 Tizen::Io::Directory::Create(contentPath,true);
5558 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5560 AppLog("Already exists");
5562 else if(GetLastResult() == E_SUCCESS)
5564 AppLog("created success");
5566 contentPath.Append(imageName);
5567 contentPath.Append(".jpg");
5568 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5569 ShowIndicatorNotification(L"Download Complete",contentPath);
5570 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5574 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5576 AppLogDebug("ENTER");
5578 NotificationRequest request;
5579 request.SetAlertText(messageText);
5580 request.SetTitleText(L"");
5581 request.SetAppMessage(contentPath);
5582 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5583 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5584 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5585 String homePath = pApp->GetAppRootPath();
5586 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5587 AppLog("The iconPath is : %ls", homePath.GetPointer());
5588 request.SetIconFilePath(iconPath);
5590 Tizen::Shell::NotificationManager notiMgr;
5591 notiMgr.Construct();
5592 notiMgr.NotifyOngoingActivity(request);
5593 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5598 MainForm::SetForwardButtonEnabled(bool isEnabled)
5600 __pGoForwardBtn->SetEnabled(isEnabled);
5601 __pGoForwardBtn->Invalidate(true);
5605 MainForm::SetBackButtonEnabled(bool isEnabled)
5607 __pGoBackBtn->SetEnabled(isEnabled);
5608 __pGoBackBtn->Invalidate(true);
5612 MainForm::UpdateProgress(int percentage)
5614 __progressPercentage = percentage;
5615 if (percentage == 0 || percentage == 100)
5617 __isLoadingData = false;
5618 if (percentage == 100)
5620 __isLoadingCompleted = true;
5621 __progressPercentage = 0;
5625 __isLoadingCompleted = false;
5630 __isLoadingData = true;
5632 UpdateProgressBitmap();
5636 MainForm::GetProgress(void)
5638 return __progressPercentage;
5642 MainForm::UpdateProgressBitmap(void)
5644 result r = E_SUCCESS;
5645 if (__pProgressbarLabel == null)
5647 int w = __pProgressbarLabel->GetWidth();
5648 int h = __pProgressbarLabel->GetHeight();
5650 int progressWidth = 0;
5651 Bitmap* pRetBitmap = null;
5653 if (__progressPercentage == 0 || __progressPercentage == 100)
5655 __pProgressbarLabel->SetShowState(false);
5656 __pProgressbarLabel->Invalidate(false);
5661 __pProgressbarLabel->SetShowState(true);
5662 __pProgressbarLabel->Invalidate(false);
5665 r = canvas.Construct(Rectangle(0, 0, w, h));
5669 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5674 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5678 pBgBmp->Scale(Dimension(w, h));
5679 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5683 progressWidth = (double) (w) * __progressPercentage / 100;
5684 AppLogDebug("progressWidth: %d", progressWidth);
5685 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5687 if (pProgressBmp != null)
5689 pProgressBmp->Scale(Dimension(progressWidth, h));
5690 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5691 delete pProgressBmp;
5694 pRetBitmap = new (std::nothrow) Bitmap();
5696 if (pRetBitmap == null)
5698 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5702 pRetBitmap->Construct(canvas, canvas.GetBounds());
5704 if (__pProgressbarLabel != null && pRetBitmap != null)
5706 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5707 __pProgressbarLabel->Invalidate(false);
5710 if (pRetBitmap != null)
5719 MainForm::ReaderClicked()
5721 result r = E_SUCCESS;
5722 ArrayList* pArgList = new(std::nothrow) ArrayList();
5723 if (pArgList != null)
5725 r = pArgList->Construct();
5732 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5739 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5746 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5754 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5760 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5762 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5764 __currentAddMode = addMode;
5768 case ADDRESSBAR_MODE_INVALID:
5773 case ADDRESSBAR_MODE_READER:
5775 __pStopBtn->SetShowState(false);
5776 __pRefreshBtn->SetShowState(false);
5777 __pClearBtn->SetShowState(false);
5778 __pReaderBtn->SetShowState(false);
5781 case ADDRESSBAR_MODE_LOADING:
5783 __pRefreshBtn->SetShowState(false);
5784 __pStopBtn->SetShowState(true);
5785 __pClearBtn->SetShowState(false);
5786 __pReaderBtn->SetShowState(false);
5789 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5791 // SetUrl(__pAddressbar->GetUrl());
5793 __pRefreshBtn->SetShowState(true);
5794 __pStopBtn->SetShowState(false);
5795 __pClearBtn->SetShowState(false);
5796 __pReaderBtn->SetShowState(false);
5799 case ADDRESSBAR_MODE_EDIT:
5801 __pRefreshBtn->SetShowState(false);
5802 __pStopBtn->SetShowState(false);
5803 __pReaderBtn->SetShowState(false);
5804 __pClearBtn->SetShowState(true);
5811 OnAddressBarModeChanged();
5814 AddressBarMode MainForm::GetAddressbarMode(void)
5816 return __currentAddMode;
5819 void MainForm::SetUrl(const String& url)
5822 if(__displayUrl.GetLength() > 2048)
5823 __displayUrl.SubString(0,2048,__displayUrl);
5825 if (__pFooterUrlField != NULL)
5827 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5828 if (removedHttpUrl.IsEmpty() == false)
5830 __pFooterUrlField->SetText(removedHttpUrl);
5831 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5832 __pAddressbar->SetUrl(__displayUrl);
5836 __pFooterUrlField->SetText(__displayUrl);
5837 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5838 __pAddressbar->SetUrl(__displayUrl);
5840 if(__pFooterUrlField)
5841 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5842 __pFooterUrlField->Invalidate(false);
5843 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5844 __pAddressbar->Invalidate(true);
5845 // __pFooterUrlField->SetCursorPosition(0);
5850 MainForm::RemoveHttpTextFromDisplayURL(void)
5852 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5854 // bool isHttpText = __displayUrl.Contains(L"http://");
5855 String updatedDisplayUrl;
5856 updatedDisplayUrl.Clear();
5857 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5859 __displayUrl.SubString(7,updatedDisplayUrl);
5861 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5863 __displayUrl.SubString(8,updatedDisplayUrl);
5865 return updatedDisplayUrl;
5868 void MainForm::OnSharePopupControlStarted(void)
5870 __pWebViewer->AddTouchEventListener(*this);
5874 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5876 if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED)
5878 AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN");
5881 else if (requestId == BACK_GROUND_APP_EVENT)
5883 if(__pWebViewer != null)
5885 __pWebViewer->Pause();
5889 __pImageMenu->SetShowState(false);
5891 if(__pAddressbar != null)
5893 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5896 else if(requestId == FORE_GROUND_APP_EVENT)
5898 if(__pWebViewer != null)
5900 __pWebViewer->Resume();
5902 if(__pAddressbar != null)
5904 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5910 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5912 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5913 result r = E_SUCCESS;
5916 __pAddressbar->SetShowState(false);
5918 AppLog("akjshdasd 5");
5919 __pFooterPanel->SetShowState(true);
5922 __pWebViewer->SetFocus();
5923 else if(__pMostVisitedListView)
5924 __pMostVisitedListView->SetFocus();
5925 else if(__pMultiWindowButton)
5926 __pMultiWindowButton->SetFocus();
5927 else if(__pMoreButton)
5928 __pMoreButton->SetFocus();
5930 __pAddressbar->SetShowState(false);
5932 RelayoutControls(false);
5936 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5938 AppLog("MainForm::OnFormMenuRequested called");
5940 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5942 int bookmarkCount=0;
5945 url=__pWindowInfo->pageUrl;
5946 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5947 result r = E_SUCCESS;
5948 Bitmap* pBitmap = null;
5949 String lastChar = L"";
5950 // if(url.SubString(url.GetLength()-1,lastChar));
5951 // if(lastChar == L"/")
5953 // bool exist1 = false;
5954 // bool exist2 = false;
5955 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5956 // url.SubString(0,url.GetLength() - 1,url);
5957 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5958 // exist = exist1 | exist2;
5962 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5965 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5971 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5975 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5977 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5979 if (__pOptionMenu->GetItemCount() == 9)
5981 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5985 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5990 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5994 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5995 if (__pOptionMenu->GetItemCount() != 9)
5997 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5998 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5999 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
6000 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
6001 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
6002 __pOptionMenu->SetMaxVisibleItemsCount(6);
6004 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
6006 AppLog(" Orientation landscape");
6007 __pOptionMenu->SetMaxVisibleItemsCount(5);
6011 AppLog(" Orientation potrait");
6012 __pOptionMenu->SetMaxVisibleItemsCount(6);
6015 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
6018 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
6020 __pAddressbar->SetShowState(false);
6022 __pFooterPanel->SetShowState(true);
6023 result r = __pOptionMenu->SetShowState(true);
6024 AppLog("ajsghd %s",GetErrorMessage(r));
6025 RelayoutControls(false);
6026 __pOptionMenu->Invalidate(true);
6027 __pOptionMenu->Show();