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;
788 // AppLog("vinaypy %d",p.y);
791 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
795 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
797 __pImageMenu = new (std::nothrow) ContextMenu();
798 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
799 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
801 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
802 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
803 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
804 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
805 __pImageMenu->SetMaxVisibleItemsCount(4);
806 __pImageMenu->AddActionEventListener(*this);
807 SetControlAlwaysOnTop(*__pImageMenu, true);
813 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
815 result r = E_SUCCESS;
816 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
818 AppLog("MainForm::InitImageContextMenu clicked on image");
819 if (__pImageMenu != null)
825 p.y = p.y + __pAddressbar->GetHeight() + 12;
828 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
832 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
834 __pImageMenu = new (std::nothrow) ContextMenu();
835 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
836 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
838 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
839 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
840 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
841 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
843 __pImageMenu->SetMaxVisibleItemsCount(3);
844 __pImageMenu->AddActionEventListener(*this);
845 SetControlAlwaysOnTop(*__pImageMenu, true);
851 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
853 result r = E_SUCCESS;
854 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
856 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
857 if (__pImageMenu != null)
862 p.y = p.y + __pAddressbar->GetHeight() + 12;
865 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
869 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
871 __pImageMenu = new (std::nothrow) ContextMenu();
872 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
873 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
875 if(onlyPasteOption == false)
877 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
879 if (pasteOption || onlyPasteOption)
881 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
883 if(onlyPasteOption == false)
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
886 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
889 __pImageMenu->SetMaxVisibleItemsCount(3);
890 __pImageMenu->AddActionEventListener(*this);
891 SetControlAlwaysOnTop(*__pImageMenu, true);
898 MainForm::InitFindWordPanel(void)
900 result r = E_SUCCESS;
901 Bitmap *pIconBitmap = null;
903 if (__pFindWordControl != null)
905 AppLogDebug("Findword panel already initialized");
906 if (__pFindWordBgLabel != null)
908 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
911 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
918 __pFindWordControl = new (std::nothrow) Panel();
919 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
922 AppLogException("There is some problem in the xml file. Please check.");
925 AddControl(*__pFindWordControl);
926 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
927 SetControlAlwaysOnTop(*__pFindWordControl,true);
928 __pFindWordControl->SetShowState(false);
929 __pFindWordControl->Invalidate(false);
931 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
932 if (__pFindWordBgLabel != null)
934 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
935 Rectangle pRect = pPanel1->GetBounds();
936 pRect.x = pRect.y = 0;
937 __pFindWordBgLabel->SetBounds(pRect);
938 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
941 AppLogDebug("InitFindWordPanel: Coming here");
942 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
947 AppLogDebug("InitFindWordPanel: shouldn't Come here");
951 Button* pfindWordCancel = null;
952 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
953 if (pfindWordCancel == null)
955 AppLogException("There is some problem in the xml file. Please check.");
958 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
959 pfindWordCancel->AddActionEventListener(*this);
961 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
962 if (__pFindWordClear == null)
964 AppLogException("There is some problem in the xml file. Please check.");
968 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
969 __pFindWordClear->AddActionEventListener(*this);
971 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
972 if (__pFindWordNext == null)
974 AppLogException("There is some problem in the xml file. Please check.");
978 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
979 __pFindWordNext->AddActionEventListener(*this);
981 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
982 if (__pFindWordPrev == null)
984 AppLogException("There is some problem in the xml file. Please check.");
988 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
989 __pFindWordPrev->AddActionEventListener(*this);
991 __pFindWordNext->SetEnabled(false);
992 __pFindWordPrev->SetEnabled(false);
994 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
995 if (__pFindWordCountLabel == null)
997 AppLogException("There is some problem in the xml file. Please check.");
1001 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1002 if (__pFindWordEditField == null)
1004 AppLogException("There is some problem in the xml file. Please check.");
1007 __pFindWordEditField->AddTextEventListener(*this);
1008 __pFindWordEditField->AddKeypadEventListener(*this);
1009 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1015 MainForm::CreateItem (int index, int itemWidth)
1017 Rectangle listImageRect;
1018 Rectangle pagetTitleRect;
1019 Rectangle pageURLRect;
1020 Rectangle deleteImageRect;
1021 String pageTitle(L"");
1022 String pageURL(L"");
1023 result r = E_SUCCESS;
1024 Bitmap* pListIconImage = null;
1027 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1028 if(pHistory == null)
1032 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1033 if ( pAppResource == NULL )
1037 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1039 CustomItem* pItem = new(std::nothrow) CustomItem();
1040 pageTitle = pHistory->GetHistoryTitle();
1041 pageURL = pHistory->GetHistoryUrl();
1043 if (pageURL.GetLength() == 0)
1046 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1047 pageURL = L"<"+ nourl +">";
1051 Rectangle screenBounds = GetBounds();
1054 r = pItem->Construct(Dimension(itemWidth, 128), style);
1063 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1065 if ( pBitmap != NULL)
1067 pListIconImage = new Bitmap();
1068 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1072 if(pListIconImage == null)
1074 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1077 if ( pListIconImage != NULL)
1079 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1080 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1081 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1084 if (pItem != null && pListIconImage != NULL)
1086 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1090 if (pageTitle.CompareTo(L"") != 0)
1094 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1098 if (pageURL.CompareTo(L"") != 0)
1102 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1107 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1109 if ( __pItemContext!= NULL)
1113 pItem->SetContextItem(__pItemContext);
1119 if ( __pItemContextLandscape!= NULL)
1123 pItem->SetContextItem(__pItemContextLandscape);
1127 if( pListIconImage != NULL)
1129 delete pListIconImage;
1130 pListIconImage = null;
1137 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1144 MainForm::GetItemCount (void)
1146 if(__pMostVisitedSites != null)
1148 __pMostVisitedSites->RemoveAll(true);
1150 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1151 if(__pMostVisitedSites != null)
1153 return __pMostVisitedSites->GetCount();
1160 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1162 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1163 String url = pHistory->GetHistoryUrl();
1164 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1165 __pMostVisitedListView->UpdateList();
1169 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1171 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1172 String url = pHistory->GetHistoryUrl();
1180 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1186 MainForm::OnTerminating(void)
1188 result r = E_SUCCESS;
1191 delete __pItemContext;
1193 if(__pItemContextLandscape)
1195 delete __pItemContextLandscape;
1201 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1203 result r = E_SUCCESS;
1205 AppLogDebug("Clicked : %d", actionId);
1208 // case IDA_BACKBTN_CLICKED:
1210 // if (__pWebViewer && __pWebViewer->CanGoBack())
1212 // __pWebViewer->GoBack();
1216 // UiApp* pApp = null;
1217 // pApp = UiApp::GetInstance();
1218 // if (pApp != null)
1220 // r = pApp->Terminate();
1223 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1231 case IDA_BACKBTN_CLICKED:
1233 if (__pWebViewer && __pWebViewer->CanGoBack())
1235 __pWebViewer->GoBack();
1237 else if(__pWindowInfo->isJavascriptInitiated == false)
1240 pApp = UiApp::GetInstance();
1243 r = pApp->Terminate();
1246 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1254 WindowInfo* pWindowInfo = null;
1256 SceneManager* pSceneManager = SceneManager::GetInstance();
1257 if (pSceneManager == null)
1261 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1262 if (pAllWindowList == NULL)
1264 pApp = UiApp::GetInstance();
1267 r = pApp->Terminate();
1270 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1275 totalCount = pAllWindowList->GetCount();
1277 for (int count = 0; count < totalCount; count++)
1279 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1280 if (pWindowInfo == null)
1282 pApp = UiApp::GetInstance();
1285 r = pApp->Terminate();
1288 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1293 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1295 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1298 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1301 r = pAllWindowList->RemoveAt(count, true);
1302 __pWindowInfo = null;
1305 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1310 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1314 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1316 if (pWindowInfo == null)
1318 pApp = UiApp::GetInstance();
1321 r = pApp->Terminate();
1327 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1330 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1343 case IDA_FORWARD_CLICKED:
1344 if (__pWebViewer == null)
1347 if (__pWebViewer->CanGoForward())
1349 __pWebViewer->GoForward();
1351 __pMenu->SetShowState(false);
1352 __pMenu->Invalidate(false);
1355 case IDA_FINDONPAGE_CLICKED:
1357 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1358 __currentSearchStr.Clear();
1360 InitFindWordPanel();
1361 __pMenu->SetShowState(false);
1362 __pMenu->Invalidate(false);
1364 __pFindWordEditField->SetFocus();
1366 if (__pWebViewer != null)
1368 // releasing the set block
1369 __pWebViewer->ReleaseBlock();
1372 ShowFindWordPanel(true);
1375 case IDA_PRIVATEON_CLICKED:
1377 result r = E_SUCCESS;
1379 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1380 Bitmap* pBitmap = null;
1381 if (isPrivateBrowsing == true)
1383 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1386 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1390 if (__pWebViewer != NULL)
1392 __pWebViewer->SetPrivateBrowsingEnabled(false);
1395 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1397 if (__pAddressbar != null)
1399 __pAddressbar->UpdateFaviconBitmap(false);
1405 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1408 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1412 if (__pWebViewer != NULL)
1414 __pWebViewer->SetPrivateBrowsingEnabled(true);
1417 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1419 if (__pAddressbar != null)
1421 __pAddressbar->UpdateFaviconBitmap(true);
1426 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1427 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1428 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1429 __pMenu->Invalidate(true);
1431 if ( pBitmap != NULL )
1438 case IDA_SETTINGS_CLICKED:
1441 ArrayList* pArgList = new(std::nothrow) ArrayList();
1444 pArgList->Construct();
1445 pArgList->Add(*__pWindowInfo);
1446 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1448 __pMenu->SetShowState(false);
1449 __pMenu->Invalidate(false);
1450 if (pArgList != null)
1459 case IDA_ADDTOBOOKMARK_CLICKED:
1462 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1464 int bookmarkCount=0;
1467 url=__pWindowInfo->pageUrl;
1468 result r = E_SUCCESS;
1469 Bitmap* pBitmap = null;
1470 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1478 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1479 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1480 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1482 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1483 if (pNotification != null)
1485 pNotification->SetText(message);
1486 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1487 pNotification->ShowNotification();
1492 String title=__pWindowInfo->pageTitle;
1493 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1494 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1496 pBookmark->SetBookmarkTitle(title);
1497 pBookmark->SetUrl(url);
1498 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1500 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1502 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1503 pBookmark->SetFaviconId(id);
1504 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1505 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1508 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1509 if (pNotification != null)
1511 pNotification->SetText(message);
1512 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1513 pNotification->ShowNotification();
1514 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1517 if (pBitmap != null)
1519 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1523 __pMenu->Invalidate(true);
1527 case IDA_SHARE_CLICKED:
1529 if(__pPopUp != null)
1534 __pPopUp = new(std::nothrow) SharePopup();
1535 __pPopUp->Initialize();
1536 if (__pWindowInfo != null)
1538 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1539 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1540 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1541 pShareInfo->SetImageAttached(false);
1542 __pPopUp->RemoveAllShareInfo();
1543 __pPopUp->AddShareInfo(pShareInfo);
1545 __pPopUp->SetShowState(true);
1549 case IDA_BOOKMARKBTN_CLICKED:
1551 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1552 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1555 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1560 case IDA_MOREBTN_CLICKED:
1562 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1563 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1564 AppLog("Anchot pos: %d %d", p.x, p.y);
1566 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1568 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1569 int bookmarkCount=0;
1572 url=__pWindowInfo->pageUrl;
1573 result r = E_SUCCESS;
1574 Bitmap* pBitmap = null;
1576 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1579 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1584 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1588 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1590 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1592 if (__pMenu->GetItemCount() == 8)
1594 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1598 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1603 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1607 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1608 if (__pMenu->GetItemCount() != 8)
1610 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1612 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1613 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1614 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1615 __pMenu->SetMaxVisibleItemsCount(6);
1617 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1619 AppLog(" Orientation landscape");
1620 __pMenu->SetMaxVisibleItemsCount(5);
1624 AppLog(" Orientation potrait");
1625 __pMenu->SetMaxVisibleItemsCount(6);
1628 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1631 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1632 __pMenu->SetShowState(true);
1633 __pMenu->Invalidate(true);
1637 case IDA_HISTORY_CLICKED:
1639 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1640 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1643 case IDA_SAVED_PAGES_CLICKED:
1648 case IDA_DESKTOP_VIEW_CLICKED:
1653 case IDA_SAVE_CLICKED:
1658 case IDA_MULTIWINDOWBTN_CLICKED:
1660 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1661 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1665 case IDA_NEWWINDOWBTN_CLICKED:
1667 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1669 if (pNewWindowInfo == null)
1673 result r = E_SUCCESS;
1674 SceneManager* pSceneManager = SceneManager::GetInstance();
1676 if (pSceneManager == NULL)
1680 ArrayList* pArgList = new(std::nothrow) ArrayList();
1681 if (pArgList == NULL)
1685 r = pArgList->Construct();
1688 pArgList->Add(*pNewWindowInfo);
1689 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1695 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1700 case IDA_SMALLFONT_BTN_CLICKED:
1702 WebSetting setting = __pWebReader->GetSetting();
1703 setting.SetFontSize(15);
1704 __pWebReader->SetSetting(setting);
1707 case IDA_LARGEFONT_BTN_CLICKED:
1709 WebSetting setting = __pWebReader->GetSetting();
1710 setting.SetFontSize(25);
1711 __pWebReader->SetSetting(setting);
1714 case IDA_READER_CLOSE_CLICKED:
1716 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1718 //__pArticleReaderPanel->SetShowState(false);
1719 //__pArticleReaderPanel->Show();
1720 RemoveControl(*__pBlankPanel);
1721 //RemoveControl(*__pArticleReaderPanel);
1722 __pArticleReaderPanel = null;
1723 __pBlankPanel = null;
1724 __pArticleReaderLabel = null;
1726 //if (__pAddressbar)
1727 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1728 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1731 case IDA_FINDWORD_CANCEL_CLICKED:
1733 __currentSearchStr = L"";
1734 __currentWordIndex = 0;
1735 __maxOccurrances = 0;
1736 __pFindWordEditField->SetText(L"");
1737 __pFindWordNext->SetEnabled(false);
1738 __pFindWordPrev->SetEnabled(false);
1739 __pFindWordCountLabel->SetText(L"0/0");
1740 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1741 ShowFindWordPanel(false);
1744 case IDA_FINDWORD_SEARCH_CLICKED:
1746 __currentSearchStr = __pFindWordEditField->GetText();
1747 if (__currentSearchStr.GetLength() > 0)
1753 AppLogDebug("Enter something");
1757 case IDA_FINDWORD_CLEAR_CLICKED:
1759 __pFindWordCountLabel->SetText(L"0/0");
1760 __pFindWordEditField->SetText(L"");
1761 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1763 __currentSearchStr = L"";
1764 __pFindWordNext->SetEnabled(false);
1765 __pFindWordPrev->SetEnabled(false);
1766 __pFindWordControl->Invalidate(true);
1769 case IDA_FINDWORD_NEXT_CLICKED:
1774 case IDA_FINDWORD_PREV_CLICKED:
1776 FindNextWord(false);
1779 case IDA_BRIGHTNESS_BTN_CLICKED:
1781 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1782 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1785 case IDA_COPY_IMAGE_CLICKED:
1787 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1788 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1790 const Bitmap* pBitmap = null;
1791 if (__pHitElementResult != null)
1793 pBitmap = __pHitElementResult->GetImage();
1796 String resourcePath = App::GetInstance()->GetAppResourcePath();
1797 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1799 // copying the item to clipboard
1800 Clipboard* pClipboard = Clipboard::GetInstance();
1801 if (pClipboard != null)
1803 pClipboard->CopyItem(item);
1807 case IDA_VIEW_IMAGE_CLICKED:
1809 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1810 WindowInfo* pNewWindowInfo = null;
1811 if (__pHitElementResult != null)
1813 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1814 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1820 case IDA_SAVE_IMAGE_CLICKED:
1822 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1823 const Bitmap* pSaveBitmap = null;
1824 String imageName = GetImagePath();
1825 AppLog("Content manager image name %ls",imageName.GetPointer());
1828 imagePath.Append(imageName);
1829 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1830 AppLog("Content manager image path %ls",imagePath.GetPointer());
1831 if (__pHitElementResult != null)
1833 pSaveBitmap = __pHitElementResult->GetImage();
1835 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1839 UpdateImageContent(pBuffer, imageName);
1841 NotificationPanel *pNotification = new NotificationPanel(*this);
1843 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1844 msg.Append(imagePath);
1845 if (pNotification != null)
1847 pNotification->SetText(msg);
1848 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1849 pNotification->ShowNotification();
1854 int __modalMsgBoxResult;
1855 MessageBox* pMsgBox = new MessageBox();
1856 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1857 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1860 __modalMsgBoxResult = 0;
1864 case IDA_SHARE_IMAGE_CLICKED:
1866 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1867 if (__pPopUp != null)
1872 __pPopUp = new(std::nothrow) SharePopup();
1873 __pPopUp->Initialize();
1874 if (__pHitElementResult != null)
1876 const Bitmap* pSaveBitmap = null;
1877 String imageName = GetImagePath();
1878 AppLog("Content manager image name %ls",imageName.GetPointer());
1881 imagePath.Append(imageName);
1882 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1883 AppLog("Content manager image path %ls",imagePath.GetPointer());
1884 if (__pHitElementResult != null)
1886 pSaveBitmap = __pHitElementResult->GetImage();
1888 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1890 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1891 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1893 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1894 pShareInfo->SetPageTitle(L"");
1895 pShareInfo->SetPageUrl(srcUrl);
1896 pShareInfo->SetImageAttached(true);
1897 pShareInfo->SetImagePath(imagePath);
1898 __pPopUp->RemoveAllShareInfo();
1899 __pPopUp->AddShareInfo(pShareInfo);
1900 __pPopUp->SetShowState(true);
1905 case IDA_HYPERLINK_OPEN_CLICKED:
1907 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1908 WindowInfo* pNewWindowInfo = null;
1909 if (__pHitElementResult != null)
1911 String srcUrl = __pHitElementResult->GetUrl();
1912 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1917 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
1919 if(__pPopUp != null)
1924 __pPopUp = new(std::nothrow) SharePopup();
1925 __pPopUp->Initialize();
1927 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1929 if(__pHitElementResult == null)
1934 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
1935 pShareInfo->SetImageAttached(false);
1936 __pPopUp->RemoveAllShareInfo();
1937 __pPopUp->AddShareInfo(pShareInfo);
1939 __pPopUp->SetShowState(true);
1943 case IDA_HYPERLINK_COPY_LINK_CLICKED:
1947 if (__pHitElementResult != null)
1949 url = __pHitElementResult->GetUrl();
1952 String resourcePath = App::GetInstance()->GetAppResourcePath();
1953 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
1955 // copying the item to clipboard
1956 Clipboard* pClipboard = Clipboard::GetInstance();
1957 if (pClipboard != null)
1959 pClipboard->CopyItem(item);
1963 case IDA_FIND_TEXT__CLICKED:
1965 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1966 __currentSearchStr.Clear();
1967 __currentSearchStr.Append(__currentSelectedStr);
1968 InitFindWordPanel();
1971 __pMenu->SetShowState(false);
1972 __pMenu->Invalidate(false);
1975 __adressPanelPosition.y = 0;
1977 if (__pAddressbar != null && __pWebViewer != NULL)
1979 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1980 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1981 //__pAddressbar->Invalidate(true);
1982 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1984 if (__pFooterPanel->GetShowState() == false)
1985 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1987 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1988 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1989 __pWebViewer->Invalidate(true);
1992 ShowFindWordPanel(true);
1993 __pFindWordEditField->SetFocus();
1994 if (__currentSearchStr.GetLength() > 0)
2000 AppLogDebug("Enter something");
2003 if (__pWebViewer != null)
2005 // releasing the set block
2006 __pWebViewer->ReleaseBlock();
2011 case IDA_SHARE_TEXT_CLICKED:
2013 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2014 if(__pPopUp != null)
2019 __pPopUp = new(std::nothrow) SharePopup();
2020 __pPopUp->Initialize();
2021 if (__pHitElementResult != null)
2023 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2024 pShareInfo->SetPageTitle(L"");
2025 pShareInfo->SetPageUrl(__currentSelectedStr);
2026 pShareInfo->SetImageAttached(false);
2027 __pPopUp->RemoveAllShareInfo();
2028 __pPopUp->AddShareInfo(pShareInfo);
2029 __pPopUp->SetShowState(true);
2034 case IDA_COPY_TEXT_CLICKED:
2036 // need to implement
2037 //__currentSelectedStr
2038 // Sets data to a clip board item
2040 String resourcePath = App::GetInstance()->GetAppResourcePath();
2041 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2043 // copying the item to clipboard
2044 Clipboard* pClipboard = Clipboard::GetInstance();
2045 if (pClipboard != null)
2047 pClipboard->CopyItem(item);
2051 case IDA_PASTE_TEXT_CLICKED:
2053 Clipboard* pClipboard = Clipboard::GetInstance();
2055 if(pClipboard == null)
2059 // Retrieves a latest item
2060 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2066 //Gets data from the clipboard item
2067 String* pString = dynamic_cast<String*>(pItem->GetData());
2069 if (pString != null)
2071 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2072 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2073 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2074 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; } } ";
2075 if(idElement.GetLength() != 0)
2077 script.Append("insertAtCursor(");
2078 script.Append(idElement);
2080 script.Append("\"");
2081 script.Append(*pString);
2082 script.Append("\");");
2084 else if (nameElement.GetLength() != 0)
2086 script.Append("insertAtCursor(document.getElementsByName('");
2087 script.Append(nameElement);
2088 script.Append("')[0],");
2089 script.Append("\"");
2090 script.Append(*pString);
2091 script.Append("\");");
2093 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2094 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2105 case IDA_GO_FORWARD:
2110 case IDA_REFRESH_BTN_CLICKED:
2112 __isLoadingCompleted = false;
2113 __isLoadingData = true;
2114 __progressPercentage = 0;
2115 __displayUrl = __pFooterUrlField->GetText();
2117 String url = __pFooterUrlField->GetText();
2118 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2122 UpdateProgressBitmap();
2125 case IDA_STOP_BTN_CLICKED:
2127 __isLoadingCompleted = false;
2128 __isLoadingData = false;
2129 __progressPercentage = 0;
2130 __pFooterUrlField->HideKeypad();
2131 __displayUrl = __pFooterUrlField->GetText();
2135 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2136 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2137 __pWebViewer->StopLoading();
2138 RequestRedraw(true);
2141 UpdateProgressBitmap();
2146 if (__pFooterUrlField->GetText().IsEmpty() == false)
2148 //__displayUrl = __pUrlField->GetText();
2149 __pFooterUrlField->Clear();
2159 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2162 UiApp* pApp = UiApp::GetInstance();
2171 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2172 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2174 String* pSelectedScene = NULL;
2175 Object* pValue = NULL;
2176 String* pUrl = null;
2177 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2178 pSelectedScene = (String*) pValue;
2180 if (pSelectedScene != null)
2182 delete pSelectedScene;
2184 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2185 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2186 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2187 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2189 // setting the current scene ID
2190 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2192 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2194 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2196 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2197 if(__pWindowInfo == null)
2199 // if(__pWindowInfo == null)
2201 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2204 else if ( pArgs != null && pArgs->GetCount() == 1)
2206 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2212 // hiding the address bar
2213 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2214 __pAddressbar->SetShowState(false);
2215 if(__pWebViewer != null)
2217 __pWebViewer->Resume();
2220 if(pUrl != null && pUrl->GetLength() > 0)
2224 else if(__pWindowInfo != null)
2226 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)
2228 LoadUrl(__pWindowInfo->pageUrl);
2230 else if (__pWindowInfo->isJavascriptInitiated == true)
2234 __pWindowInfo->pCurrentWeb = __pWebViewer;
2238 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2239 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2240 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2242 InitMostVisitedSitesView(GetOrientationStatus());
2245 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2247 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2249 if (pBookmarkUrl == null)
2251 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2252 //__pAddressbar->SetUrl(*pBookmarkUrl);
2253 SetUrl(*pBookmarkUrl);
2255 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2256 __pWebViewer->LoadUrl(*pBookmarkUrl);
2257 delete pBookmarkUrl;
2260 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2261 Bitmap* pBitmap = null;
2262 if (isPrivateBrowsing == true)
2264 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2266 if (__pWebViewer != null)
2268 __pWebViewer->SetPrivateBrowsingEnabled(true);
2271 if (__pAddressbar != null)
2273 // __pAddressbar->UpdateFaviconBitmap(true);
2279 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2281 if (__pWebViewer != null)
2283 __pWebViewer->SetPrivateBrowsingEnabled(false);
2286 if (__pAddressbar != null)
2288 // __pAddressbar->UpdateFaviconBitmap(false);
2292 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2294 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2296 else if (__pMenu != null )
2298 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2301 if (pBitmap != null)
2306 AppLog("ABC: OnSceneActivatedN started exit");
2311 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2312 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2314 Canvas* pWebCanvas = null;
2315 if (__pWebViewer != null)
2317 pWebCanvas = __pWebViewer->GetCanvasN();
2318 __pWebViewer->Pause();
2321 if (pWebCanvas == null)
2325 if (__pWindowInfo != null)
2327 if (__pWindowInfo->pWebCanvasBitmap != null)
2329 delete __pWindowInfo->pWebCanvasBitmap;
2331 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2332 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2333 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2335 Bitmap* pBitmap = GetCapturedBitmapN();
2336 AppLog("Coming here");
2337 Canvas* pCanvas = new(std::nothrow) Canvas();
2338 pCanvas->Construct(GetClientAreaBounds());
2341 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2344 if(__pWebViewer != null && __pWindowInfo != null)
2345 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2347 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2348 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2350 AppLog("Coming here");
2354 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2355 const Tizen::Base::String& realm,
2356 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2362 MainForm::OnHttpAuthenticationCanceled(void)
2367 MainForm::OnLoadingStarted(void)
2369 AppLogDebug("MainForm::OnLoadingStarted entered");
2371 if(__pAddressbar == NULL || __pWebViewer == null)
2375 String url = __pWebViewer->GetUrl();
2376 if(url.Contains(IDS_TIZEN_SERVICE))
2379 String delim(L":;");
2381 // Creates a StringTokenizer instance
2382 StringTokenizer strTok(url, delim);
2384 int count = strTok.GetTokenCount(); // count == 4
2386 HashMap *pMap = new HashMap();
2391 while (strTok.HasMoreTokens())
2393 AppLog("Token: %ls", token.GetPointer());
2394 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2395 if(token.Contains(IDS_APPID))
2397 token.SubString(6, appId);
2398 AppLog("AppID:%ls", appId.GetPointer());
2400 else if(token.Contains("="))
2402 String *pKey = new String();
2403 String *pValue = new String();
2405 token.IndexOf("=", 0, index);
2408 token.SubString(0, index, *pKey);
2409 token.SubString(index + 1, *pValue);
2410 pMap->Add(pKey, pValue);
2416 AppControl *pAppControl = null;
2417 String operationId = L"http://tizen.org/appcontrol/operation/main";
2418 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2421 AppLog("Starting AppControl");
2422 result r = pAppControl->Start(null, null, pMap, null);
2423 AppLog("Result of Start %s", GetErrorMessage(r));
2427 AppLogException("AppControl not found");
2432 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2435 __pAddressbar->SetFaviconBitmap(*pBitmap);
2438 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2440 // updating the address bar position with respect to web control
2441 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2442 __distanceMoved = 0;
2446 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2447 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2448 if (__pWebViewer != null)
2450 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2451 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2452 SetUrl(__pWebViewer->GetUrl());
2453 if (__pWindowInfo != NULL)
2455 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2457 __pAddressbar->Invalidate(true);
2463 MainForm::OnLoadingCanceled(void)
2470 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2472 AppLog("MainForm::OnKeypadWillOpen");
2473 if (__pAddressbar != null)
2475 OnAddressBarKeypadWillOpen(*__pAddressbar);
2481 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2483 if(__pAddressbar != null)
2485 OnAddressBarKeypadOpened(*__pAddressbar);
2491 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2493 if (__pAddressbar != null)
2495 OnAddressBarKeypadClosed(*__pAddressbar);
2500 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2502 AppLog("KeypadBoundsChanged");
2503 RelayoutControls(false);
2507 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2508 const Tizen::Base::String& reason)
2510 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2514 MainForm::OnLoadingCompleted(void)
2516 AppLog("MainForm::OnLoadingCompleted start");
2518 result r = E_SUCCESS;
2520 if (__pWebViewer == null)
2525 if (__pAddressbar == null)
2529 if (__pWebViewer->CanGoForward())
2531 //__pAddressbar->SetForwardButtonEnabled(true);
2532 SetForwardButtonEnabled(true);
2536 //__pAddressbar->SetForwardButtonEnabled(false);
2537 SetForwardButtonEnabled(false);
2540 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2542 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2544 //__pAddressbar->UpdateProgress(0);
2548 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2550 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2554 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2555 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2556 if (isPrivateBrowsing == false)
2558 History* pHistory = new(std::nothrow) History;
2560 HistoryPresentationModel::GetCurrentDateTime(date);
2563 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2564 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2566 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2567 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2569 pHistory->SetVisitedTime(date);
2572 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2573 pHistory->SetFaviconId(id);*/
2575 if (__pWebViewer != null)
2577 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2579 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2580 if (pTempBitmap != null)
2582 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2583 pHistory->SetFavIconBitmap(*pTempBitmap);
2586 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2589 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2590 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2591 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2593 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2594 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2595 pHistory->SetThumbnail(pBitmap);
2597 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2600 pHistory->SetFavIconBitmap(*pFavIcon);
2604 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2611 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2613 // temperary fixed (webpage can be not loaded)
2616 AppLog("MainForm::OnLoadingCompleted done");
2620 MainForm::OnEstimatedProgress(int progress)
2622 AppLogDebug("MainForm::OnEstimatedProgress entered");
2623 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2624 progress = DEFAULT_PROGRESS_PERCENTAGE;
2626 // __pAddressbar->UpdateProgress(progress);
2627 UpdateProgress(progress);
2630 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2632 AppLog("MainForm::OnFaviconReceived");
2633 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2635 if (pFavIconBitmap != null)
2637 pFavIconBitmap->GetWidth();
2638 pFavIconBitmap->GetHeight();
2643 MainForm::OnUrlValueChanged(Addressbar&)
2649 MainForm::OnUrlSubmitted(Addressbar& addBar)
2651 AppLog("MainForm::OnUrlSubmitted");
2652 String url = addBar.GetUrl();
2653 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2655 // __pFooterPanel->SetShowState(true);
2656 if(__pFooterUrlField)
2657 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2658 OnAddressCancelledClicked(*__pAddressbar);
2659 // __pAddressbar->SetShowState(false);
2660 // RelayoutControls(false);
2665 MainForm::LoadUrl(String& url)
2669 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2670 AppLogDebug("MainForm::LoadUrl enter");
2672 if (__pWebViewer != null)
2674 __pWebViewer->SetShowState(true);
2675 __pWebViewer->Invalidate(true);
2678 if (url.CompareTo(L"") == 0)
2682 if(__pFooterPanel != null)
2684 __pFooterPanel->SetShowState(true);
2685 __pFooterPanel->Invalidate(true);
2692 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2693 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)
2695 RegularExpression firstRegex;
2696 RegularExpression secondRegex;
2698 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2699 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2702 ret = firstRegex.Match(url, false); // This returns true value
2703 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2705 if (ret == true && __pWebViewer != null)
2707 __pWebViewer->LoadUrl(url);
2709 else if(__pWebViewer != null)
2711 String tempUrl = L"http://";
2712 tempUrl.Append(url);
2716 __pWebViewer->LoadUrl(tempUrl);
2720 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2721 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2724 if (__pAddressbar != null)
2726 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2727 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2730 AppLogDebug("MainForm::LoadUrl exit");
2737 MainForm::OnStopClicked(Addressbar& addBar)
2739 AppLogDebug("MainForm::OnStopClicked called");
2742 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2743 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2744 __pWebViewer->StopLoading();
2745 RequestRedraw(true);
2750 MainForm::OnReaderClicked(const Addressbar& addBar)
2752 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2754 CreateReaderPanel();
2755 AppLogDebug("MainScene::OnReaderClicked entered");
2758 /*if (__pArticleReaderPanel)
2760 AppLogDebug("showstate true for reader panel");
2761 __pArticleReaderPanel->SetShowState(true);
2762 __pArticleReaderPanel->Show();
2764 int xPos = __pArticleReaderPanel->GetX();
2765 int yPos = __pArticleReaderPanel->GetY();
2766 AppLog("OnReaderClicked() xPos = %d",xPos);
2767 AppLog("OnReaderClicked() yPos = %d",yPos);
2769 if (__pReaderData == null)
2774 String loadData = L"<html>\
2776 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2781 background-color: transparent;\
2800 <body style='width:'";
2801 loadData.Append(bodyWidth);
2802 loadData.Append(L"px'>");
2803 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2804 loadData.Append(*__pReaderData);
2805 loadData.Append(L"</body></html>");
2808 buf.Construct(loadData.GetLength());
2809 AppLogDebug("data->GetLength %d",loadData.GetLength());
2810 for (int z=0;z<loadData.GetLength();z++)
2813 loadData.GetCharAt(z,b);
2814 buf.SetByte((byte)b);
2818 if (__pWebReader != null)
2820 __pWebReader->LoadData(L"",buf,L"text/html");
2821 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2825 AppLogDebug("cannot LoadData __pWebReader is null");
2831 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2833 // AppLog("MainForm::OnBackClicked");
2834 result r = E_FAILURE;
2836 // if (__pWebViewer != null && __pWebViewer->CanGoBack())
2838 // __pWebViewer->GoBack();
2842 // UiApp* pApp = null;
2843 // pApp = UiApp::GetInstance();
2846 // r = pApp->Terminate();
2861 if (__pWebViewer && __pWebViewer->CanGoBack())
2863 __pWebViewer->GoBack();
2865 else if(__pWindowInfo->isJavascriptInitiated == false)
2868 pApp = UiApp::GetInstance();
2871 r = pApp->Terminate();
2874 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2882 WindowInfo* pWindowInfo = null;
2884 SceneManager* pSceneManager = SceneManager::GetInstance();
2885 if (pSceneManager == null)
2889 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2890 if (pAllWindowList == NULL)
2892 pApp = UiApp::GetInstance();
2895 r = pApp->Terminate();
2898 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2903 totalCount = pAllWindowList->GetCount();
2905 for (int count = 0; count < totalCount; count++)
2907 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2908 if (pWindowInfo == null)
2910 pApp = UiApp::GetInstance();
2913 r = pApp->Terminate();
2916 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2921 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2923 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2926 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2929 r = pAllWindowList->RemoveAt(count, true);
2930 __pWindowInfo = null;
2933 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2938 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2942 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2944 if (pWindowInfo == null)
2946 pApp = UiApp::GetInstance();
2949 r = pApp->Terminate();
2955 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2958 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2972 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2974 AppLog("MainForm::OnForwardClicked");
2975 if (__pWebViewer == null)
2978 if (__pWebViewer->CanGoForward())
2980 __pWebViewer->GoForward();
2985 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2987 result r = E_SUCCESS;
2989 __pFooterPanel->SetShowState(true);
2990 __pFooterUrlField->SetFocusable(true);
2993 __pWebViewer->SetFocus();
2994 else if(__pMostVisitedListView)
2995 __pMostVisitedListView->SetFocus();
2996 else if(__pMultiWindowButton)
2997 __pMultiWindowButton->SetFocus();
2998 __pMoreButton->SetFocus();
3000 __pAddressbar->SetShowState(false);
3002 RelayoutControls(false);
3007 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3009 __prevAddressBarMode = __curAddressBarMode;
3011 if (__pAddressbar != null)
3013 __curAddressBarMode = GetAddressbarMode();
3016 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3018 __adressPanelPosition.y = 0;
3019 if (__pAddressbar != null)
3021 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3022 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3023 __pAddressbar->Invalidate(true);
3025 if (__pWebViewer != null)
3027 __pWebViewer->StopLoading();
3030 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3032 __adressPanelPosition.y = 0;
3033 if (__pAddressbar != null)
3035 __webControlPosition.y = 0;
3036 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3037 __pAddressbar->Invalidate(true);
3043 MainForm::OnClipboardClosed(const Addressbar& addBar)
3045 RelayoutControls(false);
3049 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3052 __pAddressbar->SetShowState(false);
3054 __pFooterPanel->SetShowState(true);
3056 __pWebViewer->SetFocus();
3057 if(__pFooterUrlField)
3059 __pFooterUrlField->SetFocusable(true);
3061 RelayoutControls(false);
3065 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3067 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3069 __pAddressbar->SetShowState(false);
3073 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3075 __pAddressbar->SetShowState(true);
3076 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3077 __pAddressbar->SetAddressbarURLFocus();
3081 RelayoutControls(false);
3085 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3087 __pFooterPanel->SetShowState(false);
3091 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3093 AppLog("KeypadBoundsChanged");
3094 RelayoutControls(false);
3098 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3102 __pWindowInfo->pageTitle = title;
3103 if (__pWebViewer != null)
3105 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3108 if (__pAddressbar != null && __pWebViewer != null)
3110 SetUrl(__pWebViewer->GetUrl());
3111 __pAddressbar->Invalidate(true);
3116 MainForm::UpdateFavicon(void)
3118 bool urlImageType = false;
3119 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();");
3120 Bitmap* pBitmap = null;
3122 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3124 if (__pWindowInfo != null)
3127 url.SetUri(*tempPath);
3128 if (url.GetHost().GetLength() == 0)
3131 webUrl.SetUri(__pWebViewer->GetUrl());
3132 result r = url.SetHost(webUrl.GetHost());
3139 if (url.GetScheme().GetLength() == 0)
3142 webUrl.SetUri(__pWebViewer->GetUrl());
3143 url.SetScheme(webUrl.GetScheme());
3145 __pWindowInfo->faviconUrl = url.ToString();
3147 pBitmap = __pWebViewer->GetFaviconN();
3149 if (pBitmap != null)
3151 if (__pWindowInfo->pFavicon != NULL)
3153 __pWindowInfo->pFavicon = null;
3155 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3156 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3158 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3160 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3162 else if(__pWindowInfo->pFavicon != null)
3164 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3168 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3169 if(pDefaultBmp != null)
3171 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3180 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3187 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3188 Tizen::Web::Controls::WebNavigationType type)
3190 // when load new page if find word panel is open its show state is false
3191 ShowFindWordPanel(false);
3193 __pFooterPanel->Invalidate(true);
3196 uriInfo.SetUri(url);
3198 if(url.Contains(IDS_TIZEN_SERVICE))
3201 String delim(L":;,");
3203 // Creates a StringTokenizer instance
3204 StringTokenizer strTok(url, delim);
3206 int count = strTok.GetTokenCount(); // count == 4
3208 HashMap *pMap = new HashMap();
3214 while (strTok.HasMoreTokens())
3216 AppLog("Token: %ls", token.GetPointer());
3217 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3218 if(token.Contains(IDS_APPID))
3220 token.SubString(6, appId);
3221 AppLog("AppID:%ls", appId.GetPointer());
3223 else if(token.Contains("="))
3225 String *pKey = new String();
3226 String *pValue = new String();
3228 token.IndexOf("=", 0, index);
3231 token.SubString(0, index, *pKey);
3232 token.SubString(index + 1, *pValue);
3233 pMap->Add(pKey, pValue);
3239 AppControl *pAppControl = null;
3240 String operationId = L"http://tizen.org/appcontrol/operation/main";
3241 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3244 result r = pAppControl->Start(null, null, pMap, null);
3248 AppLogException("AppControl not found");
3254 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3256 __pAddressbar->SetShowState(false);
3257 OnAddressCancelledClicked(*__pAddressbar);
3258 __pAddressbar->Invalidate(true);
3264 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3265 const Tizen::Net::Http::HttpHeader& httpHeader)
3267 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3272 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3274 AppLog("MainForm::OnWebPageBlockSelected");
3275 if (__pHitElementResult != null)
3277 delete __pHitElementResult;
3278 __pHitElementResult = null;
3281 if (__pWebViewer != null)
3283 AppLog("MainForm::OnWebPageBlockSelected web not null");
3284 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3287 if (__pHitElementResult == null)
3292 if (__pHitElementResult->HasImage() != true)
3294 String tagName = __pHitElementResult->GetTagName();
3295 String type = __pHitElementResult->GetAttributeValue("type");
3297 __currentSelectedStr.Clear();
3298 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3299 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3300 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3302 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3304 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3306 InitSelectTextContextMenu(endPoint,true);
3307 __pImageMenu->SetShowState(true);
3308 __pImageMenu->Show();
3309 __pImageMenu->Invalidate(true);
3311 else if(__isLongPressedDone == true)
3313 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3315 if(__pHitElementResult->GetUrl().GetLength() > 0)
3317 __currentSelectedStr.Clear();
3318 __currentSelectedStr = __pHitElementResult->GetUrl();
3320 InitSelectTextContextMenu(endPoint,false);
3321 __pImageMenu->SetShowState(true);
3322 __pImageMenu->Show();
3323 __pImageMenu->Invalidate(true);
3326 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3327 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3328 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3334 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3340 MainForm::OnWebWindowCreateRequested(void)
3342 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3344 if (pNewWindowInfo == null)
3348 result r = E_SUCCESS;
3349 SceneManager* pSceneManager = SceneManager::GetInstance();
3350 if (pSceneManager == NULL)
3354 ArrayList* pArgList = new(std::nothrow) ArrayList();
3355 if (pArgList == NULL)
3359 r = pArgList->Construct();
3362 pNewWindowInfo->isJavascriptInitiated = true;
3363 pArgList->Add(*pNewWindowInfo);
3364 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3368 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3375 return pNewWindowInfo->pCurrentWeb;
3379 MainForm::RelayoutControls(bool showAddressbar)
3381 __webControlPosition.y = 0;
3382 __webControlHeight = GetClientAreaBounds().height;
3383 AppLog("Client area height: %d", __webControlHeight);
3385 AppLog("Client area height: %d", __webControlHeight);
3386 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3388 __webControlPosition.y += __pAddressbar->GetHeight();
3389 __webControlHeight -= __pAddressbar->GetHeight();
3390 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3392 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3394 __webControlPosition.y += __pFindWordControl->GetHeight();
3395 __webControlHeight -= __pFindWordControl->GetHeight();
3396 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3399 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3401 __webControlHeight -= __pFooterPanel->GetHeight();
3402 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3404 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3406 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3407 __pWebViewer->Invalidate(false);
3409 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3411 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3418 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3420 if (__pFindWordControl == null)
3426 InitFindWordPanel();
3427 // __pFindWordEditField->SetText(__currentSearchStr);
3428 //__pFindWordCountLabel->SetText(L"");
3429 // __pFindWordCountLabel->SetText(L"0/0");
3430 __pFindWordControl->SetShowState(true);
3434 if(__pFindWordControl != null)
3436 __pFindWordControl->SetShowState(false);
3440 AppLog("MainForm::ShowFindWordPanel %d",show);
3441 if (show && !isTouchPressed)
3443 if (__pFindWordEditField)
3445 __pFindWordEditField->SetFocus();
3446 __pFindWordEditField->ShowKeypad();
3451 if (__pFindWordEditField)
3452 __pFindWordEditField->HideKeypad();
3455 RelayoutControls(false);
3459 MainForm::StartWordSearch()
3461 //Get the count of occurances of the word in the current page
3462 __maxOccurrances = 0;
3463 __currentWordIndex = 0;
3465 __pFindWordPrev->SetEnabled(false);
3466 String *pCountStr = null;
3467 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3468 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3469 if (pCountStr != null)
3471 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3475 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3480 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3482 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3483 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3485 if(totalCount == -1 || totalCount == 0)
3487 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3488 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3491 else if(totalCount > 100)
3493 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3494 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3498 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3499 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3502 __maxOccurrances = totalCount;
3503 __currentWordIndex = currentOrdinal;
3505 //Reset the UI controls as per the maxOccurrance value
3506 if (totalCount <= 0)
3508 AppLog("Word not found");
3509 //Show error notification to user
3510 __pFindWordNext->SetEnabled(false);
3511 __pFindWordCountLabel->SetText(L"0/0");
3512 __pFindWordNext->Invalidate(false);
3513 __pFindWordPrev->Invalidate(false);
3514 __pFindWordCountLabel->Invalidate(false);
3518 if (totalCount == 1)
3520 __pFindWordNext->SetEnabled(false);
3524 __pFindWordNext->SetEnabled(true);
3527 String countStr = L"";
3528 countStr.Append(__currentWordIndex);
3529 countStr.Append(L"/");
3530 countStr.Append(__maxOccurrances);
3531 __pFindWordCountLabel->SetText(countStr);
3532 // __pFindWordCountLabel->SetShowState(true);
3533 __pFindWordCountLabel->Invalidate(false);
3535 //FindNextWord(true);
3536 //Update the controls
3537 __pFindWordNext->Invalidate(false);
3538 __pFindWordPrev->Invalidate(false);
3539 __pFindWordCountLabel->Invalidate(false);
3543 MainForm::FindNextWord(bool next)
3547 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3549 if(__currentWordIndex < __maxOccurrances)
3551 __currentWordIndex++;
3557 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3559 if(__currentWordIndex > 1)
3561 __currentWordIndex--;
3566 String countStr = L"";
3567 countStr.Append(__currentWordIndex);
3568 countStr.Append(L"/");
3569 countStr.Append(__maxOccurrances);
3570 __pFindWordCountLabel->SetText(countStr);
3571 // __pFindWordCountLabel->SetShowState(true);
3572 __pFindWordCountLabel->Invalidate(false);
3573 if (__currentWordIndex >= __maxOccurrances)
3575 __pFindWordNext->SetEnabled(false);
3579 __pFindWordNext->SetEnabled(true);
3581 if (__currentWordIndex <= 1)
3583 __pFindWordPrev->SetEnabled(false);
3587 __pFindWordPrev->SetEnabled(true);
3589 __pFindWordPrev->Invalidate(false);
3590 __pFindWordNext->Invalidate(false);
3591 __pFindWordCountLabel->Invalidate(false);
3592 __pFindWordControl->Invalidate(true);
3595 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3597 AppLog("MainForm::OnWebKeypadWillOpen");
3598 __isWebKeypadOpened = true;
3599 // OnAddressBarKeypadOpened(*__pAddressbar);
3603 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3606 if (__pWebViewer != null && __pFooterPanel != null)
3608 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3609 if(__pAddressbar != null)
3611 __pAddressbar->SetShowState(false);
3613 if(__pFindWordControl != null)
3615 __pFindWordControl->SetShowState(false);
3617 __pFooterPanel->SetShowState(false);
3618 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3624 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3626 __pFooterPanel->SetShowState(true);
3627 OnAddressBarKeypadClosed(*__pAddressbar);
3628 __isWebKeypadOpened = false;
3632 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3634 Control* temp = const_cast< Control* >(&source);
3635 Header* pHeader = dynamic_cast< Header* >(temp);
3636 if (pHeader != null)
3638 //Header double - clicked
3639 AppLog("Header double clicked");
3641 if(__pFindWordControl)
3643 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3644 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3648 AppLog("MainScene::OnTouchDoublePressed");
3649 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3650 if (isReaderEnabled == true)
3654 delete __pReaderData;
3655 __pReaderData = null;
3657 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3658 filePath.Append(L"data/reader.js");
3664 result r = E_SUCCESS;
3665 FileAttributes attr;
3667 File::GetAttributes(filePath,attr);
3669 r = file.Construct(filePath, L"r+");
3672 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3675 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3678 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3681 file.Read(pScript,attr.GetFileSize());
3683 AppLogDebug("scipt length %d",strlen(pScript));
3684 String strScript = L"";
3685 strScript.Append(pScript);
3686 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3689 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3692 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3693 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3695 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3696 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3702 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3704 AppLog("MainForm::OnTouchLongPressed");
3706 if (__pHitElementResult != null)
3708 delete __pHitElementResult;
3709 __pHitElementResult = null;
3712 if (__pWebViewer != null)
3714 AppLog("MainForm::OnTouchLongPressed web not null");
3715 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3718 if (__pHitElementResult == null)
3723 if (__pHitElementResult->HasImage() == true)
3725 InitImageContextMenu(currentPosition);
3726 __pImageMenu->SetShowState(true);
3727 __pImageMenu->Show();
3728 __pImageMenu->Invalidate(true);
3730 else if(__pHitElementResult->HasUrl() == true)
3732 String tempURl = __pHitElementResult->GetUrl();
3733 AppLog("tempURl is %ls", tempURl.GetPointer());
3734 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3735 if (pBitmap != null)
3743 InitImageLinkContextMenu(currentPosition);
3744 __pImageMenu->SetShowState(true);
3745 __pImageMenu->Show();
3746 __pImageMenu->Invalidate(true);
3750 String tagName = __pHitElementResult->GetTagName();
3751 String type = __pHitElementResult->GetAttributeValue("type");
3752 String value = __pHitElementResult->GetAttributeValue(L"value");
3753 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3755 __currentSelectedStr.Clear();
3756 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3758 AppLog("tag name is %ls", tagName.GetPointer());
3759 AppLog("type is %ls", type.GetPointer());
3760 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3762 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3764 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3766 InitSelectTextContextMenu(currentPosition,true, true);
3767 __pImageMenu->SetShowState(true);
3768 __pImageMenu->Show();
3769 __pImageMenu->Invalidate(true);
3771 __isLongPressedDone = true;
3772 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3775 __inputEventToBeSupressed = true;
3779 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3781 AppLog("MainForm::OnTouchReleased");
3783 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3784 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3786 __pWebViewer->ConsumeInputEvent();
3788 if(pHitElement != null)
3792 __inputEventToBeSupressed = false;
3796 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3803 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3805 if(__pAddressbar->GetShowState() == false)
3807 __pAddressbar->SetShowState(true);
3808 __pAddressbar->SetAddressbarURLFocus();
3809 __pFooterUrlField->SetFocusable(false);
3810 __pFooterPanel->SetShowState(false);
3817 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3823 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3829 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3835 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3841 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3847 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3849 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3850 int widthContextItem = 0;
3851 if(__pFindWordControl != null)
3852 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3853 if ( __pFooterLabel != null)
3855 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3858 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3863 if (__pFindWordBgLabel != null)
3865 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3866 if (pBitmap != null)
3868 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3874 __pMenu->SetShowState(false);
3875 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3877 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3881 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3886 AppLog("__pFooterPanel->GetShowState() is true");
3888 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3889 __pFooterPanel->Invalidate(true);
3893 if(__pMoreButton && __pMenu)
3895 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3896 __pMenu->SetAnchorPosition(p);
3897 __pMenu->Invalidate(true);
3900 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3901 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3903 InitMostVisitedSitesView(orientationStatus);
3906 RelayoutControls(false);
3907 if (__pArticleReaderPanel != null)
3909 if (__pArticleReaderPanel->GetShowState() == true)
3911 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3913 if (__pBlankPanel != null)
3914 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3916 if (__pWebReader != null)
3918 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3920 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3921 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3923 if ( pBitmap != null && pSrcBitmap != null)
3925 AppLog("CreateReaderPanel ninepatchbitmap found");
3926 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3929 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3930 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3931 if (pBitmap != null)
3936 if (pSrcBitmap != null)
3945 if (__pAddressbar != null)
3947 int width = GetClientAreaBounds().width;
3948 __pAddressbar->OrientationChanged(width);
3953 MainForm::OnSettingsChange(int settingvalue)
3955 AppLogDebug("MainForm::OnSettingsChange entered");
3957 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
3959 __pAddressbar->ResetGuideText();
3961 if (__pWebViewer == null)
3963 AppLogDebug("Webviewer is not initialized yet.");
3967 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3969 WebSetting settings = __pWebViewer->GetSetting();
3970 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3972 settings.SetAutoFittingEnabled(true);
3974 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3976 settings.SetAutoFittingEnabled(false);
3978 __pWebViewer->SetSetting(settings);
3980 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3982 WebSetting settings = __pWebViewer->GetSetting();
3983 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3984 __pWebViewer->SetSetting(settings);
3986 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3988 WebSetting settings = __pWebViewer->GetSetting();
3989 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3990 __pWebViewer->SetSetting(settings);
3992 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3994 WebSetting settings = __pWebViewer->GetSetting();
3995 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3996 __pWebViewer->SetSetting(settings);
3998 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4002 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4006 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4008 WebSetting settings = __pWebViewer->GetSetting();
4009 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4011 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4015 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4017 __pWebViewer->SetSetting(settings);
4019 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4023 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4024 WebSetting settings = __pWebReader->GetSetting();
4025 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4026 __pWebReader->SetSetting(settings);
4032 MainForm::OnSettingsReset()
4036 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4037 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4042 MainForm::OnClearCache()
4044 result r = E_SUCCESS;
4046 if (__pWebViewer != NULL)
4048 r = __pWebViewer->ClearCache();
4051 AppLogDebug("Cache cleared success");
4055 AppLogDebug("Cache cleared fail");
4061 MainForm::OnClearCookie()
4063 result r = E_SUCCESS;
4065 if (__pWebViewer != NULL)
4067 __pWebViewer->ClearCookie();
4071 AppLogDebug("Cookie cleared success");
4075 AppLogDebug("Cache cleared fail");
4080 MainForm::OnClearFormData()
4082 result r = E_SUCCESS;
4084 if (__pWebViewer != NULL)
4086 __pWebViewer->ClearFormData();
4090 AppLogDebug("Cookie cleared success");
4094 AppLogDebug("Cache cleared fail");
4099 MainForm::OnClearPasswords()
4101 result r = E_SUCCESS;
4103 if (__pWebViewer != NULL)
4105 __pWebViewer->ClearLoginFormData();
4109 AppLogDebug("Cookie cleared success");
4113 AppLogDebug("Cache cleared fail");
4119 MainForm::findDistance(int x1,int y1,int x2, int y2)
4121 int deltaX = Math::Abs(x2 - x1);
4122 int deltaY = Math::Abs(y2 - y1);
4123 double num = deltaX*deltaX + deltaY*deltaY;
4129 for (i = 0; i < 20; i++)
4131 x = (((x*x)+ num)/(2*x));
4142 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4144 if(__pFindWordControl)
4146 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4147 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4149 __isLongPressedDone = false;
4152 IList* pList = null;
4153 pList = touch.GetTouchInfoListN(source);
4157 int count = pList->GetCount();
4160 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4161 __touchPoint1 = pTouchInfo->position;
4163 /*if (__pAddressbar != null)
4165 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4167 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4169 __pAddressbar->SaveAddressbarEditText();
4171 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4174 __pAddressbar->Invalidate(true);
4176 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4178 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4180 //__pAddressbar->SaveAddressbarEditText();
4182 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4185 else if (count == 2)
4187 AppLogDebug("MainForm::OnTouchPressed count is two");
4188 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4189 __touchPoint1 = pTouchInfo->position;
4191 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4192 __touchPoint2 = pTouchInfo->position;
4198 pList->RemoveAll(true);
4205 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4207 __currentWordIndex = 0;
4208 __isLongPressedDone = false;
4213 MainForm::MoveUiControls()
4218 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4220 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4222 if(__pFooterUrlField->GetTextLength() == 0)
4224 __pFooterUrlField->SetKeypadActionEnabled(false);
4228 __pFooterUrlField->SetKeypadActionEnabled(true);
4231 if (__pFindWordEditField != null)
4233 __currentSearchStr = __pFindWordEditField->GetText();
4234 __pFindWordNext->SetEnabled(false);
4235 __pFindWordPrev->SetEnabled(false);
4236 __pFindWordNext->Invalidate(true);
4237 __pFindWordPrev->Invalidate(true);
4238 __pFindWordCountLabel->SetText(L"0/0");
4239 __pFindWordCountLabel->Invalidate(true);
4241 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4242 if (__currentSearchStr.GetLength() > 0)
4248 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4250 __currentSearchStr = L"";
4251 AppLogDebug("Enter something");
4256 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4263 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4265 if(__pWebViewer != null)
4268 AppLog("MainForm::InitMostVisitedSitesView");
4269 result r = E_SUCCESS;
4272 if (__pWebViewer != null && __pMostVisitedListView != null)
4277 if (__pMostVisitedListView != null)
4279 RemoveControl(*__pMostVisitedListView);
4281 if(__pMostVisitedSites != null)
4283 __pMostVisitedSites->RemoveAll(true);
4286 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4288 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4289 __pMostVisitedListView = new(std::nothrow) ListView();
4291 int height = GetClientAreaBounds().height;
4293 if(__pFooterPanel->GetShowState() == true)
4295 height = height - __pFooterPanel->GetHeight();
4297 if(__pAddressbar->GetShowState() == true)
4299 height -= __pAddressbar->GetHeight();
4302 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4306 delete __pMostVisitedListView;
4307 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4310 __pMostVisitedListView->SetItemProvider(*this);
4311 __pMostVisitedListView->AddListViewItemEventListener(*this);
4312 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4313 AddControl(*__pMostVisitedListView);
4314 __pMostVisitedListView->UpdateList();
4321 MainForm::GetImagePath(void)
4325 String formattedTime;
4326 DateTime currentTime;
4327 LocaleManager localManager;
4328 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4330 localManager.Construct();
4331 Locale locale = localManager.GetSystemLocale();
4332 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4334 // Get date formatter
4335 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4339 pTimeFormatter->Format(currentTime, formattedTime);
4342 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4343 String delim(L" :");
4344 StringTokenizer strTok(formattedTime, delim);
4347 String str1("GMT+00");
4348 while (strTok.HasMoreTokens())
4350 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4351 if(token.Equals(str1))
4353 AppLog("token is %ls", token.GetPointer());
4354 imageName.Append(token);
4360 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4362 result r = E_FAILURE;
4363 AppLog("Content manager 1");
4364 ContentId contentId;
4365 ContentManager contentManager;
4366 r = contentManager.Construct();
4369 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4372 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4373 contentPath.Append(imageName);
4374 contentPath.Append(".jpg");
4375 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4376 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4380 MainForm::SetForwardButtonEnabled(bool isEnabled)
4382 __pGoForwardBtn->SetEnabled(isEnabled);
4383 __pGoBackBtn->Invalidate(true);
4387 MainForm::SetBackButtonEnabled(bool isEnabled)
4389 __pGoBackBtn->SetEnabled(isEnabled);
4390 __pGoBackBtn->Invalidate(true);
4394 MainForm::UpdateProgress(int percentage)
4396 __progressPercentage = percentage;
4397 if (percentage == 0 || percentage == 100)
4399 __isLoadingData = false;
4400 if (percentage == 100)
4402 __isLoadingCompleted = true;
4403 __progressPercentage = 0;
4407 __isLoadingCompleted = false;
4412 __isLoadingData = true;
4414 UpdateProgressBitmap();
4418 MainForm::GetProgress(void)
4420 return __progressPercentage;
4424 MainForm::UpdateProgressBitmap(void)
4426 result r = E_SUCCESS;
4427 if (__pProgressbarLabel == null)
4429 int w = __pProgressbarLabel->GetWidth();
4430 int h = __pProgressbarLabel->GetHeight();
4432 int progressWidth = 0;
4433 Bitmap* pRetBitmap = null;
4435 if (__progressPercentage == 0 || __progressPercentage == 100)
4437 __pProgressbarLabel->SetShowState(false);
4438 __pProgressbarLabel->Invalidate(false);
4443 __pProgressbarLabel->SetShowState(true);
4444 __pProgressbarLabel->Invalidate(false);
4447 r = canvas.Construct(Rectangle(0, 0, w, h));
4451 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4456 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4460 pBgBmp->Scale(Dimension(w, h));
4461 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4465 progressWidth = (double) (w) * __progressPercentage / 100;
4466 AppLogDebug("progressWidth: %d", progressWidth);
4467 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4469 if (pProgressBmp != null)
4471 pProgressBmp->Scale(Dimension(progressWidth, h));
4472 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4473 delete pProgressBmp;
4476 pRetBitmap = new (std::nothrow) Bitmap();
4478 if (pRetBitmap == null)
4480 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4484 pRetBitmap->Construct(canvas, canvas.GetBounds());
4486 if (__pProgressbarLabel != null && pRetBitmap != null)
4488 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4489 __pProgressbarLabel->Invalidate(false);
4492 if (pRetBitmap != null)
4500 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4502 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4504 __currentAddMode = addMode;
4508 case ADDRESSBAR_MODE_INVALID:
4513 case ADDRESSBAR_MODE_READER:
4515 __pStopBtn->SetShowState(false);
4516 __pClearBtn->SetShowState(false);
4519 case ADDRESSBAR_MODE_LOADING:
4521 __pRefreshBtn->SetShowState(false);
4522 __pStopBtn->SetShowState(true);
4523 __pClearBtn->SetShowState(false);
4526 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4528 // SetUrl(__pAddressbar->GetUrl());
4530 __pRefreshBtn->SetShowState(true);
4531 __pStopBtn->SetShowState(false);
4532 __pClearBtn->SetShowState(false);
4535 case ADDRESSBAR_MODE_EDIT:
4537 __pRefreshBtn->SetShowState(false);
4538 __pStopBtn->SetShowState(false);
4539 __pClearBtn->SetShowState(true);
4546 OnAddressBarModeChanged();
4549 AddressBarMode MainForm::GetAddressbarMode(void)
4551 return __currentAddMode;
4554 void MainForm::SetUrl(const String& url)
4558 if (__pFooterUrlField != NULL)
4560 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4561 if (removedHttpUrl.IsEmpty() == false)
4563 __pFooterUrlField->SetText(removedHttpUrl);
4564 __pAddressbar->SetUrl(__displayUrl);
4568 __pFooterUrlField->SetText(__displayUrl);
4569 __pAddressbar->SetUrl(__displayUrl);
4571 if(__pFooterUrlField)
4572 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4573 __pFooterUrlField->Invalidate(false);
4574 __pAddressbar->Invalidate(true);
4575 // __pFooterUrlField->SetCursorPosition(0);
4580 MainForm::RemoveHttpTextFromDisplayURL(void)
4582 bool isHttpText = __displayUrl.Contains(L"http://");
4583 String updatedDisplayUrl;
4584 updatedDisplayUrl.Clear();
4586 if (isHttpText == true)
4588 __displayUrl.SubString(7,updatedDisplayUrl);
4590 return updatedDisplayUrl;