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);
993 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
997 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
999 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
1001 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
1005 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
1007 AppLog("asdasdafdsfdgfd");
1010 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1014 Clipboard* pClipboard = Clipboard::GetInstance();
1016 if(pClipboard == null)
1018 clipboardAvailable = false;
1022 // Retrieves a latest item
1023 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1027 clipboardAvailable = false;
1031 //Gets data from the clipboard item
1032 String* pString = dynamic_cast<String*>(pItem->GetData());
1036 clipboardAvailable = false;
1040 if(clipboardAvailable == false && (onlyPasteOption == true || __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
1044 __pImageMenu = new (std::nothrow) ContextMenu();
1045 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1046 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1048 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1050 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1052 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1054 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1056 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1058 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1059 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1062 __pImageMenu->SetMaxVisibleItemsCount(3);
1063 __pImageMenu->AddActionEventListener(*this);
1064 SetControlAlwaysOnTop(*__pImageMenu, true);
1065 __pImageMenu->SetFocusable(true);
1072 MainForm::InitFindWordPanel(void)
1074 result r = E_SUCCESS;
1075 Bitmap *pIconBitmap = null;
1077 if (__pFindWordControl != null)
1079 AppLogDebug("Findword panel already initialized");
1080 if (__pFindWordBgLabel != null)
1082 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1083 if (pBitmap != null)
1085 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1089 if (__pFindWordBgLabelRightToLeft != null)
1091 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1092 if (pBitmap != null)
1094 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1099 __pAddressbar->SetShowState(false);
1101 if(__isKeypadOpened == false)
1102 __pFooterPanel->SetShowState(true);
1106 __pFindWordControl = new (std::nothrow) Panel();
1107 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1110 AppLogException("There is some problem in the xml file. Please check.");
1113 AddControl(__pFindWordControl);
1114 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1115 SetControlAlwaysOnTop(*__pFindWordControl,true);
1116 __pFindWordControl->SetShowState(false);
1117 __pFindWordControl->Invalidate(false);
1119 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1120 __pFindWordPanelLeftToRight->SetShowState(true);
1122 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1123 __pFindWordPanelRightToLeft->SetShowState(false);
1125 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1126 if (__pFindWordBgLabel != null)
1128 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1129 Rectangle pRect = pPanel1->GetBounds();
1130 pRect.x = pRect.y = 0;
1131 __pFindWordBgLabel->SetBounds(pRect);
1132 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1133 if (pBitmap != null)
1135 AppLogDebug("InitFindWordPanel: Coming here");
1136 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1141 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1145 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1146 if (__pFindWordBgLabelRightToLeft != null)
1148 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1149 Rectangle pRect = pPanel1->GetBounds();
1150 pRect.x = pRect.y = 0;
1151 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1152 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1153 if (pBitmap != null)
1155 AppLogDebug("InitFindWordPanel: Coming here");
1156 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1161 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1165 Button* pfindWordCancel = null;
1166 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1167 if (pfindWordCancel == null)
1169 AppLogException("There is some problem in the xml file. Please check.");
1172 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1173 pfindWordCancel->AddActionEventListener(*this);
1175 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1176 if (__pFindWordClear == null)
1178 AppLogException("There is some problem in the xml file. Please check.");
1182 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1183 if (__pFindWordClearRightToLeft == null)
1185 AppLogException("There is some problem in the xml file. Please check.");
1189 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1190 __pFindWordClear->AddActionEventListener(*this);
1192 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1193 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1195 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1196 if (__pFindWordNext == null)
1198 AppLogException("There is some problem in the xml file. Please check.");
1202 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1203 __pFindWordNext->AddActionEventListener(*this);
1205 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1206 if (__pFindWordPrev == null)
1208 AppLogException("There is some problem in the xml file. Please check.");
1212 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1213 __pFindWordPrev->AddActionEventListener(*this);
1215 __pFindWordNext->SetEnabled(false);
1216 __pFindWordPrev->SetEnabled(false);
1218 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1219 if (__pFindWordCountLabel == null)
1221 AppLogException("There is some problem in the xml file. Please check.");
1224 __pFindWordCountLabel->SetText(L"0/0");
1226 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1227 if (__pFindWordCountLabelRightToLeft == null)
1229 AppLogException("There is some problem in the xml file. Please check.");
1232 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1234 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1235 if (__pFindWordEditField == null)
1237 AppLogException("There is some problem in the xml file. Please check.");
1240 __pFindWordEditField->AddTextEventListener(*this);
1241 __pFindWordEditField->AddKeypadEventListener(*this);
1242 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1243 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1245 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1246 if (__pFindWordEditFieldRightToLeft == null)
1248 AppLogException("There is some problem in the xml file. Please check.");
1251 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1252 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1253 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1254 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1257 __pAddressbar->SetShowState(false);
1259 if(__isKeypadOpened == false)
1260 __pFooterPanel->SetShowState(true);
1265 MainForm::CreateItem (int index, int itemWidth)
1267 Rectangle listImageRect;
1268 Rectangle pagetTitleRect;
1269 Rectangle pageURLRect;
1270 Rectangle deleteImageRect;
1271 String pageTitle(L"");
1272 String pageURL(L"");
1273 result r = E_SUCCESS;
1274 Bitmap* pListIconImage = null;
1277 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1278 if(pHistory == null)
1282 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1283 if ( pAppResource == NULL )
1287 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1289 CustomItem* pItem = new(std::nothrow) CustomItem();
1290 pageTitle = pHistory->GetHistoryTitle();
1291 pageURL = pHistory->GetHistoryUrl();
1293 if (pageURL.GetLength() == 0)
1296 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1297 pageURL = L"<"+ nourl +">";
1301 Rectangle screenBounds = GetBounds();
1304 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1313 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1315 if ( pBitmap != NULL)
1317 pListIconImage = new Bitmap();
1318 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1322 if(pListIconImage == null)
1324 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1327 if ( pListIconImage != NULL)
1329 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1330 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1331 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1334 if (pItem != null && pListIconImage != NULL)
1336 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1340 if (pageTitle.CompareTo(L"") != 0)
1344 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1348 if (pageURL.CompareTo(L"") != 0)
1352 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
1357 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1359 if ( __pItemContext!= NULL)
1363 pItem->SetContextItem(__pItemContext);
1369 if ( __pItemContextLandscape!= NULL)
1373 pItem->SetContextItem(__pItemContextLandscape);
1377 if( pListIconImage != NULL)
1379 delete pListIconImage;
1380 pListIconImage = null;
1387 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1394 MainForm::GetItemCount (void)
1396 if(__pMostVisitedSites != null)
1398 __pMostVisitedSites->RemoveAll(true);
1400 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1401 if(__pMostVisitedSites != null)
1403 return __pMostVisitedSites->GetCount();
1410 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1412 AppLog("MainForm::OnListViewContextItemStateChanged called");
1413 if(__pMostVisitedSites != null)
1415 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1416 if (pHistory != null)
1418 String url = pHistory->GetHistoryUrl();
1420 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1421 __pMostVisitedListView->UpdateList();
1427 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1429 AppLog("MainForm::OnListViewItemStateChanged called");
1430 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1431 String url = pHistory->GetHistoryUrl();
1439 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1445 MainForm::OnTerminating(void)
1447 result r = E_SUCCESS;
1449 RemoveOrientationEventListener(*this);
1453 __pAddressbar->SetAddressbarEventListener(null);
1458 __pWebViewer->RemoveTouchEventListener(*this);
1459 __pWebViewer->SetWebUiEventListenerF(null);
1460 __pWebViewer->SetWebKeypadEventListener(null);
1461 __pWebViewer->SetTextSearchListener(null);
1467 delete __pItemContext;
1469 if (__pItemContextLandscape)
1471 delete __pItemContextLandscape;
1475 delete __pSaveImage;
1477 if (__pMostVisitedSites)
1479 __pMostVisitedSites->RemoveAll(true);
1480 delete __pMostVisitedSites;
1486 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1488 result r = E_SUCCESS;
1490 AppLogDebug("Clicked : %d", actionId);
1493 case IDA_BACKBTN_CLICKED:
1495 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1497 AppLog("Hiding the menu");
1498 __pImageMenu->SetShowState(false);
1500 if (__pWebViewer && __pWebViewer->CanGoBack())
1502 __pWebViewer->GoBack();
1504 else if(__pWindowInfo->isJavascriptInitiated == false)
1507 pApp = UiApp::GetInstance();
1510 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1513 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1521 WindowInfo* pWindowInfo = null;
1523 SceneManager* pSceneManager = SceneManager::GetInstance();
1524 if (pSceneManager == null)
1528 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1529 if (pAllWindowList == NULL)
1531 pApp = UiApp::GetInstance();
1534 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1537 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1542 if (pAllWindowList != null)
1544 totalCount = pAllWindowList->GetCount();
1546 for (int count = 0; count < totalCount; count++)
1548 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1549 if (pWindowInfo == null)
1551 pApp = UiApp::GetInstance();
1554 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1557 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1564 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1566 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1569 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1572 r = pAllWindowList->RemoveAt(count, true);
1573 __pWindowInfo = null;
1576 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1581 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1585 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1587 if (pWindowInfo == null)
1589 pApp = UiApp::GetInstance();
1592 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1598 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1599 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1602 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1614 case IDA_FORWARD_CLICKED:
1615 if (__pWebViewer == null)
1618 if (__pWebViewer->CanGoForward())
1620 __pWebViewer->GoForward();
1622 __pOptionMenu->SetShowState(false);
1623 __pOptionMenu->Invalidate(false);
1626 case IDA_FINDONPAGE_CLICKED:
1628 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1629 __currentSearchStr.Clear();
1631 InitFindWordPanel();
1632 __pOptionMenu->SetShowState(false);
1633 __pOptionMenu->Invalidate(false);
1635 ShowFindWordPanel(true);
1637 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1639 __pFindWordEditField->SetFocus();
1643 __pFindWordEditFieldRightToLeft->SetFocus();
1647 case IDA_PRIVATEON_CLICKED:
1649 result r = E_SUCCESS;
1651 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1652 Bitmap* pBitmap = null;
1653 if (isPrivateBrowsing == true)
1655 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1658 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1662 if (__pWebViewer != NULL)
1664 __pWebViewer->SetPrivateBrowsingEnabled(false);
1667 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1669 if (__pAddressbar != null)
1671 __pAddressbar->UpdateFaviconBitmap(false);
1677 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1680 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1684 if (__pWebViewer != NULL)
1686 __pWebViewer->SetPrivateBrowsingEnabled(true);
1689 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1691 if (__pAddressbar != null)
1693 __pAddressbar->UpdateFaviconBitmap(true);
1697 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1698 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1699 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1700 __pOptionMenu->Invalidate(true);
1701 if ( pBitmap != NULL )
1708 case IDA_SETTINGS_CLICKED:
1711 ArrayList* pArgList = new(std::nothrow) ArrayList();
1714 pArgList->Construct();
1715 pArgList->Add(*__pWindowInfo);
1716 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1718 __pOptionMenu->SetShowState(false);
1719 __pOptionMenu->Invalidate(false);
1721 if (pArgList != null)
1730 case IDA_ADDTOBOOKMARK_CLICKED:
1733 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1735 int bookmarkCount=0;
1738 url=__pWindowInfo->pageUrl;
1739 result r = E_SUCCESS;
1740 Bitmap* pBitmap = null;
1741 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1749 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1750 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1751 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1753 if(__pNotification != null)
1755 RemoveControl(__pNotification);
1756 __pNotification = null;
1758 __pNotification = new (std::nothrow) NotificationPanel(*this);
1759 if (__pNotification != null)
1761 __pNotification->SetText(message);
1762 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1763 __pNotification->ShowNotification();
1768 String title=__pWindowInfo->pageTitle;
1769 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1770 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1772 pBookmark->SetBookmarkTitle(title);
1773 pBookmark->SetUrl(url);
1774 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1776 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1778 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1779 pBookmark->SetFaviconId(id);
1780 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1781 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1783 if(__pNotification != null)
1785 RemoveControl(__pNotification);
1786 __pNotification = null;
1788 __pNotification = new (std::nothrow) NotificationPanel(*this);
1789 if (__pNotification != null)
1791 __pNotification->SetText(message);
1792 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1793 __pNotification->ShowNotification();
1794 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1797 if (pBitmap != null)
1799 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1804 __pOptionMenu->Invalidate(true);
1809 case IDA_PRINT_CLICKED:
1811 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1812 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1814 AppLog("RequestPrint called!");
1815 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1816 result nResult = E_FAILURE;
1819 AppLog("TestPrint if (pAc) == true");
1824 String fileType = L"service_print_files_type";
1825 String typeVal = L"DOC";
1827 String fileCount = L"service_print_files_count";
1828 String countVal = L"1";
1829 String fileFolder= L"service_print_files_folder_name";
1830 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1832 map.Add(&fileCount, &countVal);
1833 map.Add(&fileFolder, &folderVal);
1834 map.Add(&fileType, &typeVal);
1836 String fileName = L"service_print_files_files_name";
1838 ArrayList fileNameList;
1839 fileNameList.Construct();
1840 String file1 = L"test.pdf";
1842 fileNameList.Add(&file1);
1843 map.Add(&fileName, &fileNameList);
1845 nResult = pAc->Start(NULL, NULL, &map, NULL);
1847 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1848 else if (nResult == E_MAX_EXCEEDED)
1849 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1850 else if (nResult == E_OBJ_NOT_FOUND)
1851 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1852 else if (nResult == E_IN_PROGRESS)
1853 AppLog("TestPrint ret == E_IN_PROGRESS");
1854 else if (nResult == E_PRIVILEGE_DENIED)
1855 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1856 else if(nResult == E_SYSTEM)
1857 AppLog("TestPrint ret == E_SYSTEM");
1863 int __modalMsgBoxResult;
1864 MessageBox* pMsgBox = new MessageBox();
1865 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1866 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1869 __modalMsgBoxResult = 0;
1873 case IDA_SHARE_CLICKED:
1875 if(__pPopUp != null)
1882 __pAddressbar->HideKeypad();
1884 __pPopUp = new(std::nothrow) SharePopup();
1885 __pPopUp->Initialize();
1886 if (__pWindowInfo != null)
1888 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1889 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1890 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1891 pShareInfo->SetImageAttached(false);
1892 __pPopUp->RemoveAllShareInfo();
1893 __pPopUp->AddShareInfo(pShareInfo);
1895 __pPopUp->SetShowState(true);
1899 case IDA_BOOKMARKBTN_CLICKED:
1901 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1902 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1905 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1910 case IDA_MOREBTN_CLICKED:
1912 AppLog("IDA_MOREBTN_CLICKED");
1914 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1916 int bookmarkCount=0;
1919 url=__pWindowInfo->pageUrl;
1920 result r = E_SUCCESS;
1921 Bitmap* pBitmap = null;
1923 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1926 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1931 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1935 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1937 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1939 if (__pOptionMenu->GetItemCount() == 9)
1941 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1945 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1950 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1954 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1955 if (__pOptionMenu->GetItemCount() != 9)
1957 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1958 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1959 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1960 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1961 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1962 __pOptionMenu->SetMaxVisibleItemsCount(6);
1964 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1966 AppLog(" Orientation landscape");
1967 __pOptionMenu->SetMaxVisibleItemsCount(5);
1971 AppLog(" Orientation potrait");
1972 __pOptionMenu->SetMaxVisibleItemsCount(6);
1975 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1978 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1979 __pOptionMenu->SetShowState(true);
1980 __pOptionMenu->Invalidate(true);
1981 __pOptionMenu->Show();
1985 case IDA_HISTORY_CLICKED:
1987 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1988 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1991 case IDA_SAVED_PAGES_CLICKED:
1996 case IDA_DESKTOP_VIEW_CLICKED:
2001 case IDA_SAVE_CLICKED:
2006 case IDA_MULTIWINDOWBTN_CLICKED:
2008 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2009 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2013 case IDA_NEWWINDOWBTN_CLICKED:
2015 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2017 if (pNewWindowInfo == null)
2021 result r = E_SUCCESS;
2022 SceneManager* pSceneManager = SceneManager::GetInstance();
2024 if (pSceneManager == NULL)
2028 ArrayList* pArgList = new(std::nothrow) ArrayList();
2029 if (pArgList == NULL)
2033 r = pArgList->Construct();
2036 pArgList->Add(*pNewWindowInfo);
2037 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2043 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2048 case IDA_SMALLFONT_BTN_CLICKED:
2050 WebSetting setting = __pWebReader->GetSetting();
2051 setting.SetFontSize(15);
2052 __pWebReader->SetSetting(setting);
2055 case IDA_LARGEFONT_BTN_CLICKED:
2057 WebSetting setting = __pWebReader->GetSetting();
2058 setting.SetFontSize(25);
2059 __pWebReader->SetSetting(setting);
2062 case IDA_READER_CLOSE_CLICKED:
2064 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2066 RemoveControl(__pBlankPanel);
2067 __pArticleReaderPanel = null;
2068 __pBlankPanel = null;
2069 __pArticleReaderLabel = null;
2071 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2074 case IDA_FINDWORD_CANCEL_CLICKED:
2076 __currentSearchStr = L"";
2077 __currentWordIndex = 0;
2078 __maxOccurrances = 0;
2080 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2082 __pFindWordEditField->SetText(L"");
2083 __pFindWordCountLabel->SetText(L"0/0");
2085 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2087 __pFindWordEditFieldRightToLeft->SetText(L"");
2088 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2091 __pFindWordNext->SetEnabled(false);
2092 __pFindWordPrev->SetEnabled(false);
2093 __pFindWordCountLabel->SetText(L"0/0");
2094 __pWebViewer->SearchTextAllAsync(L"",true);
2095 AppLog("akjshdasd 1");
2096 if(__isKeypadOpened == false)
2097 __pFooterPanel->SetShowState(true);
2098 ShowFindWordPanel(false);
2101 case IDA_FINDWORD_SEARCH_CLICKED:
2103 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2105 __currentSearchStr = __pFindWordEditField->GetText();
2107 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2109 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2112 if (__currentSearchStr.GetLength() > 0)
2118 AppLogDebug("Enter something");
2122 case IDA_FINDWORD_CLEAR_CLICKED:
2124 __pFindWordCountLabel->SetText(L"0/0");
2125 __pFindWordEditField->SetText(L"");
2126 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2128 __currentSearchStr = L"";
2129 __pFindWordNext->SetEnabled(false);
2130 __pFindWordPrev->SetEnabled(false);
2131 // __pFindWordCountLabel->SetShowState(false);
2132 __pFindWordControl->Invalidate(true);
2135 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2137 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2138 __pFindWordEditFieldRightToLeft->SetText(L"");
2139 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2141 __currentSearchStr = L"";
2142 __pFindWordNext->SetEnabled(false);
2143 __pFindWordPrev->SetEnabled(false);
2144 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2145 __pFindWordControl->Invalidate(true);
2148 case IDA_FINDWORD_NEXT_CLICKED:
2153 case IDA_FINDWORD_PREV_CLICKED:
2155 FindNextWord(false);
2158 case IDA_BRIGHTNESS_BTN_CLICKED:
2160 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2161 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2164 case IDA_COPY_IMAGE_CLICKED:
2166 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2167 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2169 const Bitmap* pBitmap = null;
2170 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2172 pBitmap = __pHitElementResult->GetImage();
2175 String resourcePath = App::GetInstance()->GetAppResourcePath();
2176 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2177 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2178 // copying the item to clipboard
2179 Clipboard* pClipboard = Clipboard::GetInstance();
2180 if (pClipboard != null)
2182 r = pClipboard->CopyItem(item);
2183 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2187 case IDA_VIEW_IMAGE_CLICKED:
2189 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2190 WindowInfo* pNewWindowInfo = null;
2191 if (__pHitElementResult != null)
2193 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2194 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2200 case IDA_SAVE_IMAGE_CLICKED:
2202 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2203 const Bitmap* pSaveBitmap = null;
2204 String imageName = GetImagePath();
2205 AppLog("Content manager image name %ls",imageName.GetPointer());
2208 imagePath.Append(imageName);
2209 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2210 AppLog("Content manager image path %ls",imagePath.GetPointer());
2211 if (__pHitElementResult != null)
2213 pSaveBitmap = __pHitElementResult->GetImage();
2215 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2219 UpdateImageContent(pBuffer, imageName);
2221 if(__pNotification != null)
2223 RemoveControl(__pNotification);
2224 __pNotification = null;
2226 __pNotification = new NotificationPanel(*this);
2228 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2229 msg.Append(imagePath);
2230 if (__pNotification != null)
2232 __pNotification->SetText(msg);
2233 if (__pFooterPanel->GetShowState() == true)
2235 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2239 __pNotification->SetPositionDiff(0);
2241 __pNotification->ShowNotification();
2246 int __modalMsgBoxResult;
2247 MessageBox* pMsgBox = new MessageBox();
2248 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);
2249 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2252 __modalMsgBoxResult = 0;
2256 case IDA_SHARE_IMAGE_CLICKED:
2258 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2259 if (__pPopUp != null)
2266 __pAddressbar->HideKeypad();
2268 __pPopUp = new(std::nothrow) SharePopup();
2269 __pPopUp->Initialize();
2270 if (__pHitElementResult != null)
2272 const Bitmap* pSaveBitmap = null;
2273 String imageName = GetImagePath();
2274 AppLog("Content manager image name %ls",imageName.GetPointer());
2277 imagePath.Append(imageName);
2278 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2279 AppLog("Content manager image path %ls",imagePath.GetPointer());
2280 if (__pHitElementResult != null)
2282 pSaveBitmap = __pHitElementResult->GetImage();
2284 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2286 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2287 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2289 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2290 pShareInfo->SetPageTitle(L"");
2291 pShareInfo->SetPageUrl(srcUrl);
2292 pShareInfo->SetImageAttached(true);
2293 pShareInfo->SetImagePath(imagePath);
2294 __pPopUp->RemoveAllShareInfo();
2295 __pPopUp->AddShareInfo(pShareInfo);
2296 __pPopUp->SetShowState(true);
2301 case IDA_HYPERLINK_OPEN_CLICKED:
2303 if (__pHitElementResult != null)
2305 String srcUrl = __pHitElementResult->GetUrl();
2307 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2309 if (pNewWindowInfo == null)
2313 pNewWindowInfo->isJavascriptInitiated = true;
2314 result r = E_SUCCESS;
2315 SceneManager* pSceneManager = SceneManager::GetInstance();
2316 if (pSceneManager == NULL)
2320 ArrayList* pArgList = new(std::nothrow) ArrayList();
2321 if (pArgList == NULL)
2325 pArgList->Construct();
2327 pArgList->Add(*pNewWindowInfo);
2328 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2329 if (pArgList != null)
2336 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2342 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2344 if (__pHitElementResult == null)
2349 if(__pPopUp != null)
2356 __pAddressbar->HideKeypad();
2358 __pPopUp = new(std::nothrow) SharePopup();
2359 __pPopUp->Initialize();
2361 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2362 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2363 pShareInfo->SetImageAttached(false);
2364 __pPopUp->RemoveAllShareInfo();
2365 __pPopUp->AddShareInfo(pShareInfo);
2367 __pPopUp->SetShowState(true);
2371 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2375 if (__pHitElementResult != null)
2377 url = __pHitElementResult->GetUrl();
2380 String resourcePath = App::GetInstance()->GetAppResourcePath();
2381 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2383 // copying the item to clipboard
2384 Clipboard* pClipboard = Clipboard::GetInstance();
2385 if (pClipboard != null)
2387 pClipboard->CopyItem(item);
2391 case IDA_FIND_TEXT__CLICKED:
2393 // AddressBarCancelledClicked(*__pAddressbar);
2394 RelayoutControls(false);
2395 // __pFooterPanel->SetShowState(false);
2396 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2397 __currentSearchStr.Clear();
2398 __currentSearchStr.Append(__currentSelectedStr);
2399 InitFindWordPanel();
2400 __pFindWordEditField->SetText(__currentSearchStr);
2402 if(__pOptionMenu != null)
2404 __pOptionMenu->SetShowState(false);
2405 __pOptionMenu->Invalidate(false);
2407 __adressPanelPosition.y = 0;
2409 if (__pAddressbar != null && __pWebViewer != NULL)
2411 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2412 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
2413 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2414 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeightF() - 12.0f);
2416 if (__pFooterPanel->GetShowState() == false)
2417 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2419 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2420 __pWebViewer->Invalidate(true);
2423 ShowFindWordPanel(true);
2424 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2426 __pFindWordEditField->SetText(__currentSearchStr);
2427 __pFindWordEditField->SetFocus();
2429 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2431 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2432 __pFindWordEditFieldRightToLeft->SetFocus();
2435 if (__currentSearchStr.GetLength() > 0)
2441 AppLogDebug("Enter something");
2444 if (__pWebViewer != null)
2446 // releasing the set block
2447 __pWebViewer->ReleaseBlock();
2452 case IDA_SHARE_TEXT_CLICKED:
2454 __pWebViewer->ReleaseBlock();
2455 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2456 if(__pPopUp != null)
2463 __pAddressbar->HideKeypad();
2465 __pPopUp = new(std::nothrow) SharePopup();
2466 __pPopUp->Initialize();
2467 if (__pHitElementResult != null)
2469 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2470 pShareInfo->SetPageTitle(L"");
2471 pShareInfo->SetPageUrl(__currentSelectedStr);
2472 pShareInfo->SetImageAttached(false);
2473 __pPopUp->RemoveAllShareInfo();
2474 __pPopUp->AddShareInfo(pShareInfo);
2475 __pPopUp->SetShowState(true);
2480 case IDA_COPY_TEXT_CLICKED:
2482 // __pWebViewer->ReleaseBlock();//as per hyunn lee request for issue 53500
2483 // need to implement
2484 //__currentSelectedStr
2485 // Sets data to a clip board item
2487 String resourcePath = App::GetInstance()->GetAppResourcePath();
2488 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2490 // copying the item to clipboard
2491 Clipboard* pClipboard = Clipboard::GetInstance();
2492 if (pClipboard != null)
2494 pClipboard->CopyItem(item);
2498 case IDA_PASTE_TEXT_CLICKED:
2500 Clipboard* pClipboard = Clipboard::GetInstance();
2502 if(pClipboard == null)
2506 // Retrieves a latest item
2507 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2513 //Gets data from the clipboard item
2514 String* pString = dynamic_cast<String*>(pItem->GetData());
2516 if (pString != null)
2518 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2519 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2520 String classElement = __pHitElementResult->GetAttributeValue(L"class");
2521 String tagElement = __pHitElementResult->GetTagName();
2522 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
2523 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2524 String str = L"document.getElementsByName('";
2525 str.Append(nameElement);
2526 str.Append("').length");
2527 String* pNameCount = __pWebViewer->EvaluateJavascriptN(str);
2530 str = L"document.getElementsByClassName('";
2531 str.Append(classElement);
2532 str.Append("').length");
2533 String* pClassCount = __pWebViewer->EvaluateJavascriptN(str);
2536 if(contenteditable.Equals(L"true",false) == true)
2538 AppLog("gmail paste need to support");
2540 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; } }";
2541 script.Append("replaceSelectedText(");
2542 script.Append("\"");
2543 script.Append(*pString);
2544 script.Append("\");");
2546 else if(idElement.GetLength() != 0)
2548 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; } } ";
2549 script.Append("insertAtCursor(");
2550 script.Append(L"document.activeElement");
2552 script.Append("\"");
2553 script.Append(*pString);
2554 script.Append("\");");
2556 else if (classElement.GetLength() != 0 && pClassCount->Equals("1",false) == true)
2558 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; } } ";
2559 script.Append("insertAtCursor(document.getElementsByClassName('");
2560 script.Append(classElement);
2561 script.Append("')[0],");
2562 script.Append("\"");
2563 script.Append(*pString);
2564 script.Append("\");");
2566 else if (nameElement.GetLength() != 0 && pNameCount->Equals("1",false) == true)
2568 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; } } ";
2569 script.Append("insertAtCursor(document.getElementsByName('");
2570 script.Append(nameElement);
2571 script.Append("')[0],");
2572 script.Append("\"");
2573 script.Append(*pString);
2574 script.Append("\");");
2576 else if(tagElement.GetLength() != 0) //adding for twitter post page
2578 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; } } ";
2580 script.Append("insertAtCursor(document.activeElement,");
2581 script.Append("\"");
2582 script.Append(*pString);
2583 script.Append("\");");
2585 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2586 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2593 __pWebViewer->ReleaseBlock();
2601 case IDA_GO_FORWARD:
2606 case IDA_REFRESH_BTN_CLICKED:
2608 __isLoadingCompleted = false;
2609 __isLoadingData = true;
2610 __progressPercentage = 0;
2611 __displayUrl = __pFooterUrlField->GetText();
2613 String url = __pFooterUrlField->GetText();
2614 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2616 if (__pWebViewer != null && __pAddressbar != null)
2619 //__pWebViewer->Reload();
2620 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2624 UpdateProgressBitmap();
2627 case IDA_STOP_BTN_CLICKED:
2629 __isLoadingCompleted = false;
2630 __isLoadingData = false;
2631 __progressPercentage = 0;
2632 __pFooterUrlField->HideKeypad();
2633 __displayUrl = __pFooterUrlField->GetText();
2637 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2638 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2639 __pWebViewer->StopLoading();
2640 RequestRedraw(true);
2643 UpdateProgressBitmap();
2648 if (__pFooterUrlField->GetText().IsEmpty() == false)
2650 //__displayUrl = __pUrlField->GetText();
2651 __pFooterUrlField->Clear();
2656 case IDA_READER_BTN_CLICKED:
2667 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2669 AppLog("MainForm::OnFormBackRequested entered");
2670 result r = E_FAILURE;
2671 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2673 AppLog("Hiding the menu");
2674 __pImageMenu->SetShowState(false);
2676 if (__pWebViewer && __pWebViewer->CanGoBack())
2678 __pWebViewer->GoBack();
2680 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2683 pApp = UiApp::GetInstance();
2686 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2689 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2697 WindowInfo* pWindowInfo = null;
2699 SceneManager* pSceneManager = SceneManager::GetInstance();
2700 if (pSceneManager == null)
2704 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2705 if (pAllWindowList == NULL)
2707 pApp = UiApp::GetInstance();
2710 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2713 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2718 if (pAllWindowList != null)
2720 totalCount = pAllWindowList->GetCount();
2722 for (int count = 0; count < totalCount; count++)
2724 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2725 if (pWindowInfo == null)
2727 pApp = UiApp::GetInstance();
2730 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2733 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2740 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2742 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2745 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2748 r = pAllWindowList->RemoveAt(count, true);
2749 __pWindowInfo = null;
2752 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2757 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2761 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2763 if (pWindowInfo == null)
2765 pApp = UiApp::GetInstance();
2768 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2774 if(pWindowInfo != null)
2775 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2778 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2784 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2786 // UiApp* pApp = null;
2787 // pApp = UiApp::GetInstance();
2788 // if (pApp != null)
2790 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2793 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2801 AppLog("MainForm::OnFormBackRequested exit");
2805 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2806 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2809 AppLog("MainForm::OnSceneActivatedN called");
2810 String* pSelectedScene = NULL;
2811 Object* pValue = NULL;
2812 String* pUrl = null;
2813 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2814 pSelectedScene = (String*) pValue;
2816 if (pSelectedScene != null)
2818 delete pSelectedScene;
2820 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2821 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2822 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2823 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2825 // setting the current scene ID
2826 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2828 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2830 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2832 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2833 if(__pWindowInfo == null)
2835 // if(__pWindowInfo == null)
2837 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2840 else if ( pArgs != null && pArgs->GetCount() == 1)
2842 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2848 FloatRectangle footerPanelBounds = FloatRectangle(0.0f, (GetClientAreaBoundsF().height) - __pFooterPanel->GetHeightF(), GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF());
2849 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(footerPanelBounds));
2851 // hiding the address bar
2852 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2853 __pAddressbar->SetShowState(false);
2854 // if(__pWebViewer != null)
2856 // __pWebViewer->Resume();
2859 if(pUrl != null && pUrl->GetLength() > 0)
2863 else if(__pWindowInfo != null)
2865 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)
2867 LoadUrl(__pWindowInfo->pageUrl);
2869 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2871 LoadUrl(__pWindowInfo->pageUrl);
2872 __pWindowInfo->isAppcontrolTriggered = false;
2874 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2876 __pWindowInfo->isFirstLaunch = false;
2879 __pWindowInfo->pCurrentWeb = __pWebViewer;
2880 if(__pWindowInfo->pageUrl.GetLength() > 0)
2881 LoadUrl(__pWindowInfo->pageUrl);
2885 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2886 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2887 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2889 InitMostVisitedSitesView(GetOrientationStatus());
2891 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2893 if(__pMostVisitedListView != null)
2895 __pMostVisitedListView->SetShowState(false);
2899 if(__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2901 __pMostVisitedListView->UpdateList();
2903 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2905 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2907 if (pBookmarkUrl == null)
2909 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2910 //__pAddressbar->SetUrl(*pBookmarkUrl);
2911 SetUrl(*pBookmarkUrl);
2913 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2914 __pWebViewer->LoadUrl(*pBookmarkUrl);
2915 delete pBookmarkUrl;
2918 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2919 Bitmap* pBitmap = null;
2920 if (isPrivateBrowsing == true)
2922 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2924 if (__pWebViewer != null)
2926 __pWebViewer->SetPrivateBrowsingEnabled(true);
2929 if (__pAddressbar != null)
2931 // __pAddressbar->UpdateFaviconBitmap(true);
2937 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2939 if (__pWebViewer != null)
2941 __pWebViewer->SetPrivateBrowsingEnabled(false);
2944 if (__pAddressbar != null)
2946 // __pAddressbar->UpdateFaviconBitmap(false);
2950 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2952 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2954 else if (__pOptionMenu != null )
2956 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2959 if (pBitmap != null)
2964 RelayoutControls(false);
2965 AppLog("ABC: OnSceneActivatedN started exit");
2967 AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight());
2972 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2973 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2975 Canvas* pWebCanvas = null;
2976 if (__pWebViewer != null)
2978 pWebCanvas = __pWebViewer->GetCanvasN();
2981 if (pWebCanvas == null)
2985 if (__pWindowInfo != null)
2987 if (__pWindowInfo->pWebCanvasBitmap != null)
2989 delete __pWindowInfo->pWebCanvasBitmap;
2991 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2992 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2993 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2995 Bitmap* pBitmap = GetCapturedBitmapN();
2996 AppLog("Coming here");
2997 Canvas* pCanvas = new(std::nothrow) Canvas();
2998 pCanvas->Construct(GetClientAreaBounds());
3001 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
3004 if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
3005 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
3007 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
3010 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
3015 __pAddressbar->SetShowState(false);
3016 AppLog("Coming here");
3020 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
3021 const Tizen::Base::String& realm,
3022 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
3028 MainForm::OnHttpAuthenticationCanceled(void)
3033 MainForm::OnLoadingStarted(void)
3035 AppLogDebug("MainForm::OnLoadingStarted entered");
3037 if(__pAddressbar == NULL || __pWebViewer == null)
3042 // this is added in case if menu is opened and user load the page
3043 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
3045 __pOptionMenu->SetShowState(false);
3046 __pOptionMenu->Invalidate(true);
3051 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3053 __pImageMenu->SetShowState(false);
3054 __pImageMenu->Invalidate(true);
3056 String url = __pWebViewer->GetUrl();
3057 if(url.Contains(IDS_TIZEN_SERVICE))
3060 String delim(L":;,");
3062 // Creates a StringTokenizer instance
3063 StringTokenizer strTok(url, delim);
3065 int count = strTok.GetTokenCount(); // count == 4
3067 HashMap *pMap = new HashMap();
3072 while (strTok.HasMoreTokens())
3074 AppLog("Token: %ls", token.GetPointer());
3075 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3076 if(token.Contains(IDS_APPID))
3078 token.SubString(6, appId);
3079 AppLog("AppID:%ls", appId.GetPointer());
3081 else if(token.Contains(IDS_KEY))
3083 token.SubString(4, key);
3084 AppLog("key:%ls", key.GetPointer());
3086 else if(token.Contains(IDS_VALUE))
3088 token.SubString(6, value);
3089 AppLog("value:%ls", value.GetPointer());
3092 pMap->Add(key, value);
3096 AppControl *pAppControl = null;
3097 String operationId = L"http://tizen.org/appcontrol/operation/main";
3098 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3101 AppLog("Starting AppControl");
3102 result r = pAppControl->Start(null, null, pMap, null);
3103 AppLog("Result of Start %s", GetErrorMessage(r));
3107 AppLogException("AppControl not found");
3112 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3114 __pAddressbar->SetShowState(false);
3115 AddressBarCancelledClicked(*__pAddressbar);
3116 __pAddressbar->Invalidate(true);
3118 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3121 __pAddressbar->SetFaviconBitmap(*pBitmap);
3124 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3126 // updating the address bar position with respect to web control
3127 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3128 __distanceMoved = 0;
3132 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3133 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3134 if (__pWebViewer != null)
3136 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3137 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3138 SetUrl(__pWebViewer->GetUrl());
3139 if (__pWindowInfo != NULL)
3141 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3142 // __pWindowInfo->pageTitle = L"";
3143 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3145 __pAddressbar->Invalidate(true);
3151 MainForm::OnLoadingCanceled(void)
3157 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3159 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3164 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3166 AppLog("XYZ::MainForm::OnKeypadOpened");
3167 __isKeypadOpened = true;
3168 __pFooterPanel->SetShowState(false);
3169 RelayoutControls(false);
3173 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3175 AppLog("XYZ::MainForm::OnKeypadClosed");
3176 __isKeypadOpened = false;
3177 __pFooterPanel->SetShowState(true);
3178 RelayoutControls(true);
3182 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3184 AppLog("XYZ::KeypadBoundsChanged");
3185 RelayoutControls(false);
3189 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3190 const Tizen::Base::String& reason)
3192 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3196 MainForm::OnLoadingCompleted(void)
3198 AppLog("MainForm::OnLoadingCompleted start");
3200 result r = E_SUCCESS;
3202 if (__pWebViewer == null)
3207 if (__pAddressbar == null)
3212 if(__pWindowInfo && __pWebViewer)
3213 __pWindowInfo->pageTitle = __pWebViewer->GetTitle();
3214 if(__pImageMenu && __pImageMenu->GetShowState())
3216 __pImageMenu->SetShowState(false);
3217 __pImageMenu->Invalidate(true);
3220 if (__pWebViewer->CanGoForward())
3222 //__pAddressbar->SetForwardButtonEnabled(true);
3223 SetForwardButtonEnabled(true);
3227 //__pAddressbar->SetForwardButtonEnabled(false);
3228 SetForwardButtonEnabled(false);
3231 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3233 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3235 //__pAddressbar->UpdateProgress(0);
3239 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3241 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3245 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3246 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3247 if (isPrivateBrowsing == false)
3249 if(__pHistory != null)
3255 __pHistory = new(std::nothrow) History;
3256 HistoryPresentationModel::GetCurrentDateTime(date);
3259 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3260 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3262 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3263 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3265 __pHistory->SetVisitedTime(date);
3267 if (__pWebViewer != null)
3269 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3271 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3272 if (pTempBitmap != null)
3274 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3275 __pHistory->SetFavIconBitmap(*pTempBitmap);
3280 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3281 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3282 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3284 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3285 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3286 __pHistory->SetThumbnail(pBitmap);
3288 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3291 Tizen::Graphics::BufferInfo bmpInfo;
3292 pFavIcon->Lock(bmpInfo);
3293 AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height);
3295 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3297 AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight());
3298 __pHistory->SetFavIconBitmap(*pFavIcon);
3302 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3309 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3311 // temperary fixed (webpage can be not loaded)
3315 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3316 if (isReaderEnabled == true)
3320 delete __pReaderData;
3321 __pReaderData = null;
3323 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3324 filePath.Append(L"data/reader.js");
3330 result r = E_SUCCESS;
3331 FileAttributes attr;
3333 File::GetAttributes(filePath,attr);
3335 r = file.Construct(filePath, L"r+");
3338 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3341 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3344 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3347 // file.Read(pScript,attr.GetFileSize());
3349 // AppLogDebug("scipt length %d",strlen(pScript));
3350 String strScript = L"";
3351 // strScript.Append(pScript);
3352 // for(int i=0; i<25; i++)
3354 file.Read(pScript,attr.GetFileSize());
3355 // AppLog("xyzz tell %d",file.Tell());
3356 // r = strScript.Append(pScript);
3357 // AppLog("xyzz append result %s",GetErrorMessage(r));
3358 // AppLog("xyzz strScript length %d",strScript.GetLength());
3360 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3362 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3363 if (__pReaderData == null)
3365 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3366 __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>");
3369 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3370 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3372 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3373 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3379 AppLog("MainForm::OnLoadingCompleted done");
3383 MainForm::OnEstimatedProgress(int progress)
3385 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3387 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3388 progress = DEFAULT_PROGRESS_PERCENTAGE;
3390 // __pAddressbar->UpdateProgress(progress);
3391 UpdateProgress(progress);
3394 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3396 AppLog("MainForm::OnFaviconReceived");
3397 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3399 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3402 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3409 MainForm::OnUrlValueChanged(Addressbar&)
3415 MainForm::OnUrlSubmitted(Addressbar& addBar)
3417 AppLog("MainForm::OnUrlSubmitted");
3418 String url = addBar.GetUrl();
3419 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3421 if(__pFooterUrlField)
3422 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3423 AddressBarCancelledClicked(*__pAddressbar);
3428 MainForm::LoadUrl(String& url)
3432 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3433 AppLogDebug("MainForm::LoadUrl enter");
3435 if (__pWebViewer != null)
3437 __pWebViewer->SetShowState(true);
3438 __pWebViewer->Invalidate(true);
3441 if (url.CompareTo(L"") == 0)
3445 if(__pFooterPanel != null)
3447 __pFooterPanel->SetShowState(true);
3448 __pFooterPanel->Invalidate(true);
3455 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3456 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)
3458 RegularExpression firstRegex;
3459 RegularExpression secondRegex;
3461 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3462 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3465 ret = firstRegex.Match(url, false); // This returns true value
3466 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3468 if (ret == true && __pWebViewer != null)
3471 __pWebViewer->LoadUrl(url);
3473 else if(__pWebViewer != null)
3475 String tempUrl = L"http://";
3476 tempUrl.Append(url);
3480 __pWebViewer->LoadUrl(tempUrl);
3484 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3485 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3488 if (__pAddressbar != null)
3490 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3491 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3494 AppLogDebug("MainForm::LoadUrl exit");
3501 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3503 AppLog("MainForm::OnFocusGained");
3506 __pFooterPanel->SetShowState(false);
3511 __pWebViewer->ReleaseBlock();
3516 __pAddressbar->SetShowState(true);
3517 __pAddressbar->SetAddressbarURLFocus();
3519 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3521 __currentSearchStr = L"";
3522 __currentWordIndex = 0;
3523 __maxOccurrances = 0;
3525 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3527 __pFindWordEditField->SetText(L"");
3528 __pFindWordEditField->HideKeypad();
3529 __pFindWordControl->SetShowState(false);
3530 __pFindWordCountLabel->SetText(L"0/0");
3532 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3534 __pFindWordEditFieldRightToLeft->SetText(L"");
3535 __pFindWordEditFieldRightToLeft->HideKeypad();
3536 __pFindWordControl->SetShowState(false);
3537 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3540 __pFindWordNext->SetEnabled(false);
3541 __pFindWordPrev->SetEnabled(false);
3544 __pWebViewer->SearchTextAllAsync(L"",true);
3545 __pFindWordControl->SetShowState(false);
3547 RelayoutControls(false);
3551 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3553 AppLog("MainForm::OnFocusLost called");
3557 MainForm::OnStopClicked(Addressbar& addBar)
3559 AppLogDebug("MainForm::OnStopClicked called");
3562 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3563 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3564 __pWebViewer->StopLoading();
3565 RequestRedraw(true);
3570 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3572 // AppLog("MainForm::OnBackClicked");
3573 result r = E_FAILURE;
3574 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3576 AppLog("Hiding the menu");
3577 __pImageMenu->SetShowState(false);
3580 if (__pWebViewer && __pWebViewer->CanGoBack())
3582 __pWebViewer->GoBack();
3584 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3587 pApp = UiApp::GetInstance();
3590 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3593 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3601 WindowInfo* pWindowInfo = null;
3603 SceneManager* pSceneManager = SceneManager::GetInstance();
3604 if (pSceneManager == null)
3608 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3609 if (pAllWindowList == NULL)
3611 pApp = UiApp::GetInstance();
3614 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3617 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3622 if (pAllWindowList != null)
3624 totalCount = pAllWindowList->GetCount();
3626 for (int count = 0; count < totalCount; count++)
3628 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3629 if (pWindowInfo == null)
3631 pApp = UiApp::GetInstance();
3634 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3637 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3642 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3644 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3647 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3650 r = pAllWindowList->RemoveAt(count, true);
3651 __pWindowInfo = null;
3654 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3659 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3661 else if(pAllWindowList->GetCount() > 0)
3663 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3667 pApp = UiApp::GetInstance();
3670 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3675 if (pWindowInfo == null)
3677 pApp = UiApp::GetInstance();
3680 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3686 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3687 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3690 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3704 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3706 AppLog("MainForm::OnForwardClicked");
3707 if (__pWebViewer == null)
3710 if (__pWebViewer->CanGoForward())
3712 __pWebViewer->GoForward();
3717 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3719 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3720 if(__pFooterPanel != null)
3722 __pFooterPanel->SetShowState(false);
3725 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3727 __pAddressbar->SetShowState(true);
3728 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3731 RelayoutControls(false);
3735 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3737 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3739 int Height = GetClientAreaBounds().height;
3740 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3742 RelayoutControls(false);
3746 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3748 AddressBarCancelledClicked(addBar);
3752 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3754 __prevAddressBarMode = __curAddressBarMode;
3756 if (__pAddressbar != null)
3758 __curAddressBarMode = GetAddressbarMode();
3761 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3763 __adressPanelPosition.y = 0;
3764 if (__pAddressbar != null)
3766 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3767 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
3768 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3769 __pAddressbar->Invalidate(true);
3771 if (__pWebViewer != null)
3773 __pWebViewer->StopLoading();
3776 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3778 __adressPanelPosition.y = 0;
3779 if (__pAddressbar != null)
3781 __webControlPosition.y = 0;
3782 __webControlPositionF.y = 0.0f;
3783 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3784 __pAddressbar->Invalidate(true);
3790 MainForm::OnClipboardClosed(const Addressbar& addBar)
3792 AppLog("XYZ::MainForm::OnClipboardClosed");
3793 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3795 AppLog("akjshdasd 3");
3796 __pFooterPanel->SetShowState(true);
3798 __isKeypadOpened = false;
3799 RelayoutControls(false);
3803 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3805 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3806 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3808 AppLog("akjshdasd 3");
3809 __pFooterPanel->SetShowState(true);
3811 __isKeypadOpened = false;
3812 if(__pNotification && __pNotification->GetShowState())
3814 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3817 RelayoutControls(false,footerState);
3821 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3823 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3824 __isKeypadOpened = true;
3825 if(__pNotification && __pNotification->GetShowState())
3827 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3829 RelayoutControls(false);
3833 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3835 __isKeypadOpened = true;
3836 __pFooterPanel->SetShowState(false);
3840 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3842 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3843 RelayoutControls(false);
3847 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3849 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3852 __pWindowInfo->pageTitle = title;
3853 if (__pWebViewer != null)
3855 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3856 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3859 if (__pAddressbar != null && __pWebViewer != null)
3861 SetUrl(__pWebViewer->GetUrl());
3862 __pAddressbar->Invalidate(true);
3867 MainForm::UpdateFavicon(void)
3869 bool urlImageType = false;
3870 String *tempPath = null;
3872 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();");
3873 Bitmap* pBitmap = null;
3875 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3877 if (__pWindowInfo != null)
3880 url.SetUri(*tempPath);
3881 if (url.GetHost().GetLength() == 0)
3885 webUrl.SetUri(__pWebViewer->GetUrl());
3886 result r = url.SetHost(webUrl.GetHost());
3893 if (url.GetScheme().GetLength() == 0)
3897 webUrl.SetUri(__pWebViewer->GetUrl());
3898 url.SetScheme(webUrl.GetScheme());
3900 __pWindowInfo->faviconUrl = url.ToString();
3902 pBitmap = __pWebViewer->GetFaviconN();
3904 if (pBitmap != null)
3906 if (__pWindowInfo->pFavicon != NULL)
3908 __pWindowInfo->pFavicon = null;
3910 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3911 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3913 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3915 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3917 else if(__pWindowInfo->pFavicon != null)
3919 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3923 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3924 if(pDefaultBmp != null)
3926 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3940 if(tempPath != null)
3944 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3950 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3951 Tizen::Web::Controls::WebNavigationType type)
3953 AppLog("urlk %ls",url.GetPointer());
3954 // when load new page if find word panel is open its show state is false
3955 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3957 __currentSearchStr = L"";
3958 __currentWordIndex = 0;
3959 __maxOccurrances = 0;
3960 __pFindWordEditField->SetText(L"");
3961 __pFindWordNext->SetEnabled(false);
3962 __pFindWordPrev->SetEnabled(false);
3963 __pFindWordCountLabel->SetText(L"0/0");
3964 __pFindWordControl->SetShowState(false);
3965 __pFindWordEditField->HideKeypad();
3966 RelayoutControls(false);
3969 __pFooterPanel->Invalidate(true);
3972 uriInfo.SetUri(url);
3974 if(url.Contains(IDS_TIZEN_SERVICE))
3977 String delim(L":;,");
3979 // Creates a StringTokenizer instance
3980 StringTokenizer strTok(url, delim);
3982 int count = strTok.GetTokenCount(); // count == 4
3984 HashMap *pMap = new HashMap();
3990 while (strTok.HasMoreTokens())
3992 AppLog("Token: %ls", token.GetPointer());
3993 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3994 if(token.Contains(IDS_APPID))
3996 token.SubString(6, appId);
3997 AppLog("AppID:%ls", appId.GetPointer());
3999 else if(token.Contains(IDS_KEY))
4001 token.SubString(4, key);
4002 AppLog("key:%ls", key.GetPointer());
4004 else if(token.Contains(IDS_VALUE))
4006 token.SubString(6, value);
4007 AppLog("value:%ls", value.GetPointer());
4010 pMap->Add(key, value);
4014 AppControl *pAppControl = null;
4015 String operationId = L"http://tizen.org/appcontrol/operation/main";
4016 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
4019 result r = pAppControl->Start(null, null, pMap, null);
4023 AppLogException("AppControl not found");
4033 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
4034 const Tizen::Net::Http::HttpHeader& httpHeader)
4036 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
4040 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4042 AppLog("LMN::MainForm::OnWebPageBlockSelected");
4043 // if(__isLongPressedDone == false)
4046 if (__pHitElementResult != null)
4048 delete __pHitElementResult;
4049 __pHitElementResult = null;
4052 if (__pWebViewer != null)
4054 AppLog("MainForm::OnWebPageBlockSelected web not null");
4055 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4057 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4059 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4060 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4061 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4063 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4064 if(__pHitElementResult == null)
4066 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4069 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4073 if (__pHitElementResult == null)
4078 if (__pHitElementResult->HasImage() != true)
4080 String tagName = __pHitElementResult->GetTagName();
4081 String type = __pHitElementResult->GetAttributeValue("type");
4082 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
4085 AppLog("TagName %ls",tagName.GetPointer());
4086 __currentSelectedStr.Clear();
4087 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4088 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4089 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4090 if(tagName.Equals(L"TEXTAREA",false) == true)
4092 AppLog("Tagnameseemstobe TEXTAREA");
4094 else if(tagName.Equals(L"INPUT",false) == true)
4096 AppLog("Tagnameseemstobe INPUT");
4099 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 )
4101 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4103 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true);
4106 __pImageMenu->SetShowState(true);
4107 __pImageMenu->Show();
4108 __pImageMenu->Invalidate(true);
4111 else /*if(__isLongPressedDone == true)*/
4113 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4115 if(__pHitElementResult->GetUrl().GetLength() > 0)
4117 __currentSelectedStr.Clear();
4118 __currentSelectedStr = __pHitElementResult->GetUrl();
4120 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false);
4123 __pImageMenu->SetShowState(true);
4124 __pImageMenu->Show();
4125 __pImageMenu->Invalidate(true);
4129 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4130 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4131 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4137 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4143 MainForm::OnWebWindowCreateRequested(void)
4145 AppLog("MainForm::OnWebWindowCreateRequested entered");
4146 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4148 if (pNewWindowInfo == null)
4152 result r = E_SUCCESS;
4153 SceneManager* pSceneManager = SceneManager::GetInstance();
4154 if (pSceneManager == NULL)
4158 ArrayList* pArgList = new(std::nothrow) ArrayList();
4159 if (pArgList == NULL)
4163 r = pArgList->Construct();
4166 pNewWindowInfo->isJavascriptInitiated = true;
4167 pArgList->Add(*pNewWindowInfo);
4168 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4172 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4179 return pNewWindowInfo->pCurrentWeb;
4183 MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4185 AppLog("OnWebWindowCloseRequested");
4186 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4187 SceneManager* pSceneManager = SceneManager::GetInstance();
4188 WindowInfo* pWindowInfo = null;
4189 WindowInfo* pNewWindowInfo = null;
4192 result r = E_FAILURE;
4194 if (pAllWindowList != null)
4196 totalCount = pAllWindowList->GetCount();
4199 for (int count = 0; count < totalCount; count++)
4201 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4203 if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID)
4205 r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID);
4206 r = pAllWindowList->RemoveAt(count, true);
4208 Form* pCurrentForm = null;
4209 if(SceneManager::GetInstance()->GetCurrentScene() != null)
4210 pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
4213 pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null);
4216 if (pAllWindowList->GetCount() > 0)
4218 pNewWindowInfo = null;
4219 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4223 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4225 if (pNewWindowInfo == null)
4229 result r = E_SUCCESS;
4230 SceneManager* pSceneManager = SceneManager::GetInstance();
4231 if (pSceneManager == NULL)
4235 ArrayList* pArgList = new(std::nothrow) ArrayList();
4236 if (pArgList == NULL)
4240 r = pArgList->Construct();
4243 pArgList->Add(*pNewWindowInfo);
4244 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4245 if (pArgList != null)
4252 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4257 pApp = UiApp::GetInstance();
4260 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4265 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4276 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4278 AppLog("xyz:: MainForm::RelayoutControls called");
4279 __webControlPosition.y = 0;
4280 __webControlPositionF.y = 0.0f;
4281 __webControlHeight = GetClientAreaBounds().height;
4282 __webControlHeightF = GetClientAreaBoundsF().height;
4283 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4285 AppLog("Client area height: %d", __webControlHeight);
4286 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4288 __webControlPosition.y += __pAddressbar->GetHeight();
4289 __webControlPositionF.y += __pAddressbar->GetHeightF();
4290 __webControlHeight -= __pAddressbar->GetHeight();
4291 __webControlHeightF -= __pAddressbar->GetHeightF();
4292 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4294 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4296 __webControlPosition.y += __pFindWordControl->GetHeight();
4297 __webControlPositionF.y += __pFindWordControl->GetHeightF();
4298 __webControlHeight -= __pFindWordControl->GetHeight();
4299 __webControlHeightF -= __pFindWordControl->GetHeightF();
4300 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4303 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4305 __webControlHeight -= __pFooterPanel->GetHeight();
4306 __webControlHeightF -= __pFooterPanel->GetHeightF();
4308 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0F, __webControlPositionF.y + __webControlHeightF, GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF())));
4309 __webControlHeight = __webControlHeight + 12;
4310 __webControlHeightF = __webControlHeightF + 12.0f;
4315 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4317 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4322 __pWebViewer->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0f, __webControlPositionF.y, GetClientAreaBoundsF().width, __webControlHeightF)));
4323 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4324 __pWebViewer->Invalidate(false);
4328 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4330 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4337 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4339 if (__pFindWordControl == null)
4344 Tizen::Locales::LocaleManager localeManager;
4345 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4347 String languageCode;
4348 result r = SettingInfo::GetValue(L"Language", languageCode);
4349 // int languagecode = local.GetLanguageCode();
4350 AppLog("rahul language is %S", languageCode.GetPointer());
4354 InitFindWordPanel();
4356 if (languageCode.CompareTo("ara") == 0)
4358 AppLog("rahul language is arabic");
4360 __pFindWordPanelLeftToRight->SetShowState(false);
4361 __pFindWordPanelRightToLeft->SetShowState(true);
4363 __pFindWordClear->SetShowState(false);
4364 __pFindWordCountLabel->SetShowState(false);
4365 __pFindWordEditField->SetShowState(false);
4367 __pFindWordClearRightToLeft->SetShowState(true);
4368 __pFindWordCountLabelRightToLeft->SetShowState(true);
4369 __pFindWordEditFieldRightToLeft->SetShowState(true);
4373 AppLog("rahul language is not arabic");
4376 __pFindWordPanelLeftToRight->SetShowState(true);
4377 __pFindWordPanelRightToLeft->SetShowState(false);
4379 __pFindWordClear->SetShowState(true);
4380 __pFindWordCountLabel->SetShowState(true);
4381 __pFindWordEditField->SetShowState(true);
4383 __pFindWordClearRightToLeft->SetShowState(false);
4384 __pFindWordCountLabelRightToLeft->SetShowState(false);
4385 __pFindWordEditFieldRightToLeft->SetShowState(false);
4387 __pFindWordControl->SetShowState(true);
4391 if(__pFindWordControl != null)
4393 __pFindWordControl->SetShowState(false);
4397 AppLog("MainForm::ShowFindWordPanel %d",show);
4398 if (show && !isTouchPressed)
4400 if (languageCode.CompareTo("ara") == 0)
4402 if (__pFindWordEditFieldRightToLeft)
4404 __pFindWordEditFieldRightToLeft->SetFocus();
4405 __pFindWordEditFieldRightToLeft->ShowKeypad();
4410 if (__pFindWordEditField)
4412 __pFindWordEditField->SetFocus();
4413 __pFindWordEditField->ShowKeypad();
4419 if (languageCode.CompareTo("ara") == 0)
4421 if (__pFindWordEditFieldRightToLeft)
4422 __pFindWordEditFieldRightToLeft->HideKeypad();
4426 if (__pFindWordEditField)
4427 __pFindWordEditField->HideKeypad();
4431 RelayoutControls(false);
4435 MainForm::StartWordSearch()
4437 //Get the count of occurances of the word in the current page
4438 __maxOccurrances = 0;
4439 __currentWordIndex = 0;
4441 __pFindWordPrev->SetEnabled(false);
4442 String *pCountStr = null;
4445 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4446 AppLog("Search Result %s",GetErrorMessage(r));
4449 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4450 if (pCountStr != null)
4452 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4456 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4461 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4463 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4464 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4468 if (__pFindWordCountLabel)
4470 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4472 if (__pFindWordEditField)
4474 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4477 else if(totalCount >= 100)
4479 if (__pFindWordCountLabel)
4481 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4483 if (__pFindWordEditField)
4485 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4490 if (__pFindWordCountLabel)
4492 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4494 if (__pFindWordEditField)
4496 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4500 __maxOccurrances = totalCount;
4501 __currentWordIndex = currentOrdinal;
4503 //Reset the UI controls as per the maxOccurrance value
4504 if (totalCount <= 0)
4506 AppLog("Word not found");
4507 //Show error notification to user
4509 __pFindWordNext->SetEnabled(false);
4510 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4512 __pFindWordCountLabel->SetText(L"0/0");
4513 __pFindWordCountLabel->Invalidate(false);
4515 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4517 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4518 __pFindWordCountLabelRightToLeft->Invalidate(false);
4521 __pFindWordNext->Invalidate(false);
4522 __pFindWordPrev->Invalidate(false);
4527 if (totalCount == 1 || totalCount == currentOrdinal)
4530 __pFindWordNext->SetEnabled(false);
4535 __pFindWordNext->SetEnabled(true);
4538 String countStr = L"";
4539 countStr.Append(__currentWordIndex);
4540 countStr.Append(L"/");
4541 countStr.Append(__maxOccurrances);
4542 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4544 __pFindWordCountLabel->SetText(countStr);
4545 __pFindWordCountLabel->Invalidate(false);
4546 __pFindWordCountLabel->Invalidate(false);
4548 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4550 __pFindWordCountLabelRightToLeft->SetText(countStr);
4551 __pFindWordCountLabelRightToLeft->Invalidate(false);
4552 __pFindWordCountLabelRightToLeft->Invalidate(false);
4554 if (__pFindWordNext)
4556 __pFindWordNext->Invalidate(false);
4558 if (__pFindWordPrev)
4560 __pFindWordPrev->Invalidate(false);
4566 MainForm::FindNextWord(bool next)
4570 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4571 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4573 if (__currentWordIndex < __maxOccurrances)
4575 __currentWordIndex++;
4581 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4582 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4584 if(__currentWordIndex > 1)
4586 __currentWordIndex--;
4591 String countStr = L"";
4592 countStr.Append(__currentWordIndex);
4593 countStr.Append(L"/");
4594 countStr.Append(__maxOccurrances);
4596 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4598 __pFindWordCountLabel->SetText(countStr);
4599 __pFindWordCountLabel->Invalidate(false);
4601 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4603 __pFindWordCountLabelRightToLeft->SetText(countStr);
4604 __pFindWordCountLabelRightToLeft->Invalidate(false);
4607 if (__currentWordIndex >= __maxOccurrances)
4609 __pFindWordNext->SetEnabled(false);
4613 __pFindWordNext->SetEnabled(true);
4615 if (__currentWordIndex <= 1)
4617 __pFindWordPrev->SetEnabled(false);
4621 __pFindWordPrev->SetEnabled(true);
4623 __pFindWordPrev->Invalidate(false);
4624 __pFindWordNext->Invalidate(false);
4626 __pFindWordControl->Invalidate(true);
4630 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4632 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4633 __isKeypadOpened = true;
4634 __pFooterPanel->SetShowState(false);
4635 // OnAddressBarKeypadOpened(*__pAddressbar);
4639 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4641 __isKeypadOpened = true;
4642 AppLog("xyz::MainForm::OnWebKeypadOpened");
4644 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4646 __currentSearchStr = L"";
4647 __currentWordIndex = 0;
4648 __maxOccurrances = 0;
4649 __pFindWordEditField->SetText(L"");
4650 __pFindWordNext->SetEnabled(false);
4651 __pFindWordPrev->SetEnabled(false);
4652 __pFindWordCountLabel->SetText(L"0/0");
4653 __pWebViewer->SearchTextAllAsync(L"",false);
4654 __pFindWordControl->SetShowState(false);
4655 __pFindWordEditField->HideKeypad();
4659 if (__pWebViewer != null && __pFooterPanel != null)
4661 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4662 if(__pAddressbar != null)
4664 __pAddressbar->SetShowState(false);
4666 if(__pFindWordControl != null)
4668 __pFindWordControl->SetShowState(false);
4670 __pFooterPanel->SetShowState(false);
4671 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4673 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4675 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4676 // AppLog("omgomgomg");
4682 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4684 AppLog("abcde::MainForm::OnWebKeypadClosed");
4685 AppLog("xyz::MainForm::OnWebKeypadClosed");
4686 AppLog("akjshdasd 4");
4687 __pFooterPanel->SetShowState(true);
4688 // OnAddressBarKeypadClosed(*__pAddressbar);
4689 RelayoutControls(false);
4690 __isKeypadOpened = false;
4693 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4695 AppLog("abcde: imagemenu visible.");
4698 __pWebViewer->GetBlockRange(p,q);
4699 if (p == Point(0,0) && q == Point(0,0))
4707 __pImageMenu->SetAnchorPosition(p);
4708 __pImageMenu->Show();
4714 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4716 // RelativeLayout(false);
4717 if(__pWebViewer != null)
4719 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4724 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4726 Control* temp = const_cast< Control* >(&source);
4727 Header* pHeader = dynamic_cast< Header* >(temp);
4728 if (pHeader != null)
4730 //Header double - clicked
4731 AppLog("Header double clicked");
4733 if(__pFindWordControl)
4735 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4736 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4740 AppLog("MainScene::OnTouchDoublePressed");
4744 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4746 AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4747 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4749 AppLog("Returning because of more than one touch point.");
4753 // __pWebViewer->ReleaseBlock();
4755 __pWebViewer->SetFocus();
4756 __longPressPoint = currentPosition;
4758 if (__pHitElementResult != null)
4760 delete __pHitElementResult;
4761 __pHitElementResult = null;
4764 if (__pWebViewer != null)
4766 AppLog("MainForm::OnTouchLongPressed web not null");
4767 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4770 if (__pHitElementResult == null)
4775 if (__pHitElementResult->HasImage() == true)
4777 if(__pWebViewer != null)
4779 __pWebViewer->ReleaseBlock();//N_SE-52389
4780 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4782 __pImageMenu->SetShowState(true);
4783 __pImageMenu->Show();
4784 __pImageMenu->Invalidate(true);
4786 else if(__pHitElementResult->HasUrl() == true)
4788 if(__pWebViewer != null)
4789 __pWebViewer->ReleaseBlock();//N_SE-52389
4790 String tempURl = __pHitElementResult->GetUrl();
4791 AppLog("tempURl is %ls", tempURl.GetPointer());
4792 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4793 if (pBitmap != null)
4801 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4802 __pImageMenu->SetShowState(true);
4803 __pImageMenu->Show();
4804 __pImageMenu->Invalidate(true);
4808 String tagName = __pHitElementResult->GetTagName();
4809 String type = __pHitElementResult->GetAttributeValue("type");
4810 String value = __pHitElementResult->GetAttributeValue(L"value");
4811 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4812 result r = E_FAILURE;
4813 __currentSelectedStr.Clear();
4814 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4816 AppLog("tag name is %ls", tagName.GetPointer());
4817 AppLog("type is %ls", type.GetPointer());
4821 __isLongPressedDone = true;
4822 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)
4823 r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4824 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)
4826 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4828 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4831 __pImageMenu->SetShowState(true);
4832 __pImageMenu->Show();
4833 __pImageMenu->Invalidate(true);
4836 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4839 // __inputEventToBeSupressed = true;
4843 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4845 AppLog("xyz:: MainForm::OnTouchReleased called");
4847 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4849 __pAddressbar->SetShowState(false);
4851 if(__pFooterPanel && __isKeypadOpened == false)
4853 __pFooterPanel->SetShowState(true);
4857 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4858 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4860 __pWebViewer->ConsumeInputEvent();
4862 if(pHitElement != null)
4866 __inputEventToBeSupressed = false;*/
4870 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4877 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4879 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4881 __currentSearchStr = L"";
4882 __currentWordIndex = 0;
4883 __maxOccurrances = 0;
4885 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4887 __pFindWordEditField->SetText(L"");
4888 __pFindWordEditField->HideKeypad();
4889 __pFindWordControl->SetShowState(false);
4890 __pFindWordCountLabel->SetText(L"0/0");
4892 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4894 __pFindWordEditFieldRightToLeft->SetText(L"");
4895 __pFindWordEditFieldRightToLeft->HideKeypad();
4896 __pFindWordControl->SetShowState(false);
4897 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4900 __pFindWordNext->SetEnabled(false);
4901 __pFindWordPrev->SetEnabled(false);
4903 __pWebViewer->SearchTextAllAsync(L"",true);
4904 __pFindWordControl->SetShowState(false);
4906 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4907 if(__pAddressbar->GetShowState() == false)
4909 __pAddressbar->SetAddressbarURLFocus();
4910 __pFooterPanel->SetShowState(false);
4917 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4923 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4929 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4935 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4941 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4947 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4949 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4950 int widthContextItem = 0;
4951 //if(__pFindWordCountLabel)
4952 // __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4953 // As per the platform engineer comment removed this line
4954 /*if(__pWebViewer != null)
4956 // 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
4957 __pWebViewer->ReleaseBlock();
4960 // if(__pFindWordControl != null)
4961 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4963 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4965 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4967 AppLog(" Orientation landscape");
4968 __pOptionMenu->SetMaxVisibleItemsCount(5);
4972 AppLog(" Orientation potrait");
4973 __pOptionMenu->SetMaxVisibleItemsCount(6);
4976 if(__pNotification && __pNotification->GetShowState() == true)
4978 __pNotification->SetShowState(false);
4979 __pNotification->Invalidate(false);
4981 if ( __pFooterLabel != null)
4983 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4986 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4992 if (__pFindWordBgLabel != null)
4994 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4995 if (pBitmap != null)
4997 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
5002 if (__pFindWordBgLabelRightToLeft != null)
5004 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
5005 if (pBitmap != null)
5007 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
5013 // if(__pOptionMenu != null)
5014 // __pOptionMenu->SetShowState(false);
5016 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5018 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
5022 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
5027 AppLog("__pFooterPanel->GetShowState() is true");
5029 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0, GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(), __pFooterPanel->GetWidthF(), __pFooterPanel->GetHeightF())));
5030 __pFooterPanel->Invalidate(true);
5034 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
5035 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
5037 InitMostVisitedSitesView(orientationStatus);
5040 RelayoutControls(false);
5041 if (__pArticleReaderPanel != null)
5043 if (__pArticleReaderPanel->GetShowState() == true)
5045 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
5047 if (__pBlankPanel != null)
5048 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
5050 if (__pWebReader != null)
5052 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
5054 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5055 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5057 if ( pBitmap != null && pSrcBitmap != null)
5059 AppLog("CreateReaderPanel ninepatchbitmap found");
5060 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
5063 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
5064 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
5065 if (pBitmap != null)
5070 if (pSrcBitmap != null)
5079 if (__pAddressbar != null)
5081 int width = GetClientAreaBounds().width;
5082 __pAddressbar->OrientationChanged(width);
5087 MainForm::OnSettingsChange(int settingvalue)
5089 AppLogDebug("MainForm::OnSettingsChange entered");
5091 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
5093 __pAddressbar->ResetGuideText();
5095 if (__pWebViewer == null)
5097 AppLogDebug("Webviewer is not initialized yet.");
5101 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5103 WebSetting settings = __pWebViewer->GetSetting();
5104 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5106 settings.SetAutoFittingEnabled(true);
5108 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5110 settings.SetAutoFittingEnabled(false);
5112 __pWebViewer->SetSetting(settings);
5115 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5117 WebSetting settings = __pWebViewer->GetSetting();
5118 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5119 __pWebViewer->SetSetting(settings);
5121 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5123 WebSetting settings = __pWebViewer->GetSetting();
5124 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5125 __pWebViewer->SetSetting(settings);
5126 __pWebViewer->Reload();
5128 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5130 WebSetting settings = __pWebViewer->GetSetting();
5131 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5132 __pWebViewer->SetSetting(settings);
5134 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5138 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5141 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5145 WebSetting settings = __pWebViewer->GetSetting();
5146 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5147 __pWebViewer->SetSetting(settings);
5150 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5154 WebSetting settings = __pWebViewer->GetSetting();
5155 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5156 __pWebViewer->SetSetting(settings);
5159 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5161 WebSetting settings = __pWebViewer->GetSetting();
5162 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5164 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5168 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5170 __pWebViewer->SetSetting(settings);
5172 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5176 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5177 WebSetting settings = __pWebReader->GetSetting();
5178 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5179 __pWebReader->SetSetting(settings);
5185 MainForm::OnSettingsReset()
5189 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5190 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5195 MainForm::OnClearCache()
5197 result r = E_SUCCESS;
5199 if (__pWebViewer != NULL)
5201 r = __pWebViewer->ClearCache();
5204 AppLogDebug("Cache cleared success");
5208 AppLogDebug("Cache cleared fail");
5214 MainForm::OnClearCookie()
5216 result r = E_SUCCESS;
5218 if (__pWebViewer != NULL)
5220 __pWebViewer->ClearCookie();
5224 AppLogDebug("Cookie cleared success");
5228 AppLogDebug("Cache cleared fail");
5233 MainForm::OnClearFormData()
5235 result r = E_SUCCESS;
5237 if (__pWebViewer != NULL)
5239 __pWebViewer->ClearFormData();
5243 AppLogDebug("Cookie cleared success");
5247 AppLogDebug("Cache cleared fail");
5252 MainForm::OnClearPasswords()
5254 result r = E_SUCCESS;
5256 if (__pWebViewer != NULL)
5258 __pWebViewer->ClearLoginFormData();
5262 AppLogDebug("Cookie cleared success");
5266 AppLogDebug("Cache cleared fail");
5272 MainForm::findDistance(int x1,int y1,int x2, int y2)
5274 int deltaX = Math::Abs(x2 - x1);
5275 int deltaY = Math::Abs(y2 - y1);
5276 double num = deltaX*deltaX + deltaY*deltaY;
5282 for (i = 0; i < 20; i++)
5284 x = (((x*x)+ num)/(2*x));
5295 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5297 AppLog("xyz:: MainForm::OnTouchPressed called");
5298 if(__pFindWordControl)
5300 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5301 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5303 __isLongPressedDone = false;
5308 IList* pList = null;
5309 pList = touch.GetTouchInfoListN(source);
5313 int count = pList->GetCount();
5316 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5317 __touchPoint1 = pTouchInfo->position;
5319 /*if (__pAddressbar != null)
5321 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5323 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5325 __pAddressbar->SaveAddressbarEditText();
5327 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5330 __pAddressbar->Invalidate(true);
5332 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5334 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5336 //__pAddressbar->SaveAddressbarEditText();
5338 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5341 else if (count == 2)
5343 AppLogDebug("MainForm::OnTouchPressed count is two");
5344 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5345 __touchPoint1 = pTouchInfo->position;
5347 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5348 __touchPoint2 = pTouchInfo->position;
5353 pList->RemoveAll(true);
5358 __pAddressbar->SetShowState(false);
5360 if(__pFooterPanel && __isKeypadOpened == false)
5362 __pFooterPanel->SetShowState(true);
5364 RelayoutControls(false);
5369 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5371 AppLog("LMN::MainForm::OnTouchMoved entered");
5372 // __currentWordIndex = 0;
5373 __isLongPressedDone = false;
5378 MainForm::MoveUiControls()
5383 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5385 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5387 if(__pFooterUrlField->GetTextLength() == 0)
5389 __pFooterUrlField->SetKeypadActionEnabled(false);
5393 __pFooterUrlField->SetKeypadActionEnabled(true);
5396 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5398 __currentSearchStr = __pFindWordEditField->GetText();
5399 if (__currentSearchStr.GetLength() > 0)
5401 __pFindWordCountLabel->SetShowState(true);
5405 // __pFindWordCountLabel->SetShowState(false);
5406 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5407 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5410 __pFindWordNext->SetEnabled(false);
5411 __pFindWordPrev->SetEnabled(false);
5412 __pFindWordNext->Invalidate(true);
5413 __pFindWordPrev->Invalidate(true);
5414 __pFindWordCountLabel->SetText(L"0/0");
5415 __pFindWordCountLabel->Invalidate(true);
5417 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5419 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5420 if (__currentSearchStr.GetLength() > 0)
5422 __pFindWordCountLabelRightToLeft->SetShowState(true);
5426 __pFindWordCountLabelRightToLeft->SetShowState(false);
5429 __pFindWordNext->SetEnabled(false);
5430 __pFindWordPrev->SetEnabled(false);
5431 __pFindWordNext->Invalidate(true);
5432 __pFindWordPrev->Invalidate(true);
5433 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5434 __pFindWordCountLabelRightToLeft->Invalidate(true);
5436 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5437 if (__currentSearchStr.GetLength() > 0)
5443 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5445 __currentSearchStr = L"";
5446 AppLogDebug("Enter something");
5451 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5458 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5460 if(__pWebViewer != null)
5463 AppLog("MainForm::InitMostVisitedSitesView");
5464 result r = E_SUCCESS;
5467 if (__pMostVisitedListView != null)
5472 if (__pMostVisitedListView != null)
5474 RemoveControl(__pMostVisitedListView);
5476 if(__pMostVisitedSites != null)
5478 __pMostVisitedSites->RemoveAll(true);
5481 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5483 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5484 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF();
5485 __pMostVisitedListView = new(std::nothrow) ListView();
5487 int height = GetClientAreaBounds().height;
5489 if(__pFooterPanel->GetShowState() == true)
5491 height = height - __pFooterPanel->GetHeight();
5493 if(__pAddressbar->GetShowState() == true)
5495 height -= __pAddressbar->GetHeight();
5498 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5502 delete __pMostVisitedListView;
5503 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5506 __pMostVisitedListView->SetItemProvider(*this);
5507 __pMostVisitedListView->AddListViewItemEventListener(*this);
5508 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5509 AddControl(__pMostVisitedListView);
5510 __pMostVisitedListView->UpdateList();
5517 MainForm::GetImagePath(void)
5521 String formattedTime;
5522 DateTime currentTime;
5523 LocaleManager localManager;
5524 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5526 localManager.Construct();
5527 Locale locale = localManager.GetSystemLocale();
5528 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5530 // Get date formatter
5531 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5535 pTimeFormatter->Format(currentTime, formattedTime);
5538 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5539 String delim(L" :");
5540 StringTokenizer strTok(formattedTime, delim);
5543 String str1("GMT+00");
5544 while (strTok.HasMoreTokens())
5546 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5547 if(token.Equals(str1))
5549 AppLog("token is %ls", token.GetPointer());
5550 imageName.Append(token);
5556 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5558 result r = E_FAILURE;
5559 AppLog("Content manager 1");
5560 ContentId contentId;
5561 ContentManager contentManager;
5562 r = contentManager.Construct();
5565 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5568 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5569 Tizen::Io::Directory::Create(contentPath,true);
5570 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5572 AppLog("Already exists");
5574 else if(GetLastResult() == E_SUCCESS)
5576 AppLog("created success");
5578 contentPath.Append(imageName);
5579 contentPath.Append(".jpg");
5580 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5581 ShowIndicatorNotification(L"Download Complete",contentPath);
5582 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5586 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5588 AppLogDebug("ENTER");
5590 NotificationRequest request;
5591 request.SetAlertText(messageText);
5592 request.SetTitleText(L"");
5593 request.SetAppMessage(contentPath);
5594 request.SetOngoingActivityType(ONGOING_ACTIVITY_TYPE_TEXT);
5595 request.SetNotificationStyle(NOTIFICATION_STYLE_THUMBNAIL);
5596 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5597 String homePath = pApp->GetAppRootPath();
5598 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5599 AppLog("The iconPath is : %ls", homePath.GetPointer());
5600 request.SetIconFilePath(iconPath);
5602 Tizen::Shell::NotificationManager notiMgr;
5603 notiMgr.Construct();
5604 notiMgr.NotifyOngoingActivity(request);
5605 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5610 MainForm::SetForwardButtonEnabled(bool isEnabled)
5612 __pGoForwardBtn->SetEnabled(isEnabled);
5613 __pGoForwardBtn->Invalidate(true);
5617 MainForm::SetBackButtonEnabled(bool isEnabled)
5619 __pGoBackBtn->SetEnabled(isEnabled);
5620 __pGoBackBtn->Invalidate(true);
5624 MainForm::UpdateProgress(int percentage)
5626 __progressPercentage = percentage;
5627 if (percentage == 0 || percentage == 100)
5629 __isLoadingData = false;
5630 if (percentage == 100)
5632 __isLoadingCompleted = true;
5633 __progressPercentage = 0;
5637 __isLoadingCompleted = false;
5642 __isLoadingData = true;
5644 UpdateProgressBitmap();
5648 MainForm::GetProgress(void)
5650 return __progressPercentage;
5654 MainForm::UpdateProgressBitmap(void)
5656 result r = E_SUCCESS;
5657 if (__pProgressbarLabel == null)
5659 int w = __pProgressbarLabel->GetWidth();
5660 int h = __pProgressbarLabel->GetHeight();
5662 int progressWidth = 0;
5663 Bitmap* pRetBitmap = null;
5665 if (__progressPercentage == 0 || __progressPercentage == 100)
5667 __pProgressbarLabel->SetShowState(false);
5668 __pProgressbarLabel->Invalidate(false);
5673 __pProgressbarLabel->SetShowState(true);
5674 __pProgressbarLabel->Invalidate(false);
5677 r = canvas.Construct(Rectangle(0, 0, w, h));
5681 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5686 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5690 pBgBmp->Scale(Dimension(w, h));
5691 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5695 progressWidth = (double) (w) * __progressPercentage / 100;
5696 AppLogDebug("progressWidth: %d", progressWidth);
5697 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5699 if (pProgressBmp != null)
5701 pProgressBmp->Scale(Dimension(progressWidth, h));
5702 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5703 delete pProgressBmp;
5706 pRetBitmap = new (std::nothrow) Bitmap();
5708 if (pRetBitmap == null)
5710 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5714 pRetBitmap->Construct(canvas, canvas.GetBounds());
5716 if (__pProgressbarLabel != null && pRetBitmap != null)
5718 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5719 __pProgressbarLabel->Invalidate(false);
5722 if (pRetBitmap != null)
5731 MainForm::ReaderClicked()
5733 result r = E_SUCCESS;
5734 ArrayList* pArgList = new(std::nothrow) ArrayList();
5735 if (pArgList != null)
5737 r = pArgList->Construct();
5744 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5751 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5758 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5766 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5772 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5774 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5776 __currentAddMode = addMode;
5780 case ADDRESSBAR_MODE_INVALID:
5785 case ADDRESSBAR_MODE_READER:
5787 __pStopBtn->SetShowState(false);
5788 __pRefreshBtn->SetShowState(false);
5789 __pClearBtn->SetShowState(false);
5790 __pReaderBtn->SetShowState(false);
5793 case ADDRESSBAR_MODE_LOADING:
5795 __pRefreshBtn->SetShowState(false);
5796 __pStopBtn->SetShowState(true);
5797 __pClearBtn->SetShowState(false);
5798 __pReaderBtn->SetShowState(false);
5801 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5803 // SetUrl(__pAddressbar->GetUrl());
5805 __pRefreshBtn->SetShowState(true);
5806 __pStopBtn->SetShowState(false);
5807 __pClearBtn->SetShowState(false);
5808 __pReaderBtn->SetShowState(false);
5811 case ADDRESSBAR_MODE_EDIT:
5813 __pRefreshBtn->SetShowState(false);
5814 __pStopBtn->SetShowState(false);
5815 __pReaderBtn->SetShowState(false);
5816 __pClearBtn->SetShowState(true);
5823 OnAddressBarModeChanged();
5826 AddressBarMode MainForm::GetAddressbarMode(void)
5828 return __currentAddMode;
5831 void MainForm::SetUrl(const String& url)
5834 if(__displayUrl.GetLength() > 2048)
5835 __displayUrl.SubString(0,2048,__displayUrl);
5837 if (__pFooterUrlField != NULL)
5839 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5840 if (removedHttpUrl.IsEmpty() == false)
5842 __pFooterUrlField->SetText(removedHttpUrl);
5843 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5844 __pAddressbar->SetUrl(__displayUrl);
5848 __pFooterUrlField->SetText(__displayUrl);
5849 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5850 __pAddressbar->SetUrl(__displayUrl);
5852 if(__pFooterUrlField)
5853 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5854 __pFooterUrlField->Invalidate(false);
5855 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5856 __pAddressbar->Invalidate(true);
5857 // __pFooterUrlField->SetCursorPosition(0);
5862 MainForm::RemoveHttpTextFromDisplayURL(void)
5864 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5866 // bool isHttpText = __displayUrl.Contains(L"http://");
5867 String updatedDisplayUrl;
5868 updatedDisplayUrl.Clear();
5869 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5871 __displayUrl.SubString(7,updatedDisplayUrl);
5873 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5875 __displayUrl.SubString(8,updatedDisplayUrl);
5877 return updatedDisplayUrl;
5880 void MainForm::OnSharePopupControlStarted(void)
5882 __pWebViewer->AddTouchEventListener(*this);
5886 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5888 if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED)
5890 AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN");
5893 else if (requestId == BACK_GROUND_APP_EVENT)
5895 if(__pWebViewer != null)
5897 __pWebViewer->Pause();
5901 __pImageMenu->SetShowState(false);
5903 if(__pAddressbar != null)
5905 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5908 else if(requestId == FORE_GROUND_APP_EVENT)
5910 if(__pWebViewer != null)
5912 __pWebViewer->Resume();
5914 if(__pAddressbar != null)
5916 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5922 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5924 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5925 result r = E_SUCCESS;
5928 __pAddressbar->SetShowState(false);
5930 AppLog("akjshdasd 5");
5931 __pFooterPanel->SetShowState(true);
5934 __pWebViewer->SetFocus();
5935 else if(__pMostVisitedListView)
5936 __pMostVisitedListView->SetFocus();
5937 else if(__pMultiWindowButton)
5938 __pMultiWindowButton->SetFocus();
5939 else if(__pMoreButton)
5940 __pMoreButton->SetFocus();
5942 __pAddressbar->SetShowState(false);
5944 RelayoutControls(false);
5948 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5950 AppLog("MainForm::OnFormMenuRequested called");
5952 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5954 int bookmarkCount=0;
5957 url=__pWindowInfo->pageUrl;
5958 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5959 result r = E_SUCCESS;
5960 Bitmap* pBitmap = null;
5961 String lastChar = L"";
5962 // if(url.SubString(url.GetLength()-1,lastChar));
5963 // if(lastChar == L"/")
5965 // bool exist1 = false;
5966 // bool exist2 = false;
5967 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
5968 // url.SubString(0,url.GetLength() - 1,url);
5969 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
5970 // exist = exist1 | exist2;
5974 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5977 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5983 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5987 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5989 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5991 if (__pOptionMenu->GetItemCount() == 9)
5993 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5997 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
6002 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
6006 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
6007 if (__pOptionMenu->GetItemCount() != 9)
6009 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
6010 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
6011 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
6012 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
6013 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
6014 __pOptionMenu->SetMaxVisibleItemsCount(6);
6016 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
6018 AppLog(" Orientation landscape");
6019 __pOptionMenu->SetMaxVisibleItemsCount(5);
6023 AppLog(" Orientation potrait");
6024 __pOptionMenu->SetMaxVisibleItemsCount(6);
6027 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
6030 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
6032 __pAddressbar->SetShowState(false);
6034 __pFooterPanel->SetShowState(true);
6035 result r = __pOptionMenu->SetShowState(true);
6036 AppLog("ajsghd %s",GetErrorMessage(r));
6037 RelayoutControls(false);
6038 __pOptionMenu->Invalidate(true);
6039 __pOptionMenu->Show();