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 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
995 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
997 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
999 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
1003 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
1005 AppLog("asdasdafdsfdgfd");
1008 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1012 Clipboard* pClipboard = Clipboard::GetInstance();
1014 if(pClipboard == null)
1016 clipboardAvailable = false;
1020 // Retrieves a latest item
1021 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1025 clipboardAvailable = false;
1029 //Gets data from the clipboard item
1030 String* pString = dynamic_cast<String*>(pItem->GetData());
1034 clipboardAvailable = false;
1038 if(clipboardAvailable == false && (onlyPasteOption == true || __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
1042 __pImageMenu = new (std::nothrow) ContextMenu();
1043 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1044 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);
3542 __pWebViewer->SearchTextAllAsync(L"",true);
3543 __pFindWordControl->SetShowState(false);
3545 RelayoutControls(false);
3549 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3551 AppLog("MainForm::OnFocusLost called");
3555 MainForm::OnStopClicked(Addressbar& addBar)
3557 AppLogDebug("MainForm::OnStopClicked called");
3560 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3561 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3562 __pWebViewer->StopLoading();
3563 RequestRedraw(true);
3568 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3570 // AppLog("MainForm::OnBackClicked");
3571 result r = E_FAILURE;
3572 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3574 AppLog("Hiding the menu");
3575 __pImageMenu->SetShowState(false);
3578 if (__pWebViewer && __pWebViewer->CanGoBack())
3580 __pWebViewer->GoBack();
3582 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3585 pApp = UiApp::GetInstance();
3588 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3591 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3599 WindowInfo* pWindowInfo = null;
3601 SceneManager* pSceneManager = SceneManager::GetInstance();
3602 if (pSceneManager == null)
3606 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3607 if (pAllWindowList == NULL)
3609 pApp = UiApp::GetInstance();
3612 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3615 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3620 if (pAllWindowList != null)
3622 totalCount = pAllWindowList->GetCount();
3624 for (int count = 0; count < totalCount; count++)
3626 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3627 if (pWindowInfo == null)
3629 pApp = UiApp::GetInstance();
3632 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3635 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3640 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3642 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3645 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3648 r = pAllWindowList->RemoveAt(count, true);
3649 __pWindowInfo = null;
3652 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3657 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3659 else if(pAllWindowList->GetCount() > 0)
3661 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3665 pApp = UiApp::GetInstance();
3668 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3673 if (pWindowInfo == null)
3675 pApp = UiApp::GetInstance();
3678 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3684 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3685 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3688 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3702 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3704 AppLog("MainForm::OnForwardClicked");
3705 if (__pWebViewer == null)
3708 if (__pWebViewer->CanGoForward())
3710 __pWebViewer->GoForward();
3715 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3717 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3718 if(__pFooterPanel != null)
3720 __pFooterPanel->SetShowState(false);
3723 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3725 __pAddressbar->SetShowState(true);
3726 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3729 RelayoutControls(false);
3733 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3735 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3737 int Height = GetClientAreaBounds().height;
3738 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3740 RelayoutControls(false);
3744 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3746 AddressBarCancelledClicked(addBar);
3750 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3752 __prevAddressBarMode = __curAddressBarMode;
3754 if (__pAddressbar != null)
3756 __curAddressBarMode = GetAddressbarMode();
3759 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3761 __adressPanelPosition.y = 0;
3762 if (__pAddressbar != null)
3764 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3765 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
3766 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3767 __pAddressbar->Invalidate(true);
3769 if (__pWebViewer != null)
3771 __pWebViewer->StopLoading();
3774 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3776 __adressPanelPosition.y = 0;
3777 if (__pAddressbar != null)
3779 __webControlPosition.y = 0;
3780 __webControlPositionF.y = 0.0f;
3781 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3782 __pAddressbar->Invalidate(true);
3788 MainForm::OnClipboardClosed(const Addressbar& addBar)
3790 AppLog("XYZ::MainForm::OnClipboardClosed");
3791 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3793 AppLog("akjshdasd 3");
3794 __pFooterPanel->SetShowState(true);
3796 __isKeypadOpened = false;
3797 RelayoutControls(false);
3801 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3803 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3804 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3806 AppLog("akjshdasd 3");
3807 __pFooterPanel->SetShowState(true);
3809 __isKeypadOpened = false;
3810 if(__pNotification && __pNotification->GetShowState())
3812 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3815 RelayoutControls(false,footerState);
3819 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3821 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3822 __isKeypadOpened = true;
3823 if(__pNotification && __pNotification->GetShowState())
3825 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3827 RelayoutControls(false);
3831 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3833 __isKeypadOpened = true;
3834 __pFooterPanel->SetShowState(false);
3838 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3840 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3841 RelayoutControls(false);
3845 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3847 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3850 __pWindowInfo->pageTitle = title;
3851 if (__pWebViewer != null)
3853 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3854 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3857 if (__pAddressbar != null && __pWebViewer != null)
3859 SetUrl(__pWebViewer->GetUrl());
3860 __pAddressbar->Invalidate(true);
3865 MainForm::UpdateFavicon(void)
3867 bool urlImageType = false;
3868 String *tempPath = null;
3870 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();");
3871 Bitmap* pBitmap = null;
3873 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3875 if (__pWindowInfo != null)
3878 url.SetUri(*tempPath);
3879 if (url.GetHost().GetLength() == 0)
3883 webUrl.SetUri(__pWebViewer->GetUrl());
3884 result r = url.SetHost(webUrl.GetHost());
3891 if (url.GetScheme().GetLength() == 0)
3895 webUrl.SetUri(__pWebViewer->GetUrl());
3896 url.SetScheme(webUrl.GetScheme());
3898 __pWindowInfo->faviconUrl = url.ToString();
3900 pBitmap = __pWebViewer->GetFaviconN();
3902 if (pBitmap != null)
3904 if (__pWindowInfo->pFavicon != NULL)
3906 __pWindowInfo->pFavicon = null;
3908 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3909 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3911 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3913 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3915 else if(__pWindowInfo->pFavicon != null)
3917 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3921 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3922 if(pDefaultBmp != null)
3924 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3938 if(tempPath != null)
3942 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3948 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3949 Tizen::Web::Controls::WebNavigationType type)
3951 AppLog("urlk %ls",url.GetPointer());
3952 // when load new page if find word panel is open its show state is false
3953 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3955 __currentSearchStr = L"";
3956 __currentWordIndex = 0;
3957 __maxOccurrances = 0;
3958 __pFindWordEditField->SetText(L"");
3959 __pFindWordNext->SetEnabled(false);
3960 __pFindWordPrev->SetEnabled(false);
3961 __pFindWordCountLabel->SetText(L"0/0");
3962 __pFindWordControl->SetShowState(false);
3963 __pFindWordEditField->HideKeypad();
3964 RelayoutControls(false);
3967 __pFooterPanel->Invalidate(true);
3970 uriInfo.SetUri(url);
3972 if(url.Contains(IDS_TIZEN_SERVICE))
3975 String delim(L":;,");
3977 // Creates a StringTokenizer instance
3978 StringTokenizer strTok(url, delim);
3980 int count = strTok.GetTokenCount(); // count == 4
3982 HashMap *pMap = new HashMap();
3988 while (strTok.HasMoreTokens())
3990 AppLog("Token: %ls", token.GetPointer());
3991 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3992 if(token.Contains(IDS_APPID))
3994 token.SubString(6, appId);
3995 AppLog("AppID:%ls", appId.GetPointer());
3997 else if(token.Contains(IDS_KEY))
3999 token.SubString(4, key);
4000 AppLog("key:%ls", key.GetPointer());
4002 else if(token.Contains(IDS_VALUE))
4004 token.SubString(6, value);
4005 AppLog("value:%ls", value.GetPointer());
4008 pMap->Add(key, value);
4012 AppControl *pAppControl = null;
4013 String operationId = L"http://tizen.org/appcontrol/operation/main";
4014 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
4017 result r = pAppControl->Start(null, null, pMap, null);
4021 AppLogException("AppControl not found");
4031 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
4032 const Tizen::Net::Http::HttpHeader& httpHeader)
4034 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
4038 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4040 AppLog("LMN::MainForm::OnWebPageBlockSelected");
4041 // if(__isLongPressedDone == false)
4044 if (__pHitElementResult != null)
4046 delete __pHitElementResult;
4047 __pHitElementResult = null;
4050 if (__pWebViewer != null)
4052 AppLog("MainForm::OnWebPageBlockSelected web not null");
4053 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4055 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4057 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4058 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4059 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4061 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4062 if(__pHitElementResult == null)
4064 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4067 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4071 if (__pHitElementResult == null)
4076 if (__pHitElementResult->HasImage() != true)
4078 String tagName = __pHitElementResult->GetTagName();
4079 String type = __pHitElementResult->GetAttributeValue("type");
4080 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
4083 AppLog("TagName %ls",tagName.GetPointer());
4084 __currentSelectedStr.Clear();
4085 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4086 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4087 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4088 if(tagName.Equals(L"TEXTAREA",false) == true)
4090 AppLog("Tagnameseemstobe TEXTAREA");
4092 else if(tagName.Equals(L"INPUT",false) == true)
4094 AppLog("Tagnameseemstobe INPUT");
4097 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 )
4099 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4101 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true);
4104 __pImageMenu->SetShowState(true);
4105 __pImageMenu->Show();
4106 __pImageMenu->Invalidate(true);
4109 else /*if(__isLongPressedDone == true)*/
4111 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4113 if(__pHitElementResult->GetUrl().GetLength() > 0)
4115 __currentSelectedStr.Clear();
4116 __currentSelectedStr = __pHitElementResult->GetUrl();
4118 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false);
4121 __pImageMenu->SetShowState(true);
4122 __pImageMenu->Show();
4123 __pImageMenu->Invalidate(true);
4127 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4128 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4129 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4135 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4141 MainForm::OnWebWindowCreateRequested(void)
4143 AppLog("MainForm::OnWebWindowCreateRequested entered");
4144 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4146 if (pNewWindowInfo == null)
4150 result r = E_SUCCESS;
4151 SceneManager* pSceneManager = SceneManager::GetInstance();
4152 if (pSceneManager == NULL)
4156 ArrayList* pArgList = new(std::nothrow) ArrayList();
4157 if (pArgList == NULL)
4161 r = pArgList->Construct();
4164 pNewWindowInfo->isJavascriptInitiated = true;
4165 pArgList->Add(*pNewWindowInfo);
4166 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4170 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4177 return pNewWindowInfo->pCurrentWeb;
4181 MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4183 AppLog("OnWebWindowCloseRequested");
4184 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4185 SceneManager* pSceneManager = SceneManager::GetInstance();
4186 WindowInfo* pWindowInfo = null;
4187 WindowInfo* pNewWindowInfo = null;
4190 result r = E_FAILURE;
4192 if (pAllWindowList != null)
4194 totalCount = pAllWindowList->GetCount();
4197 for (int count = 0; count < totalCount; count++)
4199 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4201 if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID)
4203 r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID);
4204 r = pAllWindowList->RemoveAt(count, true);
4206 Form* pCurrentForm = null;
4207 if(SceneManager::GetInstance()->GetCurrentScene() != null)
4208 pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
4211 pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null);
4214 if (pAllWindowList->GetCount() > 0)
4216 pNewWindowInfo = null;
4217 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4221 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4223 if (pNewWindowInfo == null)
4227 result r = E_SUCCESS;
4228 SceneManager* pSceneManager = SceneManager::GetInstance();
4229 if (pSceneManager == NULL)
4233 ArrayList* pArgList = new(std::nothrow) ArrayList();
4234 if (pArgList == NULL)
4238 r = pArgList->Construct();
4241 pArgList->Add(*pNewWindowInfo);
4242 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4243 if (pArgList != null)
4250 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4255 pApp = UiApp::GetInstance();
4258 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4263 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4274 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4276 AppLog("xyz:: MainForm::RelayoutControls called");
4277 __webControlPosition.y = 0;
4278 __webControlPositionF.y = 0.0f;
4279 __webControlHeight = GetClientAreaBounds().height;
4280 __webControlHeightF = GetClientAreaBoundsF().height;
4281 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4283 AppLog("Client area height: %d", __webControlHeight);
4284 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4286 __webControlPosition.y += __pAddressbar->GetHeight();
4287 __webControlPositionF.y += __pAddressbar->GetHeightF();
4288 __webControlHeight -= __pAddressbar->GetHeight();
4289 __webControlHeightF -= __pAddressbar->GetHeightF();
4290 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4292 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4294 __webControlPosition.y += __pFindWordControl->GetHeight();
4295 __webControlPositionF.y += __pFindWordControl->GetHeightF();
4296 __webControlHeight -= __pFindWordControl->GetHeight();
4297 __webControlHeightF -= __pFindWordControl->GetHeightF();
4298 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4301 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4303 __webControlHeight -= __pFooterPanel->GetHeight();
4304 __webControlHeightF -= __pFooterPanel->GetHeightF();
4306 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0F, __webControlPositionF.y + __webControlHeightF, GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF())));
4307 __webControlHeight = __webControlHeight + 12;
4308 __webControlHeightF = __webControlHeightF + 12.0f;
4310 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4312 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4317 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight );
4318 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4319 __pWebViewer->Invalidate(false);
4322 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4324 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4331 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4333 if (__pFindWordControl == null)
4338 Tizen::Locales::LocaleManager localeManager;
4339 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4341 String languageCode;
4342 result r = SettingInfo::GetValue(L"Language", languageCode);
4343 // int languagecode = local.GetLanguageCode();
4344 AppLog("rahul language is %S", languageCode.GetPointer());
4348 InitFindWordPanel();
4350 if (languageCode.CompareTo("ara") == 0)
4352 AppLog("rahul language is arabic");
4354 __pFindWordPanelLeftToRight->SetShowState(false);
4355 __pFindWordPanelRightToLeft->SetShowState(true);
4357 __pFindWordClear->SetShowState(false);
4358 __pFindWordCountLabel->SetShowState(false);
4359 __pFindWordEditField->SetShowState(false);
4361 __pFindWordClearRightToLeft->SetShowState(true);
4362 __pFindWordCountLabelRightToLeft->SetShowState(true);
4363 __pFindWordEditFieldRightToLeft->SetShowState(true);
4367 AppLog("rahul language is not arabic");
4370 __pFindWordPanelLeftToRight->SetShowState(true);
4371 __pFindWordPanelRightToLeft->SetShowState(false);
4373 __pFindWordClear->SetShowState(true);
4374 __pFindWordCountLabel->SetShowState(true);
4375 __pFindWordEditField->SetShowState(true);
4377 __pFindWordClearRightToLeft->SetShowState(false);
4378 __pFindWordCountLabelRightToLeft->SetShowState(false);
4379 __pFindWordEditFieldRightToLeft->SetShowState(false);
4381 __pFindWordControl->SetShowState(true);
4385 if(__pFindWordControl != null)
4387 __pFindWordControl->SetShowState(false);
4391 AppLog("MainForm::ShowFindWordPanel %d",show);
4392 if (show && !isTouchPressed)
4394 if (languageCode.CompareTo("ara") == 0)
4396 if (__pFindWordEditFieldRightToLeft)
4398 __pFindWordEditFieldRightToLeft->SetFocus();
4399 __pFindWordEditFieldRightToLeft->ShowKeypad();
4404 if (__pFindWordEditField)
4406 __pFindWordEditField->SetFocus();
4407 __pFindWordEditField->ShowKeypad();
4413 if (languageCode.CompareTo("ara") == 0)
4415 if (__pFindWordEditFieldRightToLeft)
4416 __pFindWordEditFieldRightToLeft->HideKeypad();
4420 if (__pFindWordEditField)
4421 __pFindWordEditField->HideKeypad();
4425 RelayoutControls(false);
4429 MainForm::StartWordSearch()
4431 //Get the count of occurances of the word in the current page
4432 __maxOccurrances = 0;
4433 __currentWordIndex = 0;
4435 __pFindWordPrev->SetEnabled(false);
4436 String *pCountStr = null;
4439 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4440 AppLog("Search Result %s",GetErrorMessage(r));
4443 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4444 if (pCountStr != null)
4446 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4450 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4455 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4457 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4458 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4462 if (__pFindWordCountLabel)
4464 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4466 if (__pFindWordEditField)
4468 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4471 else if(totalCount >= 100)
4473 if (__pFindWordCountLabel)
4475 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4477 if (__pFindWordEditField)
4479 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4484 if (__pFindWordCountLabel)
4486 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4488 if (__pFindWordEditField)
4490 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4494 __maxOccurrances = totalCount;
4495 __currentWordIndex = currentOrdinal;
4497 //Reset the UI controls as per the maxOccurrance value
4498 if (totalCount <= 0)
4500 AppLog("Word not found");
4501 //Show error notification to user
4503 __pFindWordNext->SetEnabled(false);
4504 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4506 __pFindWordCountLabel->SetText(L"0/0");
4507 __pFindWordCountLabel->Invalidate(false);
4509 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4511 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4512 __pFindWordCountLabelRightToLeft->Invalidate(false);
4515 __pFindWordNext->Invalidate(false);
4516 __pFindWordPrev->Invalidate(false);
4521 if (totalCount == 1 || totalCount == currentOrdinal)
4524 __pFindWordNext->SetEnabled(false);
4529 __pFindWordNext->SetEnabled(true);
4532 String countStr = L"";
4533 countStr.Append(__currentWordIndex);
4534 countStr.Append(L"/");
4535 countStr.Append(__maxOccurrances);
4536 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4538 __pFindWordCountLabel->SetText(countStr);
4539 __pFindWordCountLabel->Invalidate(false);
4540 __pFindWordCountLabel->Invalidate(false);
4542 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4544 __pFindWordCountLabelRightToLeft->SetText(countStr);
4545 __pFindWordCountLabelRightToLeft->Invalidate(false);
4546 __pFindWordCountLabelRightToLeft->Invalidate(false);
4548 if (__pFindWordNext)
4550 __pFindWordNext->Invalidate(false);
4552 if (__pFindWordPrev)
4554 __pFindWordPrev->Invalidate(false);
4560 MainForm::FindNextWord(bool next)
4564 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4565 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4567 if (__currentWordIndex < __maxOccurrances)
4569 __currentWordIndex++;
4575 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4576 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4578 if(__currentWordIndex > 1)
4580 __currentWordIndex--;
4585 String countStr = L"";
4586 countStr.Append(__currentWordIndex);
4587 countStr.Append(L"/");
4588 countStr.Append(__maxOccurrances);
4590 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4592 __pFindWordCountLabel->SetText(countStr);
4593 __pFindWordCountLabel->Invalidate(false);
4595 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4597 __pFindWordCountLabelRightToLeft->SetText(countStr);
4598 __pFindWordCountLabelRightToLeft->Invalidate(false);
4601 if (__currentWordIndex >= __maxOccurrances)
4603 __pFindWordNext->SetEnabled(false);
4607 __pFindWordNext->SetEnabled(true);
4609 if (__currentWordIndex <= 1)
4611 __pFindWordPrev->SetEnabled(false);
4615 __pFindWordPrev->SetEnabled(true);
4617 __pFindWordPrev->Invalidate(false);
4618 __pFindWordNext->Invalidate(false);
4620 __pFindWordControl->Invalidate(true);
4624 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4626 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4627 __isKeypadOpened = true;
4628 __pFooterPanel->SetShowState(false);
4629 // OnAddressBarKeypadOpened(*__pAddressbar);
4633 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4635 __isKeypadOpened = true;
4636 AppLog("xyz::MainForm::OnWebKeypadOpened");
4638 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4640 __currentSearchStr = L"";
4641 __currentWordIndex = 0;
4642 __maxOccurrances = 0;
4643 __pFindWordEditField->SetText(L"");
4644 __pFindWordNext->SetEnabled(false);
4645 __pFindWordPrev->SetEnabled(false);
4646 __pFindWordCountLabel->SetText(L"0/0");
4647 __pWebViewer->SearchTextAllAsync(L"",false);
4648 __pFindWordControl->SetShowState(false);
4649 __pFindWordEditField->HideKeypad();
4653 if (__pWebViewer != null && __pFooterPanel != null)
4655 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4656 if(__pAddressbar != null)
4658 __pAddressbar->SetShowState(false);
4660 if(__pFindWordControl != null)
4662 __pFindWordControl->SetShowState(false);
4664 __pFooterPanel->SetShowState(false);
4665 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4667 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4669 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4670 // AppLog("omgomgomg");
4676 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4678 AppLog("abcde::MainForm::OnWebKeypadClosed");
4679 AppLog("xyz::MainForm::OnWebKeypadClosed");
4680 AppLog("akjshdasd 4");
4681 __pFooterPanel->SetShowState(true);
4682 // OnAddressBarKeypadClosed(*__pAddressbar);
4683 RelayoutControls(false);
4684 __isKeypadOpened = false;
4687 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4689 AppLog("abcde: imagemenu visible.");
4692 __pWebViewer->GetBlockRange(p,q);
4693 if (p == Point(0,0) && q == Point(0,0))
4701 __pImageMenu->SetAnchorPosition(p);
4702 __pImageMenu->Show();
4708 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4710 // RelativeLayout(false);
4711 if(__pWebViewer != null)
4713 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4718 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4720 Control* temp = const_cast< Control* >(&source);
4721 Header* pHeader = dynamic_cast< Header* >(temp);
4722 if (pHeader != null)
4724 //Header double - clicked
4725 AppLog("Header double clicked");
4727 if(__pFindWordControl)
4729 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4730 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4734 AppLog("MainScene::OnTouchDoublePressed");
4738 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4740 AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4741 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4743 AppLog("Returning because of more than one touch point.");
4747 // __pWebViewer->ReleaseBlock();
4749 __pWebViewer->SetFocus();
4750 __longPressPoint = currentPosition;
4752 if (__pHitElementResult != null)
4754 delete __pHitElementResult;
4755 __pHitElementResult = null;
4758 if (__pWebViewer != null)
4760 AppLog("MainForm::OnTouchLongPressed web not null");
4761 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4764 if (__pHitElementResult == null)
4769 if (__pHitElementResult->HasImage() == true)
4771 if(__pWebViewer != null)
4773 __pWebViewer->ReleaseBlock();//N_SE-52389
4774 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4776 __pImageMenu->SetShowState(true);
4777 __pImageMenu->Show();
4778 __pImageMenu->Invalidate(true);
4780 else if(__pHitElementResult->HasUrl() == true)
4782 if(__pWebViewer != null)
4783 __pWebViewer->ReleaseBlock();//N_SE-52389
4784 String tempURl = __pHitElementResult->GetUrl();
4785 AppLog("tempURl is %ls", tempURl.GetPointer());
4786 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4787 if (pBitmap != null)
4795 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4796 __pImageMenu->SetShowState(true);
4797 __pImageMenu->Show();
4798 __pImageMenu->Invalidate(true);
4802 String tagName = __pHitElementResult->GetTagName();
4803 String type = __pHitElementResult->GetAttributeValue("type");
4804 String value = __pHitElementResult->GetAttributeValue(L"value");
4805 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4806 result r = E_FAILURE;
4807 __currentSelectedStr.Clear();
4808 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4810 AppLog("tag name is %ls", tagName.GetPointer());
4811 AppLog("type is %ls", type.GetPointer());
4815 __isLongPressedDone = true;
4816 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)
4817 r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4818 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)
4820 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4822 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4825 __pImageMenu->SetShowState(true);
4826 __pImageMenu->Show();
4827 __pImageMenu->Invalidate(true);
4830 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4833 // __inputEventToBeSupressed = true;
4837 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4839 AppLog("xyz:: MainForm::OnTouchReleased called");
4841 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4843 __pAddressbar->SetShowState(false);
4845 if(__pFooterPanel && __isKeypadOpened == false)
4847 __pFooterPanel->SetShowState(true);
4851 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4852 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4854 __pWebViewer->ConsumeInputEvent();
4856 if(pHitElement != null)
4860 __inputEventToBeSupressed = false;*/
4864 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4871 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4873 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4875 __currentSearchStr = L"";
4876 __currentWordIndex = 0;
4877 __maxOccurrances = 0;
4879 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4881 __pFindWordEditField->SetText(L"");
4882 __pFindWordEditField->HideKeypad();
4883 __pFindWordControl->SetShowState(false);
4884 __pFindWordCountLabel->SetText(L"0/0");
4886 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4888 __pFindWordEditFieldRightToLeft->SetText(L"");
4889 __pFindWordEditFieldRightToLeft->HideKeypad();
4890 __pFindWordControl->SetShowState(false);
4891 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4894 __pFindWordNext->SetEnabled(false);
4895 __pFindWordPrev->SetEnabled(false);
4897 __pWebViewer->SearchTextAllAsync(L"",true);
4898 __pFindWordControl->SetShowState(false);
4900 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4901 if(__pAddressbar->GetShowState() == false)
4903 __pAddressbar->SetAddressbarURLFocus();
4904 __pFooterPanel->SetShowState(false);
4911 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4917 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4923 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4929 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4935 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4941 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4943 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4944 int widthContextItem = 0;
4945 //if(__pFindWordCountLabel)
4946 // __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4947 // As per the platform engineer comment removed this line
4948 /*if(__pWebViewer != null)
4950 // 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
4951 __pWebViewer->ReleaseBlock();
4954 // if(__pFindWordControl != null)
4955 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4957 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4959 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4961 AppLog(" Orientation landscape");
4962 __pOptionMenu->SetMaxVisibleItemsCount(5);
4966 AppLog(" Orientation potrait");
4967 __pOptionMenu->SetMaxVisibleItemsCount(6);
4970 if(__pNotification && __pNotification->GetShowState() == true)
4972 __pNotification->SetShowState(false);
4973 __pNotification->Invalidate(false);
4975 if ( __pFooterLabel != null)
4977 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4980 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4986 if (__pFindWordBgLabel != null)
4988 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4989 if (pBitmap != null)
4991 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4996 if (__pFindWordBgLabelRightToLeft != null)
4998 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4999 if (pBitmap != null)
5001 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
5007 // if(__pOptionMenu != null)
5008 // __pOptionMenu->SetShowState(false);
5010 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5012 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
5016 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
5021 AppLog("__pFooterPanel->GetShowState() is true");
5023 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0, GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(), __pFooterPanel->GetWidthF(), __pFooterPanel->GetHeightF())));
5024 __pFooterPanel->Invalidate(true);
5028 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
5029 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
5031 InitMostVisitedSitesView(orientationStatus);
5034 RelayoutControls(false);
5035 if (__pArticleReaderPanel != null)
5037 if (__pArticleReaderPanel->GetShowState() == true)
5039 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
5041 if (__pBlankPanel != null)
5042 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
5044 if (__pWebReader != null)
5046 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
5048 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5049 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5051 if ( pBitmap != null && pSrcBitmap != null)
5053 AppLog("CreateReaderPanel ninepatchbitmap found");
5054 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
5057 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
5058 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
5059 if (pBitmap != null)
5064 if (pSrcBitmap != null)
5073 if (__pAddressbar != null)
5075 int width = GetClientAreaBounds().width;
5076 __pAddressbar->OrientationChanged(width);
5081 MainForm::OnSettingsChange(int settingvalue)
5083 AppLogDebug("MainForm::OnSettingsChange entered");
5085 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
5087 __pAddressbar->ResetGuideText();
5089 if (__pWebViewer == null)
5091 AppLogDebug("Webviewer is not initialized yet.");
5095 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5097 WebSetting settings = __pWebViewer->GetSetting();
5098 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5100 settings.SetAutoFittingEnabled(true);
5102 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5104 settings.SetAutoFittingEnabled(false);
5106 __pWebViewer->SetSetting(settings);
5109 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5111 WebSetting settings = __pWebViewer->GetSetting();
5112 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5113 __pWebViewer->SetSetting(settings);
5115 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5117 WebSetting settings = __pWebViewer->GetSetting();
5118 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5119 __pWebViewer->SetSetting(settings);
5120 __pWebViewer->Reload();
5122 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5124 WebSetting settings = __pWebViewer->GetSetting();
5125 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5126 __pWebViewer->SetSetting(settings);
5128 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5132 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5135 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5139 WebSetting settings = __pWebViewer->GetSetting();
5140 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5141 __pWebViewer->SetSetting(settings);
5144 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5148 WebSetting settings = __pWebViewer->GetSetting();
5149 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5150 __pWebViewer->SetSetting(settings);
5153 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5155 WebSetting settings = __pWebViewer->GetSetting();
5156 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5158 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5162 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5164 __pWebViewer->SetSetting(settings);
5166 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5170 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5171 WebSetting settings = __pWebReader->GetSetting();
5172 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5173 __pWebReader->SetSetting(settings);
5179 MainForm::OnSettingsReset()
5183 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5184 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5189 MainForm::OnClearCache()
5191 result r = E_SUCCESS;
5193 if (__pWebViewer != NULL)
5195 r = __pWebViewer->ClearCache();
5198 AppLogDebug("Cache cleared success");
5202 AppLogDebug("Cache cleared fail");
5208 MainForm::OnClearCookie()
5210 result r = E_SUCCESS;
5212 if (__pWebViewer != NULL)
5214 __pWebViewer->ClearCookie();
5218 AppLogDebug("Cookie cleared success");
5222 AppLogDebug("Cache cleared fail");
5227 MainForm::OnClearFormData()
5229 result r = E_SUCCESS;
5231 if (__pWebViewer != NULL)
5233 __pWebViewer->ClearFormData();
5237 AppLogDebug("Cookie cleared success");
5241 AppLogDebug("Cache cleared fail");
5246 MainForm::OnClearPasswords()
5248 result r = E_SUCCESS;
5250 if (__pWebViewer != NULL)
5252 __pWebViewer->ClearLoginFormData();
5256 AppLogDebug("Cookie cleared success");
5260 AppLogDebug("Cache cleared fail");
5266 MainForm::findDistance(int x1,int y1,int x2, int y2)
5268 int deltaX = Math::Abs(x2 - x1);
5269 int deltaY = Math::Abs(y2 - y1);
5270 double num = deltaX*deltaX + deltaY*deltaY;
5276 for (i = 0; i < 20; i++)
5278 x = (((x*x)+ num)/(2*x));
5289 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5291 AppLog("xyz:: MainForm::OnTouchPressed called");
5292 if(__pFindWordControl)
5294 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5295 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5297 __isLongPressedDone = false;
5302 IList* pList = null;
5303 pList = touch.GetTouchInfoListN(source);
5307 int count = pList->GetCount();
5310 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5311 __touchPoint1 = pTouchInfo->position;
5313 /*if (__pAddressbar != null)
5315 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5317 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5319 __pAddressbar->SaveAddressbarEditText();
5321 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5324 __pAddressbar->Invalidate(true);
5326 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5328 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5330 //__pAddressbar->SaveAddressbarEditText();
5332 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5335 else if (count == 2)
5337 AppLogDebug("MainForm::OnTouchPressed count is two");
5338 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5339 __touchPoint1 = pTouchInfo->position;
5341 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5342 __touchPoint2 = pTouchInfo->position;
5347 pList->RemoveAll(true);
5352 __pAddressbar->SetShowState(false);
5354 if(__pFooterPanel && __isKeypadOpened == false)
5356 __pFooterPanel->SetShowState(true);
5358 RelayoutControls(false);
5363 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5365 AppLog("LMN::MainForm::OnTouchMoved entered");
5366 // __currentWordIndex = 0;
5367 __isLongPressedDone = false;
5372 MainForm::MoveUiControls()
5377 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5379 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5381 if(__pFooterUrlField->GetTextLength() == 0)
5383 __pFooterUrlField->SetKeypadActionEnabled(false);
5387 __pFooterUrlField->SetKeypadActionEnabled(true);
5390 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5392 __currentSearchStr = __pFindWordEditField->GetText();
5393 if (__currentSearchStr.GetLength() > 0)
5395 __pFindWordCountLabel->SetShowState(true);
5399 // __pFindWordCountLabel->SetShowState(false);
5400 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5401 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5404 __pFindWordNext->SetEnabled(false);
5405 __pFindWordPrev->SetEnabled(false);
5406 __pFindWordNext->Invalidate(true);
5407 __pFindWordPrev->Invalidate(true);
5408 __pFindWordCountLabel->SetText(L"0/0");
5409 __pFindWordCountLabel->Invalidate(true);
5411 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5413 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5414 if (__currentSearchStr.GetLength() > 0)
5416 __pFindWordCountLabelRightToLeft->SetShowState(true);
5420 __pFindWordCountLabelRightToLeft->SetShowState(false);
5423 __pFindWordNext->SetEnabled(false);
5424 __pFindWordPrev->SetEnabled(false);
5425 __pFindWordNext->Invalidate(true);
5426 __pFindWordPrev->Invalidate(true);
5427 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5428 __pFindWordCountLabelRightToLeft->Invalidate(true);
5430 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5431 if (__currentSearchStr.GetLength() > 0)
5437 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5439 __currentSearchStr = L"";
5440 AppLogDebug("Enter something");
5445 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5452 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5454 if(__pWebViewer != null)
5457 AppLog("MainForm::InitMostVisitedSitesView");
5458 result r = E_SUCCESS;
5461 if (__pMostVisitedListView != null)
5466 if (__pMostVisitedListView != null)
5468 RemoveControl(__pMostVisitedListView);
5470 if(__pMostVisitedSites != null)
5472 __pMostVisitedSites->RemoveAll(true);
5475 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5477 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5478 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF();
5479 __pMostVisitedListView = new(std::nothrow) ListView();
5481 int height = GetClientAreaBounds().height;
5483 if(__pFooterPanel->GetShowState() == true)
5485 height = height - __pFooterPanel->GetHeight();
5487 if(__pAddressbar->GetShowState() == true)
5489 height -= __pAddressbar->GetHeight();
5492 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5496 delete __pMostVisitedListView;
5497 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5500 __pMostVisitedListView->SetItemProvider(*this);
5501 __pMostVisitedListView->AddListViewItemEventListener(*this);
5502 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5503 AddControl(__pMostVisitedListView);
5504 __pMostVisitedListView->UpdateList();
5511 MainForm::GetImagePath(void)
5515 String formattedTime;
5516 DateTime currentTime;
5517 LocaleManager localManager;
5518 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5520 localManager.Construct();
5521 Locale locale = localManager.GetSystemLocale();
5522 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5524 // Get date formatter
5525 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5529 pTimeFormatter->Format(currentTime, formattedTime);
5532 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5533 String delim(L" :");
5534 StringTokenizer strTok(formattedTime, delim);
5537 String str1("GMT+00");
5538 while (strTok.HasMoreTokens())
5540 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5541 if(token.Equals(str1))
5543 AppLog("token is %ls", token.GetPointer());
5544 imageName.Append(token);
5550 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5552 result r = E_FAILURE;
5553 AppLog("Content manager 1");
5554 ContentId contentId;
5555 ContentManager contentManager;
5556 r = contentManager.Construct();
5559 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5562 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5563 Tizen::Io::Directory::Create(contentPath,true);
5564 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5566 AppLog("Already exists");
5568 else if(GetLastResult() == E_SUCCESS)
5570 AppLog("created success");
5572 contentPath.Append(imageName);
5573 contentPath.Append(".jpg");
5574 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5575 ShowIndicatorNotification(L"Download Complete",contentPath);
5576 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5580 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5582 AppLogDebug("ENTER");
5584 NotificationRequest request;
5585 request.SetAlertText(messageText);
5586 request.SetTitleText(L"");
5587 request.SetAppMessage(contentPath);
5588 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5589 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5590 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5591 String homePath = pApp->GetAppRootPath();
5592 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5593 AppLog("The iconPath is : %ls", homePath.GetPointer());
5594 request.SetIconFilePath(iconPath);
5596 Tizen::Shell::NotificationManager notiMgr;
5597 notiMgr.Construct();
5598 notiMgr.NotifyOngoingActivity(request);
5599 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5604 MainForm::SetForwardButtonEnabled(bool isEnabled)
5606 __pGoForwardBtn->SetEnabled(isEnabled);
5607 __pGoForwardBtn->Invalidate(true);
5611 MainForm::SetBackButtonEnabled(bool isEnabled)
5613 __pGoBackBtn->SetEnabled(isEnabled);
5614 __pGoBackBtn->Invalidate(true);
5618 MainForm::UpdateProgress(int percentage)
5620 __progressPercentage = percentage;
5621 if (percentage == 0 || percentage == 100)
5623 __isLoadingData = false;
5624 if (percentage == 100)
5626 __isLoadingCompleted = true;
5627 __progressPercentage = 0;
5631 __isLoadingCompleted = false;
5636 __isLoadingData = true;
5638 UpdateProgressBitmap();
5642 MainForm::GetProgress(void)
5644 return __progressPercentage;
5648 MainForm::UpdateProgressBitmap(void)
5650 result r = E_SUCCESS;
5651 if (__pProgressbarLabel == null)
5653 int w = __pProgressbarLabel->GetWidth();
5654 int h = __pProgressbarLabel->GetHeight();
5656 int progressWidth = 0;
5657 Bitmap* pRetBitmap = null;
5659 if (__progressPercentage == 0 || __progressPercentage == 100)
5661 __pProgressbarLabel->SetShowState(false);
5662 __pProgressbarLabel->Invalidate(false);
5667 __pProgressbarLabel->SetShowState(true);
5668 __pProgressbarLabel->Invalidate(false);
5671 r = canvas.Construct(Rectangle(0, 0, w, h));
5675 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5680 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5684 pBgBmp->Scale(Dimension(w, h));
5685 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5689 progressWidth = (double) (w) * __progressPercentage / 100;
5690 AppLogDebug("progressWidth: %d", progressWidth);
5691 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5693 if (pProgressBmp != null)
5695 pProgressBmp->Scale(Dimension(progressWidth, h));
5696 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5697 delete pProgressBmp;
5700 pRetBitmap = new (std::nothrow) Bitmap();
5702 if (pRetBitmap == null)
5704 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5708 pRetBitmap->Construct(canvas, canvas.GetBounds());
5710 if (__pProgressbarLabel != null && pRetBitmap != null)
5712 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5713 __pProgressbarLabel->Invalidate(false);
5716 if (pRetBitmap != null)
5725 MainForm::ReaderClicked()
5727 result r = E_SUCCESS;
5728 ArrayList* pArgList = new(std::nothrow) ArrayList();
5729 if (pArgList != null)
5731 r = pArgList->Construct();
5738 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5745 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5752 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5760 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5766 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5768 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5770 __currentAddMode = addMode;
5774 case ADDRESSBAR_MODE_INVALID:
5779 case ADDRESSBAR_MODE_READER:
5781 __pStopBtn->SetShowState(false);
5782 __pRefreshBtn->SetShowState(false);
5783 __pClearBtn->SetShowState(false);
5784 __pReaderBtn->SetShowState(false);
5787 case ADDRESSBAR_MODE_LOADING:
5789 __pRefreshBtn->SetShowState(false);
5790 __pStopBtn->SetShowState(true);
5791 __pClearBtn->SetShowState(false);
5792 __pReaderBtn->SetShowState(false);
5795 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5797 // SetUrl(__pAddressbar->GetUrl());
5799 __pRefreshBtn->SetShowState(true);
5800 __pStopBtn->SetShowState(false);
5801 __pClearBtn->SetShowState(false);
5802 __pReaderBtn->SetShowState(false);
5805 case ADDRESSBAR_MODE_EDIT:
5807 __pRefreshBtn->SetShowState(false);
5808 __pStopBtn->SetShowState(false);
5809 __pReaderBtn->SetShowState(false);
5810 __pClearBtn->SetShowState(true);
5817 OnAddressBarModeChanged();
5820 AddressBarMode MainForm::GetAddressbarMode(void)
5822 return __currentAddMode;
5825 void MainForm::SetUrl(const String& url)
5828 if(__displayUrl.GetLength() > 2048)
5829 __displayUrl.SubString(0,2048,__displayUrl);
5831 if (__pFooterUrlField != NULL)
5833 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5834 if (removedHttpUrl.IsEmpty() == false)
5836 __pFooterUrlField->SetText(removedHttpUrl);
5837 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5838 __pAddressbar->SetUrl(__displayUrl);
5842 __pFooterUrlField->SetText(__displayUrl);
5843 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5844 __pAddressbar->SetUrl(__displayUrl);
5846 if(__pFooterUrlField)
5847 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5848 __pFooterUrlField->Invalidate(false);
5849 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5850 __pAddressbar->Invalidate(true);
5851 // __pFooterUrlField->SetCursorPosition(0);
5856 MainForm::RemoveHttpTextFromDisplayURL(void)
5858 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5860 // bool isHttpText = __displayUrl.Contains(L"http://");
5861 String updatedDisplayUrl;
5862 updatedDisplayUrl.Clear();
5863 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5865 __displayUrl.SubString(7,updatedDisplayUrl);
5867 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5869 __displayUrl.SubString(8,updatedDisplayUrl);
5871 return updatedDisplayUrl;
5874 void MainForm::OnSharePopupControlStarted(void)
5876 __pWebViewer->AddTouchEventListener(*this);
5880 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5882 if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED)
5884 AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN");
5887 else if (requestId == BACK_GROUND_APP_EVENT)
5889 if(__pWebViewer != null)
5891 __pWebViewer->Pause();
5895 __pImageMenu->SetShowState(false);
5897 if(__pAddressbar != null)
5899 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5902 else if(requestId == FORE_GROUND_APP_EVENT)
5904 if(__pWebViewer != null)
5906 __pWebViewer->Resume();
5908 if(__pAddressbar != null)
5910 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5916 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5918 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5919 result r = E_SUCCESS;
5922 __pAddressbar->SetShowState(false);
5924 AppLog("akjshdasd 5");
5925 __pFooterPanel->SetShowState(true);
5928 __pWebViewer->SetFocus();
5929 else if(__pMostVisitedListView)
5930 __pMostVisitedListView->SetFocus();
5931 else if(__pMultiWindowButton)
5932 __pMultiWindowButton->SetFocus();
5933 else if(__pMoreButton)
5934 __pMoreButton->SetFocus();
5936 __pAddressbar->SetShowState(false);
5938 RelayoutControls(false);
5942 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5944 AppLog("MainForm::OnFormMenuRequested called");
5946 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5948 int bookmarkCount=0;
5951 url=__pWindowInfo->pageUrl;
5952 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5953 result r = E_SUCCESS;
5954 Bitmap* pBitmap = null;
5955 String lastChar = L"";
5956 // if(url.SubString(url.GetLength()-1,lastChar));
5957 // if(lastChar == L"/")
5959 // bool exist1 = false;
5960 // bool exist2 = false;
5961 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5962 // url.SubString(0,url.GetLength() - 1,url);
5963 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5964 // exist = exist1 | exist2;
5968 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5971 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5977 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5981 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5983 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5985 if (__pOptionMenu->GetItemCount() == 9)
5987 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5991 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5996 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
6000 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
6001 if (__pOptionMenu->GetItemCount() != 9)
6003 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
6004 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
6005 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
6006 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
6007 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
6008 __pOptionMenu->SetMaxVisibleItemsCount(6);
6010 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
6012 AppLog(" Orientation landscape");
6013 __pOptionMenu->SetMaxVisibleItemsCount(5);
6017 AppLog(" Orientation potrait");
6018 __pOptionMenu->SetMaxVisibleItemsCount(6);
6021 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
6024 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
6026 __pAddressbar->SetShowState(false);
6028 __pFooterPanel->SetShowState(true);
6029 result r = __pOptionMenu->SetShowState(true);
6030 AppLog("ajsghd %s",GetErrorMessage(r));
6031 RelayoutControls(false);
6032 __pOptionMenu->Invalidate(true);
6033 __pOptionMenu->Show();