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;
822 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
824 AppLog("MainForm::InitImageContextMenu clicked on image");
825 if (__pImageMenu != null)
830 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
835 __pImageMenu = new (std::nothrow) ContextMenu();
836 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
837 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
840 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
841 AppLog("srcUrl %ls __pWebViewer->GetUrl() %ls",srcUrl.GetPointer(),__pWebViewer->GetUrl().GetPointer());
843 if(__pWebViewer && srcUrl.Equals(__pWebViewer->GetUrl(),false) == false)
844 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
845 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
846 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
847 __pImageMenu->SetMaxVisibleItemsCount(4);
848 __pImageMenu->AddActionEventListener(*this);
849 SetControlAlwaysOnTop(*__pImageMenu, true);
850 __pImageMenu->SetFocusable(true);
856 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
858 result r = E_SUCCESS;
859 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
861 AppLog("MainForm::InitImageContextMenu clicked on image");
862 if (__pImageMenu != null)
868 // if(__pAddressbar->GetShowState() == true)
869 // p.y = p.y + __pAddressbar->GetHeight();
870 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
875 __pImageMenu = new (std::nothrow) ContextMenu();
876 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
877 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
879 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_OPEN_IN_NEW_WINDOW"),IDA_HYPERLINK_OPEN_CLICKED);
880 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_LINK_URL"),IDA_HYPERLINK_COPY_LINK_CLICKED);
881 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
882 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
884 __pImageMenu->SetMaxVisibleItemsCount(3);
885 __pImageMenu->AddActionEventListener(*this);
886 SetControlAlwaysOnTop(*__pImageMenu, true);
887 __pImageMenu->SetFocusable(true);
894 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
896 result r = E_SUCCESS;
897 bool clipboardAvailable = true;
898 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
900 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
901 if (__pImageMenu != null)
907 // __pWebViewer->GetBlockRange(p,q);
912 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
916 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
920 Clipboard* pClipboard = Clipboard::GetInstance();
922 if(pClipboard == null)
924 clipboardAvailable = false;
928 // Retrieves a latest item
929 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
933 clipboardAvailable = false;
937 //Gets data from the clipboard item
938 String* pString = dynamic_cast<String*>(pItem->GetData());
942 clipboardAvailable = false;
946 if(clipboardAvailable == false && onlyPasteOption == true)
951 __pImageMenu = new (std::nothrow) ContextMenu();
952 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
953 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
955 if(onlyPasteOption == false)
957 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
959 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
961 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
963 if(onlyPasteOption == false)
965 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
966 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
969 __pImageMenu->SetMaxVisibleItemsCount(3);
970 __pImageMenu->AddActionEventListener(*this);
971 SetControlAlwaysOnTop(*__pImageMenu, true);
972 __pImageMenu->SetFocusable(true);
979 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
981 result r = E_SUCCESS;
982 bool clipboardAvailable = true;
983 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
985 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
986 if (__pImageMenu != null)
991 // FloatPoint q(0.0,0.0);
992 // __pWebViewer->GetBlockRange(p,q);
998 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
1002 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
1004 else if(__pWebViewer != null && (p.y > (__pWebViewer->GetHeight() + __pWebViewer->GetY())))
1006 p.y = __pWebViewer->GetHeight() + __pWebViewer->GetY();
1010 if(GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE )
1012 AppLog("asdasdafdsfdgfd");
1015 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
1019 Clipboard* pClipboard = Clipboard::GetInstance();
1021 if(pClipboard == null)
1023 clipboardAvailable = false;
1027 // Retrieves a latest item
1028 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1032 clipboardAvailable = false;
1036 //Gets data from the clipboard item
1037 String* pString = dynamic_cast<String*>(pItem->GetData());
1041 clipboardAvailable = false;
1045 if(clipboardAvailable == false && (onlyPasteOption == true || __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == true))
1049 __pImageMenu = new (std::nothrow) ContextMenu();
1050 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
1051 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
1053 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1055 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
1057 if ((pasteOption || onlyPasteOption) && clipboardAvailable == true)
1059 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
1061 if(onlyPasteOption == false && __pHitElementResult->GetAttributeValue("type").Equals(L"password",false) == false)
1063 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
1064 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
1067 __pImageMenu->SetMaxVisibleItemsCount(3);
1068 __pImageMenu->AddActionEventListener(*this);
1069 SetControlAlwaysOnTop(*__pImageMenu, true);
1070 __pImageMenu->SetFocusable(true);
1077 MainForm::InitFindWordPanel(void)
1079 result r = E_SUCCESS;
1080 Bitmap *pIconBitmap = null;
1082 if (__pFindWordControl != null)
1084 AppLogDebug("Findword panel already initialized");
1085 if (__pFindWordBgLabel != null)
1087 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1088 if (pBitmap != null)
1090 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1094 if (__pFindWordBgLabelRightToLeft != null)
1096 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1097 if (pBitmap != null)
1099 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1104 __pAddressbar->SetShowState(false);
1106 if(__isKeypadOpened == false)
1107 __pFooterPanel->SetShowState(true);
1111 __pFindWordControl = new (std::nothrow) Panel();
1112 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1115 AppLogException("There is some problem in the xml file. Please check.");
1118 AddControl(__pFindWordControl);
1119 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1120 SetControlAlwaysOnTop(*__pFindWordControl,true);
1121 __pFindWordControl->SetShowState(false);
1122 __pFindWordControl->Invalidate(false);
1124 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1125 __pFindWordPanelLeftToRight->SetShowState(true);
1127 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1128 __pFindWordPanelRightToLeft->SetShowState(false);
1130 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1131 if (__pFindWordBgLabel != null)
1133 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1134 Rectangle pRect = pPanel1->GetBounds();
1135 pRect.x = pRect.y = 0;
1136 __pFindWordBgLabel->SetBounds(pRect);
1137 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.#.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1138 if (pBitmap != null)
1140 AppLogDebug("InitFindWordPanel: Coming here");
1141 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1146 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1150 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1151 if (__pFindWordBgLabelRightToLeft != null)
1153 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1154 Rectangle pRect = pPanel1->GetBounds();
1155 pRect.x = pRect.y = 0;
1156 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1157 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.#.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1158 if (pBitmap != null)
1160 AppLogDebug("InitFindWordPanel: Coming here");
1161 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1166 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1170 Button* pfindWordCancel = null;
1171 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1172 if (pfindWordCancel == null)
1174 AppLogException("There is some problem in the xml file. Please check.");
1177 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1178 pfindWordCancel->AddActionEventListener(*this);
1180 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1181 if (__pFindWordClear == null)
1183 AppLogException("There is some problem in the xml file. Please check.");
1187 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1188 if (__pFindWordClearRightToLeft == null)
1190 AppLogException("There is some problem in the xml file. Please check.");
1194 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1195 __pFindWordClear->AddActionEventListener(*this);
1197 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1198 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1200 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1201 if (__pFindWordNext == null)
1203 AppLogException("There is some problem in the xml file. Please check.");
1207 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1208 __pFindWordNext->AddActionEventListener(*this);
1210 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1211 if (__pFindWordPrev == null)
1213 AppLogException("There is some problem in the xml file. Please check.");
1217 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1218 __pFindWordPrev->AddActionEventListener(*this);
1220 __pFindWordNext->SetEnabled(false);
1221 __pFindWordPrev->SetEnabled(false);
1223 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1224 if (__pFindWordCountLabel == null)
1226 AppLogException("There is some problem in the xml file. Please check.");
1229 __pFindWordCountLabel->SetText(L"0/0");
1231 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1232 if (__pFindWordCountLabelRightToLeft == null)
1234 AppLogException("There is some problem in the xml file. Please check.");
1237 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1239 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1240 if (__pFindWordEditField == null)
1242 AppLogException("There is some problem in the xml file. Please check.");
1245 __pFindWordEditField->AddTextEventListener(*this);
1246 __pFindWordEditField->AddKeypadEventListener(*this);
1247 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1248 __pFindWordEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1250 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1251 if (__pFindWordEditFieldRightToLeft == null)
1253 AppLogException("There is some problem in the xml file. Please check.");
1256 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1257 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1258 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1259 __pFindWordEditFieldRightToLeft->SetColor(EDIT_STATUS_HIGHLIGHTED, Color(0x00, 0x00, 0x00, 0x00));
1262 __pAddressbar->SetShowState(false);
1264 if(__isKeypadOpened == false)
1265 __pFooterPanel->SetShowState(true);
1270 MainForm::CreateItem (int index, int itemWidth)
1272 Rectangle listImageRect;
1273 Rectangle pagetTitleRect;
1274 Rectangle pageURLRect;
1275 Rectangle deleteImageRect;
1276 String pageTitle(L"");
1277 String pageURL(L"");
1278 result r = E_SUCCESS;
1279 Bitmap* pListIconImage = null;
1282 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1283 if(pHistory == null)
1287 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1288 if ( pAppResource == NULL )
1292 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1294 CustomItem* pItem = new(std::nothrow) CustomItem();
1295 pageTitle = pHistory->GetHistoryTitle();
1296 pageURL = pHistory->GetHistoryUrl();
1298 if (pageURL.GetLength() == 0)
1301 pAppResource->GetString(L"IDS_BR_BODY_BLANK_PAGE", nourl);
1302 pageURL = L"<"+ nourl +">";
1306 Rectangle screenBounds = GetBounds();
1309 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1318 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1320 if ( pBitmap != NULL)
1322 pListIconImage = new Bitmap();
1323 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1327 if(pListIconImage == null)
1329 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1332 if ( pListIconImage != NULL)
1334 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1335 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 72 + (__fontSize - 44));
1336 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1339 if (pItem != null && pListIconImage != NULL)
1341 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1345 if (pageTitle.CompareTo(L"") != 0)
1349 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1353 if (pageURL.CompareTo(L"") != 0)
1357 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_LISTVIEW_TEXT, CUSTOM_COLOR_LISTVIEW_TEXT, true);
1362 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1364 if ( __pItemContext!= NULL)
1368 pItem->SetContextItem(__pItemContext);
1374 if ( __pItemContextLandscape!= NULL)
1378 pItem->SetContextItem(__pItemContextLandscape);
1382 if( pListIconImage != NULL)
1384 delete pListIconImage;
1385 pListIconImage = null;
1392 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1399 MainForm::GetItemCount (void)
1401 if(__pMostVisitedSites != null)
1403 __pMostVisitedSites->RemoveAll(true);
1405 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1406 if(__pMostVisitedSites != null)
1408 return __pMostVisitedSites->GetCount();
1415 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1417 AppLog("MainForm::OnListViewContextItemStateChanged called");
1418 if(__pMostVisitedSites != null)
1420 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1421 if (pHistory != null)
1423 String url = pHistory->GetHistoryUrl();
1425 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1426 __pMostVisitedListView->UpdateList();
1432 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1434 AppLog("MainForm::OnListViewItemStateChanged called");
1435 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1436 String url = pHistory->GetHistoryUrl();
1444 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1450 MainForm::OnTerminating(void)
1452 result r = E_SUCCESS;
1454 RemoveOrientationEventListener(*this);
1458 __pAddressbar->SetAddressbarEventListener(null);
1463 __pWebViewer->RemoveTouchEventListener(*this);
1464 __pWebViewer->SetWebUiEventListenerF(null);
1465 __pWebViewer->SetWebKeypadEventListener(null);
1466 __pWebViewer->SetTextSearchListener(null);
1472 delete __pItemContext;
1474 if (__pItemContextLandscape)
1476 delete __pItemContextLandscape;
1480 delete __pSaveImage;
1482 if (__pMostVisitedSites)
1484 __pMostVisitedSites->RemoveAll(true);
1485 delete __pMostVisitedSites;
1491 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1493 result r = E_SUCCESS;
1495 AppLogDebug("Clicked : %d", actionId);
1498 case IDA_BACKBTN_CLICKED:
1500 if(__pImageMenu && __pImageMenu->GetShowState() == true)
1502 AppLog("Hiding the menu");
1503 __pImageMenu->SetShowState(false);
1505 if (__pWebViewer && __pWebViewer->CanGoBack())
1507 __pWebViewer->GoBack();
1509 else if(__pWindowInfo->isJavascriptInitiated == false)
1512 pApp = UiApp::GetInstance();
1515 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1518 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1526 WindowInfo* pWindowInfo = null;
1528 SceneManager* pSceneManager = SceneManager::GetInstance();
1529 if (pSceneManager == null)
1533 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1534 if (pAllWindowList == NULL)
1536 pApp = UiApp::GetInstance();
1539 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1542 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1547 if (pAllWindowList != null)
1549 totalCount = pAllWindowList->GetCount();
1551 for (int count = 0; count < totalCount; count++)
1553 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1554 if (pWindowInfo == null)
1556 pApp = UiApp::GetInstance();
1559 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1562 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1569 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1571 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1574 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1577 r = pAllWindowList->RemoveAt(count, true);
1578 __pWindowInfo = null;
1581 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1586 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1590 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1592 if (pWindowInfo == null)
1594 pApp = UiApp::GetInstance();
1597 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
1603 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
1604 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1607 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1619 case IDA_FORWARD_CLICKED:
1620 if (__pWebViewer == null)
1623 if (__pWebViewer->CanGoForward())
1625 __pWebViewer->GoForward();
1627 __pOptionMenu->SetShowState(false);
1628 __pOptionMenu->Invalidate(false);
1631 case IDA_FINDONPAGE_CLICKED:
1633 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1634 __currentSearchStr.Clear();
1636 InitFindWordPanel();
1637 __pOptionMenu->SetShowState(false);
1638 __pOptionMenu->Invalidate(false);
1640 ShowFindWordPanel(true);
1642 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1644 __pFindWordEditField->SetFocus();
1648 __pFindWordEditFieldRightToLeft->SetFocus();
1652 case IDA_PRIVATEON_CLICKED:
1654 result r = E_SUCCESS;
1656 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1657 Bitmap* pBitmap = null;
1658 if (isPrivateBrowsing == true)
1660 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1663 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1667 if (__pWebViewer != NULL)
1669 __pWebViewer->SetPrivateBrowsingEnabled(false);
1672 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1674 if (__pAddressbar != null)
1676 __pAddressbar->UpdateFaviconBitmap(false);
1682 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1685 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1689 if (__pWebViewer != NULL)
1691 __pWebViewer->SetPrivateBrowsingEnabled(true);
1694 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1696 if (__pAddressbar != null)
1698 __pAddressbar->UpdateFaviconBitmap(true);
1702 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1703 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1704 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1705 __pOptionMenu->Invalidate(true);
1706 if ( pBitmap != NULL )
1713 case IDA_SETTINGS_CLICKED:
1716 ArrayList* pArgList = new(std::nothrow) ArrayList();
1719 pArgList->Construct();
1720 pArgList->Add(*__pWindowInfo);
1721 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1723 __pOptionMenu->SetShowState(false);
1724 __pOptionMenu->Invalidate(false);
1726 if (pArgList != null)
1735 case IDA_ADDTOBOOKMARK_CLICKED:
1738 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1740 int bookmarkCount=0;
1743 url=__pWindowInfo->pageUrl;
1744 result r = E_SUCCESS;
1745 Bitmap* pBitmap = null;
1746 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1754 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1755 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1756 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1758 if(__pNotification != null)
1760 RemoveControl(__pNotification);
1761 __pNotification = null;
1763 __pNotification = new (std::nothrow) NotificationPanel(*this);
1764 if (__pNotification != null)
1766 __pNotification->SetText(message);
1767 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1768 __pNotification->ShowNotification();
1773 String title=__pWindowInfo->pageTitle;
1774 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1775 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1777 pBookmark->SetBookmarkTitle(title);
1778 pBookmark->SetUrl(url);
1779 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1781 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1783 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1784 pBookmark->SetFaviconId(id);
1785 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1786 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1788 if(__pNotification != null)
1790 RemoveControl(__pNotification);
1791 __pNotification = null;
1793 __pNotification = new (std::nothrow) NotificationPanel(*this);
1794 if (__pNotification != null)
1796 __pNotification->SetText(message);
1797 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight() - 12);
1798 __pNotification->ShowNotification();
1799 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1802 if (pBitmap != null)
1804 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1809 __pOptionMenu->Invalidate(true);
1814 case IDA_PRINT_CLICKED:
1816 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1817 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1819 AppLog("RequestPrint called!");
1820 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1821 result nResult = E_FAILURE;
1824 AppLog("TestPrint if (pAc) == true");
1829 String fileType = L"service_print_files_type";
1830 String typeVal = L"DOC";
1832 String fileCount = L"service_print_files_count";
1833 String countVal = L"1";
1834 String fileFolder= L"service_print_files_folder_name";
1835 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1837 map.Add(&fileCount, &countVal);
1838 map.Add(&fileFolder, &folderVal);
1839 map.Add(&fileType, &typeVal);
1841 String fileName = L"service_print_files_files_name";
1843 ArrayList fileNameList;
1844 fileNameList.Construct();
1845 String file1 = L"test.pdf";
1847 fileNameList.Add(&file1);
1848 map.Add(&fileName, &fileNameList);
1850 nResult = pAc->Start(NULL, NULL, &map, NULL);
1852 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1853 else if (nResult == E_MAX_EXCEEDED)
1854 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1855 else if (nResult == E_OBJ_NOT_FOUND)
1856 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1857 else if (nResult == E_IN_PROGRESS)
1858 AppLog("TestPrint ret == E_IN_PROGRESS");
1859 else if (nResult == E_PRIVILEGE_DENIED)
1860 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1861 else if(nResult == E_SYSTEM)
1862 AppLog("TestPrint ret == E_SYSTEM");
1868 int __modalMsgBoxResult;
1869 MessageBox* pMsgBox = new MessageBox();
1870 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1871 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1874 __modalMsgBoxResult = 0;
1878 case IDA_SHARE_CLICKED:
1880 if(__pPopUp != null)
1887 __pAddressbar->HideKeypad();
1889 __pPopUp = new(std::nothrow) SharePopup();
1890 __pPopUp->Initialize();
1891 if (__pWindowInfo != null)
1893 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1894 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1895 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1896 pShareInfo->SetImageAttached(false);
1897 __pPopUp->RemoveAllShareInfo();
1898 __pPopUp->AddShareInfo(pShareInfo);
1900 __pPopUp->SetShowState(true);
1904 case IDA_BOOKMARKBTN_CLICKED:
1906 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1907 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1910 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1915 case IDA_MOREBTN_CLICKED:
1917 AppLog("IDA_MOREBTN_CLICKED");
1919 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1921 int bookmarkCount=0;
1924 url=__pWindowInfo->pageUrl;
1925 result r = E_SUCCESS;
1926 Bitmap* pBitmap = null;
1928 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1931 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1936 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1940 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1942 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1944 if (__pOptionMenu->GetItemCount() == 9)
1946 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1950 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1955 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1959 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1960 if (__pOptionMenu->GetItemCount() != 9)
1962 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1963 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1964 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1965 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1966 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1967 __pOptionMenu->SetMaxVisibleItemsCount(6);
1969 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
1971 AppLog(" Orientation landscape");
1972 __pOptionMenu->SetMaxVisibleItemsCount(5);
1976 AppLog(" Orientation potrait");
1977 __pOptionMenu->SetMaxVisibleItemsCount(6);
1980 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1983 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1984 __pOptionMenu->SetShowState(true);
1985 __pOptionMenu->Invalidate(true);
1986 __pOptionMenu->Show();
1990 case IDA_HISTORY_CLICKED:
1992 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1993 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1996 case IDA_SAVED_PAGES_CLICKED:
2001 case IDA_DESKTOP_VIEW_CLICKED:
2006 case IDA_SAVE_CLICKED:
2011 case IDA_MULTIWINDOWBTN_CLICKED:
2013 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2014 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
2018 case IDA_NEWWINDOWBTN_CLICKED:
2020 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
2022 if (pNewWindowInfo == null)
2026 result r = E_SUCCESS;
2027 SceneManager* pSceneManager = SceneManager::GetInstance();
2029 if (pSceneManager == NULL)
2033 ArrayList* pArgList = new(std::nothrow) ArrayList();
2034 if (pArgList == NULL)
2038 r = pArgList->Construct();
2041 pArgList->Add(*pNewWindowInfo);
2042 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2048 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
2053 case IDA_SMALLFONT_BTN_CLICKED:
2055 WebSetting setting = __pWebReader->GetSetting();
2056 setting.SetFontSize(15);
2057 __pWebReader->SetSetting(setting);
2060 case IDA_LARGEFONT_BTN_CLICKED:
2062 WebSetting setting = __pWebReader->GetSetting();
2063 setting.SetFontSize(25);
2064 __pWebReader->SetSetting(setting);
2067 case IDA_READER_CLOSE_CLICKED:
2069 if (__pArticleReaderPanel != null && __pBlankPanel != null)
2071 RemoveControl(__pBlankPanel);
2072 __pArticleReaderPanel = null;
2073 __pBlankPanel = null;
2074 __pArticleReaderLabel = null;
2076 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2079 case IDA_FINDWORD_CANCEL_CLICKED:
2081 __currentSearchStr = L"";
2082 __currentWordIndex = 0;
2083 __maxOccurrances = 0;
2085 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2087 __pFindWordEditField->SetText(L"");
2088 __pFindWordCountLabel->SetText(L"0/0");
2090 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2092 __pFindWordEditFieldRightToLeft->SetText(L"");
2093 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2096 __pFindWordNext->SetEnabled(false);
2097 __pFindWordPrev->SetEnabled(false);
2098 __pFindWordCountLabel->SetText(L"0/0");
2099 __pWebViewer->SearchTextAllAsync(L"",true);
2100 AppLog("akjshdasd 1");
2101 if(__isKeypadOpened == false)
2102 __pFooterPanel->SetShowState(true);
2103 ShowFindWordPanel(false);
2106 case IDA_FINDWORD_SEARCH_CLICKED:
2108 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2110 __currentSearchStr = __pFindWordEditField->GetText();
2112 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2114 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
2117 if (__currentSearchStr.GetLength() > 0)
2123 AppLogDebug("Enter something");
2127 case IDA_FINDWORD_CLEAR_CLICKED:
2129 __pFindWordCountLabel->SetText(L"0/0");
2130 __pFindWordEditField->SetText(L"");
2131 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2133 __currentSearchStr = L"";
2134 __pFindWordNext->SetEnabled(false);
2135 __pFindWordPrev->SetEnabled(false);
2136 // __pFindWordCountLabel->SetShowState(false);
2137 __pFindWordControl->Invalidate(true);
2140 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2142 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2143 __pFindWordEditFieldRightToLeft->SetText(L"");
2144 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2146 __currentSearchStr = L"";
2147 __pFindWordNext->SetEnabled(false);
2148 __pFindWordPrev->SetEnabled(false);
2149 // __pFindWordCountLabelRightToLeft->SetShowState(false);
2150 __pFindWordControl->Invalidate(true);
2153 case IDA_FINDWORD_NEXT_CLICKED:
2158 case IDA_FINDWORD_PREV_CLICKED:
2160 FindNextWord(false);
2163 case IDA_BRIGHTNESS_BTN_CLICKED:
2165 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2166 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2169 case IDA_COPY_IMAGE_CLICKED:
2171 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2172 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2174 const Bitmap* pBitmap = null;
2175 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2177 pBitmap = __pHitElementResult->GetImage();
2180 String resourcePath = App::GetInstance()->GetAppResourcePath();
2181 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2182 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2183 // copying the item to clipboard
2184 Clipboard* pClipboard = Clipboard::GetInstance();
2185 if (pClipboard != null)
2187 r = pClipboard->CopyItem(item);
2188 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2192 case IDA_VIEW_IMAGE_CLICKED:
2194 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2195 WindowInfo* pNewWindowInfo = null;
2196 if (__pHitElementResult != null)
2198 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2199 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2202 currentUri.SetUri(__pWebViewer->GetUrl());
2206 newUri.SetUri(srcUrl);
2207 AppLog("newuri gethost %ls",newUri.GetHost().GetPointer());
2208 if(newUri.GetHost().GetLength() == 0)
2210 newUrl = currentUri.GetHost();
2211 newUrl.Append(srcUrl);
2219 case IDA_SAVE_IMAGE_CLICKED:
2221 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2222 const Bitmap* pSaveBitmap = null;
2223 String imageName = GetImagePath();
2224 AppLog("Content manager image name %ls",imageName.GetPointer());
2227 imagePath.Append(imageName);
2228 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2229 AppLog("Content manager image path %ls",imagePath.GetPointer());
2230 if (__pHitElementResult != null)
2232 pSaveBitmap = __pHitElementResult->GetImage();
2234 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2238 UpdateImageContent(pBuffer, imageName);
2240 if(__pNotification != null)
2242 RemoveControl(__pNotification);
2243 __pNotification = null;
2245 __pNotification = new NotificationPanel(*this);
2247 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2248 msg.Append(imagePath);
2249 if (__pNotification != null)
2251 __pNotification->SetText(msg);
2252 if (__pFooterPanel->GetShowState() == true)
2254 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2258 __pNotification->SetPositionDiff(0);
2260 __pNotification->ShowNotification();
2265 int __modalMsgBoxResult;
2266 MessageBox* pMsgBox = new MessageBox();
2267 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);
2268 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2271 __modalMsgBoxResult = 0;
2275 case IDA_SHARE_IMAGE_CLICKED:
2277 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2278 if (__pPopUp != null)
2285 __pAddressbar->HideKeypad();
2287 __pPopUp = new(std::nothrow) SharePopup();
2288 __pPopUp->Initialize();
2289 if (__pHitElementResult != null)
2291 const Bitmap* pSaveBitmap = null;
2292 String imageName = GetImagePath();
2293 AppLog("Content manager image name %ls",imageName.GetPointer());
2296 imagePath.Append(imageName);
2297 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2298 AppLog("Content manager image path %ls",imagePath.GetPointer());
2299 if (__pHitElementResult != null)
2301 pSaveBitmap = __pHitElementResult->GetImage();
2303 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2305 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2306 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2308 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2309 pShareInfo->SetPageTitle(L"");
2310 pShareInfo->SetPageUrl(srcUrl);
2311 pShareInfo->SetImageAttached(true);
2312 pShareInfo->SetImagePath(imagePath);
2313 __pPopUp->RemoveAllShareInfo();
2314 __pPopUp->AddShareInfo(pShareInfo);
2315 __pPopUp->SetShowState(true);
2320 case IDA_HYPERLINK_OPEN_CLICKED:
2322 if (__pHitElementResult != null)
2324 String srcUrl = __pHitElementResult->GetUrl();
2326 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2328 if (pNewWindowInfo == null)
2332 pNewWindowInfo->isJavascriptInitiated = true;
2333 result r = E_SUCCESS;
2334 SceneManager* pSceneManager = SceneManager::GetInstance();
2335 if (pSceneManager == NULL)
2339 ArrayList* pArgList = new(std::nothrow) ArrayList();
2340 if (pArgList == NULL)
2344 pArgList->Construct();
2346 pArgList->Add(*pNewWindowInfo);
2347 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2348 if (pArgList != null)
2355 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2361 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2363 if (__pHitElementResult == null)
2368 if(__pPopUp != null)
2375 __pAddressbar->HideKeypad();
2377 __pPopUp = new(std::nothrow) SharePopup();
2378 __pPopUp->Initialize();
2380 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2381 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2382 pShareInfo->SetImageAttached(false);
2383 __pPopUp->RemoveAllShareInfo();
2384 __pPopUp->AddShareInfo(pShareInfo);
2386 __pPopUp->SetShowState(true);
2390 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2394 if (__pHitElementResult != null)
2396 url = __pHitElementResult->GetUrl();
2399 String resourcePath = App::GetInstance()->GetAppResourcePath();
2400 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2402 // copying the item to clipboard
2403 Clipboard* pClipboard = Clipboard::GetInstance();
2404 if (pClipboard != null)
2406 pClipboard->CopyItem(item);
2410 case IDA_FIND_TEXT__CLICKED:
2412 // AddressBarCancelledClicked(*__pAddressbar);
2413 RelayoutControls(false);
2414 // __pFooterPanel->SetShowState(false);
2415 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2416 __currentSearchStr.Clear();
2417 __currentSearchStr.Append(__currentSelectedStr);
2418 InitFindWordPanel();
2419 __pFindWordEditField->SetText(__currentSearchStr);
2421 if(__pOptionMenu != null)
2423 __pOptionMenu->SetShowState(false);
2424 __pOptionMenu->Invalidate(false);
2426 __adressPanelPosition.y = 0;
2428 if (__pAddressbar != null && __pWebViewer != NULL)
2430 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2431 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
2432 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2433 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeightF() - 12.0f);
2435 if (__pFooterPanel->GetShowState() == false)
2436 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2438 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2439 __pWebViewer->Invalidate(true);
2442 ShowFindWordPanel(true);
2443 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2445 __pFindWordEditField->SetText(__currentSearchStr);
2446 __pFindWordEditField->SetFocus();
2448 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2450 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2451 __pFindWordEditFieldRightToLeft->SetFocus();
2454 if (__currentSearchStr.GetLength() > 0)
2460 AppLogDebug("Enter something");
2463 if (__pWebViewer != null)
2465 // releasing the set block
2466 __pWebViewer->ReleaseBlock();
2471 case IDA_SHARE_TEXT_CLICKED:
2473 __pWebViewer->ReleaseBlock();
2474 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2475 if(__pPopUp != null)
2482 __pAddressbar->HideKeypad();
2484 __pPopUp = new(std::nothrow) SharePopup();
2485 __pPopUp->Initialize();
2486 if (__pHitElementResult != null)
2488 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2489 pShareInfo->SetPageTitle(L"");
2490 pShareInfo->SetPageUrl(__currentSelectedStr);
2491 pShareInfo->SetImageAttached(false);
2492 __pPopUp->RemoveAllShareInfo();
2493 __pPopUp->AddShareInfo(pShareInfo);
2494 __pPopUp->SetShowState(true);
2499 case IDA_COPY_TEXT_CLICKED:
2501 // __pWebViewer->ReleaseBlock();//as per hyunn lee request for issue 53500
2502 // need to implement
2503 //__currentSelectedStr
2504 // Sets data to a clip board item
2506 String resourcePath = App::GetInstance()->GetAppResourcePath();
2507 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2509 // copying the item to clipboard
2510 Clipboard* pClipboard = Clipboard::GetInstance();
2511 if (pClipboard != null)
2513 pClipboard->CopyItem(item);
2517 case IDA_PASTE_TEXT_CLICKED:
2519 Clipboard* pClipboard = Clipboard::GetInstance();
2521 if(pClipboard == null)
2525 // Retrieves a latest item
2526 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2532 //Gets data from the clipboard item
2533 String* pString = dynamic_cast<String*>(pItem->GetData());
2535 if (pString != null)
2537 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2538 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2539 String classElement = __pHitElementResult->GetAttributeValue(L"class");
2540 String tagElement = __pHitElementResult->GetTagName();
2541 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
2542 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2543 String str = L"document.getElementsByName('";
2544 str.Append(nameElement);
2545 str.Append("').length");
2546 String* pNameCount = __pWebViewer->EvaluateJavascriptN(str);
2549 str = L"document.getElementsByClassName('";
2550 str.Append(classElement);
2551 str.Append("').length");
2552 String* pClassCount = __pWebViewer->EvaluateJavascriptN(str);
2555 if(contenteditable.Equals(L"true",false) == true)
2557 AppLog("gmail paste need to support");
2559 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; } }";
2560 script.Append("replaceSelectedText(");
2561 script.Append("\"");
2562 script.Append(*pString);
2563 script.Append("\");");
2565 else if(idElement.GetLength() != 0)
2567 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; } } ";
2568 script.Append("insertAtCursor(");
2569 script.Append(L"document.activeElement");
2571 script.Append("\"");
2572 script.Append(*pString);
2573 script.Append("\");");
2575 else if (classElement.GetLength() != 0 && pClassCount->Equals("1",false) == true)
2577 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
2578 script.Append("insertAtCursor(document.getElementsByClassName('");
2579 script.Append(classElement);
2580 script.Append("')[0],");
2581 script.Append("\"");
2582 script.Append(*pString);
2583 script.Append("\");");
2585 else if (nameElement.GetLength() != 0 && pNameCount->Equals("1",false) == true)
2587 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; } } ";
2588 script.Append("insertAtCursor(document.getElementsByName('");
2589 script.Append(nameElement);
2590 script.Append("')[0],");
2591 script.Append("\"");
2592 script.Append(*pString);
2593 script.Append("\");");
2595 else if(tagElement.GetLength() != 0) //adding for twitter post page
2597 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; } } ";
2599 script.Append("insertAtCursor(document.activeElement,");
2600 script.Append("\"");
2601 script.Append(*pString);
2602 script.Append("\");");
2604 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2605 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2612 __pWebViewer->ReleaseBlock();
2620 case IDA_GO_FORWARD:
2625 case IDA_REFRESH_BTN_CLICKED:
2627 __isLoadingCompleted = false;
2628 __isLoadingData = true;
2629 __progressPercentage = 0;
2630 __displayUrl = __pFooterUrlField->GetText();
2632 String url = __pFooterUrlField->GetText();
2633 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2635 if (__pWebViewer != null && __pAddressbar != null)
2638 //__pWebViewer->Reload();
2639 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2643 UpdateProgressBitmap();
2646 case IDA_STOP_BTN_CLICKED:
2648 __isLoadingCompleted = false;
2649 __isLoadingData = false;
2650 __progressPercentage = 0;
2651 __pFooterUrlField->HideKeypad();
2652 __displayUrl = __pFooterUrlField->GetText();
2656 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2657 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2658 __pWebViewer->StopLoading();
2659 RequestRedraw(true);
2662 UpdateProgressBitmap();
2667 if (__pFooterUrlField->GetText().IsEmpty() == false)
2669 //__displayUrl = __pUrlField->GetText();
2670 __pFooterUrlField->Clear();
2675 case IDA_READER_BTN_CLICKED:
2686 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2688 AppLog("MainForm::OnFormBackRequested entered");
2689 result r = E_FAILURE;
2690 if(__pImageMenu && __pImageMenu->GetShowState() == true)
2692 AppLog("Hiding the menu");
2693 __pImageMenu->SetShowState(false);
2695 if (__pWebViewer && __pWebViewer->CanGoBack())
2697 __pWebViewer->GoBack();
2699 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2702 pApp = UiApp::GetInstance();
2705 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2708 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2716 WindowInfo* pWindowInfo = null;
2718 SceneManager* pSceneManager = SceneManager::GetInstance();
2719 if (pSceneManager == null)
2723 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2724 if (pAllWindowList == NULL)
2726 pApp = UiApp::GetInstance();
2729 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2732 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2737 if (pAllWindowList != null)
2739 totalCount = pAllWindowList->GetCount();
2741 for (int count = 0; count < totalCount; count++)
2743 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2744 if (pWindowInfo == null)
2746 pApp = UiApp::GetInstance();
2749 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2752 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2759 if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2761 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2764 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2767 r = pAllWindowList->RemoveAt(count, true);
2768 __pWindowInfo = null;
2771 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2776 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2780 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2782 if (pWindowInfo == null)
2784 pApp = UiApp::GetInstance();
2787 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2793 if(pWindowInfo != null)
2794 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
2797 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2803 // else if (pWindowInfo && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == false)
2805 // UiApp* pApp = null;
2806 // pApp = UiApp::GetInstance();
2807 // if (pApp != null)
2809 // r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
2812 // AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2820 AppLog("MainForm::OnFormBackRequested exit");
2824 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2825 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2828 AppLog("MainForm::OnSceneActivatedN called");
2829 String* pSelectedScene = NULL;
2830 Object* pValue = NULL;
2831 String* pUrl = null;
2832 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2833 pSelectedScene = (String*) pValue;
2835 if (pSelectedScene != null)
2837 delete pSelectedScene;
2839 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2840 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2841 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2842 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2844 // setting the current scene ID
2845 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2847 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2849 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2851 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2852 if(__pWindowInfo == null)
2854 // if(__pWindowInfo == null)
2856 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2859 else if ( pArgs != null && pArgs->GetCount() == 1)
2861 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2867 FloatRectangle footerPanelBounds = FloatRectangle(0.0f, (GetClientAreaBoundsF().height) - __pFooterPanel->GetHeightF(), GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF());
2868 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(footerPanelBounds));
2870 // hiding the address bar
2871 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2872 __pAddressbar->SetShowState(false);
2873 // if(__pWebViewer != null)
2875 // __pWebViewer->Resume();
2878 if(pUrl != null && pUrl->GetLength() > 0)
2882 else if(__pWindowInfo != null)
2884 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)
2886 LoadUrl(__pWindowInfo->pageUrl);
2888 else if(__pWindowInfo->pageUrl.GetLength() > 0 && __pWindowInfo->isAppcontrolTriggered == true)
2890 LoadUrl(__pWindowInfo->pageUrl);
2891 __pWindowInfo->isAppcontrolTriggered = false;
2893 else if (__pWindowInfo->isJavascriptInitiated == true && __pWindowInfo->isFirstLaunch == true)
2895 __pWindowInfo->isFirstLaunch = false;
2898 __pWindowInfo->pCurrentWeb = __pWebViewer;
2899 if(__pWindowInfo->pageUrl.GetLength() > 0)
2900 LoadUrl(__pWindowInfo->pageUrl);
2904 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2905 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2906 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2908 InitMostVisitedSitesView(GetOrientationStatus());
2912 if(__pMostVisitedListView != null)
2914 __pMostVisitedListView->SetShowState(false);
2918 if(__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2920 __pMostVisitedListView->UpdateList();
2922 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2924 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2926 if (pBookmarkUrl == null)
2928 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2929 //__pAddressbar->SetUrl(*pBookmarkUrl);
2930 SetUrl(*pBookmarkUrl);
2932 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2933 __pWebViewer->LoadUrl(*pBookmarkUrl);
2934 delete pBookmarkUrl;
2937 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2938 Bitmap* pBitmap = null;
2939 if (isPrivateBrowsing == true)
2941 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2943 if (__pWebViewer != null)
2945 __pWebViewer->SetPrivateBrowsingEnabled(true);
2948 if (__pAddressbar != null)
2950 // __pAddressbar->UpdateFaviconBitmap(true);
2956 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2958 if (__pWebViewer != null)
2960 __pWebViewer->SetPrivateBrowsingEnabled(false);
2963 if (__pAddressbar != null)
2965 // __pAddressbar->UpdateFaviconBitmap(false);
2969 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2971 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2973 else if (__pOptionMenu != null )
2975 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2978 if (pBitmap != null)
2983 RelayoutControls(false);
2984 AppLog("ABC: OnSceneActivatedN started exit");
2987 AppLog("WebControl's width height %d %d,",__pWebViewer->GetWidth(),__pWebViewer->GetHeight());
2988 __pWebViewer->Resume();
2994 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2995 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2997 Canvas* pWebCanvas = null;
2998 if (__pWebViewer != null)
3000 pWebCanvas = __pWebViewer->GetCanvasN();
3003 if (pWebCanvas == null)
3007 if (__pWindowInfo != null)
3009 if (__pWindowInfo->pWebCanvasBitmap != null)
3011 delete __pWindowInfo->pWebCanvasBitmap;
3013 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
3014 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
3015 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
3017 Bitmap* pBitmap = GetCapturedBitmapN();
3018 AppLog("Coming here");
3019 Canvas* pCanvas = new(std::nothrow) Canvas();
3020 pCanvas->Construct(GetClientAreaBounds());
3023 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
3026 if(__pWebViewer != null && __pWindowInfo != null && __pWindowInfo->pWebCanvasBitmap != null)
3027 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
3029 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
3032 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
3037 __pAddressbar->SetShowState(false);
3040 __pWebViewer->Pause();
3042 AppLog("Coming here");
3046 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
3047 const Tizen::Base::String& realm,
3048 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
3054 MainForm::OnHttpAuthenticationCanceled(void)
3059 MainForm::OnLoadingStarted(void)
3061 AppLogDebug("MainForm::OnLoadingStarted entered");
3063 if(__pAddressbar == NULL || __pWebViewer == null)
3068 // this is added in case if menu is opened and user load the page
3069 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
3071 __pOptionMenu->SetShowState(false);
3072 __pOptionMenu->Invalidate(true);
3077 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
3079 __pImageMenu->SetShowState(false);
3080 __pImageMenu->Invalidate(true);
3082 String url = __pWebViewer->GetUrl();
3083 if(url.Contains(IDS_TIZEN_SERVICE))
3086 String delim(L":;,");
3088 // Creates a StringTokenizer instance
3089 StringTokenizer strTok(url, delim);
3091 int count = strTok.GetTokenCount(); // count == 4
3093 HashMap *pMap = new HashMap();
3098 while (strTok.HasMoreTokens())
3100 AppLog("Token: %ls", token.GetPointer());
3101 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3102 if(token.Contains(IDS_APPID))
3104 token.SubString(6, appId);
3105 AppLog("AppID:%ls", appId.GetPointer());
3107 else if(token.Contains(IDS_KEY))
3109 token.SubString(4, key);
3110 AppLog("key:%ls", key.GetPointer());
3112 else if(token.Contains(IDS_VALUE))
3114 token.SubString(6, value);
3115 AppLog("value:%ls", value.GetPointer());
3118 pMap->Add(key, value);
3122 AppControl *pAppControl = null;
3123 String operationId = L"http://tizen.org/appcontrol/operation/main";
3124 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3127 AppLog("Starting AppControl");
3128 result r = pAppControl->Start(null, null, pMap, null);
3129 AppLog("Result of Start %s", GetErrorMessage(r));
3133 AppLogException("AppControl not found");
3138 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3140 __pAddressbar->SetShowState(false);
3141 AddressBarCancelledClicked(*__pAddressbar);
3142 __pAddressbar->Invalidate(true);
3144 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
3147 __pAddressbar->SetFaviconBitmap(*pBitmap);
3150 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
3152 // updating the address bar position with respect to web control
3153 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
3154 __distanceMoved = 0;
3158 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3159 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3160 if (__pWebViewer != null)
3162 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3163 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
3164 SetUrl(__pWebViewer->GetUrl());
3165 if (__pWindowInfo != NULL)
3167 // resetting the page title to blank, it will be received in OnPageTitleReceived()
3168 // __pWindowInfo->pageTitle = L"";
3169 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3171 __pAddressbar->Invalidate(true);
3177 MainForm::OnLoadingCanceled(void)
3183 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
3185 AppLog("XYZ::MainForm::OnKeypadWillOpen");
3190 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
3192 AppLog("XYZ::MainForm::OnKeypadOpened");
3193 __isKeypadOpened = true;
3194 __pFooterPanel->SetShowState(false);
3195 RelayoutControls(false);
3199 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3201 AppLog("XYZ::MainForm::OnKeypadClosed");
3202 __isKeypadOpened = false;
3203 __pFooterPanel->SetShowState(true);
3204 RelayoutControls(true);
3208 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3210 AppLog("XYZ::KeypadBoundsChanged");
3211 RelayoutControls(false);
3215 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3216 const Tizen::Base::String& reason)
3218 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3222 MainForm::OnLoadingCompleted(void)
3224 AppLog("MainForm::OnLoadingCompleted start");
3226 result r = E_SUCCESS;
3228 if (__pWebViewer == null)
3233 if (__pAddressbar == null)
3238 if(__pWindowInfo && __pWebViewer)
3239 __pWindowInfo->pageTitle = __pWebViewer->GetTitle();
3240 if(__pImageMenu && __pImageMenu->GetShowState())
3242 __pImageMenu->SetShowState(false);
3243 __pImageMenu->Invalidate(true);
3246 if (__pWebViewer->CanGoForward())
3248 //__pAddressbar->SetForwardButtonEnabled(true);
3249 SetForwardButtonEnabled(true);
3253 //__pAddressbar->SetForwardButtonEnabled(false);
3254 SetForwardButtonEnabled(false);
3257 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3259 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3261 //__pAddressbar->UpdateProgress(0);
3265 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3267 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3271 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3272 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3273 if (isPrivateBrowsing == false)
3275 if(__pHistory != null)
3281 __pHistory = new(std::nothrow) History;
3282 HistoryPresentationModel::GetCurrentDateTime(date);
3285 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3286 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3288 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3289 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3291 __pHistory->SetVisitedTime(date);
3293 if (__pWebViewer != null)
3295 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3297 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3298 if (pTempBitmap != null)
3300 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3301 __pHistory->SetFavIconBitmap(*pTempBitmap);
3306 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3307 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3308 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3310 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3311 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3312 __pHistory->SetThumbnail(pBitmap);
3314 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3317 Tizen::Graphics::BufferInfo bmpInfo;
3318 pFavIcon->Lock(bmpInfo);
3319 AppLog("rrrr:: width %d height %d of the faviconbitmap from bufferinfo", bmpInfo.width, bmpInfo.height);
3321 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3323 AppLog("rrrr:: width %d height %d of the faviconbitmap",pFavIcon->GetWidth(),pFavIcon->GetHeight());
3324 __pHistory->SetFavIconBitmap(*pFavIcon);
3328 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3335 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3337 // temperary fixed (webpage can be not loaded)
3341 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3342 if (isReaderEnabled == true)
3346 delete __pReaderData;
3347 __pReaderData = null;
3349 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3350 filePath.Append(L"data/reader.js");
3356 result r = E_SUCCESS;
3357 FileAttributes attr;
3359 File::GetAttributes(filePath,attr);
3361 r = file.Construct(filePath, L"r+");
3364 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3367 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3370 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3373 // file.Read(pScript,attr.GetFileSize());
3375 // AppLogDebug("scipt length %d",strlen(pScript));
3376 String strScript = L"";
3377 // strScript.Append(pScript);
3378 // for(int i=0; i<25; i++)
3380 file.Read(pScript,attr.GetFileSize());
3381 // AppLog("xyzz tell %d",file.Tell());
3382 // r = strScript.Append(pScript);
3383 // AppLog("xyzz append result %s",GetErrorMessage(r));
3384 // AppLog("xyzz strScript length %d",strScript.GetLength());
3386 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3388 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3389 if (__pReaderData == null)
3391 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3392 __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>");
3395 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3396 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3398 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3399 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3405 AppLog("MainForm::OnLoadingCompleted done");
3409 MainForm::OnEstimatedProgress(int progress)
3411 AppLogDebug("MainForm::OnEstimatedProgress entered %d",progress);
3413 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3414 progress = DEFAULT_PROGRESS_PERCENTAGE;
3416 // __pAddressbar->UpdateProgress(progress);
3417 UpdateProgress(progress);
3420 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3422 AppLog("MainForm::OnFaviconReceived");
3423 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3425 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3428 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3435 MainForm::OnUrlValueChanged(Addressbar&)
3441 MainForm::OnUrlSubmitted(Addressbar& addBar)
3443 AppLog("MainForm::OnUrlSubmitted");
3444 String url = addBar.GetUrl();
3445 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3448 if(__pFooterUrlField)
3450 AppLog("Position:: %d, %ls",__pFooterUrlField->GetTextLength(),__pFooterUrlField->GetText().GetPointer());
3451 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3453 AddressBarCancelledClicked(*__pAddressbar);
3458 MainForm::LoadUrl(String& url)
3462 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3463 AppLogDebug("MainForm::LoadUrl enter");
3465 if (__pWebViewer != null)
3467 __pWebViewer->SetShowState(true);
3468 __pWebViewer->Invalidate(true);
3471 if (url.CompareTo(L"") == 0)
3475 if(__pFooterPanel != null)
3477 __pFooterPanel->SetShowState(true);
3478 __pFooterPanel->Invalidate(true);
3485 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3486 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)
3488 RegularExpression firstRegex;
3489 RegularExpression secondRegex;
3491 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3492 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3495 ret = firstRegex.Match(url, false); // This returns true value
3496 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3500 if (ret == true && __pWebViewer != null)
3503 __pWebViewer->LoadUrl(url);
3505 else if(__pWebViewer != null)
3507 String tempUrl = L"http://";
3508 tempUrl.Append(url);
3512 __pWebViewer->LoadUrl(tempUrl);
3516 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3517 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3520 if (__pAddressbar != null)
3522 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3523 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3526 AppLogDebug("MainForm::LoadUrl exit");
3533 MainForm::OnFocusGained(const Tizen::Ui::Control& source)
3535 AppLog("MainForm::OnFocusGained");
3538 __pFooterPanel->SetShowState(false);
3543 __pWebViewer->ReleaseBlock();
3548 __pAddressbar->SetShowState(true);
3549 __pAddressbar->SetAddressbarURLFocus();
3551 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3553 __currentSearchStr = L"";
3554 __currentWordIndex = 0;
3555 __maxOccurrances = 0;
3557 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
3559 __pFindWordEditField->SetText(L"");
3560 __pFindWordEditField->HideKeypad();
3561 __pFindWordControl->SetShowState(false);
3562 __pFindWordCountLabel->SetText(L"0/0");
3564 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
3566 __pFindWordEditFieldRightToLeft->SetText(L"");
3567 __pFindWordEditFieldRightToLeft->HideKeypad();
3568 __pFindWordControl->SetShowState(false);
3569 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3572 __pFindWordNext->SetEnabled(false);
3573 __pFindWordPrev->SetEnabled(false);
3576 __pWebViewer->SearchTextAllAsync(L"",true);
3577 __pFindWordControl->SetShowState(false);
3579 RelayoutControls(false);
3583 MainForm::OnFocusLost(const Tizen::Ui::Control& source)
3585 AppLog("MainForm::OnFocusLost called");
3589 MainForm::OnStopClicked(Addressbar& addBar)
3591 AppLogDebug("MainForm::OnStopClicked called");
3594 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3595 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3596 __pWebViewer->StopLoading();
3597 RequestRedraw(true);
3602 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3604 // AppLog("MainForm::OnBackClicked");
3605 result r = E_FAILURE;
3606 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3608 AppLog("Hiding the menu");
3609 __pImageMenu->SetShowState(false);
3612 if (__pWebViewer && __pWebViewer->CanGoBack())
3614 __pWebViewer->GoBack();
3616 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3619 pApp = UiApp::GetInstance();
3622 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3625 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3633 WindowInfo* pWindowInfo = null;
3635 SceneManager* pSceneManager = SceneManager::GetInstance();
3636 if (pSceneManager == null)
3640 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3641 if (pAllWindowList == NULL)
3643 pApp = UiApp::GetInstance();
3646 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3649 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3654 if (pAllWindowList != null)
3656 totalCount = pAllWindowList->GetCount();
3658 for (int count = 0; count < totalCount; count++)
3660 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3661 if (pWindowInfo == null)
3663 pApp = UiApp::GetInstance();
3666 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3669 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3674 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3676 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3679 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3682 r = pAllWindowList->RemoveAt(count, true);
3683 __pWindowInfo = null;
3686 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3691 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3693 else if(pAllWindowList->GetCount() > 0)
3695 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3699 pApp = UiApp::GetInstance();
3702 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3707 if (pWindowInfo == null)
3709 pApp = UiApp::GetInstance();
3712 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
3718 r = pSceneManager->GoForward(ForwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
3719 // r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3722 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3736 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3738 AppLog("MainForm::OnForwardClicked");
3739 if (__pWebViewer == null)
3742 if (__pWebViewer->CanGoForward())
3744 __pWebViewer->GoForward();
3749 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3751 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3752 if(__pFooterPanel != null)
3754 __pFooterPanel->SetShowState(false);
3757 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3759 __pAddressbar->SetShowState(true);
3760 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3763 RelayoutControls(false);
3767 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3769 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3771 int Height = GetClientAreaBounds().height;
3772 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3774 RelayoutControls(false);
3778 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3780 AddressBarCancelledClicked(addBar);
3784 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3786 __prevAddressBarMode = __curAddressBarMode;
3788 if (__pAddressbar != null)
3790 __curAddressBarMode = GetAddressbarMode();
3793 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3795 __adressPanelPosition.y = 0;
3796 if (__pAddressbar != null)
3798 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3799 __webControlPositionF.y = __pAddressbar->GetHeightF() - 12.0f;
3800 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3801 __pAddressbar->Invalidate(true);
3803 if (__pWebViewer != null)
3805 __pWebViewer->StopLoading();
3808 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3810 __adressPanelPosition.y = 0;
3811 if (__pAddressbar != null)
3813 __webControlPosition.y = 0;
3814 __webControlPositionF.y = 0.0f;
3815 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3816 __pAddressbar->Invalidate(true);
3822 MainForm::OnClipboardClosed(const Addressbar& addBar)
3824 AppLog("XYZ::MainForm::OnClipboardClosed");
3825 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3827 AppLog("akjshdasd 3");
3828 __pFooterPanel->SetShowState(true);
3830 __isKeypadOpened = false;
3831 RelayoutControls(false);
3835 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3837 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3838 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3840 AppLog("akjshdasd 3");
3841 __pFooterPanel->SetShowState(true);
3843 __isKeypadOpened = false;
3844 if(__pNotification && __pNotification->GetShowState())
3846 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3849 RelayoutControls(false,footerState);
3853 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3855 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3856 __isKeypadOpened = true;
3857 if(__pNotification && __pNotification->GetShowState())
3859 __pNotification->SetPosition(0,GetClientAreaBounds().height - __pNotification->GetHeight());
3861 RelayoutControls(false);
3865 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3867 __isKeypadOpened = true;
3868 __pFooterPanel->SetShowState(false);
3872 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3874 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3875 RelayoutControls(false);
3879 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3881 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3884 __pWindowInfo->pageTitle = title;
3885 if (__pWebViewer != null)
3887 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3888 AppLog("MainForm::OnPageTitleReceived url %ls",__pWindowInfo->pageUrl.GetPointer());
3891 if (__pAddressbar != null && __pWebViewer != null)
3893 SetUrl(__pWebViewer->GetUrl());
3894 __pAddressbar->Invalidate(true);
3899 MainForm::UpdateFavicon(void)
3901 AppLog("MainForm::UpdateFavicon called");
3902 bool urlImageType = false;
3903 String *tempPath = null;
3905 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();");
3906 Bitmap* pBitmap = null;
3908 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3910 if (__pWindowInfo != null)
3913 url.SetUri(*tempPath);
3914 if (url.GetHost().GetLength() == 0)
3918 webUrl.SetUri(__pWebViewer->GetUrl());
3919 result r = url.SetHost(webUrl.GetHost());
3926 if (url.GetScheme().GetLength() == 0)
3930 webUrl.SetUri(__pWebViewer->GetUrl());
3931 url.SetScheme(webUrl.GetScheme());
3933 __pWindowInfo->faviconUrl = url.ToString();
3935 pBitmap = __pWebViewer->GetFaviconN();
3937 if (pBitmap != null)
3939 AppLog("__pWindowInfo->pFavicon updating favicon");
3940 if (__pWindowInfo->pFavicon != NULL)
3942 __pWindowInfo->pFavicon = null;
3944 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3945 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3947 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3949 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3951 else if(__pWindowInfo->pFavicon != null)
3953 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3957 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3958 if(pDefaultBmp != null)
3960 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3974 if(tempPath != null)
3978 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3984 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3985 Tizen::Web::Controls::WebNavigationType type)
3987 AppLog("urlk %ls",url.GetPointer());
3988 // when load new page if find word panel is open its show state is false
3989 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3991 __currentSearchStr = L"";
3992 __currentWordIndex = 0;
3993 __maxOccurrances = 0;
3994 __pFindWordEditField->SetText(L"");
3995 __pFindWordNext->SetEnabled(false);
3996 __pFindWordPrev->SetEnabled(false);
3997 __pFindWordCountLabel->SetText(L"0/0");
3998 __pFindWordControl->SetShowState(false);
3999 __pFindWordEditField->HideKeypad();
4000 RelayoutControls(false);
4003 __pFooterPanel->Invalidate(true);
4006 uriInfo.SetUri(url);
4008 if(url.Contains(IDS_TIZEN_SERVICE))
4011 String delim(L":;,");
4013 // Creates a StringTokenizer instance
4014 StringTokenizer strTok(url, delim);
4016 int count = strTok.GetTokenCount(); // count == 4
4018 HashMap *pMap = new HashMap();
4024 while (strTok.HasMoreTokens())
4026 AppLog("Token: %ls", token.GetPointer());
4027 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
4028 if(token.Contains(IDS_APPID))
4030 token.SubString(6, appId);
4031 AppLog("AppID:%ls", appId.GetPointer());
4033 else if(token.Contains(IDS_KEY))
4035 token.SubString(4, key);
4036 AppLog("key:%ls", key.GetPointer());
4038 else if(token.Contains(IDS_VALUE))
4040 token.SubString(6, value);
4041 AppLog("value:%ls", value.GetPointer());
4044 pMap->Add(key, value);
4048 AppControl *pAppControl = null;
4049 String operationId = L"http://tizen.org/appcontrol/operation/main";
4050 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
4053 result r = pAppControl->Start(null, null, pMap, null);
4057 AppLogException("AppControl not found");
4067 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
4068 const Tizen::Net::Http::HttpHeader& httpHeader)
4070 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
4074 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
4076 AppLog("LMN::MainForm::OnWebPageBlockSelected");
4077 // if(__isLongPressedDone == false)
4080 if (__pHitElementResult != null)
4082 delete __pHitElementResult;
4083 __pHitElementResult = null;
4086 if (__pWebViewer != null)
4088 AppLog("MainForm::OnWebPageBlockSelected web not null");
4089 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
4091 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4093 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
4094 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4095 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().Equals(L"INPUT",false) == false && __pHitElementResult->GetTagName().Equals(L"TEXTAREA",false) == false))
4097 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
4098 if(__pHitElementResult == null)
4100 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
4103 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
4107 if (__pHitElementResult == null)
4112 if (__pHitElementResult->HasImage() != true)
4114 String tagName = __pHitElementResult->GetTagName();
4115 String type = __pHitElementResult->GetAttributeValue("type");
4116 String contenteditable = __pHitElementResult->GetAttributeValue("contenteditable");
4119 AppLog("TagName %ls",tagName.GetPointer());
4120 __currentSelectedStr.Clear();
4121 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
4122 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4123 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
4124 if(tagName.Equals(L"TEXTAREA",false) == true)
4126 AppLog("Tagnameseemstobe TEXTAREA");
4128 else if(tagName.Equals(L"INPUT",false) == true)
4130 AppLog("Tagnameseemstobe INPUT");
4133 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 )
4135 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4137 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),true);
4140 __pImageMenu->SetShowState(true);
4141 __pImageMenu->Show();
4142 __pImageMenu->Invalidate(true);
4145 else /*if(__isLongPressedDone == true)*/
4147 AppLog("MainForm::OnWebPageBlockSelected no paste option");
4149 if(__pHitElementResult->GetUrl().GetLength() > 0)
4151 __currentSelectedStr.Clear();
4152 __currentSelectedStr = __pHitElementResult->GetUrl();
4154 InitSelectTextContextMenuF(FloatPoint(startPoint.x,startPoint.y + __pWebViewer->GetY()),false);
4157 __pImageMenu->SetShowState(true);
4158 __pImageMenu->Show();
4159 __pImageMenu->Invalidate(true);
4163 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
4164 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
4165 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
4171 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
4177 MainForm::OnWebWindowCreateRequested(void)
4179 AppLog("MainForm::OnWebWindowCreateRequested entered");
4180 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4182 if (pNewWindowInfo == null)
4186 result r = E_SUCCESS;
4187 SceneManager* pSceneManager = SceneManager::GetInstance();
4188 if (pSceneManager == NULL)
4192 ArrayList* pArgList = new(std::nothrow) ArrayList();
4193 if (pArgList == NULL)
4197 r = pArgList->Construct();
4200 pNewWindowInfo->isJavascriptInitiated = true;
4201 pArgList->Add(*pNewWindowInfo);
4202 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4206 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
4213 return pNewWindowInfo->pCurrentWeb;
4217 MainForm::OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source)
4219 AppLog("OnWebWindowCloseRequested");
4220 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
4221 SceneManager* pSceneManager = SceneManager::GetInstance();
4222 WindowInfo* pWindowInfo = null;
4223 WindowInfo* pNewWindowInfo = null;
4226 result r = E_FAILURE;
4228 if (pAllWindowList != null)
4230 totalCount = pAllWindowList->GetCount();
4233 for (int count = 0; count < totalCount; count++)
4235 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
4237 if (__pWindowInfo != null && pWindowInfo != null && __pWindowInfo->sceneID == pWindowInfo->sceneID)
4239 r = SceneRegister::DestroyAndUnRegisterScene(__pWindowInfo->sceneID);
4240 r = pAllWindowList->RemoveAt(count, true);
4242 Form* pCurrentForm = null;
4243 if(SceneManager::GetInstance()->GetCurrentScene() != null)
4244 pCurrentForm = (SceneManager::GetInstance()->GetCurrentScene()->GetForm());
4247 pCurrentForm->SendUserEvent(UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED, null);
4250 if (pAllWindowList->GetCount() > 0)
4252 pNewWindowInfo = null;
4253 pNewWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
4257 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
4259 if (pNewWindowInfo == null)
4263 result r = E_SUCCESS;
4264 SceneManager* pSceneManager = SceneManager::GetInstance();
4265 if (pSceneManager == NULL)
4269 ArrayList* pArgList = new(std::nothrow) ArrayList();
4270 if (pArgList == NULL)
4274 r = pArgList->Construct();
4277 pArgList->Add(*pNewWindowInfo);
4278 result r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4279 if (pArgList != null)
4286 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
4291 pApp = UiApp::GetInstance();
4294 r = pApp->GetFrameAt(0)->SetShowMode(FRAME_SHOW_MODE_MINIMIZED);
4299 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE,SCENE_HISTORY_OPTION_ADD_HISTORY,SCENE_DESTROY_OPTION_DESTROY));
4310 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
4312 AppLog("xyz:: MainForm::RelayoutControls called");
4313 __webControlPosition.y = 0;
4314 __webControlPositionF.y = 0.0f;
4315 __webControlHeight = GetClientAreaBounds().height;
4316 __webControlHeightF = GetClientAreaBoundsF().height;
4317 AppLog("Client area height: %d width %d", __webControlHeight,GetClientAreaBounds().width);
4319 AppLog("Client area height: %d", __webControlHeight);
4320 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
4322 __webControlPosition.y += __pAddressbar->GetHeight();
4323 __webControlPositionF.y += __pAddressbar->GetHeightF();
4324 __webControlHeight -= __pAddressbar->GetHeight();
4325 __webControlHeightF -= __pAddressbar->GetHeightF();
4326 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
4328 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
4330 __webControlPosition.y += __pFindWordControl->GetHeight();
4331 __webControlPositionF.y += __pFindWordControl->GetHeightF();
4332 __webControlHeight -= __pFindWordControl->GetHeight();
4333 __webControlHeightF -= __pFindWordControl->GetHeightF();
4334 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
4337 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
4339 __webControlHeight -= __pFooterPanel->GetHeight();
4340 __webControlHeightF -= __pFooterPanel->GetHeightF();
4342 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0F, __webControlPositionF.y + __webControlHeightF, GetClientAreaBoundsF().width, __pFooterPanel->GetHeightF())));
4343 __webControlHeight = __webControlHeight + 12;
4344 __webControlHeightF = __webControlHeightF + 12.0f;
4349 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
4351 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight )
4356 __pWebViewer->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0.0f, __webControlPositionF.y, GetClientAreaBoundsF().width, __webControlHeightF)));
4357 AppLog("xyz:: MainForm::RelayoutControls called __webControlHeight %d",__webControlHeight);
4358 __pWebViewer->Invalidate(false);
4362 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
4364 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
4371 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
4373 if (__pFindWordControl == null)
4378 Tizen::Locales::LocaleManager localeManager;
4379 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
4381 String languageCode;
4382 result r = SettingInfo::GetValue(L"Language", languageCode);
4383 // int languagecode = local.GetLanguageCode();
4384 AppLog("rahul language is %S", languageCode.GetPointer());
4388 InitFindWordPanel();
4390 if (languageCode.CompareTo("ara") == 0)
4392 AppLog("rahul language is arabic");
4394 __pFindWordPanelLeftToRight->SetShowState(false);
4395 __pFindWordPanelRightToLeft->SetShowState(true);
4397 __pFindWordClear->SetShowState(false);
4398 __pFindWordCountLabel->SetShowState(false);
4399 __pFindWordEditField->SetShowState(false);
4401 __pFindWordClearRightToLeft->SetShowState(true);
4402 __pFindWordCountLabelRightToLeft->SetShowState(true);
4403 __pFindWordEditFieldRightToLeft->SetShowState(true);
4407 AppLog("rahul language is not arabic");
4410 __pFindWordPanelLeftToRight->SetShowState(true);
4411 __pFindWordPanelRightToLeft->SetShowState(false);
4413 __pFindWordClear->SetShowState(true);
4414 __pFindWordCountLabel->SetShowState(true);
4415 __pFindWordEditField->SetShowState(true);
4417 __pFindWordClearRightToLeft->SetShowState(false);
4418 __pFindWordCountLabelRightToLeft->SetShowState(false);
4419 __pFindWordEditFieldRightToLeft->SetShowState(false);
4421 __pFindWordControl->SetShowState(true);
4425 if(__pFindWordControl != null)
4427 __pFindWordControl->SetShowState(false);
4431 AppLog("MainForm::ShowFindWordPanel %d",show);
4432 if (show && !isTouchPressed)
4434 if (languageCode.CompareTo("ara") == 0)
4436 if (__pFindWordEditFieldRightToLeft)
4438 __pFindWordEditFieldRightToLeft->SetFocus();
4439 __pFindWordEditFieldRightToLeft->ShowKeypad();
4444 if (__pFindWordEditField)
4446 __pFindWordEditField->SetFocus();
4447 __pFindWordEditField->ShowKeypad();
4453 if (languageCode.CompareTo("ara") == 0)
4455 if (__pFindWordEditFieldRightToLeft)
4456 __pFindWordEditFieldRightToLeft->HideKeypad();
4460 if (__pFindWordEditField)
4461 __pFindWordEditField->HideKeypad();
4465 RelayoutControls(false);
4469 MainForm::StartWordSearch()
4471 //Get the count of occurances of the word in the current page
4472 __maxOccurrances = 0;
4473 __currentWordIndex = 0;
4475 __pFindWordPrev->SetEnabled(false);
4476 String *pCountStr = null;
4479 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4480 AppLog("Search Result %s",GetErrorMessage(r));
4483 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4484 if (pCountStr != null)
4486 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4490 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4495 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4497 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4498 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4502 if (__pFindWordCountLabel)
4504 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4506 if (__pFindWordEditField)
4508 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4511 else if(totalCount >= 100)
4513 if (__pFindWordCountLabel)
4515 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4517 if (__pFindWordEditField)
4519 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4524 if (__pFindWordCountLabel)
4526 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4528 if (__pFindWordEditField)
4530 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4534 __maxOccurrances = totalCount;
4535 __currentWordIndex = currentOrdinal;
4537 //Reset the UI controls as per the maxOccurrance value
4538 if (totalCount <= 0)
4540 AppLog("Word not found");
4541 //Show error notification to user
4543 __pFindWordNext->SetEnabled(false);
4544 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4546 __pFindWordCountLabel->SetText(L"0/0");
4547 __pFindWordCountLabel->Invalidate(false);
4549 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4551 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4552 __pFindWordCountLabelRightToLeft->Invalidate(false);
4555 __pFindWordNext->Invalidate(false);
4556 __pFindWordPrev->Invalidate(false);
4561 if (totalCount == 1 || totalCount == currentOrdinal)
4564 __pFindWordNext->SetEnabled(false);
4569 __pFindWordNext->SetEnabled(true);
4572 String countStr = L"";
4573 countStr.Append(__currentWordIndex);
4574 countStr.Append(L"/");
4575 countStr.Append(__maxOccurrances);
4576 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4578 __pFindWordCountLabel->SetText(countStr);
4579 __pFindWordCountLabel->Invalidate(false);
4580 __pFindWordCountLabel->Invalidate(false);
4582 else if (__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4584 __pFindWordCountLabelRightToLeft->SetText(countStr);
4585 __pFindWordCountLabelRightToLeft->Invalidate(false);
4586 __pFindWordCountLabelRightToLeft->Invalidate(false);
4588 if (__pFindWordNext)
4590 __pFindWordNext->Invalidate(false);
4592 if (__pFindWordPrev)
4594 __pFindWordPrev->Invalidate(false);
4600 MainForm::FindNextWord(bool next)
4604 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4605 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4607 if (__currentWordIndex < __maxOccurrances)
4609 __currentWordIndex++;
4615 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4616 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4618 if(__currentWordIndex > 1)
4620 __currentWordIndex--;
4625 String countStr = L"";
4626 countStr.Append(__currentWordIndex);
4627 countStr.Append(L"/");
4628 countStr.Append(__maxOccurrances);
4630 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4632 __pFindWordCountLabel->SetText(countStr);
4633 __pFindWordCountLabel->Invalidate(false);
4635 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4637 __pFindWordCountLabelRightToLeft->SetText(countStr);
4638 __pFindWordCountLabelRightToLeft->Invalidate(false);
4641 if (__currentWordIndex >= __maxOccurrances)
4643 __pFindWordNext->SetEnabled(false);
4647 __pFindWordNext->SetEnabled(true);
4649 if (__currentWordIndex <= 1)
4651 __pFindWordPrev->SetEnabled(false);
4655 __pFindWordPrev->SetEnabled(true);
4657 __pFindWordPrev->Invalidate(false);
4658 __pFindWordNext->Invalidate(false);
4660 __pFindWordControl->Invalidate(true);
4664 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4666 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4667 __isKeypadOpened = true;
4668 __pFooterPanel->SetShowState(false);
4669 // OnAddressBarKeypadOpened(*__pAddressbar);
4673 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4675 __isKeypadOpened = true;
4676 AppLog("xyz::MainForm::OnWebKeypadOpened");
4678 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4680 __currentSearchStr = L"";
4681 __currentWordIndex = 0;
4682 __maxOccurrances = 0;
4683 __pFindWordEditField->SetText(L"");
4684 __pFindWordNext->SetEnabled(false);
4685 __pFindWordPrev->SetEnabled(false);
4686 __pFindWordCountLabel->SetText(L"0/0");
4687 __pWebViewer->SearchTextAllAsync(L"",false);
4688 __pFindWordControl->SetShowState(false);
4689 __pFindWordEditField->HideKeypad();
4693 if (__pWebViewer != null && __pFooterPanel != null)
4695 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4696 if(__pAddressbar != null)
4698 __pAddressbar->SetShowState(false);
4700 if(__pFindWordControl != null)
4702 __pFindWordControl->SetShowState(false);
4704 __pFooterPanel->SetShowState(false);
4705 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4707 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4709 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4710 // AppLog("omgomgomg");
4716 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4718 AppLog("abcde::MainForm::OnWebKeypadClosed");
4719 AppLog("xyz::MainForm::OnWebKeypadClosed");
4720 AppLog("akjshdasd 4");
4721 __pFooterPanel->SetShowState(true);
4722 // OnAddressBarKeypadClosed(*__pAddressbar);
4723 RelayoutControls(false);
4724 __isKeypadOpened = false;
4727 if(__pImageMenu && __pImageMenu->GetShowState() == true)
4729 AppLog("abcde: imagemenu visible.");
4732 __pWebViewer->GetBlockRange(p,q);
4733 if (p == Point(0,0) && q == Point(0,0))
4741 __pImageMenu->SetAnchorPosition(p);
4742 __pImageMenu->Show();
4748 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4750 // RelativeLayout(false);
4751 if(__pWebViewer != null)
4753 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4758 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4760 Control* temp = const_cast< Control* >(&source);
4761 Header* pHeader = dynamic_cast< Header* >(temp);
4762 if (pHeader != null)
4764 //Header double - clicked
4765 AppLog("Header double clicked");
4767 if(__pFindWordControl)
4769 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4770 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4774 AppLog("MainScene::OnTouchDoublePressed");
4778 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4780 AppLog("LMN::abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4781 if(TouchEventManager::GetInstance() && TouchEventManager::GetInstance()->GetTouchInfoListN() && TouchEventManager::GetInstance()->GetTouchInfoListN()->GetCount() >1)
4783 AppLog("Returning because of more than one touch point.");
4787 // __pWebViewer->ReleaseBlock();
4789 __pWebViewer->SetFocus();
4790 __longPressPoint = currentPosition;
4792 if (__pHitElementResult != null)
4794 delete __pHitElementResult;
4795 __pHitElementResult = null;
4798 if (__pWebViewer != null)
4800 AppLog("MainForm::OnTouchLongPressed web not null");
4801 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4804 if (__pHitElementResult == null)
4809 if (__pHitElementResult->HasImage() == true)
4811 if(__pWebViewer != null)
4813 __pWebViewer->ReleaseBlock();//N_SE-52389
4814 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4816 __pImageMenu->SetShowState(true);
4817 __pImageMenu->Show();
4818 __pImageMenu->Invalidate(true);
4820 else if(__pHitElementResult->HasUrl() == true)
4822 if(__pWebViewer != null)
4823 __pWebViewer->ReleaseBlock();//N_SE-52389
4824 String tempURl = __pHitElementResult->GetUrl();
4825 AppLog("tempURl is %ls", tempURl.GetPointer());
4826 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4827 if (pBitmap != null)
4835 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4836 __pImageMenu->SetShowState(true);
4837 __pImageMenu->Show();
4838 __pImageMenu->Invalidate(true);
4842 String tagName = __pHitElementResult->GetTagName();
4843 String type = __pHitElementResult->GetAttributeValue("type");
4844 String value = __pHitElementResult->GetAttributeValue(L"value");
4845 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4846 result r = E_FAILURE;
4847 __currentSelectedStr.Clear();
4848 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4850 AppLog("tag name is %ls", tagName.GetPointer());
4851 AppLog("type is %ls", type.GetPointer());
4855 __isLongPressedDone = true;
4856 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)
4857 r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4858 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)
4860 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4862 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4865 __pImageMenu->SetShowState(true);
4866 __pImageMenu->Show();
4867 __pImageMenu->Invalidate(true);
4870 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4873 // __inputEventToBeSupressed = true;
4877 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4879 AppLog("xyz:: MainForm::OnTouchReleased called");
4881 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4883 __pAddressbar->SetShowState(false);
4885 if(__pFooterPanel && __isKeypadOpened == false)
4887 __pFooterPanel->SetShowState(true);
4891 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4892 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4894 __pWebViewer->ConsumeInputEvent();
4896 if(pHitElement != null)
4900 __inputEventToBeSupressed = false;*/
4904 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4911 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4913 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4915 __currentSearchStr = L"";
4916 __currentWordIndex = 0;
4917 __maxOccurrances = 0;
4919 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4921 __pFindWordEditField->SetText(L"");
4922 __pFindWordEditField->HideKeypad();
4923 __pFindWordControl->SetShowState(false);
4924 __pFindWordCountLabel->SetText(L"0/0");
4926 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4928 __pFindWordEditFieldRightToLeft->SetText(L"");
4929 __pFindWordEditFieldRightToLeft->HideKeypad();
4930 __pFindWordControl->SetShowState(false);
4931 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4934 __pFindWordNext->SetEnabled(false);
4935 __pFindWordPrev->SetEnabled(false);
4937 __pWebViewer->SearchTextAllAsync(L"",true);
4938 __pFindWordControl->SetShowState(false);
4940 AppLog("__pAddressbar->GetShowState() %d",__pAddressbar->GetShowState());
4941 if(__pAddressbar->GetShowState() == false)
4943 __pAddressbar->SetAddressbarURLFocus();
4944 __pFooterPanel->SetShowState(false);
4951 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4957 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4963 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4969 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4975 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4981 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4983 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4984 int widthContextItem = 0;
4985 //if(__pFindWordCountLabel)
4986 // __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4987 // As per the platform engineer comment removed this line
4988 /*if(__pWebViewer != null)
4990 // 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
4991 __pWebViewer->ReleaseBlock();
4994 // if(__pFindWordControl != null)
4995 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4997 if(__pOptionMenu && __pOptionMenu->GetShowState() == true)
4999 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5001 AppLog(" Orientation landscape");
5002 __pOptionMenu->SetMaxVisibleItemsCount(5);
5006 AppLog(" Orientation potrait");
5007 __pOptionMenu->SetMaxVisibleItemsCount(6);
5010 if(__pNotification && __pNotification->GetShowState() == true)
5012 __pNotification->SetShowState(false);
5013 __pNotification->Invalidate(false);
5015 if ( __pFooterLabel != null)
5017 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
5020 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
5026 if (__pFindWordBgLabel != null)
5028 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
5029 if (pBitmap != null)
5031 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
5036 if (__pFindWordBgLabelRightToLeft != null)
5038 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
5039 if (pBitmap != null)
5041 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
5047 // if(__pOptionMenu != null)
5048 // __pOptionMenu->SetShowState(false);
5050 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
5052 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
5056 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
5061 AppLog("__pFooterPanel->GetShowState() is true");
5063 __pFooterPanel->SetBounds(CoordinateSystem::AlignToDevice(FloatRectangle(0, GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF(), __pFooterPanel->GetWidthF(), __pFooterPanel->GetHeightF())));
5064 __pFooterPanel->Invalidate(true);
5068 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
5069 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
5071 InitMostVisitedSitesView(orientationStatus);
5074 RelayoutControls(false);
5075 if (__pArticleReaderPanel != null)
5077 if (__pArticleReaderPanel->GetShowState() == true)
5079 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
5081 if (__pBlankPanel != null)
5082 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
5084 if (__pWebReader != null)
5086 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
5088 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5089 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
5091 if ( pBitmap != null && pSrcBitmap != null)
5093 AppLog("CreateReaderPanel ninepatchbitmap found");
5094 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
5097 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
5098 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
5099 if (pBitmap != null)
5104 if (pSrcBitmap != null)
5113 if (__pAddressbar != null)
5115 int width = GetClientAreaBounds().width;
5116 __pAddressbar->OrientationChanged(width);
5121 MainForm::OnSettingsChange(int settingvalue)
5123 AppLogDebug("MainForm::OnSettingsChange entered");
5125 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
5127 __pAddressbar->ResetGuideText();
5129 if (__pWebViewer == null)
5131 AppLogDebug("Webviewer is not initialized yet.");
5135 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
5137 WebSetting settings = __pWebViewer->GetSetting();
5138 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
5140 settings.SetAutoFittingEnabled(true);
5142 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
5144 settings.SetAutoFittingEnabled(false);
5146 __pWebViewer->SetSetting(settings);
5149 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
5151 WebSetting settings = __pWebViewer->GetSetting();
5152 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
5153 __pWebViewer->SetSetting(settings);
5155 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
5157 WebSetting settings = __pWebViewer->GetSetting();
5158 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
5159 __pWebViewer->SetSetting(settings);
5160 __pWebViewer->Reload();
5162 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
5164 WebSetting settings = __pWebViewer->GetSetting();
5165 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
5166 __pWebViewer->SetSetting(settings);
5168 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
5172 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5175 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
5179 WebSetting settings = __pWebViewer->GetSetting();
5180 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
5181 __pWebViewer->SetSetting(settings);
5184 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
5188 WebSetting settings = __pWebViewer->GetSetting();
5189 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
5190 __pWebViewer->SetSetting(settings);
5193 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
5195 WebSetting settings = __pWebViewer->GetSetting();
5196 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
5198 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
5202 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
5204 __pWebViewer->SetSetting(settings);
5206 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
5210 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
5211 WebSetting settings = __pWebReader->GetSetting();
5212 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
5213 __pWebReader->SetSetting(settings);
5219 MainForm::OnSettingsReset()
5223 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
5224 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
5229 MainForm::OnClearCache()
5231 result r = E_SUCCESS;
5233 if (__pWebViewer != NULL)
5235 r = __pWebViewer->ClearCache();
5238 AppLogDebug("Cache cleared success");
5242 AppLogDebug("Cache cleared fail");
5248 MainForm::OnClearCookie()
5250 result r = E_SUCCESS;
5252 if (__pWebViewer != NULL)
5254 __pWebViewer->ClearCookie();
5258 AppLogDebug("Cookie cleared success");
5262 AppLogDebug("Cache cleared fail");
5267 MainForm::OnClearFormData()
5269 result r = E_SUCCESS;
5271 if (__pWebViewer != NULL)
5273 __pWebViewer->ClearFormData();
5277 AppLogDebug("Cookie cleared success");
5281 AppLogDebug("Cache cleared fail");
5286 MainForm::OnClearPasswords()
5288 result r = E_SUCCESS;
5290 if (__pWebViewer != NULL)
5292 __pWebViewer->ClearLoginFormData();
5296 AppLogDebug("Cookie cleared success");
5300 AppLogDebug("Cache cleared fail");
5306 MainForm::findDistance(int x1,int y1,int x2, int y2)
5308 int deltaX = Math::Abs(x2 - x1);
5309 int deltaY = Math::Abs(y2 - y1);
5310 double num = deltaX*deltaX + deltaY*deltaY;
5316 for (i = 0; i < 20; i++)
5318 x = (((x*x)+ num)/(2*x));
5329 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5331 AppLog("xyz:: MainForm::OnTouchPressed called");
5332 if(__pFindWordControl)
5334 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
5335 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
5337 __isLongPressedDone = false;
5342 IList* pList = null;
5343 pList = touch.GetTouchInfoListN(source);
5347 int count = pList->GetCount();
5350 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5351 __touchPoint1 = pTouchInfo->position;
5353 /*if (__pAddressbar != null)
5355 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5357 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5359 __pAddressbar->SaveAddressbarEditText();
5361 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5364 __pAddressbar->Invalidate(true);
5366 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
5368 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
5370 //__pAddressbar->SaveAddressbarEditText();
5372 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
5375 else if (count == 2)
5377 AppLogDebug("MainForm::OnTouchPressed count is two");
5378 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
5379 __touchPoint1 = pTouchInfo->position;
5381 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
5382 __touchPoint2 = pTouchInfo->position;
5387 pList->RemoveAll(true);
5392 __pAddressbar->SetShowState(false);
5394 if(__pFooterPanel && __isKeypadOpened == false)
5396 __pFooterPanel->SetShowState(true);
5398 RelayoutControls(false);
5403 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
5405 AppLog("LMN::MainForm::OnTouchMoved entered");
5406 // __currentWordIndex = 0;
5407 __isLongPressedDone = false;
5412 MainForm::MoveUiControls()
5417 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
5419 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
5421 if(__pFooterUrlField->GetTextLength() == 0)
5423 __pFooterUrlField->SetKeypadActionEnabled(false);
5427 __pFooterUrlField->SetKeypadActionEnabled(true);
5430 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
5432 __currentSearchStr = __pFindWordEditField->GetText();
5433 if (__currentSearchStr.GetLength() > 0)
5435 __pFindWordCountLabel->SetShowState(true);
5439 // __pFindWordCountLabel->SetShowState(false);
5440 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
5441 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
5444 __pFindWordNext->SetEnabled(false);
5445 __pFindWordPrev->SetEnabled(false);
5446 __pFindWordNext->Invalidate(true);
5447 __pFindWordPrev->Invalidate(true);
5448 __pFindWordCountLabel->SetText(L"0/0");
5449 __pFindWordCountLabel->Invalidate(true);
5451 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
5453 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
5454 if (__currentSearchStr.GetLength() > 0)
5456 __pFindWordCountLabelRightToLeft->SetShowState(true);
5460 __pFindWordCountLabelRightToLeft->SetShowState(false);
5463 __pFindWordNext->SetEnabled(false);
5464 __pFindWordPrev->SetEnabled(false);
5465 __pFindWordNext->Invalidate(true);
5466 __pFindWordPrev->Invalidate(true);
5467 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
5468 __pFindWordCountLabelRightToLeft->Invalidate(true);
5470 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
5471 if (__currentSearchStr.GetLength() > 0)
5477 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
5479 __currentSearchStr = L"";
5480 AppLogDebug("Enter something");
5485 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
5492 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
5494 if(__pWebViewer != null)
5497 AppLog("MainForm::InitMostVisitedSitesView");
5498 result r = E_SUCCESS;
5501 if (__pMostVisitedListView != null)
5503 __pMostVisitedListView->SetShowState(true);
5507 if (__pMostVisitedListView != null)
5509 RemoveControl(__pMostVisitedListView);
5511 if(__pMostVisitedSites != null)
5513 __pMostVisitedSites->RemoveAll(true);
5516 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
5518 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
5519 __webControlHeightF = GetClientAreaBoundsF().height - __pFooterPanel->GetHeightF();
5520 __pMostVisitedListView = new(std::nothrow) ListView();
5522 int height = GetClientAreaBounds().height;
5524 if(__pFooterPanel->GetShowState() == true)
5526 height = height - __pFooterPanel->GetHeight();
5528 if(__pAddressbar->GetShowState() == true)
5530 height -= __pAddressbar->GetHeight();
5533 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
5537 delete __pMostVisitedListView;
5538 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
5541 __pMostVisitedListView->SetItemProvider(*this);
5542 __pMostVisitedListView->AddListViewItemEventListener(*this);
5543 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_VISITED_SITES"));
5544 AddControl(__pMostVisitedListView);
5545 __pMostVisitedListView->UpdateList();
5552 MainForm::GetImagePath(void)
5556 String formattedTime;
5557 DateTime currentTime;
5558 LocaleManager localManager;
5559 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5561 localManager.Construct();
5562 Locale locale = localManager.GetSystemLocale();
5563 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5565 // Get date formatter
5566 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5570 pTimeFormatter->Format(currentTime, formattedTime);
5573 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5574 String delim(L" :");
5575 StringTokenizer strTok(formattedTime, delim);
5578 String str1("GMT+00");
5579 while (strTok.HasMoreTokens())
5581 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5582 if(token.Equals(str1))
5584 AppLog("token is %ls", token.GetPointer());
5585 imageName.Append(token);
5591 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5593 result r = E_FAILURE;
5594 AppLog("Content manager 1");
5595 ContentId contentId;
5596 ContentManager contentManager;
5597 r = contentManager.Construct();
5600 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5603 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5604 Tizen::Io::Directory::Create(contentPath,true);
5605 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5607 AppLog("Already exists");
5609 else if(GetLastResult() == E_SUCCESS)
5611 AppLog("created success");
5613 contentPath.Append(imageName);
5614 contentPath.Append(".jpg");
5615 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5616 ShowIndicatorNotification(L"Download Complete",contentPath);
5617 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5621 MainForm::ShowIndicatorNotification(const String& messageText, const String& contentPath)
5623 AppLogDebug("ENTER");
5625 NotificationRequest request;
5626 request.SetAlertText(messageText);
5627 request.SetTitleText(L"");
5628 request.SetAppMessage(contentPath);
5630 Tizen::App::App* pApp = Tizen::App::App::GetInstance();
5631 String homePath = pApp->GetAppRootPath();
5632 String iconPath = homePath + L"res/screen-density-xhigh/Notification_download_complete.png";
5633 AppLog("The iconPath is : %ls", homePath.GetPointer());
5634 request.SetIconFilePath(iconPath);
5636 Tizen::Shell::NotificationManager notiMgr;
5637 notiMgr.Construct();
5638 notiMgr.Notify(request);
5639 AppLogDebug("EXIT: %s", GetErrorMessage(GetLastResult()));
5644 MainForm::SetForwardButtonEnabled(bool isEnabled)
5646 __pGoForwardBtn->SetEnabled(isEnabled);
5647 __pGoForwardBtn->Invalidate(true);
5651 MainForm::SetBackButtonEnabled(bool isEnabled)
5653 __pGoBackBtn->SetEnabled(isEnabled);
5654 __pGoBackBtn->Invalidate(true);
5658 MainForm::UpdateProgress(int percentage)
5660 __progressPercentage = percentage;
5661 if (percentage == 0 || percentage == 100)
5663 __isLoadingData = false;
5664 if (percentage == 100)
5666 __isLoadingCompleted = true;
5667 __progressPercentage = 0;
5671 __isLoadingCompleted = false;
5676 __isLoadingData = true;
5678 UpdateProgressBitmap();
5682 MainForm::GetProgress(void)
5684 return __progressPercentage;
5688 MainForm::UpdateProgressBitmap(void)
5690 result r = E_SUCCESS;
5691 if (__pProgressbarLabel == null)
5693 int w = __pProgressbarLabel->GetWidth();
5694 int h = __pProgressbarLabel->GetHeight();
5696 int progressWidth = 0;
5697 Bitmap* pRetBitmap = null;
5699 if (__progressPercentage == 0 || __progressPercentage == 100)
5701 __pProgressbarLabel->SetShowState(false);
5702 __pProgressbarLabel->Invalidate(false);
5707 __pProgressbarLabel->SetShowState(true);
5708 __pProgressbarLabel->Invalidate(false);
5711 r = canvas.Construct(Rectangle(0, 0, w, h));
5715 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5720 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5724 pBgBmp->Scale(Dimension(w, h));
5725 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5729 progressWidth = (double) (w) * __progressPercentage / 100;
5730 AppLogDebug("progressWidth: %d", progressWidth);
5731 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5733 if (pProgressBmp != null)
5735 pProgressBmp->Scale(Dimension(progressWidth, h));
5736 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5737 delete pProgressBmp;
5740 pRetBitmap = new (std::nothrow) Bitmap();
5742 if (pRetBitmap == null)
5744 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5748 pRetBitmap->Construct(canvas, canvas.GetBounds());
5750 if (__pProgressbarLabel != null && pRetBitmap != null)
5752 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5753 __pProgressbarLabel->Invalidate(false);
5756 if (pRetBitmap != null)
5765 MainForm::ReaderClicked()
5767 result r = E_SUCCESS;
5768 ArrayList* pArgList = new(std::nothrow) ArrayList();
5769 if (pArgList != null)
5771 r = pArgList->Construct();
5778 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5785 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5792 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5800 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5806 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5808 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5810 __currentAddMode = addMode;
5814 case ADDRESSBAR_MODE_INVALID:
5819 case ADDRESSBAR_MODE_READER:
5821 __pStopBtn->SetShowState(false);
5822 __pRefreshBtn->SetShowState(false);
5823 __pClearBtn->SetShowState(false);
5824 __pReaderBtn->SetShowState(false);
5827 case ADDRESSBAR_MODE_LOADING:
5829 __pRefreshBtn->SetShowState(false);
5830 __pStopBtn->SetShowState(true);
5831 __pClearBtn->SetShowState(false);
5832 __pReaderBtn->SetShowState(false);
5835 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5837 // SetUrl(__pAddressbar->GetUrl());
5839 __pRefreshBtn->SetShowState(true);
5840 __pStopBtn->SetShowState(false);
5841 __pClearBtn->SetShowState(false);
5842 __pReaderBtn->SetShowState(false);
5845 case ADDRESSBAR_MODE_EDIT:
5847 __pRefreshBtn->SetShowState(false);
5848 __pStopBtn->SetShowState(false);
5849 __pReaderBtn->SetShowState(false);
5850 __pClearBtn->SetShowState(true);
5857 OnAddressBarModeChanged();
5860 AddressBarMode MainForm::GetAddressbarMode(void)
5862 return __currentAddMode;
5865 void MainForm::SetUrl(const String& url)
5868 if(__displayUrl.GetLength() > 2048)
5869 __displayUrl.SubString(0,2048,__displayUrl);
5871 if (__pFooterUrlField != NULL)
5873 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5874 if (removedHttpUrl.IsEmpty() == false)
5876 __pFooterUrlField->SetText(removedHttpUrl);
5877 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5878 __pAddressbar->SetUrl(__displayUrl);
5882 __pFooterUrlField->SetText(__displayUrl);
5883 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5884 __pAddressbar->SetUrl(__displayUrl);
5886 if(__pFooterUrlField)
5888 AppLog("Position:: %d, %ls",__pFooterUrlField->GetTextLength(),__pFooterUrlField->GetText().GetPointer());
5889 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5891 __pFooterUrlField->Invalidate(false);
5892 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5893 __pAddressbar->Invalidate(true);
5894 // __pFooterUrlField->SetCursorPosition(0);
5899 MainForm::RemoveHttpTextFromDisplayURL(void)
5901 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5903 // bool isHttpText = __displayUrl.Contains(L"http://");
5904 String updatedDisplayUrl;
5905 updatedDisplayUrl.Clear();
5906 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5908 __displayUrl.SubString(7,updatedDisplayUrl);
5910 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5912 __displayUrl.SubString(8,updatedDisplayUrl);
5914 return updatedDisplayUrl;
5917 void MainForm::OnSharePopupControlStarted(void)
5919 __pWebViewer->AddTouchEventListener(*this);
5923 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5925 if (requestId == UPDATE_MAINFORM_FOOTER_ON_WINDOWCLOSED)
5927 AppLog("OnWebWindowCloseRequested mainform test 1 OnUserEventReceivedN");
5930 else if (requestId == BACK_GROUND_APP_EVENT)
5932 if(__pWebViewer != null)
5934 __pWebViewer->Pause();
5938 __pImageMenu->SetShowState(false);
5940 if(__pAddressbar != null)
5942 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5945 else if(requestId == FORE_GROUND_APP_EVENT)
5947 if(__pWebViewer != null)
5949 __pWebViewer->Resume();
5951 if(__pAddressbar != null)
5953 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5959 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5961 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5962 result r = E_SUCCESS;
5965 __pAddressbar->SetShowState(false);
5967 AppLog("akjshdasd 5");
5968 __pFooterPanel->SetShowState(true);
5971 __pWebViewer->SetFocus();
5972 else if(__pMostVisitedListView)
5973 __pMostVisitedListView->SetFocus();
5974 else if(__pMultiWindowButton)
5975 __pMultiWindowButton->SetFocus();
5976 else if(__pMoreButton)
5977 __pMoreButton->SetFocus();
5979 __pAddressbar->SetShowState(false);
5981 RelayoutControls(false);
5985 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5987 AppLog("MainForm::OnFormMenuRequested called");
5989 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer && __pWebViewer->GetShowState() == true)
5991 int bookmarkCount=0;
5994 url=__pWindowInfo->pageUrl;
5995 AppLog("MainForm::OnFormMenuRequested url %ls",url.GetPointer());
5996 result r = E_SUCCESS;
5997 Bitmap* pBitmap = null;
5998 String lastChar = L"";
5999 // if(url.SubString(url.GetLength()-1,lastChar));
6000 // if(lastChar == L"/")
6002 // bool exist1 = false;
6003 // bool exist2 = false;
6004 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist1);
6005 // url.SubString(0,url.GetLength() - 1,url);
6006 // r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist2);
6007 // exist = exist1 | exist2;
6011 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
6014 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
6020 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
6024 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
6026 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
6028 if (__pOptionMenu->GetItemCount() == 9)
6030 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
6034 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
6039 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
6043 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
6044 if (__pOptionMenu->GetItemCount() != 9)
6046 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
6047 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
6048 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
6049 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
6050 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
6051 __pOptionMenu->SetMaxVisibleItemsCount(6);
6053 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
6055 AppLog(" Orientation landscape");
6056 __pOptionMenu->SetMaxVisibleItemsCount(5);
6060 AppLog(" Orientation potrait");
6061 __pOptionMenu->SetMaxVisibleItemsCount(6);
6064 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
6067 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
6069 __pAddressbar->SetShowState(false);
6071 __pFooterPanel->SetShowState(true);
6072 result r = __pOptionMenu->SetShowState(true);
6073 AppLog("ajsghd %s",GetErrorMessage(r));
6074 RelayoutControls(false);
6075 __pOptionMenu->Invalidate(true);
6076 __pOptionMenu->Show();