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_BTN_BACK = L"I01_icon_Back.png";
57 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
58 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
64 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
65 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
66 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
67 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
69 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
70 static const wchar_t* IDS_APPID = L"AppID";
71 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
74 const int IDA_BACKBTN_CLICKED = 101;
75 const int IDA_BOOKMARKBTN_CLICKED = 102;
76 const int IDA_MOREBTN_CLICKED = 103;
77 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
78 const int IDA_NEWWINDOWBTN_CLICKED = 105;
79 const int IDA_FORWARD_CLICKED = 106;
80 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
81 const int IDA_SHARE_CLICKED = 108;
82 const int IDA_FINDONPAGE_CLICKED = 109;
83 const int IDA_PRIVATEON_CLICKED = 110;
84 const int IDA_SETTINGS_CLICKED = 111;
85 const int IDA_READER_CLOSE_CLICKED = 112;
86 const int IDA_SMALLFONT_BTN_CLICKED = 113;
87 const int IDA_LARGEFONT_BTN_CLICKED = 114;
88 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
89 const int IDA_HISTORY_CLICKED = 116;
90 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
91 const int IDA_ADD_TO_HOME_CLICKED = 118;
92 const int IDA_SAVED_PAGES_CLICKED = 119;
93 const int IDA_DESKTOP_VIEW_CLICKED = 120;
94 const int IDA_SAVE_CLICKED = 121;
96 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
97 const int IDA_FINDWORD_NEXT_CLICKED = 202;
98 const int IDA_FINDWORD_PREV_CLICKED = 203;
99 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
100 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
102 const int IDA_COPY_IMAGE_CLICKED = 206;
103 const int IDA_VIEW_IMAGE_CLICKED = 207;
104 const int IDA_SAVE_IMAGE_CLICKED = 208;
105 const int IDA_SHARE_IMAGE_CLICKED = 209;
107 const int IDA_COPY_TEXT_CLICKED = 210;
108 const int IDA_PASTE_TEXT_CLICKED = 211;
109 const int IDA_FIND_TEXT__CLICKED = 212;
110 const int IDA_SHARE_TEXT_CLICKED = 213;
112 const int IDA_GO_BACK = 214;
113 const int IDA_GO_FORWARD = 215;
114 const int IDA_REFRESH_BTN_CLICKED = 216;
115 const int IDA_STOP_BTN_CLICKED = 217;
116 const int IDA_CLEAR_URL = 218;
118 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
120 const int MainForm::IDA_FORMAT_BITMAP = 500;
121 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
122 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
123 const int MainForm::IDA_FORMAT_URL_STRING = 503;
124 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
126 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
128 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
130 MainForm::MainForm(void)
132 __pAddressbar = null;
133 // __pMostVisitedSitesPanel = null;
134 __pMostVisitedListView = null;
135 __pFooterPanel = null;
136 __pHitElementResult = null;
137 __pWindowInfo = null;
141 __pFindWordControl = null;
142 __pFindWordPanel = null;
143 __pFindWordBgLabel = null;
144 __pFindWordEditField = null;
145 __pFindWordClear = null;
146 __pFindWordCountLabel = null;
147 __pFindWordNext = null;
148 __pFindWordPrev = null;
149 __previousZoomLevel = 1.0;
151 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
154 __currentSearchStr = L"";
155 __currentSelectedStr = L"";
156 __maxOccurrances = 0;
157 __currentWordIndex = 0;
160 __inputEventToBeSupressed = false;
161 __isLoadingData = false;
162 __isLoadingCompleted = false;
163 __progressPercentage = 0;
164 __touchPoint1 = Point(-1,-1);
165 __touchPoint2 = Point(-1,-1);
167 // __pReaderPopup = null;
168 __pReaderData = null;
170 __pReaderCloseBtn = null;
171 //__pNewWindowButton = null;
172 __pMoreButton = null;
173 __pMultiWindowButton = null;
174 __pArticleReaderPanel = null;
175 __pBlankPanel = null;
176 __pArticleReaderLabel = null;
177 __webControlHeight = 0;
178 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
179 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
180 __pMostVisitedSites = null;
181 __pFooterUrlField = null;
183 __pGoForwardBtn = null;
184 __pRefreshBtn = null;
185 __pProgressbarLabel = null;
186 __pFooterLabel = null;
191 MainForm::~MainForm(void)
193 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
197 __pAddressbar->SetAddressbarEventListener(null);
199 if (__pReaderData != null)
201 delete __pReaderData;
202 __pReaderData = null;
205 if (__pPopUp != null)
211 if (__pHitElementResult != null)
213 delete __pHitElementResult;
214 __pHitElementResult = null;
216 String* pSelectedScene = NULL;
217 Object* pValue = NULL;
218 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
219 pSelectedScene = (String*) pValue;
221 /*if (pSelectedScene != null)
223 delete pSelectedScene;
225 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
229 MainForm::Initialize(void)
231 Construct(L"IDL_FORM");
236 MainForm::OnInitializing(void)
238 AppLog("get client area width = %d",GetClientAreaBounds().width);
239 AppLog("get client area height = %d",GetClientAreaBounds().height);
240 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
241 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
243 Panel* pFooterPanel = null;
245 __pSaveImage = new Image();
246 __pSaveImage->Construct();
248 // Setup back event listener
249 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
250 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
251 AddOrientationEventListener(*this);
252 AppLogDebug(" MainForm::OnInitializing ended");
253 if (__pMostVisitedSites == null)
255 __pMostVisitedSites = new(std::nothrow) ArrayList();
256 __pMostVisitedSites->Construct();
258 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
260 __pItemContext= new(std::nothrow) ListContextItem();
261 __pItemContext->Construct();
262 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
263 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
265 if (pBitmapNormal != null && pBitmapPressed != null)
267 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
270 if (pBitmapNormal != null)
272 delete pBitmapNormal;
275 if (pBitmapPressed != null)
277 delete pBitmapPressed;
280 __pItemContextLandscape= new(std::nothrow) ListContextItem();
281 __pItemContextLandscape->Construct();
282 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
283 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
285 if (pBitmapNormal != null && pBitmapPressed != null)
287 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
290 if (pBitmapNormal != null)
292 delete pBitmapNormal;
295 if (pBitmapPressed != null)
297 delete pBitmapPressed;
304 MainForm::InitAddressbar(void)
306 AppLogDebug("MainForm::InitAddressbar entered");
308 result r = E_SUCCESS;
310 if (__pAddressbar != null)
314 __pAddressbar = new(std::nothrow) Addressbar();
315 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
316 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
319 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
322 __pAddressbar->SetAddressbarEventListener(this);
323 AddControl(*__pAddressbar);
324 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
325 SetControlAlwaysOnTop(*__pAddressbar, true);
326 __adressPanelPosition = __pAddressbar->GetPosition();
328 AppLogDebug("MainForm::InitAddressbar exit");
334 MainForm::CreateReaderPanel(void)
336 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
337 result r = E_FAILURE;
339 Button *pSmallFontBtn = null;
340 Button *pLargeFontBtn = null;
342 __pBlankPanel = new (std::nothrow) Panel();
343 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
345 __pArticleReaderPanel = new (std::nothrow) Panel();
346 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
348 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
349 if (__pReaderCloseBtn)
351 AppLogDebug("CreateReaderPanel() 6");
352 __pReaderCloseBtn->AddActionEventListener(*this);
353 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
356 __pWebReader = new (std::nothrow) Web();
357 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
359 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
360 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
362 r = __pWebReader->SetSetting(settings);
364 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
367 __pArticleReaderLabel = new Label();
368 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
370 __pBlankPanel->AddControl(*__pArticleReaderLabel);
371 __pBlankPanel->AddControl(*__pArticleReaderPanel);
372 AddControl(*__pBlankPanel);
374 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
375 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
376 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
378 __pArticleReaderPanel->AddControl(*__pWebReader);
379 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
380 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
381 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
383 if (pBitmap != null && pSrcBitmap != null)
385 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
387 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
389 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
392 pSmallFontBtn->AddActionEventListener(*this);
393 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
396 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
399 pLargeFontBtn->AddActionEventListener(*this);
400 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
409 if (pSrcBitmap != null)
415 SetControlAlwaysOnTop(*__pBlankPanel, true);
416 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
423 MainForm::InitWebControl()
425 AppLogDebug("MainForm::InitWebControl enter");
426 result r = E_SUCCESS;
427 AppLogDebug("InitWebControl");
429 if (__pAddressbar == null || __pFooterPanel == null)
432 const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12;
433 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
434 if (__pMostVisitedListView)
436 __pMostVisitedListView->SetShowState(false);
438 if (__pWebViewer != null)
440 AppLogDebug("Already initialized");
443 __pWebViewer = new(std::nothrow) Web();
444 if(__pWebViewer == NULL)
446 AppLogDebug("Initialization failed");
449 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
453 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
458 r = AddControl(*__pWebViewer);
462 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
465 __webControlPosition = __pWebViewer->GetPosition();
466 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
469 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
473 __pWebViewer->SetLoadingListener(this);
474 __pWebViewer->SetWebUiEventListener(this);
475 __pWebViewer->SetWebKeypadEventListener(this);
476 __pWebViewer->SetFocus();
477 __pWebViewer->AddTouchEventListener(*this);
479 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
480 __pWebViewer->SetTextSearchListener(this);
483 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
484 AppLogDebug("MainForm :before return");
486 AppLogDebug("MainForm::InitWebControl Exit");
492 MainForm::SetJavascriptEnabled()
494 WebSetting settings = __pWebViewer->GetSetting();
495 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
496 __pWebViewer->SetSetting(settings);
500 MainForm::SetImageLoadEnabled()
502 WebSetting settings = __pWebViewer->GetSetting();
503 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
504 __pWebViewer->SetSetting(settings);
508 MainForm::InitFooter(void)
510 AppLogDebug("MainForm::InitFooter entered");
511 Button* pBackButton = null;
512 Button* pBookmarkButton = null;
513 Button* pMultiWindowButton = null;
514 Bitmap *pIconBitmap = null;
515 Bitmap *pBGBitmap = null;
516 Label *pBGLabel = null;
518 if (__pFooterPanel == null)
520 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
523 if (__pFooterPanel == null)
528 SetControlAlwaysOnTop(*__pFooterPanel, true);
530 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
531 if ( __pFooterLabel == NULL )
535 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
536 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
539 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
543 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
545 if ( __pMultiWindowButton == NULL )
550 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
552 if ( __pMoreButton == NULL )
557 if (__pMultiWindowButton != null)
559 Bitmap* pBitmap = null;
560 Bitmap* pPressedBitmap = null;
561 String imagePath = "I01_toolbar_icon_windows_manager_0";
562 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
563 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
564 imagePath.Append(totalCount);
565 imagePath.Append(".png");
567 pressedImagePath.Append(totalCount);
568 pressedImagePath.Append("_press.png");
570 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
571 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
572 if ( pBitmap == null )
577 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
580 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
581 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
586 __pMultiWindowButton->AddActionEventListener(*this);
587 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
592 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
593 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
596 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
597 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
598 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
602 __pMoreButton->AddActionEventListener(*this);
603 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
606 //Add the editfield for url
607 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
608 if (__pFooterUrlField == NULL)
610 AppLogDebug("__pFooterUrlField Control not found returning E_INVALID_KEY");
611 return E_INVALID_KEY;
614 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
615 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
616 //__pFooterUrlField->AddFocusEventListener(*this);
617 __pFooterUrlField->AddKeypadEventListener(*this);
619 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
621 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
623 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
625 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
629 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
630 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
633 //Add the go Back Button
634 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
635 if (__pGoBackBtn == NULL)
637 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
638 return E_INVALID_KEY;
640 __pGoBackBtn->SetActionId(IDA_GO_BACK);
641 __pGoBackBtn->AddActionEventListener(*this);
643 //Add the go forward Button
644 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
645 if (__pGoForwardBtn == NULL)
647 AppLogDebug("Control not found returning E_INVALID_KEY");
648 return E_INVALID_KEY;
650 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
651 __pGoForwardBtn->AddActionEventListener(*this);
652 __pGoForwardBtn->SetEnabled(false);
654 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
655 if (__pRefreshBtn == NULL)
657 AppLogDebug("Control not found returning E_INVALID_KEY");
658 return E_INVALID_KEY;
661 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
662 __pRefreshBtn->AddActionEventListener(*this);
663 __pRefreshBtn->SetShowState(true);
665 //Add the backround label for displaying progressbar
666 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
667 if (__pProgressbarLabel == NULL)
669 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
670 return E_INVALID_KEY;
672 __pProgressbarLabel->SetShowState(false);
674 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
675 if (__pStopBtn == NULL)
677 AppLogDebug("Control not found returning E_INVALID_KEY");
678 return E_INVALID_KEY;
680 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
681 __pStopBtn->AddActionEventListener(*this);
682 __pStopBtn->SetShowState(false);
684 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
685 if (__pClearBtn == NULL)
687 AppLogDebug("Control not found returning E_INVALID_KEY");
688 return E_INVALID_KEY;
690 __pClearBtn->SetActionId(IDA_CLEAR_URL);
691 __pClearBtn->AddActionEventListener(*this);
692 __pClearBtn->SetShowState(false);
694 // __pFooterPanel->Invalidate(true);
695 AppLogDebug("MainForm::InitFooter exit");
701 MainForm::InitContextMenu(Point& p)
703 result r = E_SUCCESS;
704 bool isPrivateBrowsing = false;
705 Bitmap* pBitmap = null;
709 __pMenu->SetAnchorPosition(p);
710 __pMenu->Invalidate(true);
714 __pMenu = new(std::nothrow) ContextMenu();
715 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
716 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
718 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
721 if (isPrivateBrowsing == true)
723 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
727 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
730 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
732 if ( pBitmap != NULL)
734 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
737 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
738 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
739 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
742 __pMenu->SetMaxVisibleItemsCount(6);
743 __pMenu->SetShowState(false);
744 __pMenu->AddActionEventListener(*this);
745 SetControlAlwaysOnTop(*__pMenu, true);
751 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
753 result r = E_SUCCESS;
754 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
756 AppLog("MainForm::InitImageContextMenu clicked on image");
757 if (__pImageMenu != null)
763 p.y = p.y + __pAddressbar->GetHeight() + 12;
766 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
770 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
772 __pImageMenu = new (std::nothrow) ContextMenu();
773 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
774 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
776 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
777 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
778 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
779 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
780 __pImageMenu->SetMaxVisibleItemsCount(4);
781 __pImageMenu->AddActionEventListener(*this);
782 SetControlAlwaysOnTop(*__pImageMenu, true);
787 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
789 result r = E_SUCCESS;
790 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
792 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
793 if (__pImageMenu != null)
798 p.y = p.y + __pAddressbar->GetHeight() + 12;
801 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
805 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
807 __pImageMenu = new (std::nothrow) ContextMenu();
808 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
809 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
811 if(onlyPasteOption == false)
813 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
815 if (pasteOption || onlyPasteOption)
817 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
819 if(onlyPasteOption == false)
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
825 __pImageMenu->SetMaxVisibleItemsCount(3);
826 __pImageMenu->AddActionEventListener(*this);
827 SetControlAlwaysOnTop(*__pImageMenu, true);
834 MainForm::InitFindWordPanel(void)
836 result r = E_SUCCESS;
837 Bitmap *pIconBitmap = null;
839 if (__pFindWordPanel != null)
841 AppLogDebug("Findword panel already initialized");
842 if (__pFindWordBgLabel != null)
844 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
847 AppLogDebug("InitFindWordPanel: Coming here");
848 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
855 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
856 if (__pFindWordPanel == null)
858 AppLogException("There is some problem in the xml file. Please check.");
862 __pFindWordControl = new (std::nothrow) Panel();
863 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
866 AppLogException("There is some problem in the xml file. Please check.");
869 __pFindWordPanel->AddControl(*__pFindWordControl);
870 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
871 SetControlAlwaysOnTop(*__pFindWordPanel,true);
872 __pFindWordPanel->SetShowState(false);
873 __pFindWordPanel->Invalidate(false);
875 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
876 if (__pFindWordBgLabel != null)
878 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
879 Rectangle pRect = pPanel1->GetBounds();
880 pRect.x = pRect.y = 0;
881 __pFindWordBgLabel->SetBounds(pRect);
882 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
885 AppLogDebug("InitFindWordPanel: Coming here");
886 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
891 AppLogDebug("InitFindWordPanel: shouldn't Come here");
895 Button* pfindWordCancel = null;
896 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
897 if (pfindWordCancel == null)
899 AppLogException("There is some problem in the xml file. Please check.");
902 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
903 pfindWordCancel->AddActionEventListener(*this);
905 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
906 if (__pFindWordClear == null)
908 AppLogException("There is some problem in the xml file. Please check.");
912 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
913 __pFindWordClear->AddActionEventListener(*this);
915 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
916 if (__pFindWordNext == null)
918 AppLogException("There is some problem in the xml file. Please check.");
922 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
923 __pFindWordNext->AddActionEventListener(*this);
925 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
926 if (__pFindWordPrev == null)
928 AppLogException("There is some problem in the xml file. Please check.");
932 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
933 __pFindWordPrev->AddActionEventListener(*this);
935 __pFindWordNext->SetEnabled(false);
936 __pFindWordPrev->SetEnabled(false);
938 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
939 if (__pFindWordCountLabel == null)
941 AppLogException("There is some problem in the xml file. Please check.");
945 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
946 if (__pFindWordEditField == null)
948 AppLogException("There is some problem in the xml file. Please check.");
951 __pFindWordEditField->AddTextEventListener(*this);
952 __pFindWordEditField->AddKeypadEventListener(*this);
953 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
959 MainForm::CreateItem (int index, int itemWidth)
961 Rectangle listImageRect;
962 Rectangle pagetTitleRect;
963 Rectangle pageURLRect;
964 Rectangle deleteImageRect;
965 String pageTitle(L"");
967 result r = E_SUCCESS;
968 Bitmap* pListIconImage = null;
971 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
976 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
977 if ( pAppResource == NULL )
981 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
983 CustomItem* pItem = new(std::nothrow) CustomItem();
984 pageTitle = pHistory->GetHistoryTitle();
985 pageURL = pHistory->GetHistoryUrl();
987 if (pageURL.GetLength() == 0)
990 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
991 pageURL = L"<"+ nourl +">";
995 Rectangle screenBounds = GetBounds();
998 r = pItem->Construct(Dimension(itemWidth, 128), style);
1007 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1009 if ( pBitmap != NULL)
1011 pListIconImage = new Bitmap();
1012 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1016 if(pListIconImage == null)
1018 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1021 if ( pListIconImage != NULL)
1023 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1024 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1025 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1028 if (pItem != null && pListIconImage != NULL)
1030 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1034 if (pageTitle.CompareTo(L"") != 0)
1038 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1042 if (pageURL.CompareTo(L"") != 0)
1046 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1051 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1053 if ( __pItemContext!= NULL)
1057 pItem->SetContextItem(__pItemContext);
1063 if ( __pItemContextLandscape!= NULL)
1067 pItem->SetContextItem(__pItemContextLandscape);
1071 if( pListIconImage != NULL)
1073 delete pListIconImage;
1074 pListIconImage = null;
1081 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1088 MainForm::GetItemCount (void)
1090 if(__pMostVisitedSites != null)
1092 __pMostVisitedSites->RemoveAll(true);
1094 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1095 if(__pMostVisitedSites != null)
1097 return __pMostVisitedSites->GetCount();
1104 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1106 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1107 String url = pHistory->GetHistoryUrl();
1108 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1109 __pMostVisitedListView->UpdateList();
1113 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1115 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1116 String url = pHistory->GetHistoryUrl();
1124 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1130 MainForm::OnTerminating(void)
1132 result r = E_SUCCESS;
1135 delete __pItemContext;
1137 if(__pItemContextLandscape)
1139 delete __pItemContextLandscape;
1145 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1147 result r = E_SUCCESS;
1149 AppLogDebug("Clicked : %d", actionId);
1152 case IDA_BACKBTN_CLICKED:
1154 if (__pWebViewer && __pWebViewer->CanGoBack())
1156 __pWebViewer->GoBack();
1161 pApp = UiApp::GetInstance();
1164 r = pApp->Terminate();
1167 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1175 case IDA_FORWARD_CLICKED:
1176 if (__pWebViewer == null)
1179 if (__pWebViewer->CanGoForward())
1181 __pWebViewer->GoForward();
1183 __pMenu->SetShowState(false);
1184 __pMenu->Invalidate(false);
1187 case IDA_FINDONPAGE_CLICKED:
1189 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1190 __currentSearchStr.Clear();
1192 InitFindWordPanel();
1193 __pMenu->SetShowState(false);
1194 __pMenu->Invalidate(false);
1196 /*__adressPanelPosition.y = 0 ;
1198 if (__pAddressbar != null && __pWebViewer != NULL)
1200 __webControlPosition.y = __pAddressbar->GetHeight();
1201 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1202 //__pAddressbar->Invalidate(true);
1203 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1204 __pWebViewer->Invalidate(true);
1206 if (__pWebViewer != null)
1208 // releasing the set block
1209 __pWebViewer->ReleaseBlock();
1211 ShowFindWordPanel(true);
1214 case IDA_PRIVATEON_CLICKED:
1216 result r = E_SUCCESS;
1218 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1219 Bitmap* pBitmap = null;
1220 if (isPrivateBrowsing == true)
1222 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1225 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1229 if (__pWebViewer != NULL)
1231 __pWebViewer->SetPrivateBrowsingEnabled(false);
1234 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1236 if (__pAddressbar != null)
1238 __pAddressbar->UpdateFaviconBitmap(false);
1244 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1247 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1251 if (__pWebViewer != NULL)
1253 __pWebViewer->SetPrivateBrowsingEnabled(true);
1256 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1258 if (__pAddressbar != null)
1260 __pAddressbar->UpdateFaviconBitmap(true);
1265 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1266 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1267 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1268 __pMenu->Invalidate(true);
1270 if ( pBitmap != NULL )
1277 case IDA_SETTINGS_CLICKED:
1280 ArrayList* pArgList = new(std::nothrow) ArrayList();
1283 pArgList->Construct();
1284 pArgList->Add(*__pWindowInfo);
1285 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1287 __pMenu->SetShowState(false);
1288 __pMenu->Invalidate(false);
1289 if (pArgList != null)
1298 case IDA_ADDTOBOOKMARK_CLICKED:
1301 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1303 int bookmarkCount=0;
1306 url=__pWindowInfo->pageUrl;
1307 result r = E_SUCCESS;
1308 Bitmap* pBitmap = null;
1309 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1317 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1318 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1319 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1321 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1322 if (pNotification != null)
1324 pNotification->SetText(message);
1325 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1326 pNotification->ShowNotification();
1331 String title=__pWindowInfo->pageTitle;
1332 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1333 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1335 pBookmark->SetBookmarkTitle(title);
1336 pBookmark->SetUrl(url);
1337 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1339 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1341 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1342 pBookmark->SetFaviconId(id);
1343 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1344 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1347 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1348 if (pNotification != null)
1350 pNotification->SetText(message);
1351 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1352 pNotification->ShowNotification();
1353 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1356 if (pBitmap != null)
1358 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1362 __pMenu->Invalidate(true);
1366 case IDA_SHARE_CLICKED:
1368 if(__pPopUp != null)
1373 __pPopUp = new(std::nothrow) SharePopup();
1374 __pPopUp->Initialize();
1375 if (__pWindowInfo != null)
1377 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1378 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1379 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1380 pShareInfo->SetImageAttached(false);
1381 __pPopUp->RemoveAllShareInfo();
1382 __pPopUp->AddShareInfo(pShareInfo);
1384 __pPopUp->SetShowState(true);
1388 case IDA_BOOKMARKBTN_CLICKED:
1390 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1391 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1394 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1399 case IDA_MOREBTN_CLICKED:
1401 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1402 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1403 AppLog("Anchot pos: %d %d", p.x, p.y);
1405 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1407 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1408 int bookmarkCount=0;
1411 url=__pWindowInfo->pageUrl;
1412 result r = E_SUCCESS;
1413 Bitmap* pBitmap = null;
1415 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1418 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1423 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1427 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1429 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1431 if (__pMenu->GetItemCount() == 12)
1433 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1437 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1442 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1446 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1447 if (__pMenu->GetItemCount() != 12)
1449 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1451 __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1452 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1453 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1454 __pMenu->SetMaxVisibleItemsCount(6);
1456 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1458 AppLog(" Orientation landscape");
1459 __pMenu->SetMaxVisibleItemsCount(5);
1463 AppLog(" Orientation potrait");
1464 __pMenu->SetMaxVisibleItemsCount(6);
1467 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1470 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1471 __pMenu->SetShowState(true);
1472 __pMenu->Invalidate(true);
1476 case IDA_HISTORY_CLICKED:
1478 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1479 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1482 case IDA_SAVED_PAGES_CLICKED:
1487 case IDA_DESKTOP_VIEW_CLICKED:
1492 case IDA_SAVE_CLICKED:
1497 case IDA_MULTIWINDOWBTN_CLICKED:
1499 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1500 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1504 case IDA_NEWWINDOWBTN_CLICKED:
1506 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1508 if (pNewWindowInfo == null)
1512 result r = E_SUCCESS;
1513 SceneManager* pSceneManager = SceneManager::GetInstance();
1515 if (pSceneManager == NULL)
1519 ArrayList* pArgList = new(std::nothrow) ArrayList();
1520 if (pArgList == NULL)
1524 r = pArgList->Construct();
1527 pArgList->Add(*pNewWindowInfo);
1528 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1534 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1539 case IDA_SMALLFONT_BTN_CLICKED:
1541 WebSetting setting = __pWebReader->GetSetting();
1542 setting.SetFontSize(15);
1543 __pWebReader->SetSetting(setting);
1546 case IDA_LARGEFONT_BTN_CLICKED:
1548 WebSetting setting = __pWebReader->GetSetting();
1549 setting.SetFontSize(25);
1550 __pWebReader->SetSetting(setting);
1553 case IDA_READER_CLOSE_CLICKED:
1555 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1557 //__pArticleReaderPanel->SetShowState(false);
1558 //__pArticleReaderPanel->Show();
1559 RemoveControl(*__pBlankPanel);
1560 //RemoveControl(*__pArticleReaderPanel);
1561 __pArticleReaderPanel = null;
1562 __pBlankPanel = null;
1563 __pArticleReaderLabel = null;
1565 //if (__pAddressbar)
1566 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1567 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1570 case IDA_FINDWORD_CANCEL_CLICKED:
1572 __currentSearchStr = L"";
1573 __currentWordIndex = 0;
1574 __maxOccurrances = 0;
1575 __pFindWordEditField->SetText(L"");
1576 __pFindWordNext->SetEnabled(false);
1577 __pFindWordPrev->SetEnabled(false);
1578 __pFindWordCountLabel->SetText(L"0/0");
1579 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1580 ShowFindWordPanel(false);
1583 case IDA_FINDWORD_SEARCH_CLICKED:
1585 __currentSearchStr = __pFindWordEditField->GetText();
1586 if (__currentSearchStr.GetLength() > 0)
1592 AppLogDebug("Enter something");
1596 case IDA_FINDWORD_CLEAR_CLICKED:
1598 __pFindWordCountLabel->SetText(L"0/0");
1599 __pFindWordEditField->SetText(L"");
1600 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1602 __pFindWordNext->SetEnabled(false);
1603 __pFindWordPrev->SetEnabled(false);
1604 __pFindWordPanel->Invalidate(true);
1607 case IDA_FINDWORD_NEXT_CLICKED:
1612 case IDA_FINDWORD_PREV_CLICKED:
1614 FindNextWord(false);
1617 case IDA_BRIGHTNESS_BTN_CLICKED:
1619 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1620 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1623 case IDA_COPY_IMAGE_CLICKED:
1625 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1626 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1628 const Bitmap* pBitmap = null;
1629 if (__pHitElementResult != null)
1631 pBitmap = __pHitElementResult->GetImage();
1634 String resourcePath = App::GetInstance()->GetAppResourcePath();
1635 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1637 // copying the item to clipboard
1638 Clipboard* pClipboard = Clipboard::GetInstance();
1639 if (pClipboard != null)
1641 pClipboard->CopyItem(item);
1645 case IDA_VIEW_IMAGE_CLICKED:
1647 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1648 WindowInfo* pNewWindowInfo = null;
1649 if (__pHitElementResult != null)
1651 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1652 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1658 case IDA_SAVE_IMAGE_CLICKED:
1660 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1661 const Bitmap* pSaveBitmap = null;
1662 String imageName = GetImagePath();
1663 AppLog("Content manager image name %ls",imageName.GetPointer());
1666 imagePath.Append(imageName);
1667 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1668 AppLog("Content manager image path %ls",imagePath.GetPointer());
1669 if (__pHitElementResult != null)
1671 pSaveBitmap = __pHitElementResult->GetImage();
1673 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1677 UpdateImageContent(pBuffer, imageName);
1679 NotificationPanel *pNotification = new NotificationPanel(*this);
1681 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1682 msg.Append(imagePath);
1683 if (pNotification != null)
1685 pNotification->SetText(msg);
1686 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1687 pNotification->ShowNotification();
1692 int __modalMsgBoxResult;
1693 MessageBox* pMsgBox = new MessageBox();
1694 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1695 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1698 __modalMsgBoxResult = 0;
1702 case IDA_SHARE_IMAGE_CLICKED:
1704 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1705 if (__pPopUp != null)
1710 __pPopUp = new(std::nothrow) SharePopup();
1711 __pPopUp->Initialize();
1712 if (__pHitElementResult != null)
1714 const Bitmap* pSaveBitmap = null;
1715 String imageName = GetImagePath();
1716 AppLog("Content manager image name %ls",imageName.GetPointer());
1719 imagePath.Append(imageName);
1720 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1721 AppLog("Content manager image path %ls",imagePath.GetPointer());
1722 if (__pHitElementResult != null)
1724 pSaveBitmap = __pHitElementResult->GetImage();
1726 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1728 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1729 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1731 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1732 pShareInfo->SetPageTitle(L"");
1733 pShareInfo->SetPageUrl(srcUrl);
1734 pShareInfo->SetImageAttached(true);
1735 pShareInfo->SetImagePath(imagePath);
1736 __pPopUp->RemoveAllShareInfo();
1737 __pPopUp->AddShareInfo(pShareInfo);
1738 __pPopUp->SetShowState(true);
1743 case IDA_FIND_TEXT__CLICKED:
1745 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1746 __currentSearchStr.Clear();
1747 __currentSearchStr.Append(__currentSelectedStr);
1748 InitFindWordPanel();
1751 __pMenu->SetShowState(false);
1752 __pMenu->Invalidate(false);
1755 __adressPanelPosition.y = 0;
1757 if (__pAddressbar != null && __pWebViewer != NULL)
1759 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1760 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1761 __pAddressbar->Invalidate(true);
1762 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
1764 if(__pFooterPanel->GetShowState() == false)
1765 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
1767 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1768 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1769 __pWebViewer->Invalidate(true);
1772 ShowFindWordPanel(true);
1773 if (__currentSearchStr.GetLength() > 0)
1779 AppLogDebug("Enter something");
1782 if (__pWebViewer != null)
1784 // releasing the set block
1785 __pWebViewer->ReleaseBlock();
1790 case IDA_SHARE_TEXT_CLICKED:
1792 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1793 if(__pPopUp != null)
1798 __pPopUp = new(std::nothrow) SharePopup();
1799 __pPopUp->Initialize();
1800 if (__pHitElementResult != null)
1802 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1803 pShareInfo->SetPageTitle(L"");
1804 pShareInfo->SetPageUrl(__currentSelectedStr);
1805 pShareInfo->SetImageAttached(false);
1806 __pPopUp->RemoveAllShareInfo();
1807 __pPopUp->AddShareInfo(pShareInfo);
1808 __pPopUp->SetShowState(true);
1813 case IDA_COPY_TEXT_CLICKED:
1815 // need to implement
1816 //__currentSelectedStr
1817 // Sets data to a clip board item
1819 String resourcePath = App::GetInstance()->GetAppResourcePath();
1820 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1822 // copying the item to clipboard
1823 Clipboard* pClipboard = Clipboard::GetInstance();
1824 if (pClipboard != null)
1826 pClipboard->CopyItem(item);
1830 case IDA_PASTE_TEXT_CLICKED:
1832 Clipboard* pClipboard = Clipboard::GetInstance();
1834 if(pClipboard == null)
1838 // Retrieves a latest item
1839 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1845 //Gets data from the clipboard item
1846 String* pString = dynamic_cast<String*>(pItem->GetData());
1848 if (pString != null)
1850 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1851 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1852 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1853 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; } } ";
1854 if(idElement.GetLength() != 0)
1856 script.Append("insertAtCursor(");
1857 script.Append(idElement);
1859 script.Append("\"");
1860 script.Append(*pString);
1861 script.Append("\");");
1863 else if (nameElement.GetLength() != 0)
1865 script.Append("insertAtCursor(document.getElementsByName('");
1866 script.Append(nameElement);
1867 script.Append("')[0],");
1868 script.Append("\"");
1869 script.Append(*pString);
1870 script.Append("\");");
1872 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1873 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1884 case IDA_GO_FORWARD:
1889 case IDA_REFRESH_BTN_CLICKED:
1891 __isLoadingCompleted = false;
1892 __isLoadingData = true;
1893 __progressPercentage = 0;
1894 __displayUrl = __pFooterUrlField->GetText();
1896 String url = __pFooterUrlField->GetText();
1897 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1901 UpdateProgressBitmap();
1904 case IDA_STOP_BTN_CLICKED:
1906 __isLoadingCompleted = false;
1907 __isLoadingData = false;
1908 __progressPercentage = 0;
1909 __pFooterUrlField->HideKeypad();
1910 __displayUrl = __pFooterUrlField->GetText();
1914 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1915 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1916 __pWebViewer->StopLoading();
1917 RequestRedraw(true);
1920 UpdateProgressBitmap();
1925 if (__pFooterUrlField->GetText().IsEmpty() == false)
1927 //__displayUrl = __pUrlField->GetText();
1928 __pFooterUrlField->Clear();
1938 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1941 UiApp* pApp = UiApp::GetInstance();
1950 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1951 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1953 String* pSelectedScene = NULL;
1954 Object* pValue = NULL;
1955 String* pUrl = null;
1956 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1957 pSelectedScene = (String*) pValue;
1959 if (pSelectedScene != null)
1961 delete pSelectedScene;
1963 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1964 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1965 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1966 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1968 // setting the current scene ID
1969 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1971 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1973 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1975 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1976 if(__pWindowInfo == null)
1978 // if(__pWindowInfo == null)
1980 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1983 else if ( pArgs != null && pArgs->GetCount() == 1)
1985 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1991 // hiding the address bar
1992 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
1993 __pAddressbar->SetShowState(false);
1994 if(__pWebViewer != null)
1996 __pWebViewer->Resume();
1999 if(pUrl != null && pUrl->GetLength() > 0)
2003 else if(__pWindowInfo != null)
2005 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)
2007 LoadUrl(__pWindowInfo->pageUrl);
2009 else if (__pWindowInfo->isJavascriptInitiated == true)
2013 __pWindowInfo->pCurrentWeb = __pWebViewer;
2017 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2018 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2019 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2021 InitMostVisitedSitesView(GetOrientationStatus());
2024 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2026 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2028 if (pBookmarkUrl == null)
2030 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2031 //__pAddressbar->SetUrl(*pBookmarkUrl);
2032 SetUrl(*pBookmarkUrl);
2034 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2035 __pWebViewer->LoadUrl(*pBookmarkUrl);
2036 delete pBookmarkUrl;
2039 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2040 Bitmap* pBitmap = null;
2041 if (isPrivateBrowsing == true)
2043 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2045 if (__pWebViewer != null)
2047 __pWebViewer->SetPrivateBrowsingEnabled(true);
2050 if (__pAddressbar != null)
2052 // __pAddressbar->UpdateFaviconBitmap(true);
2058 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2060 if (__pWebViewer != null)
2062 __pWebViewer->SetPrivateBrowsingEnabled(false);
2065 if (__pAddressbar != null)
2067 // __pAddressbar->UpdateFaviconBitmap(false);
2071 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2073 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2075 else if (__pMenu != null )
2077 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2080 if (pBitmap != null)
2085 AppLog("ABC: OnSceneActivatedN started exit");
2090 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2091 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2093 Canvas* pWebCanvas = null;
2094 if (__pWebViewer != null)
2096 pWebCanvas = __pWebViewer->GetCanvasN();
2097 __pWebViewer->Pause();
2100 if (pWebCanvas == null)
2104 if (__pWindowInfo != null)
2106 if (__pWindowInfo->pWebCanvasBitmap != null)
2108 delete __pWindowInfo->pWebCanvasBitmap;
2110 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2111 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2112 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2114 Bitmap* pBitmap = GetCapturedBitmapN();
2115 AppLog("Coming here");
2116 Canvas* pCanvas = new(std::nothrow) Canvas();
2117 pCanvas->Construct(GetClientAreaBounds());
2120 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2123 if(__pWebViewer != null && __pWindowInfo != null)
2124 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2126 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2127 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2129 AppLog("Coming here");
2133 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2134 const Tizen::Base::String& realm,
2135 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2141 MainForm::OnHttpAuthenticationCanceled(void)
2146 MainForm::OnLoadingStarted(void)
2148 AppLogDebug("MainForm::OnLoadingStarted entered");
2150 if(__pAddressbar == NULL)
2154 String url = __pWebViewer->GetUrl();
2155 if(url.Contains(IDS_TIZEN_SERVICE))
2158 String delim(L":;");
2160 // Creates a StringTokenizer instance
2161 StringTokenizer strTok(url, delim);
2163 int count = strTok.GetTokenCount(); // count == 4
2165 HashMap *pMap = new HashMap();
2170 while (strTok.HasMoreTokens())
2172 AppLog("Token: %ls", token.GetPointer());
2173 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2174 if(token.Contains(IDS_APPID))
2176 token.SubString(6, appId);
2177 AppLog("AppID:%ls", appId.GetPointer());
2179 else if(token.Contains("="))
2181 String *pKey = new String();
2182 String *pValue = new String();
2184 token.IndexOf("=", 0, index);
2187 token.SubString(0, index, *pKey);
2188 token.SubString(index + 1, *pValue);
2189 pMap->Add(pKey, pValue);
2195 AppControl *pAppControl = null;
2196 String operationId = L"http://tizen.org/appcontrol/operation/main";
2197 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2200 AppLog("Starting AppControl");
2201 result r = pAppControl->Start(null, null, pMap, null);
2202 AppLog("Result of Start %s", GetErrorMessage(r));
2206 AppLogException("AppControl not found");
2211 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2212 __pAddressbar->SetFaviconBitmap(*pBitmap);
2214 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2216 // updating the address bar position with respect to web control
2217 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2218 __distanceMoved = 0;
2222 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2223 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2226 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2227 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2228 SetUrl(__pWebViewer->GetUrl());
2229 if (__pWindowInfo != NULL)
2231 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2233 __pAddressbar->Invalidate(true);
2239 MainForm::OnLoadingCanceled(void)
2246 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2248 AppLog("MainForm::OnKeypadWillOpen");
2249 if (__pAddressbar != null)
2251 OnAddressBarKeypadOpened(*__pAddressbar);
2254 //__pAddressbar->SetAddressbarURLFocus();
2259 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2261 if(__pAddressbar != null)
2263 OnAddressBarKeypadClosed(*__pAddressbar, false);
2269 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2271 if (__pAddressbar != null)
2273 OnAddressBarKeypadClosed(*__pAddressbar);
2278 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2279 const Tizen::Base::String& reason)
2281 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2285 MainForm::OnLoadingCompleted(void)
2287 AppLog("MainForm::OnLoadingCompleted start");
2289 result r = E_SUCCESS;
2291 if (__pWebViewer == null)
2296 if (__pAddressbar == null)
2300 if (__pWebViewer->CanGoForward())
2302 //__pAddressbar->SetForwardButtonEnabled(true);
2303 SetForwardButtonEnabled(true);
2307 //__pAddressbar->SetForwardButtonEnabled(false);
2308 SetForwardButtonEnabled(false);
2311 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2313 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2315 //__pAddressbar->UpdateProgress(0);
2319 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2321 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2325 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2326 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2327 if (isPrivateBrowsing == false)
2329 History* pHistory = new(std::nothrow) History;
2331 HistoryPresentationModel::GetCurrentDateTime(date);
2334 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2335 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2337 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2338 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2340 pHistory->SetVisitedTime(date);
2343 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2344 pHistory->SetFaviconId(id);*/
2346 if (__pWebViewer != null)
2348 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2350 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2351 if (pTempBitmap != null)
2353 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2354 pHistory->SetFavIconBitmap(*pTempBitmap);
2357 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2360 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2361 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2362 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2364 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2365 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2366 pHistory->SetThumbnail(pBitmap);
2368 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2371 pHistory->SetFavIconBitmap(*pFavIcon);
2375 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2382 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2384 // temperary fixed (webpage can be not loaded)
2387 AppLog("MainForm::OnLoadingCompleted done");
2391 MainForm::OnEstimatedProgress(int progress)
2393 AppLogDebug("MainForm::OnEstimatedProgress entered");
2394 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2395 progress = DEFAULT_PROGRESS_PERCENTAGE;
2397 // __pAddressbar->UpdateProgress(progress);
2398 UpdateProgress(progress);
2401 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2403 AppLog("MainForm::OnFaviconReceived");
2404 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2406 if (pFavIconBitmap != null)
2408 pFavIconBitmap->GetWidth();
2409 pFavIconBitmap->GetHeight();
2414 MainForm::OnUrlValueChanged(Addressbar&)
2420 MainForm::OnUrlSubmitted(Addressbar& addBar)
2422 AppLog("MainForm::OnUrlSubmitted");
2423 String url = addBar.GetUrl();
2424 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2427 __pFooterPanel->SetShowState(true);
2428 __pFooterPanel->Invalidate(true);
2429 RequestRedraw(true);
2433 MainForm::LoadUrl(String& url)
2436 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2437 AppLogDebug("MainForm::LoadUrl enter");
2439 if (__pWebViewer != null)
2441 __pWebViewer->SetShowState(true);
2442 __pWebViewer->Invalidate(true);
2445 if (encodedUrl.CompareTo(L"") == 0)
2449 if(__pFooterPanel != null)
2451 __pFooterPanel->SetShowState(true);
2452 __pFooterPanel->Invalidate(true);
2459 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2460 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)
2462 RegularExpression firstRegex;
2463 RegularExpression secondRegex;
2465 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2466 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2469 ret = firstRegex.Match(encodedUrl, false); // This returns true value
2470 flag = secondRegex.Match(encodedUrl, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2472 if (ret == true && __pWebViewer != null)
2474 __pWebViewer->LoadUrl(encodedUrl);
2476 else if(__pWebViewer != null)
2478 String tempUrl = L"http://";
2479 tempUrl.Append(encodedUrl);
2483 __pWebViewer->LoadUrl(tempUrl);
2487 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2490 if (__pAddressbar != null)
2492 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2493 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2496 AppLogDebug("MainForm::LoadUrl exit");
2503 MainForm::OnStopClicked(Addressbar& addBar)
2505 AppLogDebug("MainForm::OnStopClicked called");
2508 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2509 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2510 __pWebViewer->StopLoading();
2511 RequestRedraw(true);
2516 MainForm::OnReaderClicked(const Addressbar& addBar)
2518 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2520 CreateReaderPanel();
2521 AppLogDebug("MainScene::OnReaderClicked entered");
2524 /*if (__pArticleReaderPanel)
2526 AppLogDebug("showstate true for reader panel");
2527 __pArticleReaderPanel->SetShowState(true);
2528 __pArticleReaderPanel->Show();
2530 int xPos = __pArticleReaderPanel->GetX();
2531 int yPos = __pArticleReaderPanel->GetY();
2532 AppLog("OnReaderClicked() xPos = %d",xPos);
2533 AppLog("OnReaderClicked() yPos = %d",yPos);
2535 if (__pReaderData == null)
2540 String loadData = L"<html>\
2542 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2547 background-color: transparent;\
2566 <body style='width:'";
2567 loadData.Append(bodyWidth);
2568 loadData.Append(L"px'>");
2569 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2570 loadData.Append(*__pReaderData);
2571 loadData.Append(L"</body></html>");
2574 buf.Construct(loadData.GetLength());
2575 AppLogDebug("data->GetLength %d",loadData.GetLength());
2576 for (int z=0;z<loadData.GetLength();z++)
2579 loadData.GetCharAt(z,b);
2580 buf.SetByte((byte)b);
2584 if (__pWebReader != null)
2586 __pWebReader->LoadData(L"",buf,L"text/html");
2587 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2591 AppLogDebug("cannot LoadData __pWebReader is null");
2597 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2599 AppLog("MainForm::OnBackClicked");
2600 result r = E_FAILURE;
2602 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2604 __pWebViewer->GoBack();
2609 pApp = UiApp::GetInstance();
2612 r = pApp->Terminate();
2622 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2624 AppLog("MainForm::OnForwardClicked");
2625 if (__pWebViewer == null)
2628 if (__pWebViewer->CanGoForward())
2630 __pWebViewer->GoForward();
2635 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2637 result r = E_SUCCESS;
2638 // hiding the address bar
2639 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2640 __pAddressbar->SetShowState(false);
2642 if (__pMostVisitedListView != null && __pMostVisitedListView->GetShowState() == true)
2644 AppLog("MainForm::OnAddressCancelledClicked 1");
2645 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2646 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()/*GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14*/));
2648 if (__pMostVisitedListView != null)
2649 __pMostVisitedListView->Invalidate(true);
2652 __pFooterPanel->SetShowState(true);
2653 __pFooterPanel->Invalidate(false);
2657 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2659 __prevAddressBarMode = __curAddressBarMode;
2661 if (__pAddressbar != null)
2663 //__curAddressBarMode = __pAddressbar->GetAddressbarMode();
2664 __curAddressBarMode = GetAddressbarMode();
2667 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2669 __adressPanelPosition.y = 0;
2670 if (__pAddressbar != null)
2672 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2673 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2674 __pAddressbar->Invalidate(true);
2676 if (__pWebViewer != null)
2678 __pWebViewer->StopLoading();
2681 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2683 __adressPanelPosition.y = 0;
2684 if (__pAddressbar != null)
2687 __webControlPosition.y = 0;//__pAddressbar->GetHeight() - 12;
2688 __pAddressbar->SetBounds(Rectangle(0,__pAddressbar->GetY() - __pAddressbar->GetHeight(),GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2689 __pAddressbar->Invalidate(true);
2692 if (__pWebViewer != null)
2694 if(__pFooterPanel->GetShowState() == false)
2695 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2697 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2698 __pWebViewer->Invalidate(true);
2703 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2706 if(__pFooterPanel != null)
2708 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2709 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2711 InitMostVisitedSitesView(GetOrientationStatus());
2713 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
2714 __pFooterPanel->SetShowState(footerState);
2715 __pFooterPanel->Invalidate(false);
2720 //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");
2722 if (__pWebViewer != null && __pFooterPanel != null)
2724 AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2725 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2727 if(__pFooterPanel->GetShowState() == false)
2728 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2730 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2731 __pWebViewer->Invalidate(false);
2732 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2734 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2735 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2740 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2742 AppLog("MainForm::OnAddressBarKeypadOpened");
2744 if (__pFindWordPanel && __pFindWordPanel->GetShowState() == true)
2746 __pAddressbar->SetShowState(false);
2747 __pAddressbar->Invalidate(true);
2751 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2753 __pAddressbar->SetShowState(true);
2754 __pAddressbar->Invalidate(true);
2755 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2756 __pAddressbar->SetAddressbarURLFocus();
2761 //__pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2764 if (__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2766 AppLog("MainForm::OnAddressBarKeypadOpened 1");
2767 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2768 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pMostVisitedListView->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2770 if(__pMostVisitedListView != null)
2771 __pMostVisitedListView->Invalidate(true);
2773 else if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
2775 AppLog("MainForm::OnAddressBarKeypadOpened 2");
2776 if (__pWebViewer != null && __pAddressbar != null && __pFooterPanel != null)
2777 __pWebViewer->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pWebViewer->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2779 if(__pWebViewer != null)
2780 __pWebViewer->Invalidate(true);
2785 if (__pWebViewer != null)
2787 __pWebViewer->SetShowState(false);
2788 __pWebViewer->Invalidate(true);
2791 __pMostVisitedListView->SetShowState(true);
2792 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2793 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2795 if(__pMostVisitedListView != null)
2796 __pMostVisitedListView->Invalidate(true);
2801 __pFooterPanel->SetShowState(false);
2802 __pFooterPanel->Invalidate(true);
2806 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2808 __pFooterPanel->SetShowState(false);
2809 __pFooterPanel->Invalidate(false);
2813 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2817 __pWindowInfo->pageTitle = title;
2818 if (__pWebViewer != null)
2820 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2823 if (__pAddressbar != null && __pWebViewer != null)
2825 SetUrl(__pWebViewer->GetUrl());
2826 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2827 //__pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2828 __pAddressbar->Invalidate(true);
2834 MainForm::UpdateFavicon(void)
2836 bool urlImageType = false;
2837 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();");
2838 Bitmap* pBitmap = null;
2840 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2842 if (__pWindowInfo != null)
2845 url.SetUri(*tempPath);
2846 if (url.GetHost().GetLength() == 0)
2849 webUrl.SetUri(__pWebViewer->GetUrl());
2850 result r = url.SetHost(webUrl.GetHost());
2857 if (url.GetScheme().GetLength() == 0)
2860 webUrl.SetUri(__pWebViewer->GetUrl());
2861 url.SetScheme(webUrl.GetScheme());
2863 __pWindowInfo->faviconUrl = url.ToString();
2865 pBitmap = __pWebViewer->GetFaviconN();
2867 if (pBitmap != null)
2869 if (__pWindowInfo->pFavicon != NULL)
2871 // delete __pWindowInfo->pFavicon;
2872 __pWindowInfo->pFavicon = null;
2874 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2875 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2876 //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();
2878 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2880 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2882 else if(__pWindowInfo->pFavicon != null)
2884 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2888 __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());
2891 AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());
2898 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2905 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2906 Tizen::Web::Controls::WebNavigationType type)
2908 // when load new page if find word panel is open its show state is false
2909 ShowFindWordPanel(false);
2910 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
2912 __pFooterPanel->Invalidate(true);
2915 uriInfo.SetUri(url);
2917 if(url.Contains(IDS_TIZEN_SERVICE))
2920 String delim(L":;");
2922 // Creates a StringTokenizer instance
2923 StringTokenizer strTok(url, delim);
2925 int count = strTok.GetTokenCount(); // count == 4
2927 HashMap *pMap = new HashMap();
2933 while (strTok.HasMoreTokens())
2935 AppLog("Token: %ls", token.GetPointer());
2936 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2937 if(token.Contains(IDS_APPID))
2939 token.SubString(6, appId);
2940 AppLog("AppID:%ls", appId.GetPointer());
2942 else if(token.Contains("="))
2944 String *pKey = new String();
2945 String *pValue = new String();
2947 token.IndexOf("=", 0, index);
2950 token.SubString(0, index, *pKey);
2951 token.SubString(index + 1, *pValue);
2952 pMap->Add(pKey, pValue);
2958 AppControl *pAppControl = null;
2959 String operationId = L"http://tizen.org/appcontrol/operation/main";
2960 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2963 AppLog("Starting AppControl");
2964 result r = pAppControl->Start(null, null, pMap, null);
2965 AppLog("Result of Start %s", GetErrorMessage(r));
2969 AppLogException("AppControl not found");
2975 if (__pWebViewer && __pAddressbar)
2977 __pAddressbar->SetShowState(false);
2978 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2979 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2980 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2984 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2985 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2986 __pWindowInfo->faviconUrl = "";
2987 __pWindowInfo->faviconFilePath = "";
2989 if (__pWindowInfo->pFavicon != NULL)
2991 // delete __pWindowInfo->pFavicon;
2992 __pWindowInfo->pFavicon = null ;
2994 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2998 __pAddressbar->Invalidate(true);
3004 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3005 const Tizen::Net::Http::HttpHeader& httpHeader)
3007 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3012 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3014 AppLog("MainForm::OnWebPageBlockSelected");
3015 if (__pHitElementResult != null)
3017 delete __pHitElementResult;
3018 __pHitElementResult = null;
3021 if (__pWebViewer != null)
3023 AppLog("MainForm::OnWebPageBlockSelected web not null");
3024 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3027 if (__pHitElementResult == null)
3032 if (__pHitElementResult->HasImage() != true)
3034 String tagName = __pHitElementResult->GetTagName();
3035 String type = __pHitElementResult->GetAttributeValue("type");
3037 __currentSelectedStr.Clear();
3038 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3039 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3040 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3042 if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)
3044 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3046 InitSelectTextContextMenu(endPoint,true);
3047 __pImageMenu->SetShowState(true);
3048 __pImageMenu->Show();
3049 __pImageMenu->Invalidate(true);
3051 else /*if (__pHitElementResult->HasUrl() == true )*/
3053 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3055 if(__pHitElementResult->GetUrl().GetLength() > 0)
3057 __currentSelectedStr.Clear();
3058 __currentSelectedStr = __pHitElementResult->GetUrl();
3060 InitSelectTextContextMenu(endPoint,false);
3061 __pImageMenu->SetShowState(true);
3062 __pImageMenu->Show();
3063 __pImageMenu->Invalidate(true);
3066 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3067 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3068 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3074 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3080 MainForm::OnWebWindowCreateRequested(void)
3082 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3084 if (pNewWindowInfo == null)
3088 result r = E_SUCCESS;
3089 SceneManager* pSceneManager = SceneManager::GetInstance();
3090 if (pSceneManager == NULL)
3094 ArrayList* pArgList = new(std::nothrow) ArrayList();
3095 if (pArgList == NULL)
3099 r = pArgList->Construct();
3102 pNewWindowInfo->isJavascriptInitiated = true;
3103 pArgList->Add(*pNewWindowInfo);
3104 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3108 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3115 return pNewWindowInfo->pCurrentWeb;
3119 MainForm::RelayoutControls(bool showAddressbar)
3121 if (showAddressbar == false)
3123 __pAddressbar->SetShowState(false);
3124 __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);
3125 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3129 __pAddressbar->SetShowState(true);
3130 __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);
3131 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3133 RequestRedraw(true);
3136 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3138 if (__pFindWordPanel == null)
3144 InitFindWordPanel();
3145 __pFindWordEditField->SetText(__currentSearchStr);
3146 //__pFindWordCountLabel->SetText(L"");
3147 __pFindWordCountLabel->SetText(L"0/0");
3150 AppLog("MainForm::ShowFindWordPanel %d",show);
3151 if (show && !isTouchPressed)
3153 if (__pFindWordEditField)
3155 __pFindWordEditField->SetFocus();
3156 __pFindWordEditField->ShowKeypad();
3161 if (__pFindWordEditField)
3162 __pFindWordEditField->HideKeypad();
3165 if (__pAddressbar != null)
3167 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3168 __pAddressbar->SetShowState(false);
3169 __pAddressbar->Invalidate(true);
3171 if (__pFindWordPanel != null)
3173 __pFindWordPanel->SetShowState(show);
3174 __pFindWordPanel->Invalidate(true);
3180 MainForm::StartWordSearch()
3182 //Get the count of occurances of the word in the current page
3183 __maxOccurrances = 0;
3184 __currentWordIndex = 0;
3186 __pFindWordPrev->SetEnabled(false);
3187 String *pCountStr = null;
3188 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3189 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3190 if (pCountStr != null)
3192 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3196 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3201 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3203 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3204 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3206 if(totalCount == -1 || totalCount == 0)
3208 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight());
3209 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3212 else if(totalCount > 100)
3214 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3215 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3218 __maxOccurrances = totalCount;
3219 __currentWordIndex = currentOrdinal;
3221 //Reset the UI controls as per the maxOccurrance value
3222 if (totalCount <= 0)
3224 AppLog("Word not found");
3225 //Show error notification to user
3226 __pFindWordNext->SetEnabled(false);
3227 __pFindWordCountLabel->SetText(L"0/0");
3228 __pFindWordNext->Invalidate(false);
3229 __pFindWordPrev->Invalidate(false);
3230 __pFindWordCountLabel->Invalidate(false);
3234 if (totalCount == 1)
3236 __pFindWordNext->SetEnabled(false);
3240 __pFindWordNext->SetEnabled(true);
3243 String countStr = L"";
3244 countStr.Append(__currentWordIndex);
3245 countStr.Append(L"/");
3246 countStr.Append(__maxOccurrances);
3247 __pFindWordCountLabel->SetText(countStr);
3248 // __pFindWordCountLabel->SetShowState(true);
3249 __pFindWordCountLabel->Invalidate(false);
3251 //FindNextWord(true);
3252 //Update the controls
3253 __pFindWordNext->Invalidate(false);
3254 __pFindWordPrev->Invalidate(false);
3255 __pFindWordCountLabel->Invalidate(false);
3259 MainForm::FindNextWord(bool next)
3263 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3265 if(__currentWordIndex < __maxOccurrances)
3267 __currentWordIndex++;
3273 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3275 if(__currentWordIndex > 1)
3277 __currentWordIndex--;
3282 String countStr = L"";
3283 countStr.Append(__currentWordIndex);
3284 countStr.Append(L"/");
3285 countStr.Append(__maxOccurrances);
3286 __pFindWordCountLabel->SetText(countStr);
3287 // __pFindWordCountLabel->SetShowState(true);
3288 __pFindWordCountLabel->Invalidate(false);
3289 if (__currentWordIndex >= __maxOccurrances)
3291 __pFindWordNext->SetEnabled(false);
3295 __pFindWordNext->SetEnabled(true);
3297 if (__currentWordIndex <= 1)
3299 __pFindWordPrev->SetEnabled(false);
3303 __pFindWordPrev->SetEnabled(true);
3305 __pFindWordPrev->Invalidate(false);
3306 __pFindWordNext->Invalidate(false);
3307 __pFindWordCountLabel->Invalidate(false);
3308 __pFindWordPanel->Invalidate(true);
3311 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3313 AppLog("MainForm::OnWebKeypadWillOpen");
3314 // OnAddressBarKeypadOpened(*__pAddressbar);
3318 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3321 if (__pWebViewer != null && __pFooterPanel != null)
3323 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3325 // __pFooterPanel->SetShowState(false);
3326 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3329 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3334 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3336 OnAddressBarKeypadClosed(*__pAddressbar);
3340 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3342 Control* temp = const_cast< Control* >(&source);
3343 Header* pHeader = dynamic_cast< Header* >(temp);
3344 if (pHeader != null)
3346 //Header double - clicked
3347 AppLog("Header double clicked");
3349 if(__pFindWordPanel)
3351 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3352 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3356 AppLog("MainScene::OnTouchDoublePressed");
3357 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3358 if (isReaderEnabled == true)
3362 delete __pReaderData;
3363 __pReaderData = null;
3365 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3366 filePath.Append(L"data/reader.js");
3372 result r = E_SUCCESS;
3373 FileAttributes attr;
3375 File::GetAttributes(filePath,attr);
3377 r = file.Construct(filePath, L"r+");
3380 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3383 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3386 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3389 file.Read(pScript,attr.GetFileSize());
3391 AppLogDebug("scipt length %d",strlen(pScript));
3392 String strScript = L"";
3393 strScript.Append(pScript);
3394 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3397 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3400 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3401 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3403 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3404 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3410 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3412 AppLog("MainForm::OnTouchLongPressed");
3414 if (__pHitElementResult != null)
3416 delete __pHitElementResult;
3417 __pHitElementResult = null;
3420 if (__pWebViewer != null)
3422 AppLog("MainForm::OnTouchLongPressed web not null");
3423 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3426 if (__pHitElementResult == null)
3431 if (__pHitElementResult->HasImage() == true)
3433 InitImageContextMenu(currentPosition);
3434 __pImageMenu->SetShowState(true);
3435 __pImageMenu->Show();
3436 __pImageMenu->Invalidate(true);
3440 String tagName = __pHitElementResult->GetTagName();
3441 String type = __pHitElementResult->GetAttributeValue("type");
3442 String value = __pHitElementResult->GetAttributeValue(L"value");
3443 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3445 __currentSelectedStr.Clear();
3446 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3448 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3450 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3452 InitSelectTextContextMenu(currentPosition,true, true);
3453 __pImageMenu->SetShowState(true);
3454 __pImageMenu->Show();
3455 __pImageMenu->Invalidate(true);
3457 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3462 __inputEventToBeSupressed = true;
3466 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3468 AppLog("MainForm::OnTouchReleased");
3470 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3471 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3473 __pWebViewer->ConsumeInputEvent();
3475 if(pHitElement != null)
3479 __inputEventToBeSupressed = false;
3483 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3485 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3486 int widthContextItem = 0;
3488 Bitmap *pBitmap = null;
3490 if (pBitmap != null && __pFooterLabel != null)
3492 pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3493 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3498 __pMenu->SetShowState(false);
3499 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3501 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3505 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3508 if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3510 __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());
3511 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
3512 __pFindWordControl->SetShowState(true);
3513 __pFindWordControl->Invalidate(true);
3514 __pFindWordPanel->SetShowState(true);
3515 __pFindWordPanel->Invalidate(true);
3518 if (__pWebViewer != null && __pFooterPanel != null)
3520 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3521 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3523 if(__pFooterPanel->GetShowState() == false)
3524 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3526 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3527 __pWebViewer->Invalidate(true);
3529 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3531 if (__pAddressbar != null)
3533 if(__pAddressbar->GetShowState() == false)
3535 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3539 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3541 //__pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3542 //__pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());
3543 SetAddressbarMode(GetAddressbarMode());
3544 // __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
3546 if (__pFindWordBgLabel != null)
3548 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3549 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3550 if (pBitmap != null)
3552 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3556 if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)
3558 AppLog("__pFooterPanel->GetShowState() is true");
3560 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3561 __pFooterPanel->Invalidate(true);
3565 if(__pMoreButton && __pMenu)
3567 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3568 __pMenu->SetAnchorPosition(p);
3569 __pMenu->Invalidate(true);
3574 __pFooterPanel->Invalidate(true);
3576 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3577 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3579 InitMostVisitedSitesView(orientationStatus);
3582 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3584 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3586 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight());
3588 else if(__pAddressbar != null && __pAddressbar->GetShowState() == false)
3590 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight());
3593 if (__pArticleReaderPanel != null)
3595 if (__pArticleReaderPanel->GetShowState() == true)
3597 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3599 if (__pBlankPanel != null)
3600 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3602 if (__pWebReader != null)
3604 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3606 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3607 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3609 if ( pBitmap != null && pSrcBitmap != null)
3611 AppLog("CreateReaderPanel ninepatchbitmap found");
3612 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3615 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3616 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3617 if (pBitmap != null)
3622 if (pSrcBitmap != null)
3630 if(__pAddressbar != null)
3632 __pAddressbar->OrientationChanged();
3637 MainForm::OnSettingsChange(int settingvalue)
3639 AppLogDebug("MainForm::OnSettingsChange entered");
3640 if (__pWebViewer == null)
3642 AppLogDebug("Webviewer is not initialized yet.");
3645 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3647 WebSetting settings = __pWebViewer->GetSetting();
3648 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3650 settings.SetAutoFittingEnabled(true);
3652 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3654 settings.SetAutoFittingEnabled(false);
3656 __pWebViewer->SetSetting(settings);
3658 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3660 WebSetting settings = __pWebViewer->GetSetting();
3661 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3662 __pWebViewer->SetSetting(settings);
3664 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3666 WebSetting settings = __pWebViewer->GetSetting();
3667 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3668 __pWebViewer->SetSetting(settings);
3670 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3672 WebSetting settings = __pWebViewer->GetSetting();
3673 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3674 __pWebViewer->SetSetting(settings);
3676 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3680 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3684 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3686 WebSetting settings = __pWebViewer->GetSetting();
3687 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3689 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3693 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3695 __pWebViewer->SetSetting(settings);
3697 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3701 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3702 WebSetting settings = __pWebReader->GetSetting();
3703 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3704 __pWebReader->SetSetting(settings);
3710 MainForm::OnSettingsReset()
3714 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3715 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3720 MainForm::OnClearCache()
3722 result r = E_SUCCESS;
3724 if (__pWebViewer != NULL)
3726 r = __pWebViewer->ClearCache();
3729 AppLogDebug("Cache cleared success");
3733 AppLogDebug("Cache cleared fail");
3739 MainForm::OnClearCookie()
3741 result r = E_SUCCESS;
3743 if (__pWebViewer != NULL)
3745 __pWebViewer->ClearCookie();
3749 AppLogDebug("Cookie cleared success");
3753 AppLogDebug("Cache cleared fail");
3758 MainForm::findDistance(int x1,int y1,int x2, int y2)
3760 int deltaX = Math::Abs(x2 - x1);
3761 int deltaY = Math::Abs(y2 - y1);
3762 double num = deltaX*deltaX + deltaY*deltaY;
3768 for (i = 0; i < 20; i++)
3770 x = (((x*x)+ num)/(2*x));
3781 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3783 if(__pFindWordPanel)
3785 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3786 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3790 IList* pList = null;
3791 pList = touch.GetTouchInfoListN(source);
3795 int count = pList->GetCount();
3798 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3799 __touchPoint1 = pTouchInfo->position;
3801 /*if (__pAddressbar != null)
3803 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3805 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3807 __pAddressbar->SaveAddressbarEditText();
3809 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3812 __pAddressbar->Invalidate(true);
3814 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3816 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3818 //__pAddressbar->SaveAddressbarEditText();
3820 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3823 else if (count == 2)
3825 AppLogDebug("MainForm::OnTouchPressed count is two");
3826 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3827 __touchPoint1 = pTouchInfo->position;
3829 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3830 __touchPoint2 = pTouchInfo->position;
3836 pList->RemoveAll(true);
3843 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3845 __pWebViewer->ReleaseBlock();
3846 __currentWordIndex = 0;
3847 AppLog("Start MainForm::OnTouchMoved MoveUiControls");
3848 if(__pFindWordPanel)
3850 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3851 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3854 if (__pFindWordEditField != null)
3856 __pFindWordEditField->HideKeypad();
3859 /*if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3863 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3869 IList* pList = null;
3870 pList = touch.GetTouchInfoListN(source);
3874 int count = pList->GetCount();
3877 AppLogDebug("MainForm::OnTouchMoved count 1");
3878 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3880 if( pTouchInfo == NULL )
3884 pTouchInfo->position.y += __pWebViewer->GetY();
3885 AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);
3887 if (__isLoaded == false)
3890 __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;
3891 __touchPoint1 = pTouchInfo->position;
3893 // move the address bar and web control according to distance moved
3896 else if (count == 2)
3898 AppLogDebug("MainForm::OnTouchMoved count 2");
3902 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3904 if( pTouchInfo == NULL )
3908 Point firstPoint = pTouchInfo->position;
3910 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3911 if( pTouchInfo == NULL )
3915 Point secondPoint = pTouchInfo->position;
3917 if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))
3919 __touchPoint1 = firstPoint;
3920 __touchPoint2 = secondPoint;
3925 int currX1 = firstPoint.x;
3926 int currY1 = firstPoint.y;
3927 int currX2 = secondPoint.x;
3928 int currY2 = secondPoint.y;
3930 double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);
3931 double dist = findDistance(currX1, currY1, currX2, currY2);
3932 __distanceMoved = prevDist - dist;
3934 __touchPoint1 = firstPoint;
3935 __touchPoint2 = secondPoint;
3947 MainForm::MoveUiControls()
3952 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3954 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3956 if(__pFooterUrlField->GetTextLength() == 0)
3958 __pFooterUrlField->SetKeypadActionEnabled(false);
3962 __pFooterUrlField->SetKeypadActionEnabled(true);
3965 if (__pFindWordEditField != null)
3967 __currentSearchStr = __pFindWordEditField->GetText();
3968 __pFindWordNext->SetEnabled(false);
3969 __pFindWordPrev->SetEnabled(false);
3970 __pFindWordNext->Invalidate(true);
3971 __pFindWordPrev->Invalidate(true);
3972 __pFindWordCountLabel->SetText(L"0/0");
3973 __pFindWordCountLabel->Invalidate(true);
3975 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3976 if (__currentSearchStr.GetLength() > 0)
3982 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3984 AppLogDebug("Enter something");
3989 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3996 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3998 if(__pWebViewer != null)
4001 AppLog("MainForm::InitMostVisitedSitesView");
4002 result r = E_SUCCESS;
4005 if (__pWebViewer != null && __pMostVisitedListView != null)
4010 if (__pMostVisitedListView != null)
4012 RemoveControl(*__pMostVisitedListView);
4014 if(__pMostVisitedSites != null)
4016 __pMostVisitedSites->RemoveAll(true);
4019 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4021 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4022 __pMostVisitedListView = new(std::nothrow) ListView();
4023 if(__pFooterPanel->GetShowState() == false)
4025 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);
4029 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);
4034 delete __pMostVisitedListView;
4035 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4038 __pMostVisitedListView->SetItemProvider(*this);
4039 __pMostVisitedListView->AddListViewItemEventListener(*this);
4040 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4041 AddControl(*__pMostVisitedListView);
4042 AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));
4043 if(__pFooterPanel->GetShowState() == false)
4044 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));
4046 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
4048 __pMostVisitedListView->UpdateList();
4055 MainForm::GetImagePath(void)
4059 String formattedTime;
4060 DateTime currentTime;
4061 LocaleManager localManager;
4062 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4064 localManager.Construct();
4065 Locale locale = localManager.GetSystemLocale();
4066 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4068 // Get date formatter
4069 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4073 pTimeFormatter->Format(currentTime, formattedTime);
4076 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4077 String delim(L" :");
4078 StringTokenizer strTok(formattedTime, delim);
4081 String str1("GMT+00");
4082 while (strTok.HasMoreTokens())
4084 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4085 if(token.Equals(str1))
4087 AppLog("token is %ls", token.GetPointer());
4088 imageName.Append(token);
4094 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4096 result r = E_FAILURE;
4097 AppLog("Content manager 1");
4098 ContentId contentId;
4099 ContentManager contentManager;
4100 r = contentManager.Construct();
4103 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4106 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4107 contentPath.Append(imageName);
4108 contentPath.Append(".jpg");
4109 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4110 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4114 MainForm::SetForwardButtonEnabled(bool isEnabled)
4116 __pGoForwardBtn->SetEnabled(isEnabled);
4117 __pGoBackBtn->Invalidate(true);
4121 MainForm::SetBackButtonEnabled(bool isEnabled)
4123 __pGoBackBtn->SetEnabled(isEnabled);
4124 __pGoBackBtn->Invalidate(true);
4128 MainForm::UpdateProgress(int percentage)
4130 __progressPercentage = percentage;
4131 if (percentage == 0 || percentage == 100)
4133 __isLoadingData = false;
4134 if (percentage == 100)
4136 __isLoadingCompleted = true;
4137 __progressPercentage = 0;
4141 __isLoadingCompleted = false;
4146 __isLoadingData = true;
4148 UpdateProgressBitmap();
4152 MainForm::GetProgress(void)
4154 return __progressPercentage;
4158 MainForm::UpdateProgressBitmap(void)
4160 result r = E_SUCCESS;
4161 if (__pProgressbarLabel == null)
4163 int w = __pProgressbarLabel->GetWidth();
4164 int h = __pProgressbarLabel->GetHeight();
4166 int progressWidth = 0;
4167 Bitmap* pRetBitmap = null;
4169 if (__progressPercentage == 0 || __progressPercentage == 100)
4171 __pProgressbarLabel->SetShowState(false);
4172 __pProgressbarLabel->Invalidate(false);
4177 __pProgressbarLabel->SetShowState(true);
4178 __pProgressbarLabel->Invalidate(false);
4181 r = canvas.Construct(Rectangle(0, 0, w, h));
4185 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4190 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4194 pBgBmp->Scale(Dimension(w, h));
4195 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4199 progressWidth = (double) (w) * __progressPercentage / 100;
4200 AppLogDebug("progressWidth: %d", progressWidth);
4201 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4203 if (pProgressBmp != null)
4205 pProgressBmp->Scale(Dimension(progressWidth, h));
4206 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4207 delete pProgressBmp;
4210 pRetBitmap = new (std::nothrow) Bitmap();
4212 if (pRetBitmap == null)
4214 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4218 pRetBitmap->Construct(canvas, canvas.GetBounds());
4220 if (__pProgressbarLabel != null && pRetBitmap != null)
4222 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4223 __pProgressbarLabel->Invalidate(false);
4226 if (pRetBitmap != null)
4234 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4236 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4238 __currentAddMode = addMode;
4242 case ADDRESSBAR_MODE_INVALID:
4247 case ADDRESSBAR_MODE_READER:
4249 __pStopBtn->SetShowState(false);
4250 __pClearBtn->SetShowState(false);
4253 case ADDRESSBAR_MODE_LOADING:
4255 __pRefreshBtn->SetShowState(false);
4256 __pStopBtn->SetShowState(true);
4257 __pClearBtn->SetShowState(false);
4260 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4262 SetUrl(__pAddressbar->GetUrl());
4264 __pRefreshBtn->SetShowState(true);
4265 __pStopBtn->SetShowState(false);
4266 __pClearBtn->SetShowState(false);
4269 case ADDRESSBAR_MODE_EDIT:
4271 __pRefreshBtn->SetShowState(false);
4272 __pStopBtn->SetShowState(false);
4273 __pClearBtn->SetShowState(true);
4280 OnAddressBarModeChanged();
4283 AddressBarMode MainForm::GetAddressbarMode(void)
4285 return __currentAddMode;
4288 void MainForm::SetUrl(const String& url)
4292 if (__pFooterUrlField != NULL)
4294 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4295 if (removedHttpUrl.IsEmpty() == false)
4297 __pFooterUrlField->SetText(removedHttpUrl);
4298 __pAddressbar->SetUrl(__displayUrl);
4302 __pFooterUrlField->SetText(__displayUrl);
4303 __pAddressbar->SetUrl(__displayUrl);
4306 __pFooterUrlField->Invalidate(false);
4307 __pAddressbar->Invalidate(true);
4308 __pFooterUrlField->SetCursorPosition(0);
4313 MainForm::RemoveHttpTextFromDisplayURL(void)
4315 bool isHttpText = __displayUrl.Contains(L"http://");
4316 String updatedDisplayUrl;
4317 updatedDisplayUrl.Clear();
4319 if (isHttpText == true)
4321 __displayUrl.SubString(7,updatedDisplayUrl);
4323 return updatedDisplayUrl;