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 "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
96 const int IDA_PRINT_CLICKED = 122;
98 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
99 const int IDA_FINDWORD_NEXT_CLICKED = 202;
100 const int IDA_FINDWORD_PREV_CLICKED = 203;
101 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
102 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
104 const int IDA_COPY_IMAGE_CLICKED = 206;
105 const int IDA_VIEW_IMAGE_CLICKED = 207;
106 const int IDA_SAVE_IMAGE_CLICKED = 208;
107 const int IDA_SHARE_IMAGE_CLICKED = 209;
109 const int IDA_COPY_TEXT_CLICKED = 210;
110 const int IDA_PASTE_TEXT_CLICKED = 211;
111 const int IDA_FIND_TEXT__CLICKED = 212;
112 const int IDA_SHARE_TEXT_CLICKED = 213;
114 const int IDA_GO_BACK = 214;
115 const int IDA_GO_FORWARD = 215;
116 const int IDA_REFRESH_BTN_CLICKED = 216;
117 const int IDA_STOP_BTN_CLICKED = 217;
118 const int IDA_CLEAR_URL = 218;
120 const int IDA_HYPERLINK_OPEN_CLICKED = 219;
121 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220;
122 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
123 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
125 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
127 const int MainForm::IDA_FORMAT_BITMAP = 500;
128 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
129 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
130 const int MainForm::IDA_FORMAT_URL_STRING = 503;
131 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
133 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
134 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
135 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
137 MainForm::MainForm(void)
139 __isLongPressedDone = false;
141 __pAddressbar = null;
142 // __pMostVisitedSitesPanel = null;
143 __pMostVisitedListView = null;
144 __pFooterPanel = null;
145 __pHitElementResult = null;
146 __pWindowInfo = null;
150 __pFindWordControl = null;
152 __pFindWordBgLabel = null;
153 __pFindWordEditField = null;
154 __pFindWordClear = null;
155 __pFindWordCountLabel = null;
156 __pFindWordNext = null;
157 __pFindWordPrev = null;
158 __previousZoomLevel = 1.0;
160 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
163 __currentSearchStr = L"";
164 __currentSelectedStr = L"";
165 __maxOccurrances = 0;
166 __currentWordIndex = 0;
169 __inputEventToBeSupressed = false;
170 __isLoadingData = false;
171 __isLoadingCompleted = false;
172 __progressPercentage = 0;
173 __touchPoint1 = Point(-1,-1);
174 __touchPoint2 = Point(-1,-1);
176 // __pReaderPopup = null;
177 __pReaderData = null;
179 __pReaderCloseBtn = null;
180 //__pNewWindowButton = null;
181 __pMoreButton = null;
182 __pMultiWindowButton = null;
183 __pArticleReaderPanel = null;
184 __pBlankPanel = null;
185 __pArticleReaderLabel = null;
186 __webControlHeight = 0;
187 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
188 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
189 __pMostVisitedSites = null;
190 __pFooterUrlField = null;
192 __pGoForwardBtn = null;
193 __pRefreshBtn = null;
194 __pProgressbarLabel = null;
195 __pFooterLabel = null;
198 __isWebKeypadOpened = false;
201 MainForm::~MainForm(void)
203 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
207 __pAddressbar->SetAddressbarEventListener(null);
210 if(__pHistory != null)
216 if (__pReaderData != null)
218 delete __pReaderData;
219 __pReaderData = null;
222 if (__pPopUp != null)
228 if (__pHitElementResult != null)
230 delete __pHitElementResult;
231 __pHitElementResult = null;
234 String* pSelectedScene = NULL;
235 Object* pValue = NULL;
236 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
237 pSelectedScene = (String*) pValue;
239 /*if (pSelectedScene != null)
241 delete pSelectedScene;
243 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
247 MainForm::Initialize(void)
249 Construct(L"IDL_FORM");
254 MainForm::OnInitializing(void)
256 AppLog("get client area width = %d",GetClientAreaBounds().width);
257 AppLog("get client area height = %d",GetClientAreaBounds().height);
258 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
259 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
261 Panel* pFooterPanel = null;
263 __pSaveImage = new Image();
264 __pSaveImage->Construct();
266 // Setup back event listener
267 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
268 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
269 AddOrientationEventListener(*this);
270 AppLogDebug(" MainForm::OnInitializing ended");
271 if (__pMostVisitedSites == null)
273 __pMostVisitedSites = new(std::nothrow) ArrayList();
274 __pMostVisitedSites->Construct();
276 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
278 __pItemContext= new(std::nothrow) ListContextItem();
279 __pItemContext->Construct();
280 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
281 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
283 if (pBitmapNormal != null && pBitmapPressed != null)
285 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
288 if (pBitmapNormal != null)
290 delete pBitmapNormal;
293 if (pBitmapPressed != null)
295 delete pBitmapPressed;
298 __pItemContextLandscape= new(std::nothrow) ListContextItem();
299 __pItemContextLandscape->Construct();
300 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
301 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
303 if (pBitmapNormal != null && pBitmapPressed != null)
305 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
308 if (pBitmapNormal != null)
310 delete pBitmapNormal;
313 if (pBitmapPressed != null)
315 delete pBitmapPressed;
322 MainForm::InitAddressbar(void)
324 AppLogDebug("MainForm::InitAddressbar entered");
326 result r = E_SUCCESS;
328 if (__pAddressbar != null)
332 __pAddressbar = new(std::nothrow) Addressbar();
333 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
334 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
337 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
340 __pAddressbar->SetAddressbarEventListener(this);
341 AddControl(__pAddressbar);
342 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
343 SetControlAlwaysOnTop(*__pAddressbar, true);
344 __adressPanelPosition = __pAddressbar->GetPosition();
346 AppLogDebug("MainForm::InitAddressbar exit");
352 MainForm::CreateReaderPanel(void)
354 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
355 result r = E_FAILURE;
357 Button *pSmallFontBtn = null;
358 Button *pLargeFontBtn = null;
360 __pBlankPanel = new (std::nothrow) Panel();
361 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
363 __pArticleReaderPanel = new (std::nothrow) Panel();
364 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
366 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
367 if (__pReaderCloseBtn)
369 AppLogDebug("CreateReaderPanel() 6");
370 __pReaderCloseBtn->AddActionEventListener(*this);
371 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
374 __pWebReader = new (std::nothrow) Web();
375 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
377 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
378 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
380 r = __pWebReader->SetSetting(settings);
382 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
385 __pArticleReaderLabel = new Label();
386 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
388 __pBlankPanel->AddControl(__pArticleReaderLabel);
389 __pBlankPanel->AddControl(__pArticleReaderPanel);
390 AddControl(__pBlankPanel);
392 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
393 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
394 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
396 __pArticleReaderPanel->AddControl(__pWebReader);
397 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
398 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
399 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
401 if (pBitmap != null && pSrcBitmap != null)
403 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
405 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
407 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
410 pSmallFontBtn->AddActionEventListener(*this);
411 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
414 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
417 pLargeFontBtn->AddActionEventListener(*this);
418 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
427 if (pSrcBitmap != null)
433 SetControlAlwaysOnTop(*__pBlankPanel, true);
434 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
441 MainForm::InitWebControl()
443 AppLogDebug("MainForm::InitWebControl enter");
444 result r = E_SUCCESS;
445 AppLogDebug("InitWebControl");
447 if (__pAddressbar == null || __pFooterPanel == null)
450 const int Y_WEBCONTROL_POSITION = 0;
451 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
452 if (__pMostVisitedListView)
454 __pMostVisitedListView->SetShowState(false);
456 if (__pWebViewer != null)
458 AppLogDebug("Already initialized");
461 __pWebViewer = new(std::nothrow) Web();
462 if(__pWebViewer == NULL)
464 AppLogDebug("Initialization failed");
467 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
471 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
478 r = AddControl(__pWebViewer);
484 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
487 __webControlPosition = __pWebViewer->GetPosition();
488 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
491 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
495 __pWebViewer->SetLoadingListener(this);
496 __pWebViewer->SetWebUiEventListener(this);
497 __pWebViewer->SetWebKeypadEventListener(this);
498 __pWebViewer->SetFocus();
499 __pWebViewer->AddTouchEventListener(*this);
501 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
502 __pWebViewer->SetTextSearchListener(this);
505 AppLogDebug("MainForm :before return");
507 AppLogDebug("MainForm::InitWebControl Exit");
513 MainForm::OnFocusGained(const Control& source)
515 AppLog("MainForm::OnFocusGained");
519 MainForm::OnFocusLost(const Control& source)
521 AppLog("MainForm::OnFocusLost");
525 MainForm::SetJavascriptEnabled()
527 WebSetting settings = __pWebViewer->GetSetting();
528 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
529 __pWebViewer->SetSetting(settings);
533 MainForm::SetImageLoadEnabled()
535 WebSetting settings = __pWebViewer->GetSetting();
536 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
537 __pWebViewer->SetSetting(settings);
541 MainForm::InitFooter(void)
543 AppLogDebug("MainForm::InitFooter entered");
544 Button* pBackButton = null;
545 Button* pBookmarkButton = null;
546 Button* pMultiWindowButton = null;
547 Bitmap *pIconBitmap = null;
548 Bitmap *pBGBitmap = null;
549 Label *pBGLabel = null;
551 if (__pFooterPanel == null)
553 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
556 if (__pFooterPanel == null)
561 SetControlAlwaysOnTop(*__pFooterPanel, true);
563 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
564 if ( __pFooterLabel == NULL )
568 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
569 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
572 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
576 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
578 if ( __pMultiWindowButton == NULL )
583 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
585 if ( __pMoreButton == NULL )
590 if (__pMultiWindowButton != null)
592 Bitmap* pBitmap = null;
593 Bitmap* pPressedBitmap = null;
594 String imagePath = "I01_toolbar_icon_windows_manager_0";
595 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
596 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
597 imagePath.Append(totalCount);
598 imagePath.Append(".png");
600 pressedImagePath.Append(totalCount);
601 pressedImagePath.Append("_press.png");
603 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
604 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
605 if ( pBitmap == null )
610 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
613 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
614 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
619 __pMultiWindowButton->AddActionEventListener(*this);
620 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
625 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
626 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
629 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
630 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
631 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
635 __pMoreButton->AddActionEventListener(*this);
636 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
639 //Add the editfield for url
640 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
641 if (__pFooterUrlField == NULL)
643 return E_INVALID_KEY;
646 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
647 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
648 //__pFooterUrlField->AddFocusEventListener(*this);
649 __pFooterUrlField->AddKeypadEventListener(*this);
650 //__pFooterUrlField->AddFocusEventListener(*this);
651 __pFooterUrlField->SetPropagatedTouchEventListener(this);
653 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
655 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
657 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
659 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
663 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
664 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
668 //Add the go Back Button
669 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
670 if (__pGoBackBtn == NULL)
672 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
673 return E_INVALID_KEY;
675 __pGoBackBtn->SetActionId(IDA_GO_BACK);
676 __pGoBackBtn->AddActionEventListener(*this);
678 //Add the go forward Button
679 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
680 if (__pGoForwardBtn == NULL)
682 AppLogDebug("Control not found returning E_INVALID_KEY");
683 return E_INVALID_KEY;
685 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
686 __pGoForwardBtn->AddActionEventListener(*this);
687 // __pGoForwardBtn->SetEnabled(false);
688 if (__pWebViewer && __pWebViewer->CanGoForward())
690 //__pAddressbar->SetForwardButtonEnabled(true);
691 SetForwardButtonEnabled(true);
695 //__pAddressbar->SetForwardButtonEnabled(false);
696 SetForwardButtonEnabled(false);
699 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
700 if (__pRefreshBtn == NULL)
702 AppLogDebug("Control not found returning E_INVALID_KEY");
703 return E_INVALID_KEY;
706 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
707 __pRefreshBtn->AddActionEventListener(*this);
708 __pRefreshBtn->SetShowState(true);
710 //Add the backround label for displaying progressbar
711 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
712 if (__pProgressbarLabel == NULL)
714 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
715 return E_INVALID_KEY;
717 __pProgressbarLabel->SetShowState(false);
719 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
720 if (__pStopBtn == NULL)
722 AppLogDebug("Control not found returning E_INVALID_KEY");
723 return E_INVALID_KEY;
725 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
726 __pStopBtn->AddActionEventListener(*this);
727 __pStopBtn->SetShowState(false);
729 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
730 if (__pClearBtn == NULL)
732 AppLogDebug("Control not found returning E_INVALID_KEY");
733 return E_INVALID_KEY;
735 __pClearBtn->SetActionId(IDA_CLEAR_URL);
736 __pClearBtn->AddActionEventListener(*this);
737 __pClearBtn->SetShowState(false);
739 // __pFooterPanel->Invalidate(true);
740 AppLogDebug("MainForm::InitFooter exit");
746 MainForm::InitContextMenu(Point& p)
748 result r = E_SUCCESS;
749 bool isPrivateBrowsing = false;
750 Bitmap* pBitmap = null;
754 __pMenu->SetAnchorPosition(p);
755 __pMenu->Invalidate(true);
759 __pMenu = new(std::nothrow) ContextMenu();
760 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
761 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
763 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
766 if (isPrivateBrowsing == true)
768 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
772 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
775 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
777 if ( pBitmap != NULL)
779 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
782 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
783 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
784 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
787 __pMenu->SetMaxVisibleItemsCount(6);
788 __pMenu->SetShowState(false);
789 __pMenu->AddActionEventListener(*this);
790 SetControlAlwaysOnTop(*__pMenu, true);
796 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
798 result r = E_SUCCESS;
799 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
801 AppLog("MainForm::InitImageContextMenu clicked on image");
802 if (__pImageMenu != null)
808 // p.y = p.y + __pAddressbar->GetHeight() + 12;
809 // AppLog("vinaypy %d",p.y);
812 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
816 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
818 __pImageMenu = new (std::nothrow) ContextMenu();
819 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
820 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
823 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
824 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
825 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
826 __pImageMenu->SetMaxVisibleItemsCount(4);
827 __pImageMenu->AddActionEventListener(*this);
828 SetControlAlwaysOnTop(*__pImageMenu, true);
834 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
836 result r = E_SUCCESS;
837 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
839 AppLog("MainForm::InitImageContextMenu clicked on image");
840 if (__pImageMenu != null)
846 if(__pAddressbar->GetShowState() == true)
847 p.y = p.y + __pAddressbar->GetHeight();
850 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
854 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
856 __pImageMenu = new (std::nothrow) ContextMenu();
857 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
858 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
860 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
861 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
862 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
863 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
865 __pImageMenu->SetMaxVisibleItemsCount(3);
866 __pImageMenu->AddActionEventListener(*this);
867 SetControlAlwaysOnTop(*__pImageMenu, true);
874 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
876 result r = E_SUCCESS;
877 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
879 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
880 if (__pImageMenu != null)
885 // p.y = p.y + __pAddressbar->GetHeight() + 12;
890 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
895 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
897 __pImageMenu = new (std::nothrow) ContextMenu();
898 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
899 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
901 if(onlyPasteOption == false)
903 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
905 if (pasteOption || onlyPasteOption)
907 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
909 if(onlyPasteOption == false)
911 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
912 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
915 __pImageMenu->SetMaxVisibleItemsCount(3);
916 __pImageMenu->AddActionEventListener(*this);
917 SetControlAlwaysOnTop(*__pImageMenu, true);
924 MainForm::InitFindWordPanel(void)
926 result r = E_SUCCESS;
927 Bitmap *pIconBitmap = null;
929 if (__pFindWordControl != null)
931 AppLogDebug("Findword panel already initialized");
932 if (__pFindWordBgLabel != null)
934 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
937 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
944 __pFindWordControl = new (std::nothrow) Panel();
945 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
948 AppLogException("There is some problem in the xml file. Please check.");
951 AddControl(__pFindWordControl);
952 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
953 SetControlAlwaysOnTop(*__pFindWordControl,true);
954 __pFindWordControl->SetShowState(false);
955 __pFindWordControl->Invalidate(false);
957 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
958 if (__pFindWordBgLabel != null)
960 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
961 Rectangle pRect = pPanel1->GetBounds();
962 pRect.x = pRect.y = 0;
963 __pFindWordBgLabel->SetBounds(pRect);
964 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
967 AppLogDebug("InitFindWordPanel: Coming here");
968 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
973 AppLogDebug("InitFindWordPanel: shouldn't Come here");
977 Button* pfindWordCancel = null;
978 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
979 if (pfindWordCancel == null)
981 AppLogException("There is some problem in the xml file. Please check.");
984 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
985 pfindWordCancel->AddActionEventListener(*this);
987 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
988 if (__pFindWordClear == null)
990 AppLogException("There is some problem in the xml file. Please check.");
994 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
995 __pFindWordClear->AddActionEventListener(*this);
997 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
998 if (__pFindWordNext == null)
1000 AppLogException("There is some problem in the xml file. Please check.");
1004 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1005 __pFindWordNext->AddActionEventListener(*this);
1007 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1008 if (__pFindWordPrev == null)
1010 AppLogException("There is some problem in the xml file. Please check.");
1014 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1015 __pFindWordPrev->AddActionEventListener(*this);
1017 __pFindWordNext->SetEnabled(false);
1018 __pFindWordPrev->SetEnabled(false);
1020 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1021 if (__pFindWordCountLabel == null)
1023 AppLogException("There is some problem in the xml file. Please check.");
1027 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1028 if (__pFindWordEditField == null)
1030 AppLogException("There is some problem in the xml file. Please check.");
1033 __pFindWordEditField->AddTextEventListener(*this);
1034 __pFindWordEditField->AddKeypadEventListener(*this);
1035 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1041 MainForm::CreateItem (int index, int itemWidth)
1043 Rectangle listImageRect;
1044 Rectangle pagetTitleRect;
1045 Rectangle pageURLRect;
1046 Rectangle deleteImageRect;
1047 String pageTitle(L"");
1048 String pageURL(L"");
1049 result r = E_SUCCESS;
1050 Bitmap* pListIconImage = null;
1053 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1054 if(pHistory == null)
1058 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1059 if ( pAppResource == NULL )
1063 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1065 CustomItem* pItem = new(std::nothrow) CustomItem();
1066 pageTitle = pHistory->GetHistoryTitle();
1067 pageURL = pHistory->GetHistoryUrl();
1069 if (pageURL.GetLength() == 0)
1072 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1073 pageURL = L"<"+ nourl +">";
1077 Rectangle screenBounds = GetBounds();
1080 r = pItem->Construct(Dimension(itemWidth, 128), style);
1089 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1091 if ( pBitmap != NULL)
1093 pListIconImage = new Bitmap();
1094 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1098 if(pListIconImage == null)
1100 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1103 if ( pListIconImage != NULL)
1105 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1106 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1107 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1110 if (pItem != null && pListIconImage != NULL)
1112 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1116 if (pageTitle.CompareTo(L"") != 0)
1120 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1124 if (pageURL.CompareTo(L"") != 0)
1128 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1133 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1135 if ( __pItemContext!= NULL)
1139 pItem->SetContextItem(__pItemContext);
1145 if ( __pItemContextLandscape!= NULL)
1149 pItem->SetContextItem(__pItemContextLandscape);
1153 if( pListIconImage != NULL)
1155 delete pListIconImage;
1156 pListIconImage = null;
1163 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1170 MainForm::GetItemCount (void)
1172 if(__pMostVisitedSites != null)
1174 __pMostVisitedSites->RemoveAll(true);
1176 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1177 if(__pMostVisitedSites != null)
1179 return __pMostVisitedSites->GetCount();
1186 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1188 if(__pMostVisitedSites != null)
1190 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1191 if (pHistory != null)
1193 String url = pHistory->GetHistoryUrl();
1195 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1196 __pMostVisitedListView->UpdateList();
1202 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1204 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1205 String url = pHistory->GetHistoryUrl();
1213 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1219 MainForm::OnTerminating(void)
1221 result r = E_SUCCESS;
1224 delete __pItemContext;
1226 if(__pItemContextLandscape)
1228 delete __pItemContextLandscape;
1234 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1236 result r = E_SUCCESS;
1238 AppLogDebug("Clicked : %d", actionId);
1241 // case IDA_BACKBTN_CLICKED:
1243 // if (__pWebViewer && __pWebViewer->CanGoBack())
1245 // __pWebViewer->GoBack();
1249 // UiApp* pApp = null;
1250 // pApp = UiApp::GetInstance();
1251 // if (pApp != null)
1253 // r = pApp->Terminate();
1256 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1264 case IDA_BACKBTN_CLICKED:
1266 if (__pWebViewer && __pWebViewer->CanGoBack())
1268 __pWebViewer->GoBack();
1270 else if(__pWindowInfo->isJavascriptInitiated == false)
1273 pApp = UiApp::GetInstance();
1276 r = pApp->Terminate();
1279 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1287 WindowInfo* pWindowInfo = null;
1289 SceneManager* pSceneManager = SceneManager::GetInstance();
1290 if (pSceneManager == null)
1294 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1295 if (pAllWindowList == NULL)
1297 pApp = UiApp::GetInstance();
1300 r = pApp->Terminate();
1303 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1308 if (pAllWindowList != null)
1310 totalCount = pAllWindowList->GetCount();
1312 for (int count = 0; count < totalCount; count++)
1314 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1315 if (pWindowInfo == null)
1317 pApp = UiApp::GetInstance();
1320 r = pApp->Terminate();
1323 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1330 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1332 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1335 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1338 r = pAllWindowList->RemoveAt(count, true);
1339 __pWindowInfo = null;
1342 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1347 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1351 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1353 if (pWindowInfo == null)
1355 pApp = UiApp::GetInstance();
1358 r = pApp->Terminate();
1364 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1367 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1379 case IDA_FORWARD_CLICKED:
1380 if (__pWebViewer == null)
1383 if (__pWebViewer->CanGoForward())
1385 __pWebViewer->GoForward();
1387 __pMenu->SetShowState(false);
1388 __pMenu->Invalidate(false);
1391 case IDA_FINDONPAGE_CLICKED:
1393 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1394 __currentSearchStr.Clear();
1396 InitFindWordPanel();
1397 __pMenu->SetShowState(false);
1398 __pMenu->Invalidate(false);
1400 __pFindWordEditField->SetFocus();
1402 if (__pWebViewer != null)
1404 // releasing the set block
1405 __pWebViewer->ReleaseBlock();
1408 ShowFindWordPanel(true);
1411 case IDA_PRIVATEON_CLICKED:
1413 result r = E_SUCCESS;
1415 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1416 Bitmap* pBitmap = null;
1417 if (isPrivateBrowsing == true)
1419 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1422 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1426 if (__pWebViewer != NULL)
1428 __pWebViewer->SetPrivateBrowsingEnabled(false);
1431 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1433 if (__pAddressbar != null)
1435 __pAddressbar->UpdateFaviconBitmap(false);
1441 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1444 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1448 if (__pWebViewer != NULL)
1450 __pWebViewer->SetPrivateBrowsingEnabled(true);
1453 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1455 if (__pAddressbar != null)
1457 __pAddressbar->UpdateFaviconBitmap(true);
1462 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1463 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1464 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1465 __pMenu->Invalidate(true);
1467 if ( pBitmap != NULL )
1474 case IDA_SETTINGS_CLICKED:
1477 ArrayList* pArgList = new(std::nothrow) ArrayList();
1480 pArgList->Construct();
1481 pArgList->Add(*__pWindowInfo);
1482 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1484 __pMenu->SetShowState(false);
1485 __pMenu->Invalidate(false);
1486 if (pArgList != null)
1495 case IDA_ADDTOBOOKMARK_CLICKED:
1498 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1500 int bookmarkCount=0;
1503 url=__pWindowInfo->pageUrl;
1504 result r = E_SUCCESS;
1505 Bitmap* pBitmap = null;
1506 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1514 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1515 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1516 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1518 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1519 if (pNotification != null)
1521 pNotification->SetText(message);
1522 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1523 pNotification->ShowNotification();
1528 String title=__pWindowInfo->pageTitle;
1529 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1530 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1532 pBookmark->SetBookmarkTitle(title);
1533 pBookmark->SetUrl(url);
1534 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1536 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1538 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1539 pBookmark->SetFaviconId(id);
1540 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1541 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1544 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1545 if (pNotification != null)
1547 pNotification->SetText(message);
1548 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1549 pNotification->ShowNotification();
1550 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1553 if (pBitmap != null)
1555 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1559 __pMenu->Invalidate(true);
1563 case IDA_PRINT_CLICKED:
1565 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1566 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1568 AppLog("RequestPrint called!");
1569 Tizen::App::AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1570 result nResult = E_FAILURE;
1573 AppLog("TestPrint if (pAc) == true");
1578 String fileType = L"service_print_files_type";
1579 String typeVal = L"DOC";
1581 String fileCount = L"service_print_files_count";
1582 String countVal = L"1";
1583 String fileFolder= L"service_print_files_folder_name";
1584 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1586 map.Add(&fileCount, &countVal);
1587 // map.Add(&fileIndex, &indexVal);
1588 map.Add(&fileFolder, &folderVal);
1589 map.Add(&fileType, &typeVal);
1591 String fileName = L"service_print_files_files_name";
1593 ArrayList fileNameList;
1594 fileNameList.Construct();
1595 String file1 = L"test.pdf";
1597 fileNameList.Add(&file1);
1598 map.Add(&fileName, &fileNameList);
1600 nResult = pAc->Start(NULL, NULL, &map, NULL);
1602 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1603 else if (nResult == E_MAX_EXCEEDED)
1604 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1605 else if (nResult == E_OBJ_NOT_FOUND)
1606 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1607 else if (nResult == E_IN_PROGRESS)
1608 AppLog("TestPrint ret == E_IN_PROGRESS");
1609 else if (nResult == E_PRIVILEGE_DENIED)
1610 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1611 else if(nResult == E_SYSTEM)
1612 AppLog("TestPrint ret == E_SYSTEM");
1618 int __modalMsgBoxResult;
1619 MessageBox* pMsgBox = new MessageBox();
1620 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1621 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1624 __modalMsgBoxResult = 0;
1628 case IDA_SHARE_CLICKED:
1630 if(__pPopUp != null)
1635 __pPopUp = new(std::nothrow) SharePopup();
1636 __pPopUp->Initialize();
1637 if (__pWindowInfo != null)
1639 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1640 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1641 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1642 pShareInfo->SetImageAttached(false);
1643 __pPopUp->RemoveAllShareInfo();
1644 __pPopUp->AddShareInfo(pShareInfo);
1646 __pPopUp->SetShowState(true);
1650 case IDA_BOOKMARKBTN_CLICKED:
1652 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1653 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1656 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1661 case IDA_MOREBTN_CLICKED:
1663 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1664 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1665 AppLog("Anchot pos: %d %d", p.x, p.y);
1667 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1669 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1670 int bookmarkCount=0;
1673 url=__pWindowInfo->pageUrl;
1674 result r = E_SUCCESS;
1675 Bitmap* pBitmap = null;
1677 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1680 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1685 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1689 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1691 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1693 if (__pMenu->GetItemCount() == 9)
1695 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1699 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1704 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1708 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1709 if (__pMenu->GetItemCount() != 9)
1711 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1712 __pMenu->InsertItemAt(2,"Print", IDA_PRINT_CLICKED);
1713 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1714 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1715 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1716 __pMenu->SetMaxVisibleItemsCount(6);
1718 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1720 AppLog(" Orientation landscape");
1721 __pMenu->SetMaxVisibleItemsCount(5);
1725 AppLog(" Orientation potrait");
1726 __pMenu->SetMaxVisibleItemsCount(6);
1729 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1732 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1733 __pMenu->SetShowState(true);
1734 __pMenu->Invalidate(true);
1738 case IDA_HISTORY_CLICKED:
1740 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1741 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1744 case IDA_SAVED_PAGES_CLICKED:
1749 case IDA_DESKTOP_VIEW_CLICKED:
1754 case IDA_SAVE_CLICKED:
1759 case IDA_MULTIWINDOWBTN_CLICKED:
1761 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1762 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1766 case IDA_NEWWINDOWBTN_CLICKED:
1768 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1770 if (pNewWindowInfo == null)
1774 result r = E_SUCCESS;
1775 SceneManager* pSceneManager = SceneManager::GetInstance();
1777 if (pSceneManager == NULL)
1781 ArrayList* pArgList = new(std::nothrow) ArrayList();
1782 if (pArgList == NULL)
1786 r = pArgList->Construct();
1789 pArgList->Add(*pNewWindowInfo);
1790 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1796 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1801 case IDA_SMALLFONT_BTN_CLICKED:
1803 WebSetting setting = __pWebReader->GetSetting();
1804 setting.SetFontSize(15);
1805 __pWebReader->SetSetting(setting);
1808 case IDA_LARGEFONT_BTN_CLICKED:
1810 WebSetting setting = __pWebReader->GetSetting();
1811 setting.SetFontSize(25);
1812 __pWebReader->SetSetting(setting);
1815 case IDA_READER_CLOSE_CLICKED:
1817 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1819 //__pArticleReaderPanel->SetShowState(false);
1820 //__pArticleReaderPanel->Show();
1821 RemoveControl(__pBlankPanel);
1822 //RemoveControl(*__pArticleReaderPanel);
1823 __pArticleReaderPanel = null;
1824 __pBlankPanel = null;
1825 __pArticleReaderLabel = null;
1827 //if (__pAddressbar)
1828 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1829 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1832 case IDA_FINDWORD_CANCEL_CLICKED:
1834 __currentSearchStr = L"";
1835 __currentWordIndex = 0;
1836 __maxOccurrances = 0;
1837 __pFindWordEditField->SetText(L"");
1838 __pFindWordNext->SetEnabled(false);
1839 __pFindWordPrev->SetEnabled(false);
1840 __pFindWordCountLabel->SetText(L"0/0");
1841 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1842 ShowFindWordPanel(false);
1845 case IDA_FINDWORD_SEARCH_CLICKED:
1847 __currentSearchStr = __pFindWordEditField->GetText();
1848 if (__currentSearchStr.GetLength() > 0)
1854 AppLogDebug("Enter something");
1858 case IDA_FINDWORD_CLEAR_CLICKED:
1860 __pFindWordCountLabel->SetText(L"0/0");
1861 __pFindWordEditField->SetText(L"");
1862 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1864 __currentSearchStr = L"";
1865 __pFindWordNext->SetEnabled(false);
1866 __pFindWordPrev->SetEnabled(false);
1867 __pFindWordControl->Invalidate(true);
1870 case IDA_FINDWORD_NEXT_CLICKED:
1875 case IDA_FINDWORD_PREV_CLICKED:
1877 FindNextWord(false);
1880 case IDA_BRIGHTNESS_BTN_CLICKED:
1882 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1883 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1886 case IDA_COPY_IMAGE_CLICKED:
1888 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1889 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1891 const Bitmap* pBitmap = null;
1892 if (__pHitElementResult != null)
1894 pBitmap = __pHitElementResult->GetImage();
1897 String resourcePath = App::GetInstance()->GetAppResourcePath();
1898 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1900 // copying the item to clipboard
1901 Clipboard* pClipboard = Clipboard::GetInstance();
1902 if (pClipboard != null)
1904 pClipboard->CopyItem(item);
1908 case IDA_VIEW_IMAGE_CLICKED:
1910 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1911 WindowInfo* pNewWindowInfo = null;
1912 if (__pHitElementResult != null)
1914 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1915 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1921 case IDA_SAVE_IMAGE_CLICKED:
1923 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1924 const Bitmap* pSaveBitmap = null;
1925 String imageName = GetImagePath();
1926 AppLog("Content manager image name %ls",imageName.GetPointer());
1929 imagePath.Append(imageName);
1930 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1931 AppLog("Content manager image path %ls",imagePath.GetPointer());
1932 if (__pHitElementResult != null)
1934 pSaveBitmap = __pHitElementResult->GetImage();
1936 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1940 UpdateImageContent(pBuffer, imageName);
1942 NotificationPanel *pNotification = new NotificationPanel(*this);
1944 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1945 msg.Append(imagePath);
1946 if (pNotification != null)
1948 pNotification->SetText(msg);
1949 if (__pFooterPanel->GetShowState() == true)
1951 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1955 pNotification->SetPositionDiff(0);
1958 pNotification->ShowNotification();
1963 int __modalMsgBoxResult;
1964 MessageBox* pMsgBox = new MessageBox();
1965 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1966 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1969 __modalMsgBoxResult = 0;
1973 case IDA_SHARE_IMAGE_CLICKED:
1975 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1976 if (__pPopUp != null)
1981 __pPopUp = new(std::nothrow) SharePopup();
1982 __pPopUp->Initialize();
1983 if (__pHitElementResult != null)
1985 const Bitmap* pSaveBitmap = null;
1986 String imageName = GetImagePath();
1987 AppLog("Content manager image name %ls",imageName.GetPointer());
1990 imagePath.Append(imageName);
1991 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1992 AppLog("Content manager image path %ls",imagePath.GetPointer());
1993 if (__pHitElementResult != null)
1995 pSaveBitmap = __pHitElementResult->GetImage();
1997 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1999 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2000 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2002 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2003 pShareInfo->SetPageTitle(L"");
2004 pShareInfo->SetPageUrl(srcUrl);
2005 pShareInfo->SetImageAttached(true);
2006 pShareInfo->SetImagePath(imagePath);
2007 __pPopUp->RemoveAllShareInfo();
2008 __pPopUp->AddShareInfo(pShareInfo);
2009 __pPopUp->SetShowState(true);
2014 case IDA_HYPERLINK_OPEN_CLICKED:
2016 if (__pHitElementResult != null)
2018 String srcUrl = __pHitElementResult->GetUrl();
2020 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
2022 if (pNewWindowInfo == null)
2026 result r = E_SUCCESS;
2027 SceneManager* pSceneManager = SceneManager::GetInstance();
2028 if (pSceneManager == NULL)
2032 ArrayList* pArgList = new(std::nothrow) ArrayList();
2033 if (pArgList == NULL)
2037 pArgList->Construct();
2039 pArgList->Add(*pNewWindowInfo);
2040 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2041 if (pArgList != null)
2048 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2054 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2056 if (__pHitElementResult == null)
2061 if(__pPopUp != null)
2066 __pPopUp = new(std::nothrow) SharePopup();
2067 __pPopUp->Initialize();
2069 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2070 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2071 pShareInfo->SetImageAttached(false);
2072 __pPopUp->RemoveAllShareInfo();
2073 __pPopUp->AddShareInfo(pShareInfo);
2075 __pPopUp->SetShowState(true);
2079 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2083 if (__pHitElementResult != null)
2085 url = __pHitElementResult->GetUrl();
2088 String resourcePath = App::GetInstance()->GetAppResourcePath();
2089 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2091 // copying the item to clipboard
2092 Clipboard* pClipboard = Clipboard::GetInstance();
2093 if (pClipboard != null)
2095 pClipboard->CopyItem(item);
2099 case IDA_FIND_TEXT__CLICKED:
2101 OnAddressCancelledClicked(*__pAddressbar);
2102 // __pFooterPanel->SetShowState(false);
2103 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2104 __currentSearchStr.Clear();
2105 __currentSearchStr.Append(__currentSelectedStr);
2106 InitFindWordPanel();
2107 __pFindWordEditField->SetText(__currentSearchStr);
2110 __pMenu->SetShowState(false);
2111 __pMenu->Invalidate(false);
2114 __adressPanelPosition.y = 0;
2116 if (__pAddressbar != null && __pWebViewer != NULL)
2118 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2119 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2120 //__pAddressbar->Invalidate(true);
2121 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2123 if (__pFooterPanel->GetShowState() == false)
2124 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2126 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2127 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2128 __pWebViewer->Invalidate(true);
2131 ShowFindWordPanel(true);
2132 __pFindWordEditField->SetFocus();
2133 if (__currentSearchStr.GetLength() > 0)
2139 AppLogDebug("Enter something");
2142 if (__pWebViewer != null)
2144 // releasing the set block
2145 __pWebViewer->ReleaseBlock();
2150 case IDA_SHARE_TEXT_CLICKED:
2152 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2153 if(__pPopUp != null)
2158 __pPopUp = new(std::nothrow) SharePopup();
2159 __pPopUp->Initialize();
2160 if (__pHitElementResult != null)
2162 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2163 pShareInfo->SetPageTitle(L"");
2164 pShareInfo->SetPageUrl(__currentSelectedStr);
2165 pShareInfo->SetImageAttached(false);
2166 __pPopUp->RemoveAllShareInfo();
2167 __pPopUp->AddShareInfo(pShareInfo);
2168 __pPopUp->SetShowState(true);
2173 case IDA_COPY_TEXT_CLICKED:
2175 __pWebViewer->ReleaseBlock();
2176 // need to implement
2177 //__currentSelectedStr
2178 // Sets data to a clip board item
2180 String resourcePath = App::GetInstance()->GetAppResourcePath();
2181 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2183 // copying the item to clipboard
2184 Clipboard* pClipboard = Clipboard::GetInstance();
2185 if (pClipboard != null)
2187 pClipboard->CopyItem(item);
2191 case IDA_PASTE_TEXT_CLICKED:
2193 Clipboard* pClipboard = Clipboard::GetInstance();
2195 if(pClipboard == null)
2199 // Retrieves a latest item
2200 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2206 //Gets data from the clipboard item
2207 String* pString = dynamic_cast<String*>(pItem->GetData());
2209 if (pString != null)
2211 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2212 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2213 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2216 if(idElement.GetLength() != 0)
2218 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } ";
2219 script.Append("insertAtCursor('");
2220 script.Append(idElement);
2221 script.Append("',");
2222 script.Append("\"");
2223 script.Append(*pString);
2224 script.Append("\");");
2226 else if (nameElement.GetLength() != 0)
2228 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].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 { document.getElementByName(myField)[0].value += myValue; } } ";
2229 script.Append("insertAtCursor(document.getElementsByName('");
2230 script.Append(nameElement);
2231 script.Append("')[0],");
2232 script.Append("\"");
2233 script.Append(*pString);
2234 script.Append("\");");
2236 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2237 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2248 case IDA_GO_FORWARD:
2253 case IDA_REFRESH_BTN_CLICKED:
2255 __isLoadingCompleted = false;
2256 __isLoadingData = true;
2257 __progressPercentage = 0;
2258 __displayUrl = __pFooterUrlField->GetText();
2260 String url = __pFooterUrlField->GetText();
2261 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2265 UpdateProgressBitmap();
2268 case IDA_STOP_BTN_CLICKED:
2270 __isLoadingCompleted = false;
2271 __isLoadingData = false;
2272 __progressPercentage = 0;
2273 __pFooterUrlField->HideKeypad();
2274 __displayUrl = __pFooterUrlField->GetText();
2278 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2279 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2280 __pWebViewer->StopLoading();
2281 RequestRedraw(true);
2284 UpdateProgressBitmap();
2289 if (__pFooterUrlField->GetText().IsEmpty() == false)
2291 //__displayUrl = __pUrlField->GetText();
2292 __pFooterUrlField->Clear();
2303 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2306 UiApp* pApp = UiApp::GetInstance();
2315 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2316 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2318 AppLog("MainForm::OnSceneActivatedN called");
2319 String* pSelectedScene = NULL;
2320 Object* pValue = NULL;
2321 String* pUrl = null;
2322 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2323 pSelectedScene = (String*) pValue;
2325 if (pSelectedScene != null)
2327 delete pSelectedScene;
2329 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2330 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2331 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2332 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2334 // setting the current scene ID
2335 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2337 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2339 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2341 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2342 if(__pWindowInfo == null)
2344 // if(__pWindowInfo == null)
2346 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2349 else if ( pArgs != null && pArgs->GetCount() == 1)
2351 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2357 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2359 // hiding the address bar
2360 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2361 __pAddressbar->SetShowState(false);
2362 if(__pWebViewer != null)
2364 __pWebViewer->Resume();
2367 if(pUrl != null && pUrl->GetLength() > 0)
2371 else if(__pWindowInfo != null)
2373 if(__pWindowInfo->pageUrl.GetLength() > 0 && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2375 LoadUrl(__pWindowInfo->pageUrl);
2377 else if (__pWindowInfo->isJavascriptInitiated == true)
2381 __pWindowInfo->pCurrentWeb = __pWebViewer;
2385 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2386 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2387 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2389 InitMostVisitedSitesView(GetOrientationStatus());
2391 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2393 if(__pMostVisitedListView != null)
2395 __pMostVisitedListView->SetShowState(false);
2399 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2401 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2403 if (pBookmarkUrl == null)
2405 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2406 //__pAddressbar->SetUrl(*pBookmarkUrl);
2407 SetUrl(*pBookmarkUrl);
2409 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2410 __pWebViewer->LoadUrl(*pBookmarkUrl);
2411 delete pBookmarkUrl;
2414 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2415 Bitmap* pBitmap = null;
2416 if (isPrivateBrowsing == true)
2418 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2420 if (__pWebViewer != null)
2422 __pWebViewer->SetPrivateBrowsingEnabled(true);
2425 if (__pAddressbar != null)
2427 // __pAddressbar->UpdateFaviconBitmap(true);
2433 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2435 if (__pWebViewer != null)
2437 __pWebViewer->SetPrivateBrowsingEnabled(false);
2440 if (__pAddressbar != null)
2442 // __pAddressbar->UpdateFaviconBitmap(false);
2446 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2448 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2450 else if (__pMenu != null )
2452 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2455 if (pBitmap != null)
2460 AppLog("ABC: OnSceneActivatedN started exit");
2465 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2466 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2468 Canvas* pWebCanvas = null;
2469 if (__pWebViewer != null)
2471 pWebCanvas = __pWebViewer->GetCanvasN();
2472 __pWebViewer->Pause();
2475 if (pWebCanvas == null)
2479 if (__pWindowInfo != null)
2481 if (__pWindowInfo->pWebCanvasBitmap != null)
2483 delete __pWindowInfo->pWebCanvasBitmap;
2485 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2486 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2487 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2489 Bitmap* pBitmap = GetCapturedBitmapN();
2490 AppLog("Coming here");
2491 Canvas* pCanvas = new(std::nothrow) Canvas();
2492 pCanvas->Construct(GetClientAreaBounds());
2495 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2498 if(__pWebViewer != null && __pWindowInfo != null)
2499 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2501 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2502 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2504 AppLog("Coming here");
2508 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2509 const Tizen::Base::String& realm,
2510 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2516 MainForm::OnHttpAuthenticationCanceled(void)
2521 MainForm::OnLoadingStarted(void)
2523 AppLogDebug("MainForm::OnLoadingStarted entered");
2525 if(__pAddressbar == NULL || __pWebViewer == null)
2529 String url = __pWebViewer->GetUrl();
2530 if(url.Contains(IDS_TIZEN_SERVICE))
2533 String delim(L":;");
2535 // Creates a StringTokenizer instance
2536 StringTokenizer strTok(url, delim);
2538 int count = strTok.GetTokenCount(); // count == 4
2540 HashMap *pMap = new HashMap();
2545 while (strTok.HasMoreTokens())
2547 AppLog("Token: %ls", token.GetPointer());
2548 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2549 if(token.Contains(IDS_APPID))
2551 token.SubString(6, appId);
2552 AppLog("AppID:%ls", appId.GetPointer());
2554 else if(token.Contains("="))
2556 String *pKey = new String();
2557 String *pValue = new String();
2559 token.IndexOf("=", 0, index);
2562 token.SubString(0, index, *pKey);
2563 token.SubString(index + 1, *pValue);
2564 pMap->Add(pKey, pValue);
2570 AppControl *pAppControl = null;
2571 String operationId = L"http://tizen.org/appcontrol/operation/main";
2572 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2575 AppLog("Starting AppControl");
2576 result r = pAppControl->Start(null, null, pMap, null);
2577 AppLog("Result of Start %s", GetErrorMessage(r));
2581 AppLogException("AppControl not found");
2586 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2588 __pAddressbar->SetShowState(false);
2589 OnAddressCancelledClicked(*__pAddressbar);
2590 __pAddressbar->Invalidate(true);
2592 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2595 __pAddressbar->SetFaviconBitmap(*pBitmap);
2598 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2600 // updating the address bar position with respect to web control
2601 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2602 __distanceMoved = 0;
2606 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2607 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2608 if (__pWebViewer != null)
2610 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2611 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2612 SetUrl(__pWebViewer->GetUrl());
2613 if (__pWindowInfo != NULL)
2615 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2617 __pAddressbar->Invalidate(true);
2623 MainForm::OnLoadingCanceled(void)
2630 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2632 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2633 if (__pAddressbar != null)
2635 OnAddressBarKeypadWillOpen(*__pAddressbar);
2641 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2643 AppLog("XYZ::MainForm::OnKeypadOpened");
2644 if(__pAddressbar != null)
2646 OnAddressBarKeypadOpened(*__pAddressbar);
2652 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2654 AppLog("XYZ::MainForm::OnKeypadClosed");
2656 if (__pAddressbar != null)
2658 OnAddressBarKeypadClosed(*__pAddressbar);
2663 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2665 AppLog("KeypadBoundsChanged");
2666 RelayoutControls(false);
2670 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2671 const Tizen::Base::String& reason)
2673 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2677 MainForm::OnLoadingCompleted(void)
2679 AppLog("MainForm::OnLoadingCompleted start");
2681 result r = E_SUCCESS;
2683 if (__pWebViewer == null)
2688 if (__pAddressbar == null)
2692 if (__pWebViewer->CanGoForward())
2694 //__pAddressbar->SetForwardButtonEnabled(true);
2695 SetForwardButtonEnabled(true);
2699 //__pAddressbar->SetForwardButtonEnabled(false);
2700 SetForwardButtonEnabled(false);
2703 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2705 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2707 //__pAddressbar->UpdateProgress(0);
2711 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2713 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2717 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2718 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2719 if (isPrivateBrowsing == false)
2721 if(__pHistory != null)
2727 __pHistory = new(std::nothrow) History;
2728 HistoryPresentationModel::GetCurrentDateTime(date);
2731 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2732 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2734 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2735 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2737 __pHistory->SetVisitedTime(date);
2739 if (__pWebViewer != null)
2741 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2743 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2744 if (pTempBitmap != null)
2746 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2747 __pHistory->SetFavIconBitmap(*pTempBitmap);
2750 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2753 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2754 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2755 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2757 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2758 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2759 __pHistory->SetThumbnail(pBitmap);
2761 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2764 __pHistory->SetFavIconBitmap(*pFavIcon);
2768 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2775 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2777 // temperary fixed (webpage can be not loaded)
2780 AppLog("MainForm::OnLoadingCompleted done");
2784 MainForm::OnEstimatedProgress(int progress)
2786 AppLogDebug("MainForm::OnEstimatedProgress entered");
2787 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2788 progress = DEFAULT_PROGRESS_PERCENTAGE;
2790 // __pAddressbar->UpdateProgress(progress);
2791 UpdateProgress(progress);
2794 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2796 AppLog("MainForm::OnFaviconReceived");
2797 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2799 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *(__pWebViewer->GetFaviconN()));
2804 MainForm::OnUrlValueChanged(Addressbar&)
2810 MainForm::OnUrlSubmitted(Addressbar& addBar)
2812 AppLog("MainForm::OnUrlSubmitted");
2813 String url = addBar.GetUrl();
2814 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2816 // __pFooterPanel->SetShowState(true);
2817 if(__pFooterUrlField)
2818 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2819 OnAddressCancelledClicked(*__pAddressbar);
2820 // __pAddressbar->SetShowState(false);
2821 // RelayoutControls(false);
2826 MainForm::LoadUrl(String& url)
2830 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2831 AppLogDebug("MainForm::LoadUrl enter");
2833 if (__pWebViewer != null)
2835 __pWebViewer->SetShowState(true);
2836 __pWebViewer->Invalidate(true);
2839 if (url.CompareTo(L"") == 0)
2843 if(__pFooterPanel != null)
2845 __pFooterPanel->SetShowState(true);
2846 __pFooterPanel->Invalidate(true);
2853 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2854 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)
2856 RegularExpression firstRegex;
2857 RegularExpression secondRegex;
2859 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2860 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2863 ret = firstRegex.Match(url, false); // This returns true value
2864 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2866 if (ret == true && __pWebViewer != null)
2869 __pWebViewer->LoadUrl(url);
2871 else if(__pWebViewer != null)
2873 String tempUrl = L"http://";
2874 tempUrl.Append(url);
2878 __pWebViewer->LoadUrl(tempUrl);
2882 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2883 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2886 if (__pAddressbar != null)
2888 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2889 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2892 AppLogDebug("MainForm::LoadUrl exit");
2899 MainForm::OnStopClicked(Addressbar& addBar)
2901 AppLogDebug("MainForm::OnStopClicked called");
2904 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2905 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2906 __pWebViewer->StopLoading();
2907 RequestRedraw(true);
2912 MainForm::OnReaderClicked(const Addressbar& addBar)
2914 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2916 CreateReaderPanel();
2917 AppLogDebug("MainScene::OnReaderClicked entered");
2920 /*if (__pArticleReaderPanel)
2922 AppLogDebug("showstate true for reader panel");
2923 __pArticleReaderPanel->SetShowState(true);
2924 __pArticleReaderPanel->Show();
2926 int xPos = __pArticleReaderPanel->GetX();
2927 int yPos = __pArticleReaderPanel->GetY();
2928 AppLog("OnReaderClicked() xPos = %d",xPos);
2929 AppLog("OnReaderClicked() yPos = %d",yPos);
2931 if (__pReaderData == null)
2936 String loadData = L"<html>\
2938 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2943 background-color: transparent;\
2962 <body style='width:'";
2963 loadData.Append(bodyWidth);
2964 loadData.Append(L"px'>");
2965 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2966 loadData.Append(*__pReaderData);
2967 loadData.Append(L"</body></html>");
2970 buf.Construct(loadData.GetLength());
2971 AppLogDebug("data->GetLength %d",loadData.GetLength());
2972 for (int z=0;z<loadData.GetLength();z++)
2975 loadData.GetCharAt(z,b);
2976 buf.SetByte((byte)b);
2980 if (__pWebReader != null)
2982 __pWebReader->LoadData(L"",buf,L"text/html");
2983 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2987 AppLogDebug("cannot LoadData __pWebReader is null");
2993 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2995 // AppLog("MainForm::OnBackClicked");
2996 result r = E_FAILURE;
2998 if (__pWebViewer && __pWebViewer->CanGoBack())
3000 __pWebViewer->GoBack();
3002 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3005 pApp = UiApp::GetInstance();
3008 r = pApp->Terminate();
3011 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3019 WindowInfo* pWindowInfo = null;
3021 SceneManager* pSceneManager = SceneManager::GetInstance();
3022 if (pSceneManager == null)
3026 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3027 if (pAllWindowList == NULL)
3029 pApp = UiApp::GetInstance();
3032 r = pApp->Terminate();
3035 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3040 if (pAllWindowList != null)
3042 totalCount = pAllWindowList->GetCount();
3044 for (int count = 0; count < totalCount; count++)
3046 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3047 if (pWindowInfo == null)
3049 pApp = UiApp::GetInstance();
3052 r = pApp->Terminate();
3055 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3060 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3062 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3065 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3068 r = pAllWindowList->RemoveAt(count, true);
3069 __pWindowInfo = null;
3072 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3077 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3081 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3083 if (pWindowInfo == null)
3085 pApp = UiApp::GetInstance();
3088 r = pApp->Terminate();
3094 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3097 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3111 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3113 AppLog("MainForm::OnForwardClicked");
3114 if (__pWebViewer == null)
3117 if (__pWebViewer->CanGoForward())
3119 __pWebViewer->GoForward();
3124 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3126 result r = E_SUCCESS;
3128 __pFooterPanel->SetShowState(true);
3129 __pFooterUrlField->SetFocusable(true);
3132 __pWebViewer->SetFocus();
3133 else if(__pMostVisitedListView)
3134 __pMostVisitedListView->SetFocus();
3135 else if(__pMultiWindowButton)
3136 __pMultiWindowButton->SetFocus();
3137 __pMoreButton->SetFocus();
3139 __pAddressbar->SetShowState(false);
3141 RelayoutControls(false,false);
3146 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3148 __prevAddressBarMode = __curAddressBarMode;
3150 if (__pAddressbar != null)
3152 __curAddressBarMode = GetAddressbarMode();
3155 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3157 __adressPanelPosition.y = 0;
3158 if (__pAddressbar != null)
3160 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3161 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3162 __pAddressbar->Invalidate(true);
3164 if (__pWebViewer != null)
3166 __pWebViewer->StopLoading();
3169 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3171 __adressPanelPosition.y = 0;
3172 if (__pAddressbar != null)
3174 __webControlPosition.y = 0;
3175 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3176 __pAddressbar->Invalidate(true);
3182 MainForm::OnClipboardClosed(const Addressbar& addBar)
3184 RelayoutControls(false);
3188 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3191 __pAddressbar->SetShowState(false);
3194 __pFooterPanel->SetShowState(true);
3196 __pFooterPanel->Invalidate(false);
3199 // __pWebViewer->SetFocus();
3200 // if(__pMoreButton)
3201 // __pMoreButton->SetFocus();
3202 if(__pFooterUrlField)
3204 __pFooterUrlField->SetFocusable(true);
3206 RelayoutControls(false,footerState);
3210 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3212 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3214 __pAddressbar->SetShowState(false);
3218 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3220 __pAddressbar->SetShowState(true);
3221 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3222 __pAddressbar->SetAddressbarURLFocus();
3226 RelayoutControls(false);
3230 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3232 __pFooterPanel->SetShowState(false);
3236 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3238 AppLog("KeypadBoundsChanged");
3239 RelayoutControls(false);
3243 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3247 __pWindowInfo->pageTitle = title;
3248 if (__pWebViewer != null)
3250 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3253 if (__pAddressbar != null && __pWebViewer != null)
3255 SetUrl(__pWebViewer->GetUrl());
3256 __pAddressbar->Invalidate(true);
3261 MainForm::UpdateFavicon(void)
3263 bool urlImageType = false;
3264 String *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();");
3265 Bitmap* pBitmap = null;
3267 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3269 if (__pWindowInfo != null)
3272 url.SetUri(*tempPath);
3273 if (url.GetHost().GetLength() == 0)
3276 webUrl.SetUri(__pWebViewer->GetUrl());
3277 result r = url.SetHost(webUrl.GetHost());
3284 if (url.GetScheme().GetLength() == 0)
3287 webUrl.SetUri(__pWebViewer->GetUrl());
3288 url.SetScheme(webUrl.GetScheme());
3290 __pWindowInfo->faviconUrl = url.ToString();
3292 pBitmap = __pWebViewer->GetFaviconN();
3294 if (pBitmap != null)
3296 if (__pWindowInfo->pFavicon != NULL)
3298 __pWindowInfo->pFavicon = null;
3300 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3301 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3303 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3305 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3307 else if(__pWindowInfo->pFavicon != null)
3309 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3313 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3314 if(pDefaultBmp != null)
3316 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3325 if(tempPath != null)
3329 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3336 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3337 Tizen::Web::Controls::WebNavigationType type)
3339 // when load new page if find word panel is open its show state is false
3340 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3342 __currentSearchStr = L"";
3343 __currentWordIndex = 0;
3344 __maxOccurrances = 0;
3345 __pFindWordEditField->SetText(L"");
3346 __pFindWordNext->SetEnabled(false);
3347 __pFindWordPrev->SetEnabled(false);
3348 __pFindWordCountLabel->SetText(L"0/0");
3349 // __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3350 __pFindWordControl->SetShowState(false);
3351 __pFindWordEditField->HideKeypad();
3354 // ShowFindWordPanel(false);
3356 __pFooterPanel->Invalidate(true);
3359 uriInfo.SetUri(url);
3361 if(url.Contains(IDS_TIZEN_SERVICE))
3364 String delim(L":;,");
3366 // Creates a StringTokenizer instance
3367 StringTokenizer strTok(url, delim);
3369 int count = strTok.GetTokenCount(); // count == 4
3371 HashMap *pMap = new HashMap();
3377 while (strTok.HasMoreTokens())
3379 AppLog("Token: %ls", token.GetPointer());
3380 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3381 if(token.Contains(IDS_APPID))
3383 token.SubString(6, appId);
3384 AppLog("AppID:%ls", appId.GetPointer());
3386 else if(token.Contains("="))
3388 String *pKey = new String();
3389 String *pValue = new String();
3391 token.IndexOf("=", 0, index);
3394 token.SubString(0, index, *pKey);
3395 token.SubString(index + 1, *pValue);
3396 pMap->Add(pKey, pValue);
3402 AppControl *pAppControl = null;
3403 String operationId = L"http://tizen.org/appcontrol/operation/main";
3404 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3407 result r = pAppControl->Start(null, null, pMap, null);
3411 AppLogException("AppControl not found");
3421 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3422 const Tizen::Net::Http::HttpHeader& httpHeader)
3424 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3429 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3431 AppLog("MainForm::OnWebPageBlockSelected");
3432 if (__pHitElementResult != null)
3434 delete __pHitElementResult;
3435 __pHitElementResult = null;
3438 if (__pWebViewer != null)
3440 AppLog("MainForm::OnWebPageBlockSelected web not null");
3441 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3442 if(GetLastResult() == E_INVALID_ARG)
3444 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3448 if (__pHitElementResult == null)
3453 if (__pHitElementResult->HasImage() != true)
3455 String tagName = __pHitElementResult->GetTagName();
3456 String type = __pHitElementResult->GetAttributeValue("type");
3458 __currentSelectedStr.Clear();
3459 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3460 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3461 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3463 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3465 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3467 InitSelectTextContextMenu(endPoint,true);
3468 __pImageMenu->SetShowState(true);
3469 __pImageMenu->Show();
3470 __pImageMenu->Invalidate(true);
3472 else if(__isLongPressedDone == true)
3474 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3476 if(__pHitElementResult->GetUrl().GetLength() > 0)
3478 __currentSelectedStr.Clear();
3479 __currentSelectedStr = __pHitElementResult->GetUrl();
3481 InitSelectTextContextMenu(endPoint,false);
3482 __pImageMenu->SetShowState(true);
3483 __pImageMenu->Show();
3484 __pImageMenu->Invalidate(true);
3487 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3488 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3489 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3495 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3501 MainForm::OnWebWindowCreateRequested(void)
3503 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3505 if (pNewWindowInfo == null)
3509 result r = E_SUCCESS;
3510 SceneManager* pSceneManager = SceneManager::GetInstance();
3511 if (pSceneManager == NULL)
3515 ArrayList* pArgList = new(std::nothrow) ArrayList();
3516 if (pArgList == NULL)
3520 r = pArgList->Construct();
3523 pNewWindowInfo->isJavascriptInitiated = true;
3524 pArgList->Add(*pNewWindowInfo);
3525 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3529 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3536 return pNewWindowInfo->pCurrentWeb;
3540 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3542 __webControlPosition.y = 0;
3543 __webControlHeight = GetClientAreaBounds().height;
3544 AppLog("Client area height: %d", __webControlHeight);
3546 AppLog("Client area height: %d", __webControlHeight);
3547 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3549 __webControlPosition.y += __pAddressbar->GetHeight();
3550 __webControlHeight -= __pAddressbar->GetHeight();
3551 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3553 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3555 __webControlPosition.y += __pFindWordControl->GetHeight();
3556 __webControlHeight -= __pFindWordControl->GetHeight();
3557 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3560 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3562 __webControlHeight -= __pFooterPanel->GetHeight();
3564 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3566 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3568 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3569 __pWebViewer->Invalidate(false);
3571 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3573 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3580 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3582 if (__pFindWordControl == null)
3588 InitFindWordPanel();
3589 // __pFindWordEditField->SetText(__currentSearchStr);
3590 //__pFindWordCountLabel->SetText(L"");
3591 // __pFindWordCountLabel->SetText(L"0/0");
3592 __pFindWordControl->SetShowState(true);
3596 if(__pFindWordControl != null)
3598 __pFindWordControl->SetShowState(false);
3602 AppLog("MainForm::ShowFindWordPanel %d",show);
3603 if (show && !isTouchPressed)
3605 if (__pFindWordEditField)
3607 __pFindWordEditField->SetFocus();
3608 __pFindWordEditField->ShowKeypad();
3613 if (__pFindWordEditField)
3614 __pFindWordEditField->HideKeypad();
3617 RelayoutControls(false);
3621 MainForm::StartWordSearch()
3623 //Get the count of occurances of the word in the current page
3624 __maxOccurrances = 0;
3625 __currentWordIndex = 0;
3627 __pFindWordPrev->SetEnabled(false);
3628 String *pCountStr = null;
3629 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3630 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3631 if (pCountStr != null)
3633 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3637 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3642 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3644 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3645 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3647 if(totalCount == -1 || totalCount == 0)
3649 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3650 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3653 else if(totalCount > 100)
3655 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3656 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3660 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3661 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3664 __maxOccurrances = totalCount;
3665 __currentWordIndex = currentOrdinal;
3667 //Reset the UI controls as per the maxOccurrance value
3668 if (totalCount <= 0)
3670 AppLog("Word not found");
3671 //Show error notification to user
3672 __pFindWordNext->SetEnabled(false);
3673 __pFindWordCountLabel->SetText(L"0/0");
3674 __pFindWordNext->Invalidate(false);
3675 __pFindWordPrev->Invalidate(false);
3676 __pFindWordCountLabel->Invalidate(false);
3680 if (totalCount == 1)
3682 __pFindWordNext->SetEnabled(false);
3686 __pFindWordNext->SetEnabled(true);
3689 String countStr = L"";
3690 countStr.Append(__currentWordIndex);
3691 countStr.Append(L"/");
3692 countStr.Append(__maxOccurrances);
3693 __pFindWordCountLabel->SetText(countStr);
3694 // __pFindWordCountLabel->SetShowState(true);
3695 __pFindWordCountLabel->Invalidate(false);
3697 //FindNextWord(true);
3698 //Update the controls
3699 __pFindWordNext->Invalidate(false);
3700 __pFindWordPrev->Invalidate(false);
3701 __pFindWordCountLabel->Invalidate(false);
3705 MainForm::FindNextWord(bool next)
3709 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3711 if(__currentWordIndex < __maxOccurrances)
3713 __currentWordIndex++;
3719 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3721 if(__currentWordIndex > 1)
3723 __currentWordIndex--;
3728 String countStr = L"";
3729 countStr.Append(__currentWordIndex);
3730 countStr.Append(L"/");
3731 countStr.Append(__maxOccurrances);
3732 __pFindWordCountLabel->SetText(countStr);
3733 // __pFindWordCountLabel->SetShowState(true);
3734 __pFindWordCountLabel->Invalidate(false);
3735 if (__currentWordIndex >= __maxOccurrances)
3737 __pFindWordNext->SetEnabled(false);
3741 __pFindWordNext->SetEnabled(true);
3743 if (__currentWordIndex <= 1)
3745 __pFindWordPrev->SetEnabled(false);
3749 __pFindWordPrev->SetEnabled(true);
3751 __pFindWordPrev->Invalidate(false);
3752 __pFindWordNext->Invalidate(false);
3753 __pFindWordCountLabel->Invalidate(false);
3754 __pFindWordControl->Invalidate(true);
3757 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3759 AppLog("MainForm::OnWebKeypadWillOpen");
3760 __isWebKeypadOpened = true;
3761 // OnAddressBarKeypadOpened(*__pAddressbar);
3765 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3768 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3770 __currentSearchStr = L"";
3771 __currentWordIndex = 0;
3772 __maxOccurrances = 0;
3773 __pFindWordEditField->SetText(L"");
3774 __pFindWordNext->SetEnabled(false);
3775 __pFindWordPrev->SetEnabled(false);
3776 __pFindWordCountLabel->SetText(L"0/0");
3777 __pWebViewer->SearchTextAllAsync(L"",false);
3778 __pFindWordControl->SetShowState(false);
3779 __pFindWordEditField->HideKeypad();
3783 if (__pWebViewer != null && __pFooterPanel != null)
3785 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3786 if(__pAddressbar != null)
3788 __pAddressbar->SetShowState(false);
3790 if(__pFindWordControl != null)
3792 __pFindWordControl->SetShowState(false);
3794 __pFooterPanel->SetShowState(false);
3795 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3797 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3799 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3800 // AppLog("omgomgomg");
3806 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3808 __pFooterPanel->SetShowState(true);
3809 OnAddressBarKeypadClosed(*__pAddressbar);
3810 __isWebKeypadOpened = false;
3814 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3816 Control* temp = const_cast< Control* >(&source);
3817 Header* pHeader = dynamic_cast< Header* >(temp);
3818 if (pHeader != null)
3820 //Header double - clicked
3821 AppLog("Header double clicked");
3823 if(__pFindWordControl)
3825 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3826 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3830 AppLog("MainScene::OnTouchDoublePressed");
3831 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3832 if (isReaderEnabled == true)
3836 delete __pReaderData;
3837 __pReaderData = null;
3839 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3840 filePath.Append(L"data/reader.js");
3846 result r = E_SUCCESS;
3847 FileAttributes attr;
3849 File::GetAttributes(filePath,attr);
3851 r = file.Construct(filePath, L"r+");
3854 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3857 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3860 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3863 file.Read(pScript,attr.GetFileSize());
3865 AppLogDebug("scipt length %d",strlen(pScript));
3866 String strScript = L"";
3867 strScript.Append(pScript);
3868 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3871 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3874 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3875 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3877 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3878 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3884 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3886 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3888 if (__pHitElementResult != null)
3890 delete __pHitElementResult;
3891 __pHitElementResult = null;
3894 if (__pWebViewer != null)
3896 AppLog("MainForm::OnTouchLongPressed web not null");
3897 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3900 if (__pHitElementResult == null)
3905 if (__pHitElementResult->HasImage() == true)
3907 InitImageContextMenu(currentPosition);
3908 __pImageMenu->SetShowState(true);
3909 __pImageMenu->Show();
3910 __pImageMenu->Invalidate(true);
3912 else if(__pHitElementResult->HasUrl() == true)
3914 String tempURl = __pHitElementResult->GetUrl();
3915 AppLog("tempURl is %ls", tempURl.GetPointer());
3916 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3917 if (pBitmap != null)
3925 InitImageLinkContextMenu(currentPosition);
3926 __pImageMenu->SetShowState(true);
3927 __pImageMenu->Show();
3928 __pImageMenu->Invalidate(true);
3932 String tagName = __pHitElementResult->GetTagName();
3933 String type = __pHitElementResult->GetAttributeValue("type");
3934 String value = __pHitElementResult->GetAttributeValue(L"value");
3935 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3937 __currentSelectedStr.Clear();
3938 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3940 AppLog("tag name is %ls", tagName.GetPointer());
3941 AppLog("type is %ls", type.GetPointer());
3942 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3944 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3946 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3948 InitSelectTextContextMenu(currentPosition,true, true);
3951 __pImageMenu->SetShowState(true);
3952 __pImageMenu->Show();
3953 __pImageMenu->Invalidate(true);
3956 __isLongPressedDone = true;
3957 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3958 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3961 __inputEventToBeSupressed = true;
3965 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3967 AppLog("MainForm::OnTouchReleased");
3969 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3970 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3972 __pWebViewer->ConsumeInputEvent();
3974 if(pHitElement != null)
3978 __inputEventToBeSupressed = false;
3982 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3989 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3991 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3993 __currentSearchStr = L"";
3994 __currentWordIndex = 0;
3995 __maxOccurrances = 0;
3996 __pFindWordEditField->SetText(L"");
3997 __pFindWordNext->SetEnabled(false);
3998 __pFindWordPrev->SetEnabled(false);
3999 __pFindWordCountLabel->SetText(L"0/0");
4000 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4001 __pFindWordControl->SetShowState(false);
4002 __pFindWordEditField->HideKeypad();
4004 if(__pAddressbar->GetShowState() == false)
4006 __pAddressbar->SetShowState(true);
4007 __pAddressbar->SetAddressbarURLFocus();
4008 __pFooterUrlField->SetFocusable(false);
4009 __pFooterPanel->SetShowState(false);
4016 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4022 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4028 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4034 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4040 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4046 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4048 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4049 int widthContextItem = 0;
4051 // As per the platform engineer comment removed this line
4052 /*if(__pWebViewer != null)
4054 // 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
4055 __pWebViewer->ReleaseBlock();
4058 if(__pFindWordControl != null)
4059 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4060 if ( __pFooterLabel != null)
4062 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4065 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4070 if (__pFindWordBgLabel != null)
4072 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4073 if (pBitmap != null)
4075 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4081 __pMenu->SetShowState(false);
4082 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4084 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4088 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4093 AppLog("__pFooterPanel->GetShowState() is true");
4095 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4096 __pFooterPanel->Invalidate(true);
4100 if(__pMoreButton && __pMenu)
4102 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4103 __pMenu->SetAnchorPosition(p);
4104 __pMenu->Invalidate(true);
4107 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4108 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4110 InitMostVisitedSitesView(orientationStatus);
4113 RelayoutControls(false);
4114 if (__pArticleReaderPanel != null)
4116 if (__pArticleReaderPanel->GetShowState() == true)
4118 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4120 if (__pBlankPanel != null)
4121 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4123 if (__pWebReader != null)
4125 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4127 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4128 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4130 if ( pBitmap != null && pSrcBitmap != null)
4132 AppLog("CreateReaderPanel ninepatchbitmap found");
4133 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4136 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4137 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4138 if (pBitmap != null)
4143 if (pSrcBitmap != null)
4152 if (__pAddressbar != null)
4154 int width = GetClientAreaBounds().width;
4155 __pAddressbar->OrientationChanged(width);
4160 MainForm::OnSettingsChange(int settingvalue)
4162 AppLogDebug("MainForm::OnSettingsChange entered");
4164 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4166 __pAddressbar->ResetGuideText();
4168 if (__pWebViewer == null)
4170 AppLogDebug("Webviewer is not initialized yet.");
4174 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4176 WebSetting settings = __pWebViewer->GetSetting();
4177 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4179 settings.SetAutoFittingEnabled(true);
4181 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4183 settings.SetAutoFittingEnabled(false);
4185 __pWebViewer->SetSetting(settings);
4187 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4189 WebSetting settings = __pWebViewer->GetSetting();
4190 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4191 __pWebViewer->SetSetting(settings);
4193 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4195 WebSetting settings = __pWebViewer->GetSetting();
4196 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4197 __pWebViewer->SetSetting(settings);
4199 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4201 WebSetting settings = __pWebViewer->GetSetting();
4202 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4203 __pWebViewer->SetSetting(settings);
4205 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4209 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4213 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4215 WebSetting settings = __pWebViewer->GetSetting();
4216 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4218 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4222 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4224 __pWebViewer->SetSetting(settings);
4226 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4230 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4231 WebSetting settings = __pWebReader->GetSetting();
4232 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4233 __pWebReader->SetSetting(settings);
4239 MainForm::OnSettingsReset()
4243 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4244 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4249 MainForm::OnClearCache()
4251 result r = E_SUCCESS;
4253 if (__pWebViewer != NULL)
4255 r = __pWebViewer->ClearCache();
4258 AppLogDebug("Cache cleared success");
4262 AppLogDebug("Cache cleared fail");
4268 MainForm::OnClearCookie()
4270 result r = E_SUCCESS;
4272 if (__pWebViewer != NULL)
4274 __pWebViewer->ClearCookie();
4278 AppLogDebug("Cookie cleared success");
4282 AppLogDebug("Cache cleared fail");
4287 MainForm::OnClearFormData()
4289 result r = E_SUCCESS;
4291 if (__pWebViewer != NULL)
4293 __pWebViewer->ClearFormData();
4297 AppLogDebug("Cookie cleared success");
4301 AppLogDebug("Cache cleared fail");
4306 MainForm::OnClearPasswords()
4308 result r = E_SUCCESS;
4310 if (__pWebViewer != NULL)
4312 __pWebViewer->ClearLoginFormData();
4316 AppLogDebug("Cookie cleared success");
4320 AppLogDebug("Cache cleared fail");
4326 MainForm::findDistance(int x1,int y1,int x2, int y2)
4328 int deltaX = Math::Abs(x2 - x1);
4329 int deltaY = Math::Abs(y2 - y1);
4330 double num = deltaX*deltaX + deltaY*deltaY;
4336 for (i = 0; i < 20; i++)
4338 x = (((x*x)+ num)/(2*x));
4349 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4351 if(__pFindWordControl)
4353 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4354 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4356 __isLongPressedDone = false;
4359 IList* pList = null;
4360 pList = touch.GetTouchInfoListN(source);
4364 int count = pList->GetCount();
4367 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4368 __touchPoint1 = pTouchInfo->position;
4370 /*if (__pAddressbar != null)
4372 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4374 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4376 __pAddressbar->SaveAddressbarEditText();
4378 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4381 __pAddressbar->Invalidate(true);
4383 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4385 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4387 //__pAddressbar->SaveAddressbarEditText();
4389 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4392 else if (count == 2)
4394 AppLogDebug("MainForm::OnTouchPressed count is two");
4395 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4396 __touchPoint1 = pTouchInfo->position;
4398 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4399 __touchPoint2 = pTouchInfo->position;
4405 pList->RemoveAll(true);
4412 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4414 // __currentWordIndex = 0;
4415 __isLongPressedDone = false;
4420 MainForm::MoveUiControls()
4425 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4427 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4429 if(__pFooterUrlField->GetTextLength() == 0)
4431 __pFooterUrlField->SetKeypadActionEnabled(false);
4435 __pFooterUrlField->SetKeypadActionEnabled(true);
4438 if (__pFindWordEditField != null)
4440 __currentSearchStr = __pFindWordEditField->GetText();
4441 __pFindWordNext->SetEnabled(false);
4442 __pFindWordPrev->SetEnabled(false);
4443 __pFindWordNext->Invalidate(true);
4444 __pFindWordPrev->Invalidate(true);
4445 __pFindWordCountLabel->SetText(L"0/0");
4446 __pFindWordCountLabel->Invalidate(true);
4448 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4449 if (__currentSearchStr.GetLength() > 0)
4455 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4457 __currentSearchStr = L"";
4458 AppLogDebug("Enter something");
4463 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4470 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4472 if(__pWebViewer != null)
4475 AppLog("MainForm::InitMostVisitedSitesView");
4476 result r = E_SUCCESS;
4479 if (__pWebViewer != null && __pMostVisitedListView != null)
4484 if (__pMostVisitedListView != null)
4486 RemoveControl(__pMostVisitedListView);
4488 if(__pMostVisitedSites != null)
4490 __pMostVisitedSites->RemoveAll(true);
4493 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4495 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4496 __pMostVisitedListView = new(std::nothrow) ListView();
4498 int height = GetClientAreaBounds().height;
4500 if(__pFooterPanel->GetShowState() == true)
4502 height = height - __pFooterPanel->GetHeight();
4504 if(__pAddressbar->GetShowState() == true)
4506 height -= __pAddressbar->GetHeight();
4509 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4513 delete __pMostVisitedListView;
4514 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4517 __pMostVisitedListView->SetItemProvider(*this);
4518 __pMostVisitedListView->AddListViewItemEventListener(*this);
4519 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4520 AddControl(__pMostVisitedListView);
4521 __pMostVisitedListView->UpdateList();
4528 MainForm::GetImagePath(void)
4532 String formattedTime;
4533 DateTime currentTime;
4534 LocaleManager localManager;
4535 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4537 localManager.Construct();
4538 Locale locale = localManager.GetSystemLocale();
4539 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4541 // Get date formatter
4542 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4546 pTimeFormatter->Format(currentTime, formattedTime);
4549 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4550 String delim(L" :");
4551 StringTokenizer strTok(formattedTime, delim);
4554 String str1("GMT+00");
4555 while (strTok.HasMoreTokens())
4557 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4558 if(token.Equals(str1))
4560 AppLog("token is %ls", token.GetPointer());
4561 imageName.Append(token);
4567 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4569 result r = E_FAILURE;
4570 AppLog("Content manager 1");
4571 ContentId contentId;
4572 ContentManager contentManager;
4573 r = contentManager.Construct();
4576 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4579 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4580 contentPath.Append(imageName);
4581 contentPath.Append(".jpg");
4582 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4583 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4587 MainForm::SetForwardButtonEnabled(bool isEnabled)
4589 __pGoForwardBtn->SetEnabled(isEnabled);
4590 __pGoForwardBtn->Invalidate(true);
4594 MainForm::SetBackButtonEnabled(bool isEnabled)
4596 __pGoBackBtn->SetEnabled(isEnabled);
4597 __pGoBackBtn->Invalidate(true);
4601 MainForm::UpdateProgress(int percentage)
4603 __progressPercentage = percentage;
4604 if (percentage == 0 || percentage == 100)
4606 __isLoadingData = false;
4607 if (percentage == 100)
4609 __isLoadingCompleted = true;
4610 __progressPercentage = 0;
4614 __isLoadingCompleted = false;
4619 __isLoadingData = true;
4621 UpdateProgressBitmap();
4625 MainForm::GetProgress(void)
4627 return __progressPercentage;
4631 MainForm::UpdateProgressBitmap(void)
4633 result r = E_SUCCESS;
4634 if (__pProgressbarLabel == null)
4636 int w = __pProgressbarLabel->GetWidth();
4637 int h = __pProgressbarLabel->GetHeight();
4639 int progressWidth = 0;
4640 Bitmap* pRetBitmap = null;
4642 if (__progressPercentage == 0 || __progressPercentage == 100)
4644 __pProgressbarLabel->SetShowState(false);
4645 __pProgressbarLabel->Invalidate(false);
4650 __pProgressbarLabel->SetShowState(true);
4651 __pProgressbarLabel->Invalidate(false);
4654 r = canvas.Construct(Rectangle(0, 0, w, h));
4658 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4663 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4667 pBgBmp->Scale(Dimension(w, h));
4668 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4672 progressWidth = (double) (w) * __progressPercentage / 100;
4673 AppLogDebug("progressWidth: %d", progressWidth);
4674 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4676 if (pProgressBmp != null)
4678 pProgressBmp->Scale(Dimension(progressWidth, h));
4679 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4680 delete pProgressBmp;
4683 pRetBitmap = new (std::nothrow) Bitmap();
4685 if (pRetBitmap == null)
4687 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4691 pRetBitmap->Construct(canvas, canvas.GetBounds());
4693 if (__pProgressbarLabel != null && pRetBitmap != null)
4695 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4696 __pProgressbarLabel->Invalidate(false);
4699 if (pRetBitmap != null)
4707 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4709 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4711 __currentAddMode = addMode;
4715 case ADDRESSBAR_MODE_INVALID:
4720 case ADDRESSBAR_MODE_READER:
4722 __pStopBtn->SetShowState(false);
4723 __pClearBtn->SetShowState(false);
4726 case ADDRESSBAR_MODE_LOADING:
4728 __pRefreshBtn->SetShowState(false);
4729 __pStopBtn->SetShowState(true);
4730 __pClearBtn->SetShowState(false);
4733 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4735 // SetUrl(__pAddressbar->GetUrl());
4737 __pRefreshBtn->SetShowState(true);
4738 __pStopBtn->SetShowState(false);
4739 __pClearBtn->SetShowState(false);
4742 case ADDRESSBAR_MODE_EDIT:
4744 __pRefreshBtn->SetShowState(false);
4745 __pStopBtn->SetShowState(false);
4746 __pClearBtn->SetShowState(true);
4753 OnAddressBarModeChanged();
4756 AddressBarMode MainForm::GetAddressbarMode(void)
4758 return __currentAddMode;
4761 void MainForm::SetUrl(const String& url)
4765 if (__pFooterUrlField != NULL)
4767 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4768 if (removedHttpUrl.IsEmpty() == false)
4770 __pFooterUrlField->SetText(removedHttpUrl);
4771 if(__pAddressbar != NULL)
4772 __pAddressbar->SetUrl(__displayUrl);
4776 __pFooterUrlField->SetText(__displayUrl);
4777 if(__pAddressbar != NULL)
4778 __pAddressbar->SetUrl(__displayUrl);
4780 if(__pFooterUrlField)
4781 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4782 __pFooterUrlField->Invalidate(false);
4783 if(__pAddressbar != NULL)
4784 __pAddressbar->Invalidate(true);
4785 // __pFooterUrlField->SetCursorPosition(0);
4790 MainForm::RemoveHttpTextFromDisplayURL(void)
4792 bool isHttpText = __displayUrl.Contains(L"http://");
4793 String updatedDisplayUrl;
4794 updatedDisplayUrl.Clear();
4796 if (isHttpText == true)
4798 __displayUrl.SubString(7,updatedDisplayUrl);
4800 return updatedDisplayUrl;
4803 void MainForm::OnSharePopupControlStarted(void)
4805 __pWebViewer->AddTouchEventListener(*this);
4808 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4810 if (requestId == BACK_GROUND_APP_EVENT)
4812 if(__pWebViewer != null)
4814 __pWebViewer->Pause();
4817 else if(requestId == FORE_GROUND_APP_EVENT)
4819 if(__pWebViewer != null)
4821 __pWebViewer->Resume();