2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (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;
97 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
98 const int IDA_FINDWORD_NEXT_CLICKED = 202;
99 const int IDA_FINDWORD_PREV_CLICKED = 203;
100 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
101 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
103 const int IDA_COPY_IMAGE_CLICKED = 206;
104 const int IDA_VIEW_IMAGE_CLICKED = 207;
105 const int IDA_SAVE_IMAGE_CLICKED = 208;
106 const int IDA_SHARE_IMAGE_CLICKED = 209;
108 const int IDA_COPY_TEXT_CLICKED = 210;
109 const int IDA_PASTE_TEXT_CLICKED = 211;
110 const int IDA_FIND_TEXT__CLICKED = 212;
111 const int IDA_SHARE_TEXT_CLICKED = 213;
113 const int IDA_GO_BACK = 214;
114 const int IDA_GO_FORWARD = 215;
115 const int IDA_REFRESH_BTN_CLICKED = 216;
116 const int IDA_STOP_BTN_CLICKED = 217;
117 const int IDA_CLEAR_URL = 218;
119 const int IDA_HYPERLINK_OPEN_CLICKED = 219;
120 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220;
121 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
122 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
124 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
126 const int MainForm::IDA_FORMAT_BITMAP = 500;
127 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
128 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
129 const int MainForm::IDA_FORMAT_URL_STRING = 503;
130 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
132 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
133 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
134 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
136 MainForm::MainForm(void)
138 __isLongPressedDone = false;
139 __pAddressbar = null;
140 // __pMostVisitedSitesPanel = null;
141 __pMostVisitedListView = null;
142 __pFooterPanel = null;
143 __pHitElementResult = null;
144 __pWindowInfo = null;
148 __pFindWordControl = null;
150 __pFindWordBgLabel = null;
151 __pFindWordEditField = null;
152 __pFindWordClear = null;
153 __pFindWordCountLabel = null;
154 __pFindWordNext = null;
155 __pFindWordPrev = null;
156 __previousZoomLevel = 1.0;
158 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
161 __currentSearchStr = L"";
162 __currentSelectedStr = L"";
163 __maxOccurrances = 0;
164 __currentWordIndex = 0;
167 __inputEventToBeSupressed = false;
168 __isLoadingData = false;
169 __isLoadingCompleted = false;
170 __progressPercentage = 0;
171 __touchPoint1 = Point(-1,-1);
172 __touchPoint2 = Point(-1,-1);
174 // __pReaderPopup = null;
175 __pReaderData = null;
177 __pReaderCloseBtn = null;
178 //__pNewWindowButton = null;
179 __pMoreButton = null;
180 __pMultiWindowButton = null;
181 __pArticleReaderPanel = null;
182 __pBlankPanel = null;
183 __pArticleReaderLabel = null;
184 __webControlHeight = 0;
185 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
186 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
187 __pMostVisitedSites = null;
188 __pFooterUrlField = null;
190 __pGoForwardBtn = null;
191 __pRefreshBtn = null;
192 __pProgressbarLabel = null;
193 __pFooterLabel = null;
196 __isWebKeypadOpened = false;
199 MainForm::~MainForm(void)
201 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
205 __pAddressbar->SetAddressbarEventListener(null);
207 if (__pReaderData != null)
209 delete __pReaderData;
210 __pReaderData = null;
213 if (__pPopUp != null)
219 if (__pHitElementResult != null)
221 delete __pHitElementResult;
222 __pHitElementResult = null;
225 String* pSelectedScene = NULL;
226 Object* pValue = NULL;
227 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
228 pSelectedScene = (String*) pValue;
230 /*if (pSelectedScene != null)
232 delete pSelectedScene;
234 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
238 MainForm::Initialize(void)
240 Construct(L"IDL_FORM");
245 MainForm::OnInitializing(void)
247 AppLog("get client area width = %d",GetClientAreaBounds().width);
248 AppLog("get client area height = %d",GetClientAreaBounds().height);
249 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
250 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
252 Panel* pFooterPanel = null;
254 __pSaveImage = new Image();
255 __pSaveImage->Construct();
257 // Setup back event listener
258 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
259 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
260 AddOrientationEventListener(*this);
261 AppLogDebug(" MainForm::OnInitializing ended");
262 if (__pMostVisitedSites == null)
264 __pMostVisitedSites = new(std::nothrow) ArrayList();
265 __pMostVisitedSites->Construct();
267 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
269 __pItemContext= new(std::nothrow) ListContextItem();
270 __pItemContext->Construct();
271 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
272 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
274 if (pBitmapNormal != null && pBitmapPressed != null)
276 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
279 if (pBitmapNormal != null)
281 delete pBitmapNormal;
284 if (pBitmapPressed != null)
286 delete pBitmapPressed;
289 __pItemContextLandscape= new(std::nothrow) ListContextItem();
290 __pItemContextLandscape->Construct();
291 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
292 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
294 if (pBitmapNormal != null && pBitmapPressed != null)
296 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
299 if (pBitmapNormal != null)
301 delete pBitmapNormal;
304 if (pBitmapPressed != null)
306 delete pBitmapPressed;
313 MainForm::InitAddressbar(void)
315 AppLogDebug("MainForm::InitAddressbar entered");
317 result r = E_SUCCESS;
319 if (__pAddressbar != null)
323 __pAddressbar = new(std::nothrow) Addressbar();
324 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
325 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
328 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
331 __pAddressbar->SetAddressbarEventListener(this);
332 AddControl(*__pAddressbar);
333 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
334 SetControlAlwaysOnTop(*__pAddressbar, true);
335 __adressPanelPosition = __pAddressbar->GetPosition();
337 AppLogDebug("MainForm::InitAddressbar exit");
343 MainForm::CreateReaderPanel(void)
345 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
346 result r = E_FAILURE;
348 Button *pSmallFontBtn = null;
349 Button *pLargeFontBtn = null;
351 __pBlankPanel = new (std::nothrow) Panel();
352 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
354 __pArticleReaderPanel = new (std::nothrow) Panel();
355 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
357 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
358 if (__pReaderCloseBtn)
360 AppLogDebug("CreateReaderPanel() 6");
361 __pReaderCloseBtn->AddActionEventListener(*this);
362 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
365 __pWebReader = new (std::nothrow) Web();
366 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
368 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
369 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
371 r = __pWebReader->SetSetting(settings);
373 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
376 __pArticleReaderLabel = new Label();
377 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
379 __pBlankPanel->AddControl(*__pArticleReaderLabel);
380 __pBlankPanel->AddControl(*__pArticleReaderPanel);
381 AddControl(*__pBlankPanel);
383 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
384 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
385 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
387 __pArticleReaderPanel->AddControl(*__pWebReader);
388 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
389 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
390 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
392 if (pBitmap != null && pSrcBitmap != null)
394 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
396 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
398 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
401 pSmallFontBtn->AddActionEventListener(*this);
402 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
405 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
408 pLargeFontBtn->AddActionEventListener(*this);
409 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
418 if (pSrcBitmap != null)
424 SetControlAlwaysOnTop(*__pBlankPanel, true);
425 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
432 MainForm::InitWebControl()
434 AppLogDebug("MainForm::InitWebControl enter");
435 result r = E_SUCCESS;
436 AppLogDebug("InitWebControl");
438 if (__pAddressbar == null || __pFooterPanel == null)
441 const int Y_WEBCONTROL_POSITION = 0;
442 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
443 if (__pMostVisitedListView)
445 __pMostVisitedListView->SetShowState(false);
447 if (__pWebViewer != null)
449 AppLogDebug("Already initialized");
452 __pWebViewer = new(std::nothrow) Web();
453 if(__pWebViewer == NULL)
455 AppLogDebug("Initialization failed");
458 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
462 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
469 r = AddControl(*__pWebViewer);
473 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
476 __webControlPosition = __pWebViewer->GetPosition();
477 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
480 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
484 __pWebViewer->SetLoadingListener(this);
485 __pWebViewer->SetWebUiEventListener(this);
486 __pWebViewer->SetWebKeypadEventListener(this);
487 __pWebViewer->SetFocus();
488 __pWebViewer->AddTouchEventListener(*this);
490 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
491 __pWebViewer->SetTextSearchListener(this);
494 AppLogDebug("MainForm :before return");
496 AppLogDebug("MainForm::InitWebControl Exit");
502 MainForm::OnFocusGained(const Control& source)
504 AppLog("MainForm::OnFocusGained");
508 MainForm::OnFocusLost(const Control& source)
510 AppLog("MainForm::OnFocusLost");
514 MainForm::SetJavascriptEnabled()
516 WebSetting settings = __pWebViewer->GetSetting();
517 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
518 __pWebViewer->SetSetting(settings);
522 MainForm::SetImageLoadEnabled()
524 WebSetting settings = __pWebViewer->GetSetting();
525 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
526 __pWebViewer->SetSetting(settings);
530 MainForm::InitFooter(void)
532 AppLogDebug("MainForm::InitFooter entered");
533 Button* pBackButton = null;
534 Button* pBookmarkButton = null;
535 Button* pMultiWindowButton = null;
536 Bitmap *pIconBitmap = null;
537 Bitmap *pBGBitmap = null;
538 Label *pBGLabel = null;
540 if (__pFooterPanel == null)
542 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
545 if (__pFooterPanel == null)
550 SetControlAlwaysOnTop(*__pFooterPanel, true);
552 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
553 if ( __pFooterLabel == NULL )
557 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
558 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
561 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
565 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
567 if ( __pMultiWindowButton == NULL )
572 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
574 if ( __pMoreButton == NULL )
579 if (__pMultiWindowButton != null)
581 Bitmap* pBitmap = null;
582 Bitmap* pPressedBitmap = null;
583 String imagePath = "I01_toolbar_icon_windows_manager_0";
584 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
585 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
586 imagePath.Append(totalCount);
587 imagePath.Append(".png");
589 pressedImagePath.Append(totalCount);
590 pressedImagePath.Append("_press.png");
592 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
593 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
594 if ( pBitmap == null )
599 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
602 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
603 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
608 __pMultiWindowButton->AddActionEventListener(*this);
609 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
614 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
615 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
618 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
619 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
620 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
624 __pMoreButton->AddActionEventListener(*this);
625 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
628 //Add the editfield for url
629 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
630 if (__pFooterUrlField == NULL)
632 return E_INVALID_KEY;
635 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
636 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
637 //__pFooterUrlField->AddFocusEventListener(*this);
638 __pFooterUrlField->AddKeypadEventListener(*this);
639 //__pFooterUrlField->AddFocusEventListener(*this);
640 __pFooterUrlField->SetPropagatedTouchEventListener(this);
642 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
644 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
646 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
648 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
652 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
653 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
657 //Add the go Back Button
658 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
659 if (__pGoBackBtn == NULL)
661 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
662 return E_INVALID_KEY;
664 __pGoBackBtn->SetActionId(IDA_GO_BACK);
665 __pGoBackBtn->AddActionEventListener(*this);
667 //Add the go forward Button
668 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
669 if (__pGoForwardBtn == NULL)
671 AppLogDebug("Control not found returning E_INVALID_KEY");
672 return E_INVALID_KEY;
674 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
675 __pGoForwardBtn->AddActionEventListener(*this);
676 __pGoForwardBtn->SetEnabled(false);
678 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
679 if (__pRefreshBtn == NULL)
681 AppLogDebug("Control not found returning E_INVALID_KEY");
682 return E_INVALID_KEY;
685 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
686 __pRefreshBtn->AddActionEventListener(*this);
687 __pRefreshBtn->SetShowState(true);
689 //Add the backround label for displaying progressbar
690 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
691 if (__pProgressbarLabel == NULL)
693 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
694 return E_INVALID_KEY;
696 __pProgressbarLabel->SetShowState(false);
698 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
699 if (__pStopBtn == NULL)
701 AppLogDebug("Control not found returning E_INVALID_KEY");
702 return E_INVALID_KEY;
704 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
705 __pStopBtn->AddActionEventListener(*this);
706 __pStopBtn->SetShowState(false);
708 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
709 if (__pClearBtn == NULL)
711 AppLogDebug("Control not found returning E_INVALID_KEY");
712 return E_INVALID_KEY;
714 __pClearBtn->SetActionId(IDA_CLEAR_URL);
715 __pClearBtn->AddActionEventListener(*this);
716 __pClearBtn->SetShowState(false);
718 // __pFooterPanel->Invalidate(true);
719 AppLogDebug("MainForm::InitFooter exit");
725 MainForm::InitContextMenu(Point& p)
727 result r = E_SUCCESS;
728 bool isPrivateBrowsing = false;
729 Bitmap* pBitmap = null;
733 __pMenu->SetAnchorPosition(p);
734 __pMenu->Invalidate(true);
738 __pMenu = new(std::nothrow) ContextMenu();
739 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
740 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
742 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
745 if (isPrivateBrowsing == true)
747 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
751 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
754 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
756 if ( pBitmap != NULL)
758 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
761 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
762 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
763 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
766 __pMenu->SetMaxVisibleItemsCount(6);
767 __pMenu->SetShowState(false);
768 __pMenu->AddActionEventListener(*this);
769 SetControlAlwaysOnTop(*__pMenu, true);
775 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
777 result r = E_SUCCESS;
778 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
780 AppLog("MainForm::InitImageContextMenu clicked on image");
781 if (__pImageMenu != null)
787 p.y = p.y + __pAddressbar->GetHeight() + 12;
790 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
794 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
796 __pImageMenu = new (std::nothrow) ContextMenu();
797 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
798 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
800 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
801 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
802 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
803 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
804 __pImageMenu->SetMaxVisibleItemsCount(4);
805 __pImageMenu->AddActionEventListener(*this);
806 SetControlAlwaysOnTop(*__pImageMenu, true);
812 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
814 result r = E_SUCCESS;
815 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
817 AppLog("MainForm::InitImageContextMenu clicked on image");
818 if (__pImageMenu != null)
824 p.y = p.y + __pAddressbar->GetHeight() + 12;
827 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
831 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
833 __pImageMenu = new (std::nothrow) ContextMenu();
834 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
835 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
837 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
838 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
839 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
840 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
842 __pImageMenu->SetMaxVisibleItemsCount(3);
843 __pImageMenu->AddActionEventListener(*this);
844 SetControlAlwaysOnTop(*__pImageMenu, true);
850 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
852 result r = E_SUCCESS;
853 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
855 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
856 if (__pImageMenu != null)
861 p.y = p.y + __pAddressbar->GetHeight() + 12;
864 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
868 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
870 __pImageMenu = new (std::nothrow) ContextMenu();
871 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
872 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
874 if(onlyPasteOption == false)
876 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
878 if (pasteOption || onlyPasteOption)
880 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
882 if(onlyPasteOption == false)
884 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
888 __pImageMenu->SetMaxVisibleItemsCount(3);
889 __pImageMenu->AddActionEventListener(*this);
890 SetControlAlwaysOnTop(*__pImageMenu, true);
897 MainForm::InitFindWordPanel(void)
899 result r = E_SUCCESS;
900 Bitmap *pIconBitmap = null;
902 if (__pFindWordControl != null)
904 AppLogDebug("Findword panel already initialized");
905 if (__pFindWordBgLabel != null)
907 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
910 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
917 __pFindWordControl = new (std::nothrow) Panel();
918 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
921 AppLogException("There is some problem in the xml file. Please check.");
924 AddControl(*__pFindWordControl);
925 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
926 SetControlAlwaysOnTop(*__pFindWordControl,true);
927 __pFindWordControl->SetShowState(false);
928 __pFindWordControl->Invalidate(false);
930 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
931 if (__pFindWordBgLabel != null)
933 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
934 Rectangle pRect = pPanel1->GetBounds();
935 pRect.x = pRect.y = 0;
936 __pFindWordBgLabel->SetBounds(pRect);
937 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
940 AppLogDebug("InitFindWordPanel: Coming here");
941 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
946 AppLogDebug("InitFindWordPanel: shouldn't Come here");
950 Button* pfindWordCancel = null;
951 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
952 if (pfindWordCancel == null)
954 AppLogException("There is some problem in the xml file. Please check.");
957 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
958 pfindWordCancel->AddActionEventListener(*this);
960 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
961 if (__pFindWordClear == null)
963 AppLogException("There is some problem in the xml file. Please check.");
967 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
968 __pFindWordClear->AddActionEventListener(*this);
970 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
971 if (__pFindWordNext == null)
973 AppLogException("There is some problem in the xml file. Please check.");
977 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
978 __pFindWordNext->AddActionEventListener(*this);
980 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
981 if (__pFindWordPrev == null)
983 AppLogException("There is some problem in the xml file. Please check.");
987 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
988 __pFindWordPrev->AddActionEventListener(*this);
990 __pFindWordNext->SetEnabled(false);
991 __pFindWordPrev->SetEnabled(false);
993 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
994 if (__pFindWordCountLabel == null)
996 AppLogException("There is some problem in the xml file. Please check.");
1000 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1001 if (__pFindWordEditField == null)
1003 AppLogException("There is some problem in the xml file. Please check.");
1006 __pFindWordEditField->AddTextEventListener(*this);
1007 __pFindWordEditField->AddKeypadEventListener(*this);
1008 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1014 MainForm::CreateItem (int index, int itemWidth)
1016 Rectangle listImageRect;
1017 Rectangle pagetTitleRect;
1018 Rectangle pageURLRect;
1019 Rectangle deleteImageRect;
1020 String pageTitle(L"");
1021 String pageURL(L"");
1022 result r = E_SUCCESS;
1023 Bitmap* pListIconImage = null;
1026 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1027 if(pHistory == null)
1031 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1032 if ( pAppResource == NULL )
1036 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1038 CustomItem* pItem = new(std::nothrow) CustomItem();
1039 pageTitle = pHistory->GetHistoryTitle();
1040 pageURL = pHistory->GetHistoryUrl();
1042 if (pageURL.GetLength() == 0)
1045 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1046 pageURL = L"<"+ nourl +">";
1050 Rectangle screenBounds = GetBounds();
1053 r = pItem->Construct(Dimension(itemWidth, 128), style);
1062 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1064 if ( pBitmap != NULL)
1066 pListIconImage = new Bitmap();
1067 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1071 if(pListIconImage == null)
1073 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1076 if ( pListIconImage != NULL)
1078 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1079 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1080 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1083 if (pItem != null && pListIconImage != NULL)
1085 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1089 if (pageTitle.CompareTo(L"") != 0)
1093 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1097 if (pageURL.CompareTo(L"") != 0)
1101 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1106 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1108 if ( __pItemContext!= NULL)
1112 pItem->SetContextItem(__pItemContext);
1118 if ( __pItemContextLandscape!= NULL)
1122 pItem->SetContextItem(__pItemContextLandscape);
1126 if( pListIconImage != NULL)
1128 delete pListIconImage;
1129 pListIconImage = null;
1136 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1143 MainForm::GetItemCount (void)
1145 if(__pMostVisitedSites != null)
1147 __pMostVisitedSites->RemoveAll(true);
1149 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1150 if(__pMostVisitedSites != null)
1152 return __pMostVisitedSites->GetCount();
1159 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1161 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1162 String url = pHistory->GetHistoryUrl();
1163 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1164 __pMostVisitedListView->UpdateList();
1168 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1170 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1171 String url = pHistory->GetHistoryUrl();
1179 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1185 MainForm::OnTerminating(void)
1187 result r = E_SUCCESS;
1190 delete __pItemContext;
1192 if(__pItemContextLandscape)
1194 delete __pItemContextLandscape;
1200 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1202 result r = E_SUCCESS;
1204 AppLogDebug("Clicked : %d", actionId);
1207 // case IDA_BACKBTN_CLICKED:
1209 // if (__pWebViewer && __pWebViewer->CanGoBack())
1211 // __pWebViewer->GoBack();
1215 // UiApp* pApp = null;
1216 // pApp = UiApp::GetInstance();
1217 // if (pApp != null)
1219 // r = pApp->Terminate();
1222 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1230 case IDA_BACKBTN_CLICKED:
1232 if (__pWebViewer && __pWebViewer->CanGoBack())
1234 __pWebViewer->GoBack();
1236 else if(__pWindowInfo->isJavascriptInitiated == false)
1239 pApp = UiApp::GetInstance();
1242 r = pApp->Terminate();
1245 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1253 WindowInfo* pWindowInfo = null;
1255 SceneManager* pSceneManager = SceneManager::GetInstance();
1256 if (pSceneManager == null)
1260 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1261 if (pAllWindowList == NULL)
1263 pApp = UiApp::GetInstance();
1266 r = pApp->Terminate();
1269 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1274 totalCount = pAllWindowList->GetCount();
1276 for (int count = 0; count < totalCount; count++)
1278 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1279 if (pWindowInfo == null)
1281 pApp = UiApp::GetInstance();
1284 r = pApp->Terminate();
1287 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1292 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1294 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1297 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1300 r = pAllWindowList->RemoveAt(count, true);
1301 __pWindowInfo = null;
1304 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1309 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1313 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1315 if (pWindowInfo == null)
1317 pApp = UiApp::GetInstance();
1320 r = pApp->Terminate();
1326 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1329 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1342 case IDA_FORWARD_CLICKED:
1343 if (__pWebViewer == null)
1346 if (__pWebViewer->CanGoForward())
1348 __pWebViewer->GoForward();
1350 __pMenu->SetShowState(false);
1351 __pMenu->Invalidate(false);
1354 case IDA_FINDONPAGE_CLICKED:
1356 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1357 __currentSearchStr.Clear();
1359 InitFindWordPanel();
1360 __pMenu->SetShowState(false);
1361 __pMenu->Invalidate(false);
1363 __pFindWordEditField->SetFocus();
1365 if (__pWebViewer != null)
1367 // releasing the set block
1368 __pWebViewer->ReleaseBlock();
1371 ShowFindWordPanel(true);
1374 case IDA_PRIVATEON_CLICKED:
1376 result r = E_SUCCESS;
1378 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1379 Bitmap* pBitmap = null;
1380 if (isPrivateBrowsing == true)
1382 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1385 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1389 if (__pWebViewer != NULL)
1391 __pWebViewer->SetPrivateBrowsingEnabled(false);
1394 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1396 if (__pAddressbar != null)
1398 __pAddressbar->UpdateFaviconBitmap(false);
1404 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1407 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1411 if (__pWebViewer != NULL)
1413 __pWebViewer->SetPrivateBrowsingEnabled(true);
1416 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1418 if (__pAddressbar != null)
1420 __pAddressbar->UpdateFaviconBitmap(true);
1425 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1426 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1427 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1428 __pMenu->Invalidate(true);
1430 if ( pBitmap != NULL )
1437 case IDA_SETTINGS_CLICKED:
1440 ArrayList* pArgList = new(std::nothrow) ArrayList();
1443 pArgList->Construct();
1444 pArgList->Add(*__pWindowInfo);
1445 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1447 __pMenu->SetShowState(false);
1448 __pMenu->Invalidate(false);
1449 if (pArgList != null)
1458 case IDA_ADDTOBOOKMARK_CLICKED:
1461 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1463 int bookmarkCount=0;
1466 url=__pWindowInfo->pageUrl;
1467 result r = E_SUCCESS;
1468 Bitmap* pBitmap = null;
1469 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1477 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1478 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1479 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1481 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1482 if (pNotification != null)
1484 pNotification->SetText(message);
1485 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1486 pNotification->ShowNotification();
1491 String title=__pWindowInfo->pageTitle;
1492 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1493 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1495 pBookmark->SetBookmarkTitle(title);
1496 pBookmark->SetUrl(url);
1497 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1499 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1501 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1502 pBookmark->SetFaviconId(id);
1503 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1504 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1507 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1508 if (pNotification != null)
1510 pNotification->SetText(message);
1511 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1512 pNotification->ShowNotification();
1513 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1516 if (pBitmap != null)
1518 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1522 __pMenu->Invalidate(true);
1526 case IDA_SHARE_CLICKED:
1528 if(__pPopUp != null)
1533 __pPopUp = new(std::nothrow) SharePopup();
1534 __pPopUp->Initialize();
1535 if (__pWindowInfo != null)
1537 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1538 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1539 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1540 pShareInfo->SetImageAttached(false);
1541 __pPopUp->RemoveAllShareInfo();
1542 __pPopUp->AddShareInfo(pShareInfo);
1544 __pPopUp->SetShowState(true);
1548 case IDA_BOOKMARKBTN_CLICKED:
1550 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1551 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1554 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1559 case IDA_MOREBTN_CLICKED:
1561 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1562 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1563 AppLog("Anchot pos: %d %d", p.x, p.y);
1565 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1567 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1568 int bookmarkCount=0;
1571 url=__pWindowInfo->pageUrl;
1572 result r = E_SUCCESS;
1573 Bitmap* pBitmap = null;
1575 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1578 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1583 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1587 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1589 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1591 if (__pMenu->GetItemCount() == 8)
1593 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1597 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1602 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1606 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1607 if (__pMenu->GetItemCount() != 8)
1609 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1611 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1612 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1613 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1614 __pMenu->SetMaxVisibleItemsCount(6);
1616 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1618 AppLog(" Orientation landscape");
1619 __pMenu->SetMaxVisibleItemsCount(5);
1623 AppLog(" Orientation potrait");
1624 __pMenu->SetMaxVisibleItemsCount(6);
1627 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1630 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1631 __pMenu->SetShowState(true);
1632 __pMenu->Invalidate(true);
1636 case IDA_HISTORY_CLICKED:
1638 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1639 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1642 case IDA_SAVED_PAGES_CLICKED:
1647 case IDA_DESKTOP_VIEW_CLICKED:
1652 case IDA_SAVE_CLICKED:
1657 case IDA_MULTIWINDOWBTN_CLICKED:
1659 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1660 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1664 case IDA_NEWWINDOWBTN_CLICKED:
1666 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1668 if (pNewWindowInfo == null)
1672 result r = E_SUCCESS;
1673 SceneManager* pSceneManager = SceneManager::GetInstance();
1675 if (pSceneManager == NULL)
1679 ArrayList* pArgList = new(std::nothrow) ArrayList();
1680 if (pArgList == NULL)
1684 r = pArgList->Construct();
1687 pArgList->Add(*pNewWindowInfo);
1688 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1694 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1699 case IDA_SMALLFONT_BTN_CLICKED:
1701 WebSetting setting = __pWebReader->GetSetting();
1702 setting.SetFontSize(15);
1703 __pWebReader->SetSetting(setting);
1706 case IDA_LARGEFONT_BTN_CLICKED:
1708 WebSetting setting = __pWebReader->GetSetting();
1709 setting.SetFontSize(25);
1710 __pWebReader->SetSetting(setting);
1713 case IDA_READER_CLOSE_CLICKED:
1715 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1717 //__pArticleReaderPanel->SetShowState(false);
1718 //__pArticleReaderPanel->Show();
1719 RemoveControl(*__pBlankPanel);
1720 //RemoveControl(*__pArticleReaderPanel);
1721 __pArticleReaderPanel = null;
1722 __pBlankPanel = null;
1723 __pArticleReaderLabel = null;
1725 //if (__pAddressbar)
1726 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1727 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1730 case IDA_FINDWORD_CANCEL_CLICKED:
1732 __currentSearchStr = L"";
1733 __currentWordIndex = 0;
1734 __maxOccurrances = 0;
1735 __pFindWordEditField->SetText(L"");
1736 __pFindWordNext->SetEnabled(false);
1737 __pFindWordPrev->SetEnabled(false);
1738 __pFindWordCountLabel->SetText(L"0/0");
1739 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1740 ShowFindWordPanel(false);
1743 case IDA_FINDWORD_SEARCH_CLICKED:
1745 __currentSearchStr = __pFindWordEditField->GetText();
1746 if (__currentSearchStr.GetLength() > 0)
1752 AppLogDebug("Enter something");
1756 case IDA_FINDWORD_CLEAR_CLICKED:
1758 __pFindWordCountLabel->SetText(L"0/0");
1759 __pFindWordEditField->SetText(L"");
1760 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1762 __currentSearchStr = L"";
1763 __pFindWordNext->SetEnabled(false);
1764 __pFindWordPrev->SetEnabled(false);
1765 __pFindWordControl->Invalidate(true);
1768 case IDA_FINDWORD_NEXT_CLICKED:
1773 case IDA_FINDWORD_PREV_CLICKED:
1775 FindNextWord(false);
1778 case IDA_BRIGHTNESS_BTN_CLICKED:
1780 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1781 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1784 case IDA_COPY_IMAGE_CLICKED:
1786 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1787 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1789 const Bitmap* pBitmap = null;
1790 if (__pHitElementResult != null)
1792 pBitmap = __pHitElementResult->GetImage();
1795 String resourcePath = App::GetInstance()->GetAppResourcePath();
1796 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1798 // copying the item to clipboard
1799 Clipboard* pClipboard = Clipboard::GetInstance();
1800 if (pClipboard != null)
1802 pClipboard->CopyItem(item);
1806 case IDA_VIEW_IMAGE_CLICKED:
1808 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1809 WindowInfo* pNewWindowInfo = null;
1810 if (__pHitElementResult != null)
1812 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1813 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1819 case IDA_SAVE_IMAGE_CLICKED:
1821 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1822 const Bitmap* pSaveBitmap = null;
1823 String imageName = GetImagePath();
1824 AppLog("Content manager image name %ls",imageName.GetPointer());
1827 imagePath.Append(imageName);
1828 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1829 AppLog("Content manager image path %ls",imagePath.GetPointer());
1830 if (__pHitElementResult != null)
1832 pSaveBitmap = __pHitElementResult->GetImage();
1834 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1838 UpdateImageContent(pBuffer, imageName);
1840 NotificationPanel *pNotification = new NotificationPanel(*this);
1842 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1843 msg.Append(imagePath);
1844 if (pNotification != null)
1846 pNotification->SetText(msg);
1847 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1848 pNotification->ShowNotification();
1853 int __modalMsgBoxResult;
1854 MessageBox* pMsgBox = new MessageBox();
1855 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1856 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1859 __modalMsgBoxResult = 0;
1863 case IDA_SHARE_IMAGE_CLICKED:
1865 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1866 if (__pPopUp != null)
1871 __pPopUp = new(std::nothrow) SharePopup();
1872 __pPopUp->Initialize();
1873 if (__pHitElementResult != null)
1875 const Bitmap* pSaveBitmap = null;
1876 String imageName = GetImagePath();
1877 AppLog("Content manager image name %ls",imageName.GetPointer());
1880 imagePath.Append(imageName);
1881 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1882 AppLog("Content manager image path %ls",imagePath.GetPointer());
1883 if (__pHitElementResult != null)
1885 pSaveBitmap = __pHitElementResult->GetImage();
1887 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1889 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1890 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1892 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1893 pShareInfo->SetPageTitle(L"");
1894 pShareInfo->SetPageUrl(srcUrl);
1895 pShareInfo->SetImageAttached(true);
1896 pShareInfo->SetImagePath(imagePath);
1897 __pPopUp->RemoveAllShareInfo();
1898 __pPopUp->AddShareInfo(pShareInfo);
1899 __pPopUp->SetShowState(true);
1904 case IDA_HYPERLINK_OPEN_CLICKED:
1906 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1907 WindowInfo* pNewWindowInfo = null;
1908 if (__pHitElementResult != null)
1910 String srcUrl = __pHitElementResult->GetUrl();
1911 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1916 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
1918 if(__pPopUp != null)
1923 __pPopUp = new(std::nothrow) SharePopup();
1924 __pPopUp->Initialize();
1926 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1928 if(__pHitElementResult == null)
1933 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
1934 pShareInfo->SetImageAttached(false);
1935 __pPopUp->RemoveAllShareInfo();
1936 __pPopUp->AddShareInfo(pShareInfo);
1938 __pPopUp->SetShowState(true);
1942 case IDA_HYPERLINK_COPY_LINK_CLICKED:
1946 if (__pHitElementResult != null)
1948 url = __pHitElementResult->GetUrl();
1951 String resourcePath = App::GetInstance()->GetAppResourcePath();
1952 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
1954 // copying the item to clipboard
1955 Clipboard* pClipboard = Clipboard::GetInstance();
1956 if (pClipboard != null)
1958 pClipboard->CopyItem(item);
1962 case IDA_FIND_TEXT__CLICKED:
1964 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1965 __currentSearchStr.Clear();
1966 __currentSearchStr.Append(__currentSelectedStr);
1967 InitFindWordPanel();
1970 __pMenu->SetShowState(false);
1971 __pMenu->Invalidate(false);
1974 __adressPanelPosition.y = 0;
1976 if (__pAddressbar != null && __pWebViewer != NULL)
1978 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1979 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1980 //__pAddressbar->Invalidate(true);
1981 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1983 if (__pFooterPanel->GetShowState() == false)
1984 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1986 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1987 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1988 __pWebViewer->Invalidate(true);
1991 ShowFindWordPanel(true);
1992 __pFindWordEditField->SetFocus();
1993 if (__currentSearchStr.GetLength() > 0)
1999 AppLogDebug("Enter something");
2002 if (__pWebViewer != null)
2004 // releasing the set block
2005 __pWebViewer->ReleaseBlock();
2010 case IDA_SHARE_TEXT_CLICKED:
2012 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2013 if(__pPopUp != null)
2018 __pPopUp = new(std::nothrow) SharePopup();
2019 __pPopUp->Initialize();
2020 if (__pHitElementResult != null)
2022 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2023 pShareInfo->SetPageTitle(L"");
2024 pShareInfo->SetPageUrl(__currentSelectedStr);
2025 pShareInfo->SetImageAttached(false);
2026 __pPopUp->RemoveAllShareInfo();
2027 __pPopUp->AddShareInfo(pShareInfo);
2028 __pPopUp->SetShowState(true);
2033 case IDA_COPY_TEXT_CLICKED:
2035 // need to implement
2036 //__currentSelectedStr
2037 // Sets data to a clip board item
2039 String resourcePath = App::GetInstance()->GetAppResourcePath();
2040 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2042 // copying the item to clipboard
2043 Clipboard* pClipboard = Clipboard::GetInstance();
2044 if (pClipboard != null)
2046 pClipboard->CopyItem(item);
2050 case IDA_PASTE_TEXT_CLICKED:
2052 Clipboard* pClipboard = Clipboard::GetInstance();
2054 if(pClipboard == null)
2058 // Retrieves a latest item
2059 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2065 //Gets data from the clipboard item
2066 String* pString = dynamic_cast<String*>(pItem->GetData());
2068 if (pString != null)
2070 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2071 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2072 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2073 String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
2074 if(idElement.GetLength() != 0)
2076 script.Append("insertAtCursor(");
2077 script.Append(idElement);
2079 script.Append("\"");
2080 script.Append(*pString);
2081 script.Append("\");");
2083 else if (nameElement.GetLength() != 0)
2085 script.Append("insertAtCursor(document.getElementsByName('");
2086 script.Append(nameElement);
2087 script.Append("')[0],");
2088 script.Append("\"");
2089 script.Append(*pString);
2090 script.Append("\");");
2092 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2093 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2104 case IDA_GO_FORWARD:
2109 case IDA_REFRESH_BTN_CLICKED:
2111 __isLoadingCompleted = false;
2112 __isLoadingData = true;
2113 __progressPercentage = 0;
2114 __displayUrl = __pFooterUrlField->GetText();
2116 String url = __pFooterUrlField->GetText();
2117 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2121 UpdateProgressBitmap();
2124 case IDA_STOP_BTN_CLICKED:
2126 __isLoadingCompleted = false;
2127 __isLoadingData = false;
2128 __progressPercentage = 0;
2129 __pFooterUrlField->HideKeypad();
2130 __displayUrl = __pFooterUrlField->GetText();
2134 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2135 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2136 __pWebViewer->StopLoading();
2137 RequestRedraw(true);
2140 UpdateProgressBitmap();
2145 if (__pFooterUrlField->GetText().IsEmpty() == false)
2147 //__displayUrl = __pUrlField->GetText();
2148 __pFooterUrlField->Clear();
2158 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2161 UiApp* pApp = UiApp::GetInstance();
2170 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2171 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2173 String* pSelectedScene = NULL;
2174 Object* pValue = NULL;
2175 String* pUrl = null;
2176 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2177 pSelectedScene = (String*) pValue;
2179 if (pSelectedScene != null)
2181 delete pSelectedScene;
2183 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2184 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2185 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2186 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2188 // setting the current scene ID
2189 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2191 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2193 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2195 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2196 if(__pWindowInfo == null)
2198 // if(__pWindowInfo == null)
2200 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2203 else if ( pArgs != null && pArgs->GetCount() == 1)
2205 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2211 // hiding the address bar
2212 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2213 __pAddressbar->SetShowState(false);
2214 if(__pWebViewer != null)
2216 __pWebViewer->Resume();
2219 if(pUrl != null && pUrl->GetLength() > 0)
2223 else if(__pWindowInfo != null)
2225 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)
2227 LoadUrl(__pWindowInfo->pageUrl);
2229 else if (__pWindowInfo->isJavascriptInitiated == true)
2233 __pWindowInfo->pCurrentWeb = __pWebViewer;
2237 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2238 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2239 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2241 InitMostVisitedSitesView(GetOrientationStatus());
2244 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2246 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2248 if (pBookmarkUrl == null)
2250 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2251 //__pAddressbar->SetUrl(*pBookmarkUrl);
2252 SetUrl(*pBookmarkUrl);
2254 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2255 __pWebViewer->LoadUrl(*pBookmarkUrl);
2256 delete pBookmarkUrl;
2259 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2260 Bitmap* pBitmap = null;
2261 if (isPrivateBrowsing == true)
2263 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2265 if (__pWebViewer != null)
2267 __pWebViewer->SetPrivateBrowsingEnabled(true);
2270 if (__pAddressbar != null)
2272 // __pAddressbar->UpdateFaviconBitmap(true);
2278 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2280 if (__pWebViewer != null)
2282 __pWebViewer->SetPrivateBrowsingEnabled(false);
2285 if (__pAddressbar != null)
2287 // __pAddressbar->UpdateFaviconBitmap(false);
2291 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2293 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2295 else if (__pMenu != null )
2297 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2300 if (pBitmap != null)
2305 AppLog("ABC: OnSceneActivatedN started exit");
2310 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2311 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2313 Canvas* pWebCanvas = null;
2314 if (__pWebViewer != null)
2316 pWebCanvas = __pWebViewer->GetCanvasN();
2317 __pWebViewer->Pause();
2320 if (pWebCanvas == null)
2324 if (__pWindowInfo != null)
2326 if (__pWindowInfo->pWebCanvasBitmap != null)
2328 delete __pWindowInfo->pWebCanvasBitmap;
2330 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2331 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2332 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2334 Bitmap* pBitmap = GetCapturedBitmapN();
2335 AppLog("Coming here");
2336 Canvas* pCanvas = new(std::nothrow) Canvas();
2337 pCanvas->Construct(GetClientAreaBounds());
2340 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2343 if(__pWebViewer != null && __pWindowInfo != null)
2344 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2346 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2347 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2349 AppLog("Coming here");
2353 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2354 const Tizen::Base::String& realm,
2355 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2361 MainForm::OnHttpAuthenticationCanceled(void)
2366 MainForm::OnLoadingStarted(void)
2368 AppLogDebug("MainForm::OnLoadingStarted entered");
2370 if(__pAddressbar == NULL || __pWebViewer == null)
2374 String url = __pWebViewer->GetUrl();
2375 if(url.Contains(IDS_TIZEN_SERVICE))
2378 String delim(L":;");
2380 // Creates a StringTokenizer instance
2381 StringTokenizer strTok(url, delim);
2383 int count = strTok.GetTokenCount(); // count == 4
2385 HashMap *pMap = new HashMap();
2390 while (strTok.HasMoreTokens())
2392 AppLog("Token: %ls", token.GetPointer());
2393 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2394 if(token.Contains(IDS_APPID))
2396 token.SubString(6, appId);
2397 AppLog("AppID:%ls", appId.GetPointer());
2399 else if(token.Contains("="))
2401 String *pKey = new String();
2402 String *pValue = new String();
2404 token.IndexOf("=", 0, index);
2407 token.SubString(0, index, *pKey);
2408 token.SubString(index + 1, *pValue);
2409 pMap->Add(pKey, pValue);
2415 AppControl *pAppControl = null;
2416 String operationId = L"http://tizen.org/appcontrol/operation/main";
2417 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2420 AppLog("Starting AppControl");
2421 result r = pAppControl->Start(null, null, pMap, null);
2422 AppLog("Result of Start %s", GetErrorMessage(r));
2426 AppLogException("AppControl not found");
2431 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2434 __pAddressbar->SetFaviconBitmap(*pBitmap);
2437 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2439 // updating the address bar position with respect to web control
2440 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2441 __distanceMoved = 0;
2445 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2446 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2447 if (__pWebViewer != null)
2449 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2450 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2451 SetUrl(__pWebViewer->GetUrl());
2452 if (__pWindowInfo != NULL)
2454 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2456 __pAddressbar->Invalidate(true);
2462 MainForm::OnLoadingCanceled(void)
2469 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2471 AppLog("MainForm::OnKeypadWillOpen");
2472 if (__pAddressbar != null)
2474 OnAddressBarKeypadWillOpen(*__pAddressbar);
2480 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2482 if(__pAddressbar != null)
2484 OnAddressBarKeypadOpened(*__pAddressbar);
2490 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2492 if (__pAddressbar != null)
2494 OnAddressBarKeypadClosed(*__pAddressbar);
2499 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2501 AppLog("KeypadBoundsChanged");
2502 RelayoutControls(false);
2506 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2507 const Tizen::Base::String& reason)
2509 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2513 MainForm::OnLoadingCompleted(void)
2515 AppLog("MainForm::OnLoadingCompleted start");
2517 result r = E_SUCCESS;
2519 if (__pWebViewer == null)
2524 if (__pAddressbar == null)
2528 if (__pWebViewer->CanGoForward())
2530 //__pAddressbar->SetForwardButtonEnabled(true);
2531 SetForwardButtonEnabled(true);
2535 //__pAddressbar->SetForwardButtonEnabled(false);
2536 SetForwardButtonEnabled(false);
2539 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2541 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2543 //__pAddressbar->UpdateProgress(0);
2547 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2549 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2553 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2554 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2555 if (isPrivateBrowsing == false)
2557 History* pHistory = new(std::nothrow) History;
2559 HistoryPresentationModel::GetCurrentDateTime(date);
2562 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2563 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2565 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2566 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2568 pHistory->SetVisitedTime(date);
2571 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2572 pHistory->SetFaviconId(id);*/
2574 if (__pWebViewer != null)
2576 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2578 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2579 if (pTempBitmap != null)
2581 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2582 pHistory->SetFavIconBitmap(*pTempBitmap);
2585 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2588 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2589 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2590 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2592 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2593 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2594 pHistory->SetThumbnail(pBitmap);
2596 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2599 pHistory->SetFavIconBitmap(*pFavIcon);
2603 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2610 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2612 // temperary fixed (webpage can be not loaded)
2615 AppLog("MainForm::OnLoadingCompleted done");
2619 MainForm::OnEstimatedProgress(int progress)
2621 AppLogDebug("MainForm::OnEstimatedProgress entered");
2622 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2623 progress = DEFAULT_PROGRESS_PERCENTAGE;
2625 // __pAddressbar->UpdateProgress(progress);
2626 UpdateProgress(progress);
2629 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2631 AppLog("MainForm::OnFaviconReceived");
2632 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2634 if (pFavIconBitmap != null)
2636 pFavIconBitmap->GetWidth();
2637 pFavIconBitmap->GetHeight();
2642 MainForm::OnUrlValueChanged(Addressbar&)
2648 MainForm::OnUrlSubmitted(Addressbar& addBar)
2650 AppLog("MainForm::OnUrlSubmitted");
2651 String url = addBar.GetUrl();
2652 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2654 // __pFooterPanel->SetShowState(true);
2655 if(__pFooterUrlField)
2656 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2657 OnAddressCancelledClicked(*__pAddressbar);
2658 // __pAddressbar->SetShowState(false);
2659 // RelayoutControls(false);
2664 MainForm::LoadUrl(String& url)
2668 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2669 AppLogDebug("MainForm::LoadUrl enter");
2671 if (__pWebViewer != null)
2673 __pWebViewer->SetShowState(true);
2674 __pWebViewer->Invalidate(true);
2677 if (url.CompareTo(L"") == 0)
2681 if(__pFooterPanel != null)
2683 __pFooterPanel->SetShowState(true);
2684 __pFooterPanel->Invalidate(true);
2691 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2692 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)
2694 RegularExpression firstRegex;
2695 RegularExpression secondRegex;
2697 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2698 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2701 ret = firstRegex.Match(url, false); // This returns true value
2702 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2704 if (ret == true && __pWebViewer != null)
2706 __pWebViewer->LoadUrl(url);
2708 else if(__pWebViewer != null)
2710 String tempUrl = L"http://";
2711 tempUrl.Append(url);
2715 __pWebViewer->LoadUrl(tempUrl);
2719 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2720 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2723 if (__pAddressbar != null)
2725 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2726 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2729 AppLogDebug("MainForm::LoadUrl exit");
2736 MainForm::OnStopClicked(Addressbar& addBar)
2738 AppLogDebug("MainForm::OnStopClicked called");
2741 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2742 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2743 __pWebViewer->StopLoading();
2744 RequestRedraw(true);
2749 MainForm::OnReaderClicked(const Addressbar& addBar)
2751 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2753 CreateReaderPanel();
2754 AppLogDebug("MainScene::OnReaderClicked entered");
2757 /*if (__pArticleReaderPanel)
2759 AppLogDebug("showstate true for reader panel");
2760 __pArticleReaderPanel->SetShowState(true);
2761 __pArticleReaderPanel->Show();
2763 int xPos = __pArticleReaderPanel->GetX();
2764 int yPos = __pArticleReaderPanel->GetY();
2765 AppLog("OnReaderClicked() xPos = %d",xPos);
2766 AppLog("OnReaderClicked() yPos = %d",yPos);
2768 if (__pReaderData == null)
2773 String loadData = L"<html>\
2775 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2780 background-color: transparent;\
2799 <body style='width:'";
2800 loadData.Append(bodyWidth);
2801 loadData.Append(L"px'>");
2802 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2803 loadData.Append(*__pReaderData);
2804 loadData.Append(L"</body></html>");
2807 buf.Construct(loadData.GetLength());
2808 AppLogDebug("data->GetLength %d",loadData.GetLength());
2809 for (int z=0;z<loadData.GetLength();z++)
2812 loadData.GetCharAt(z,b);
2813 buf.SetByte((byte)b);
2817 if (__pWebReader != null)
2819 __pWebReader->LoadData(L"",buf,L"text/html");
2820 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2824 AppLogDebug("cannot LoadData __pWebReader is null");
2830 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2832 // AppLog("MainForm::OnBackClicked");
2833 result r = E_FAILURE;
2835 // if (__pWebViewer != null && __pWebViewer->CanGoBack())
2837 // __pWebViewer->GoBack();
2841 // UiApp* pApp = null;
2842 // pApp = UiApp::GetInstance();
2845 // r = pApp->Terminate();
2860 if (__pWebViewer && __pWebViewer->CanGoBack())
2862 __pWebViewer->GoBack();
2864 else if(__pWindowInfo->isJavascriptInitiated == false)
2867 pApp = UiApp::GetInstance();
2870 r = pApp->Terminate();
2873 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2881 WindowInfo* pWindowInfo = null;
2883 SceneManager* pSceneManager = SceneManager::GetInstance();
2884 if (pSceneManager == null)
2888 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2889 if (pAllWindowList == NULL)
2891 pApp = UiApp::GetInstance();
2894 r = pApp->Terminate();
2897 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2902 totalCount = pAllWindowList->GetCount();
2904 for (int count = 0; count < totalCount; count++)
2906 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2907 if (pWindowInfo == null)
2909 pApp = UiApp::GetInstance();
2912 r = pApp->Terminate();
2915 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2920 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2922 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2925 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2928 r = pAllWindowList->RemoveAt(count, true);
2929 __pWindowInfo = null;
2932 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2937 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2941 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2943 if (pWindowInfo == null)
2945 pApp = UiApp::GetInstance();
2948 r = pApp->Terminate();
2954 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2957 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2971 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2973 AppLog("MainForm::OnForwardClicked");
2974 if (__pWebViewer == null)
2977 if (__pWebViewer->CanGoForward())
2979 __pWebViewer->GoForward();
2984 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2986 result r = E_SUCCESS;
2988 __pFooterPanel->SetShowState(true);
2989 __pFooterUrlField->SetFocusable(true);
2992 __pWebViewer->SetFocus();
2993 else if(__pMostVisitedListView)
2994 __pMostVisitedListView->SetFocus();
2995 else if(__pMultiWindowButton)
2996 __pMultiWindowButton->SetFocus();
2997 __pMoreButton->SetFocus();
2999 __pAddressbar->SetShowState(false);
3001 RelayoutControls(false);
3006 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3008 __prevAddressBarMode = __curAddressBarMode;
3010 if (__pAddressbar != null)
3012 __curAddressBarMode = GetAddressbarMode();
3015 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3017 __adressPanelPosition.y = 0;
3018 if (__pAddressbar != null)
3020 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3021 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3022 __pAddressbar->Invalidate(true);
3024 if (__pWebViewer != null)
3026 __pWebViewer->StopLoading();
3029 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3031 __adressPanelPosition.y = 0;
3032 if (__pAddressbar != null)
3034 __webControlPosition.y = 0;
3035 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3036 __pAddressbar->Invalidate(true);
3042 MainForm::OnClipboardClosed(const Addressbar& addBar)
3044 RelayoutControls(false);
3048 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3051 __pAddressbar->SetShowState(false);
3053 __pFooterPanel->SetShowState(true);
3055 __pWebViewer->SetFocus();
3056 if(__pFooterUrlField)
3058 __pFooterUrlField->SetFocusable(true);
3060 RelayoutControls(false);
3064 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3066 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3068 __pAddressbar->SetShowState(false);
3072 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3074 __pAddressbar->SetShowState(true);
3075 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3076 __pAddressbar->SetAddressbarURLFocus();
3080 RelayoutControls(false);
3084 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3086 __pFooterPanel->SetShowState(false);
3090 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3092 AppLog("KeypadBoundsChanged");
3093 RelayoutControls(false);
3097 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3101 __pWindowInfo->pageTitle = title;
3102 if (__pWebViewer != null)
3104 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3107 if (__pAddressbar != null && __pWebViewer != null)
3109 SetUrl(__pWebViewer->GetUrl());
3110 __pAddressbar->Invalidate(true);
3115 MainForm::UpdateFavicon(void)
3117 bool urlImageType = false;
3118 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();");
3119 Bitmap* pBitmap = null;
3121 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3123 if (__pWindowInfo != null)
3126 url.SetUri(*tempPath);
3127 if (url.GetHost().GetLength() == 0)
3130 webUrl.SetUri(__pWebViewer->GetUrl());
3131 result r = url.SetHost(webUrl.GetHost());
3138 if (url.GetScheme().GetLength() == 0)
3141 webUrl.SetUri(__pWebViewer->GetUrl());
3142 url.SetScheme(webUrl.GetScheme());
3144 __pWindowInfo->faviconUrl = url.ToString();
3146 pBitmap = __pWebViewer->GetFaviconN();
3148 if (pBitmap != null)
3150 if (__pWindowInfo->pFavicon != NULL)
3152 __pWindowInfo->pFavicon = null;
3154 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3155 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3157 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3159 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3161 else if(__pWindowInfo->pFavicon != null)
3163 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3167 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3168 if(pDefaultBmp != null)
3170 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3179 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3186 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3187 Tizen::Web::Controls::WebNavigationType type)
3189 // when load new page if find word panel is open its show state is false
3190 ShowFindWordPanel(false);
3192 __pFooterPanel->Invalidate(true);
3195 uriInfo.SetUri(url);
3197 if(url.Contains(IDS_TIZEN_SERVICE))
3200 String delim(L":;,");
3202 // Creates a StringTokenizer instance
3203 StringTokenizer strTok(url, delim);
3205 int count = strTok.GetTokenCount(); // count == 4
3207 HashMap *pMap = new HashMap();
3213 while (strTok.HasMoreTokens())
3215 AppLog("Token: %ls", token.GetPointer());
3216 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3217 if(token.Contains(IDS_APPID))
3219 token.SubString(6, appId);
3220 AppLog("AppID:%ls", appId.GetPointer());
3222 else if(token.Contains("="))
3224 String *pKey = new String();
3225 String *pValue = new String();
3227 token.IndexOf("=", 0, index);
3230 token.SubString(0, index, *pKey);
3231 token.SubString(index + 1, *pValue);
3232 pMap->Add(pKey, pValue);
3238 AppControl *pAppControl = null;
3239 String operationId = L"http://tizen.org/appcontrol/operation/main";
3240 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3243 result r = pAppControl->Start(null, null, pMap, null);
3247 AppLogException("AppControl not found");
3253 if ( __pAddressbar != null)
3255 __pAddressbar->SetShowState(false);
3256 __pAddressbar->Invalidate(true);
3262 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3263 const Tizen::Net::Http::HttpHeader& httpHeader)
3265 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3270 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3272 AppLog("MainForm::OnWebPageBlockSelected");
3273 if (__pHitElementResult != null)
3275 delete __pHitElementResult;
3276 __pHitElementResult = null;
3279 if (__pWebViewer != null)
3281 AppLog("MainForm::OnWebPageBlockSelected web not null");
3282 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3285 if (__pHitElementResult == null)
3290 if (__pHitElementResult->HasImage() != true)
3292 String tagName = __pHitElementResult->GetTagName();
3293 String type = __pHitElementResult->GetAttributeValue("type");
3295 __currentSelectedStr.Clear();
3296 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3297 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3298 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3300 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3302 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3304 InitSelectTextContextMenu(endPoint,true);
3305 __pImageMenu->SetShowState(true);
3306 __pImageMenu->Show();
3307 __pImageMenu->Invalidate(true);
3309 else if(__isLongPressedDone == true)
3311 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3313 if(__pHitElementResult->GetUrl().GetLength() > 0)
3315 __currentSelectedStr.Clear();
3316 __currentSelectedStr = __pHitElementResult->GetUrl();
3318 InitSelectTextContextMenu(endPoint,false);
3319 __pImageMenu->SetShowState(true);
3320 __pImageMenu->Show();
3321 __pImageMenu->Invalidate(true);
3324 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3325 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3326 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3332 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3338 MainForm::OnWebWindowCreateRequested(void)
3340 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3342 if (pNewWindowInfo == null)
3346 result r = E_SUCCESS;
3347 SceneManager* pSceneManager = SceneManager::GetInstance();
3348 if (pSceneManager == NULL)
3352 ArrayList* pArgList = new(std::nothrow) ArrayList();
3353 if (pArgList == NULL)
3357 r = pArgList->Construct();
3360 pNewWindowInfo->isJavascriptInitiated = true;
3361 pArgList->Add(*pNewWindowInfo);
3362 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3366 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3373 return pNewWindowInfo->pCurrentWeb;
3377 MainForm::RelayoutControls(bool showAddressbar)
3379 __webControlPosition.y = 0;
3380 __webControlHeight = GetClientAreaBounds().height;
3381 AppLog("Client area height: %d", __webControlHeight);
3383 AppLog("Client area height: %d", __webControlHeight);
3384 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3386 __webControlPosition.y += __pAddressbar->GetHeight();
3387 __webControlHeight -= __pAddressbar->GetHeight();
3388 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3390 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3392 __webControlPosition.y += __pFindWordControl->GetHeight();
3393 __webControlHeight -= __pFindWordControl->GetHeight();
3394 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3397 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3399 __webControlHeight -= __pFooterPanel->GetHeight();
3400 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3402 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3404 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3405 __pWebViewer->Invalidate(false);
3407 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3409 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3416 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3418 if (__pFindWordControl == null)
3424 InitFindWordPanel();
3425 // __pFindWordEditField->SetText(__currentSearchStr);
3426 //__pFindWordCountLabel->SetText(L"");
3427 // __pFindWordCountLabel->SetText(L"0/0");
3428 __pFindWordControl->SetShowState(true);
3432 if(__pFindWordControl != null)
3434 __pFindWordControl->SetShowState(false);
3438 AppLog("MainForm::ShowFindWordPanel %d",show);
3439 if (show && !isTouchPressed)
3441 if (__pFindWordEditField)
3443 __pFindWordEditField->SetFocus();
3444 __pFindWordEditField->ShowKeypad();
3449 if (__pFindWordEditField)
3450 __pFindWordEditField->HideKeypad();
3453 RelayoutControls(false);
3457 MainForm::StartWordSearch()
3459 //Get the count of occurances of the word in the current page
3460 __maxOccurrances = 0;
3461 __currentWordIndex = 0;
3463 __pFindWordPrev->SetEnabled(false);
3464 String *pCountStr = null;
3465 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3466 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3467 if (pCountStr != null)
3469 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3473 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3478 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3480 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3481 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3483 if(totalCount == -1 || totalCount == 0)
3485 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3486 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3489 else if(totalCount > 100)
3491 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3492 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3496 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3497 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3500 __maxOccurrances = totalCount;
3501 __currentWordIndex = currentOrdinal;
3503 //Reset the UI controls as per the maxOccurrance value
3504 if (totalCount <= 0)
3506 AppLog("Word not found");
3507 //Show error notification to user
3508 __pFindWordNext->SetEnabled(false);
3509 __pFindWordCountLabel->SetText(L"0/0");
3510 __pFindWordNext->Invalidate(false);
3511 __pFindWordPrev->Invalidate(false);
3512 __pFindWordCountLabel->Invalidate(false);
3516 if (totalCount == 1)
3518 __pFindWordNext->SetEnabled(false);
3522 __pFindWordNext->SetEnabled(true);
3525 String countStr = L"";
3526 countStr.Append(__currentWordIndex);
3527 countStr.Append(L"/");
3528 countStr.Append(__maxOccurrances);
3529 __pFindWordCountLabel->SetText(countStr);
3530 // __pFindWordCountLabel->SetShowState(true);
3531 __pFindWordCountLabel->Invalidate(false);
3533 //FindNextWord(true);
3534 //Update the controls
3535 __pFindWordNext->Invalidate(false);
3536 __pFindWordPrev->Invalidate(false);
3537 __pFindWordCountLabel->Invalidate(false);
3541 MainForm::FindNextWord(bool next)
3545 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3547 if(__currentWordIndex < __maxOccurrances)
3549 __currentWordIndex++;
3555 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3557 if(__currentWordIndex > 1)
3559 __currentWordIndex--;
3564 String countStr = L"";
3565 countStr.Append(__currentWordIndex);
3566 countStr.Append(L"/");
3567 countStr.Append(__maxOccurrances);
3568 __pFindWordCountLabel->SetText(countStr);
3569 // __pFindWordCountLabel->SetShowState(true);
3570 __pFindWordCountLabel->Invalidate(false);
3571 if (__currentWordIndex >= __maxOccurrances)
3573 __pFindWordNext->SetEnabled(false);
3577 __pFindWordNext->SetEnabled(true);
3579 if (__currentWordIndex <= 1)
3581 __pFindWordPrev->SetEnabled(false);
3585 __pFindWordPrev->SetEnabled(true);
3587 __pFindWordPrev->Invalidate(false);
3588 __pFindWordNext->Invalidate(false);
3589 __pFindWordCountLabel->Invalidate(false);
3590 __pFindWordControl->Invalidate(true);
3593 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3595 AppLog("MainForm::OnWebKeypadWillOpen");
3596 __isWebKeypadOpened = true;
3597 // OnAddressBarKeypadOpened(*__pAddressbar);
3601 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3604 if (__pWebViewer != null && __pFooterPanel != null)
3606 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3607 if(__pAddressbar != null)
3609 __pAddressbar->SetShowState(false);
3611 if(__pFindWordControl != null)
3613 __pFindWordControl->SetShowState(false);
3615 __pFooterPanel->SetShowState(false);
3616 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3622 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3624 __pFooterPanel->SetShowState(true);
3625 OnAddressBarKeypadClosed(*__pAddressbar);
3626 __isWebKeypadOpened = false;
3630 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3632 Control* temp = const_cast< Control* >(&source);
3633 Header* pHeader = dynamic_cast< Header* >(temp);
3634 if (pHeader != null)
3636 //Header double - clicked
3637 AppLog("Header double clicked");
3639 if(__pFindWordControl)
3641 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3642 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3646 AppLog("MainScene::OnTouchDoublePressed");
3647 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3648 if (isReaderEnabled == true)
3652 delete __pReaderData;
3653 __pReaderData = null;
3655 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3656 filePath.Append(L"data/reader.js");
3662 result r = E_SUCCESS;
3663 FileAttributes attr;
3665 File::GetAttributes(filePath,attr);
3667 r = file.Construct(filePath, L"r+");
3670 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3673 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3676 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3679 file.Read(pScript,attr.GetFileSize());
3681 AppLogDebug("scipt length %d",strlen(pScript));
3682 String strScript = L"";
3683 strScript.Append(pScript);
3684 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3687 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3690 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3691 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3693 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3694 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3700 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3702 AppLog("MainForm::OnTouchLongPressed");
3704 if (__pHitElementResult != null)
3706 delete __pHitElementResult;
3707 __pHitElementResult = null;
3710 if (__pWebViewer != null)
3712 AppLog("MainForm::OnTouchLongPressed web not null");
3713 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3716 if (__pHitElementResult == null)
3721 if (__pHitElementResult->HasImage() == true)
3723 InitImageContextMenu(currentPosition);
3724 __pImageMenu->SetShowState(true);
3725 __pImageMenu->Show();
3726 __pImageMenu->Invalidate(true);
3728 else if(__pHitElementResult->HasUrl() == true)
3730 String tempURl = __pHitElementResult->GetUrl();
3731 AppLog("tempURl is %ls", tempURl.GetPointer());
3732 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3733 if (pBitmap != null)
3741 InitImageLinkContextMenu(currentPosition);
3742 __pImageMenu->SetShowState(true);
3743 __pImageMenu->Show();
3744 __pImageMenu->Invalidate(true);
3748 String tagName = __pHitElementResult->GetTagName();
3749 String type = __pHitElementResult->GetAttributeValue("type");
3750 String value = __pHitElementResult->GetAttributeValue(L"value");
3751 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3753 __currentSelectedStr.Clear();
3754 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3756 AppLog("tag name is %ls", tagName.GetPointer());
3757 AppLog("type is %ls", type.GetPointer());
3758 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3760 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3762 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3764 InitSelectTextContextMenu(currentPosition,true, true);
3765 __pImageMenu->SetShowState(true);
3766 __pImageMenu->Show();
3767 __pImageMenu->Invalidate(true);
3769 __isLongPressedDone = true;
3770 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3773 __inputEventToBeSupressed = true;
3777 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3779 AppLog("MainForm::OnTouchReleased");
3781 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3782 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3784 __pWebViewer->ConsumeInputEvent();
3786 if(pHitElement != null)
3790 __inputEventToBeSupressed = false;
3794 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3801 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3803 if(__pAddressbar->GetShowState() == false)
3805 __pAddressbar->SetShowState(true);
3806 __pAddressbar->SetAddressbarURLFocus();
3807 __pFooterUrlField->SetFocusable(false);
3808 __pFooterPanel->SetShowState(false);
3815 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3821 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3827 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3833 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3839 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3845 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3847 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3848 int widthContextItem = 0;
3849 if(__pFindWordControl != null)
3850 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3851 if ( __pFooterLabel != null)
3853 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3856 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3861 if (__pFindWordBgLabel != null)
3863 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3864 if (pBitmap != null)
3866 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3872 __pMenu->SetShowState(false);
3873 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3875 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3879 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3884 AppLog("__pFooterPanel->GetShowState() is true");
3886 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3887 __pFooterPanel->Invalidate(true);
3891 if(__pMoreButton && __pMenu)
3893 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3894 __pMenu->SetAnchorPosition(p);
3895 __pMenu->Invalidate(true);
3898 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3899 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3901 InitMostVisitedSitesView(orientationStatus);
3904 RelayoutControls(false);
3905 if (__pArticleReaderPanel != null)
3907 if (__pArticleReaderPanel->GetShowState() == true)
3909 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3911 if (__pBlankPanel != null)
3912 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3914 if (__pWebReader != null)
3916 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3918 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3919 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3921 if ( pBitmap != null && pSrcBitmap != null)
3923 AppLog("CreateReaderPanel ninepatchbitmap found");
3924 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3927 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3928 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3929 if (pBitmap != null)
3934 if (pSrcBitmap != null)
3943 if (__pAddressbar != null)
3945 int width = GetClientAreaBounds().width;
3946 __pAddressbar->OrientationChanged(width);
3951 MainForm::OnSettingsChange(int settingvalue)
3953 AppLogDebug("MainForm::OnSettingsChange entered");
3955 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
3957 __pAddressbar->ResetGuideText();
3959 if (__pWebViewer == null)
3961 AppLogDebug("Webviewer is not initialized yet.");
3965 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3967 WebSetting settings = __pWebViewer->GetSetting();
3968 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3970 settings.SetAutoFittingEnabled(true);
3972 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3974 settings.SetAutoFittingEnabled(false);
3976 __pWebViewer->SetSetting(settings);
3978 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3980 WebSetting settings = __pWebViewer->GetSetting();
3981 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3982 __pWebViewer->SetSetting(settings);
3984 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3986 WebSetting settings = __pWebViewer->GetSetting();
3987 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3988 __pWebViewer->SetSetting(settings);
3990 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3992 WebSetting settings = __pWebViewer->GetSetting();
3993 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3994 __pWebViewer->SetSetting(settings);
3996 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4000 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4004 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4006 WebSetting settings = __pWebViewer->GetSetting();
4007 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4009 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4013 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4015 __pWebViewer->SetSetting(settings);
4017 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4021 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4022 WebSetting settings = __pWebReader->GetSetting();
4023 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4024 __pWebReader->SetSetting(settings);
4030 MainForm::OnSettingsReset()
4034 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4035 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4040 MainForm::OnClearCache()
4042 result r = E_SUCCESS;
4044 if (__pWebViewer != NULL)
4046 r = __pWebViewer->ClearCache();
4049 AppLogDebug("Cache cleared success");
4053 AppLogDebug("Cache cleared fail");
4059 MainForm::OnClearCookie()
4061 result r = E_SUCCESS;
4063 if (__pWebViewer != NULL)
4065 __pWebViewer->ClearCookie();
4069 AppLogDebug("Cookie cleared success");
4073 AppLogDebug("Cache cleared fail");
4078 MainForm::OnClearFormData()
4080 result r = E_SUCCESS;
4082 if (__pWebViewer != NULL)
4084 __pWebViewer->ClearFormData();
4088 AppLogDebug("Cookie cleared success");
4092 AppLogDebug("Cache cleared fail");
4097 MainForm::OnClearPasswords()
4099 result r = E_SUCCESS;
4101 if (__pWebViewer != NULL)
4103 __pWebViewer->ClearLoginFormData();
4107 AppLogDebug("Cookie cleared success");
4111 AppLogDebug("Cache cleared fail");
4117 MainForm::findDistance(int x1,int y1,int x2, int y2)
4119 int deltaX = Math::Abs(x2 - x1);
4120 int deltaY = Math::Abs(y2 - y1);
4121 double num = deltaX*deltaX + deltaY*deltaY;
4127 for (i = 0; i < 20; i++)
4129 x = (((x*x)+ num)/(2*x));
4140 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4142 if(__pFindWordControl)
4144 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4145 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4147 __isLongPressedDone = false;
4150 IList* pList = null;
4151 pList = touch.GetTouchInfoListN(source);
4155 int count = pList->GetCount();
4158 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4159 __touchPoint1 = pTouchInfo->position;
4161 /*if (__pAddressbar != null)
4163 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4165 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4167 __pAddressbar->SaveAddressbarEditText();
4169 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4172 __pAddressbar->Invalidate(true);
4174 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4176 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4178 //__pAddressbar->SaveAddressbarEditText();
4180 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4183 else if (count == 2)
4185 AppLogDebug("MainForm::OnTouchPressed count is two");
4186 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4187 __touchPoint1 = pTouchInfo->position;
4189 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4190 __touchPoint2 = pTouchInfo->position;
4196 pList->RemoveAll(true);
4203 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4205 __currentWordIndex = 0;
4206 __isLongPressedDone = false;
4211 MainForm::MoveUiControls()
4216 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4218 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4220 if(__pFooterUrlField->GetTextLength() == 0)
4222 __pFooterUrlField->SetKeypadActionEnabled(false);
4226 __pFooterUrlField->SetKeypadActionEnabled(true);
4229 if (__pFindWordEditField != null)
4231 __currentSearchStr = __pFindWordEditField->GetText();
4232 __pFindWordNext->SetEnabled(false);
4233 __pFindWordPrev->SetEnabled(false);
4234 __pFindWordNext->Invalidate(true);
4235 __pFindWordPrev->Invalidate(true);
4236 __pFindWordCountLabel->SetText(L"0/0");
4237 __pFindWordCountLabel->Invalidate(true);
4239 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4240 if (__currentSearchStr.GetLength() > 0)
4246 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4248 __currentSearchStr = L"";
4249 AppLogDebug("Enter something");
4254 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4261 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4263 if(__pWebViewer != null)
4266 AppLog("MainForm::InitMostVisitedSitesView");
4267 result r = E_SUCCESS;
4270 if (__pWebViewer != null && __pMostVisitedListView != null)
4275 if (__pMostVisitedListView != null)
4277 RemoveControl(*__pMostVisitedListView);
4279 if(__pMostVisitedSites != null)
4281 __pMostVisitedSites->RemoveAll(true);
4284 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4286 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4287 __pMostVisitedListView = new(std::nothrow) ListView();
4289 int height = GetClientAreaBounds().height;
4291 if(__pFooterPanel->GetShowState() == true)
4293 height = height - __pFooterPanel->GetHeight();
4295 if(__pAddressbar->GetShowState() == true)
4297 height -= __pAddressbar->GetHeight();
4300 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4304 delete __pMostVisitedListView;
4305 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4308 __pMostVisitedListView->SetItemProvider(*this);
4309 __pMostVisitedListView->AddListViewItemEventListener(*this);
4310 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4311 AddControl(*__pMostVisitedListView);
4312 __pMostVisitedListView->UpdateList();
4319 MainForm::GetImagePath(void)
4323 String formattedTime;
4324 DateTime currentTime;
4325 LocaleManager localManager;
4326 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4328 localManager.Construct();
4329 Locale locale = localManager.GetSystemLocale();
4330 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4332 // Get date formatter
4333 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4337 pTimeFormatter->Format(currentTime, formattedTime);
4340 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4341 String delim(L" :");
4342 StringTokenizer strTok(formattedTime, delim);
4345 String str1("GMT+00");
4346 while (strTok.HasMoreTokens())
4348 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4349 if(token.Equals(str1))
4351 AppLog("token is %ls", token.GetPointer());
4352 imageName.Append(token);
4358 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4360 result r = E_FAILURE;
4361 AppLog("Content manager 1");
4362 ContentId contentId;
4363 ContentManager contentManager;
4364 r = contentManager.Construct();
4367 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4370 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4371 contentPath.Append(imageName);
4372 contentPath.Append(".jpg");
4373 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4374 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4378 MainForm::SetForwardButtonEnabled(bool isEnabled)
4380 __pGoForwardBtn->SetEnabled(isEnabled);
4381 __pGoBackBtn->Invalidate(true);
4385 MainForm::SetBackButtonEnabled(bool isEnabled)
4387 __pGoBackBtn->SetEnabled(isEnabled);
4388 __pGoBackBtn->Invalidate(true);
4392 MainForm::UpdateProgress(int percentage)
4394 __progressPercentage = percentage;
4395 if (percentage == 0 || percentage == 100)
4397 __isLoadingData = false;
4398 if (percentage == 100)
4400 __isLoadingCompleted = true;
4401 __progressPercentage = 0;
4405 __isLoadingCompleted = false;
4410 __isLoadingData = true;
4412 UpdateProgressBitmap();
4416 MainForm::GetProgress(void)
4418 return __progressPercentage;
4422 MainForm::UpdateProgressBitmap(void)
4424 result r = E_SUCCESS;
4425 if (__pProgressbarLabel == null)
4427 int w = __pProgressbarLabel->GetWidth();
4428 int h = __pProgressbarLabel->GetHeight();
4430 int progressWidth = 0;
4431 Bitmap* pRetBitmap = null;
4433 if (__progressPercentage == 0 || __progressPercentage == 100)
4435 __pProgressbarLabel->SetShowState(false);
4436 __pProgressbarLabel->Invalidate(false);
4441 __pProgressbarLabel->SetShowState(true);
4442 __pProgressbarLabel->Invalidate(false);
4445 r = canvas.Construct(Rectangle(0, 0, w, h));
4449 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4454 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4458 pBgBmp->Scale(Dimension(w, h));
4459 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4463 progressWidth = (double) (w) * __progressPercentage / 100;
4464 AppLogDebug("progressWidth: %d", progressWidth);
4465 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4467 if (pProgressBmp != null)
4469 pProgressBmp->Scale(Dimension(progressWidth, h));
4470 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4471 delete pProgressBmp;
4474 pRetBitmap = new (std::nothrow) Bitmap();
4476 if (pRetBitmap == null)
4478 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4482 pRetBitmap->Construct(canvas, canvas.GetBounds());
4484 if (__pProgressbarLabel != null && pRetBitmap != null)
4486 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4487 __pProgressbarLabel->Invalidate(false);
4490 if (pRetBitmap != null)
4498 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4500 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4502 __currentAddMode = addMode;
4506 case ADDRESSBAR_MODE_INVALID:
4511 case ADDRESSBAR_MODE_READER:
4513 __pStopBtn->SetShowState(false);
4514 __pClearBtn->SetShowState(false);
4517 case ADDRESSBAR_MODE_LOADING:
4519 __pRefreshBtn->SetShowState(false);
4520 __pStopBtn->SetShowState(true);
4521 __pClearBtn->SetShowState(false);
4524 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4526 // SetUrl(__pAddressbar->GetUrl());
4528 __pRefreshBtn->SetShowState(true);
4529 __pStopBtn->SetShowState(false);
4530 __pClearBtn->SetShowState(false);
4533 case ADDRESSBAR_MODE_EDIT:
4535 __pRefreshBtn->SetShowState(false);
4536 __pStopBtn->SetShowState(false);
4537 __pClearBtn->SetShowState(true);
4544 OnAddressBarModeChanged();
4547 AddressBarMode MainForm::GetAddressbarMode(void)
4549 return __currentAddMode;
4552 void MainForm::SetUrl(const String& url)
4556 if (__pFooterUrlField != NULL)
4558 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4559 if (removedHttpUrl.IsEmpty() == false)
4561 __pFooterUrlField->SetText(removedHttpUrl);
4562 __pAddressbar->SetUrl(__displayUrl);
4566 __pFooterUrlField->SetText(__displayUrl);
4567 __pAddressbar->SetUrl(__displayUrl);
4569 if(__pFooterUrlField)
4570 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4571 __pFooterUrlField->Invalidate(false);
4572 __pAddressbar->Invalidate(true);
4573 // __pFooterUrlField->SetCursorPosition(0);
4578 MainForm::RemoveHttpTextFromDisplayURL(void)
4580 bool isHttpText = __displayUrl.Contains(L"http://");
4581 String updatedDisplayUrl;
4582 updatedDisplayUrl.Clear();
4584 if (isHttpText == true)
4586 __displayUrl.SubString(7,updatedDisplayUrl);
4588 return updatedDisplayUrl;