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 /*pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true));
552 if ( pBackButton == NULL )
557 pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true));
559 if ( pBookmarkButton == NULL )
564 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
566 if ( __pMoreButton == NULL )
571 /*__pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true));
573 if ( __pNewWindowButton == NULL )
578 if (__pMultiWindowButton != null)
580 Bitmap* pBitmap = null;
581 Bitmap* pPressedBitmap = null;
582 String imagePath = "I01_toolbar_icon_windows_manager_0";
583 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
584 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
585 imagePath.Append(totalCount);
586 imagePath.Append(".png");
588 pressedImagePath.Append(totalCount);
589 pressedImagePath.Append("_press.png");
591 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
592 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
593 if ( pBitmap == null )
598 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
601 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
602 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
607 __pMultiWindowButton->AddActionEventListener(*this);
608 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
613 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
614 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
617 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
618 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
619 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
623 __pMoreButton->AddActionEventListener(*this);
624 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
627 //Add the editfield for url
628 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
629 if (__pFooterUrlField == NULL)
631 AppLogDebug("__pFooterUrlField Control not found returning E_INVALID_KEY");
632 return E_INVALID_KEY;
635 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
636 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
637 //__pFooterUrlField->AddFocusEventListener(*this);
638 __pFooterUrlField->AddKeypadEventListener(*this);
640 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
642 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
644 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
650 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
651 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
654 //Add the go Back Button
655 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
656 if (__pGoBackBtn == NULL)
658 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
659 return E_INVALID_KEY;
661 __pGoBackBtn->SetActionId(IDA_GO_BACK);
662 __pGoBackBtn->AddActionEventListener(*this);
664 //Add the go forward Button
665 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
666 if (__pGoForwardBtn == NULL)
668 AppLogDebug("Control not found returning E_INVALID_KEY");
669 return E_INVALID_KEY;
671 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
672 __pGoForwardBtn->AddActionEventListener(*this);
673 __pGoForwardBtn->SetEnabled(false);
675 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
676 if (__pRefreshBtn == NULL)
678 AppLogDebug("Control not found returning E_INVALID_KEY");
679 return E_INVALID_KEY;
682 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
683 __pRefreshBtn->AddActionEventListener(*this);
684 __pRefreshBtn->SetShowState(true);
686 //Add the backround label for displaying progressbar
687 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
688 if (__pProgressbarLabel == NULL)
690 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
691 return E_INVALID_KEY;
693 __pProgressbarLabel->SetShowState(false);
695 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
696 if (__pStopBtn == NULL)
698 AppLogDebug("Control not found returning E_INVALID_KEY");
699 return E_INVALID_KEY;
701 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
702 __pStopBtn->AddActionEventListener(*this);
703 __pStopBtn->SetShowState(false);
705 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
706 if (__pClearBtn == NULL)
708 AppLogDebug("Control not found returning E_INVALID_KEY");
709 return E_INVALID_KEY;
711 __pClearBtn->SetActionId(IDA_CLEAR_URL);
712 __pClearBtn->AddActionEventListener(*this);
713 __pClearBtn->SetShowState(false);
715 // __pFooterPanel->Invalidate(true);
716 AppLogDebug("MainForm::InitFooter exit");
722 MainForm::InitContextMenu(Point& p)
724 result r = E_SUCCESS;
725 bool isPrivateBrowsing = false;
726 Bitmap* pBitmap = null;
730 __pMenu->SetAnchorPosition(p);
731 __pMenu->Invalidate(true);
735 __pMenu = new(std::nothrow) ContextMenu();
736 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
737 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
739 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
742 if (isPrivateBrowsing == true)
744 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
748 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
751 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
753 if ( pBitmap != NULL)
755 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
758 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
759 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
760 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
763 __pMenu->SetMaxVisibleItemsCount(6);
764 __pMenu->SetShowState(false);
765 __pMenu->AddActionEventListener(*this);
766 SetControlAlwaysOnTop(*__pMenu, true);
772 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
774 result r = E_SUCCESS;
775 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
777 AppLog("MainForm::InitImageContextMenu clicked on image");
778 if (__pImageMenu != null)
784 p.y = p.y + __pAddressbar->GetHeight() + 12;
787 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
791 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
793 __pImageMenu = new (std::nothrow) ContextMenu();
794 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
795 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
797 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
798 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
799 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
800 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
801 __pImageMenu->SetMaxVisibleItemsCount(4);
802 __pImageMenu->AddActionEventListener(*this);
803 SetControlAlwaysOnTop(*__pImageMenu, true);
808 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
810 result r = E_SUCCESS;
811 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
813 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
814 if (__pImageMenu != null)
819 p.y = p.y + __pAddressbar->GetHeight() + 12;
822 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
826 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
828 __pImageMenu = new (std::nothrow) ContextMenu();
829 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
830 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
832 if(onlyPasteOption == false)
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
836 if (pasteOption || onlyPasteOption)
838 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
840 if(onlyPasteOption == false)
842 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
843 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
846 __pImageMenu->SetMaxVisibleItemsCount(3);
847 __pImageMenu->AddActionEventListener(*this);
848 SetControlAlwaysOnTop(*__pImageMenu, true);
855 MainForm::InitFindWordPanel(void)
857 result r = E_SUCCESS;
858 Bitmap *pIconBitmap = null;
860 if (__pFindWordPanel != null)
862 AppLogDebug("Findword panel already initialized");
863 if (__pFindWordBgLabel != null)
865 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
868 AppLogDebug("InitFindWordPanel: Coming here");
869 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
876 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
877 if (__pFindWordPanel == null)
879 AppLogException("There is some problem in the xml file. Please check.");
883 __pFindWordControl = new (std::nothrow) Panel();
884 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
887 AppLogException("There is some problem in the xml file. Please check.");
890 __pFindWordPanel->AddControl(*__pFindWordControl);
891 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
892 SetControlAlwaysOnTop(*__pFindWordPanel,true);
893 __pFindWordPanel->SetShowState(false);
894 __pFindWordPanel->Invalidate(false);
896 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
897 if (__pFindWordBgLabel != null)
899 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
900 Rectangle pRect = pPanel1->GetBounds();
901 pRect.x = pRect.y = 0;
902 __pFindWordBgLabel->SetBounds(pRect);
903 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
906 AppLogDebug("InitFindWordPanel: Coming here");
907 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
912 AppLogDebug("InitFindWordPanel: shouldn't Come here");
916 Button* pfindWordCancel = null;
917 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
918 if (pfindWordCancel == null)
920 AppLogException("There is some problem in the xml file. Please check.");
923 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
924 pfindWordCancel->AddActionEventListener(*this);
926 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
927 if (__pFindWordClear == null)
929 AppLogException("There is some problem in the xml file. Please check.");
933 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
934 __pFindWordClear->AddActionEventListener(*this);
936 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
937 if (__pFindWordNext == null)
939 AppLogException("There is some problem in the xml file. Please check.");
943 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
944 __pFindWordNext->AddActionEventListener(*this);
946 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
947 if (__pFindWordPrev == null)
949 AppLogException("There is some problem in the xml file. Please check.");
953 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
954 __pFindWordPrev->AddActionEventListener(*this);
956 __pFindWordNext->SetEnabled(false);
957 __pFindWordPrev->SetEnabled(false);
959 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
960 if (__pFindWordCountLabel == null)
962 AppLogException("There is some problem in the xml file. Please check.");
966 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
967 if (__pFindWordEditField == null)
969 AppLogException("There is some problem in the xml file. Please check.");
972 __pFindWordEditField->AddTextEventListener(*this);
973 __pFindWordEditField->AddKeypadEventListener(*this);
974 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
980 MainForm::CreateItem (int index, int itemWidth)
982 Rectangle listImageRect;
983 Rectangle pagetTitleRect;
984 Rectangle pageURLRect;
985 Rectangle deleteImageRect;
986 String pageTitle(L"");
988 result r = E_SUCCESS;
989 Bitmap* pListIconImage = null;
992 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
997 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
998 if ( pAppResource == NULL )
1002 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1004 CustomItem* pItem = new(std::nothrow) CustomItem();
1005 pageTitle = pHistory->GetHistoryTitle();
1006 pageURL = pHistory->GetHistoryUrl();
1008 if (pageURL.GetLength() == 0)
1011 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1012 pageURL = L"<"+ nourl +">";
1016 Rectangle screenBounds = GetBounds();
1019 r = pItem->Construct(Dimension(itemWidth, 128), style);
1028 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1030 if ( pBitmap != NULL)
1032 pListIconImage = new Bitmap();
1033 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1037 if(pListIconImage == null)
1039 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1042 if ( pListIconImage != NULL)
1044 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1045 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1046 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1049 if (pItem != null && pListIconImage != NULL)
1051 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1055 if (pageTitle.CompareTo(L"") != 0)
1059 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1063 if (pageURL.CompareTo(L"") != 0)
1067 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1072 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1074 if ( __pItemContext!= NULL)
1078 pItem->SetContextItem(__pItemContext);
1084 if ( __pItemContextLandscape!= NULL)
1088 pItem->SetContextItem(__pItemContextLandscape);
1092 if( pListIconImage != NULL)
1094 delete pListIconImage;
1095 pListIconImage = null;
1102 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1109 MainForm::GetItemCount (void)
1111 if(__pMostVisitedSites != null)
1113 __pMostVisitedSites->RemoveAll(true);
1115 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1116 if(__pMostVisitedSites != null)
1118 return __pMostVisitedSites->GetCount();
1125 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1127 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1128 String url = pHistory->GetHistoryUrl();
1129 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1130 __pMostVisitedListView->UpdateList();
1134 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1136 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1137 String url = pHistory->GetHistoryUrl();
1145 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1151 MainForm::OnTerminating(void)
1153 result r = E_SUCCESS;
1156 delete __pItemContext;
1158 if(__pItemContextLandscape)
1160 delete __pItemContextLandscape;
1166 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1168 result r = E_SUCCESS;
1170 AppLogDebug("Clicked : %d", actionId);
1173 case IDA_BACKBTN_CLICKED:
1175 if (__pWebViewer && __pWebViewer->CanGoBack())
1177 __pWebViewer->GoBack();
1182 pApp = UiApp::GetInstance();
1185 r = pApp->Terminate();
1188 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1196 case IDA_FORWARD_CLICKED:
1197 if (__pWebViewer == null)
1200 if (__pWebViewer->CanGoForward())
1202 __pWebViewer->GoForward();
1204 __pMenu->SetShowState(false);
1205 __pMenu->Invalidate(false);
1208 case IDA_FINDONPAGE_CLICKED:
1210 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1211 __currentSearchStr.Clear();
1213 InitFindWordPanel();
1214 __pMenu->SetShowState(false);
1215 __pMenu->Invalidate(false);
1217 /*__adressPanelPosition.y = 0 ;
1219 if (__pAddressbar != null && __pWebViewer != NULL)
1221 __webControlPosition.y = __pAddressbar->GetHeight();
1222 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1223 //__pAddressbar->Invalidate(true);
1224 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1225 __pWebViewer->Invalidate(true);
1227 if (__pWebViewer != null)
1229 // releasing the set block
1230 __pWebViewer->ReleaseBlock();
1232 ShowFindWordPanel(true);
1235 case IDA_PRIVATEON_CLICKED:
1237 result r = E_SUCCESS;
1239 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1240 Bitmap* pBitmap = null;
1241 if (isPrivateBrowsing == true)
1243 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1246 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1250 if (__pWebViewer != NULL)
1252 __pWebViewer->SetPrivateBrowsingEnabled(false);
1255 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1257 if (__pAddressbar != null)
1259 __pAddressbar->UpdateFaviconBitmap(false);
1265 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1268 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1272 if (__pWebViewer != NULL)
1274 __pWebViewer->SetPrivateBrowsingEnabled(true);
1277 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1279 if (__pAddressbar != null)
1281 __pAddressbar->UpdateFaviconBitmap(true);
1286 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1287 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1288 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1289 __pMenu->Invalidate(true);
1291 if ( pBitmap != NULL )
1298 case IDA_SETTINGS_CLICKED:
1301 ArrayList* pArgList = new(std::nothrow) ArrayList();
1304 pArgList->Construct();
1305 pArgList->Add(*__pWindowInfo);
1306 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1308 __pMenu->SetShowState(false);
1309 __pMenu->Invalidate(false);
1310 if (pArgList != null)
1319 case IDA_ADDTOBOOKMARK_CLICKED:
1322 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1324 int bookmarkCount=0;
1327 url=__pWindowInfo->pageUrl;
1328 result r = E_SUCCESS;
1329 Bitmap* pBitmap = null;
1330 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1338 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1339 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1340 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1342 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1343 if (pNotification != null)
1345 pNotification->SetText(message);
1346 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1347 pNotification->ShowNotification();
1352 String title=__pWindowInfo->pageTitle;
1353 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1354 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1356 pBookmark->SetBookmarkTitle(title);
1357 pBookmark->SetUrl(url);
1358 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1360 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1362 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1363 pBookmark->SetFaviconId(id);
1364 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1365 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1368 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1369 if (pNotification != null)
1371 pNotification->SetText(message);
1372 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1373 pNotification->ShowNotification();
1374 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1377 if (pBitmap != null)
1379 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1383 __pMenu->Invalidate(true);
1387 case IDA_SHARE_CLICKED:
1389 if(__pPopUp != null)
1394 __pPopUp = new(std::nothrow) SharePopup();
1395 __pPopUp->Initialize();
1396 if (__pWindowInfo != null)
1398 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1399 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1400 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1401 pShareInfo->SetImageAttached(false);
1402 __pPopUp->RemoveAllShareInfo();
1403 __pPopUp->AddShareInfo(pShareInfo);
1405 __pPopUp->SetShowState(true);
1409 case IDA_BOOKMARKBTN_CLICKED:
1411 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1412 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1415 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1420 case IDA_MOREBTN_CLICKED:
1422 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1423 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1424 AppLog("Anchot pos: %d %d", p.x, p.y);
1426 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1428 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1429 int bookmarkCount=0;
1432 url=__pWindowInfo->pageUrl;
1433 result r = E_SUCCESS;
1434 Bitmap* pBitmap = null;
1436 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1439 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1444 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1448 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1450 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1452 if (__pMenu->GetItemCount() == 12)
1454 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1458 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1463 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1467 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1468 if (__pMenu->GetItemCount() != 12)
1470 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1472 __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1473 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1474 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1475 __pMenu->SetMaxVisibleItemsCount(6);
1477 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1479 AppLog(" Orientation landscape");
1480 __pMenu->SetMaxVisibleItemsCount(5);
1484 AppLog(" Orientation potrait");
1485 __pMenu->SetMaxVisibleItemsCount(6);
1488 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1491 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1492 __pMenu->SetShowState(true);
1493 __pMenu->Invalidate(true);
1497 case IDA_HISTORY_CLICKED:
1499 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1500 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1503 case IDA_SAVED_PAGES_CLICKED:
1508 case IDA_DESKTOP_VIEW_CLICKED:
1513 case IDA_SAVE_CLICKED:
1518 case IDA_MULTIWINDOWBTN_CLICKED:
1520 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1521 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1525 case IDA_NEWWINDOWBTN_CLICKED:
1527 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1529 if (pNewWindowInfo == null)
1533 result r = E_SUCCESS;
1534 SceneManager* pSceneManager = SceneManager::GetInstance();
1536 if (pSceneManager == NULL)
1540 ArrayList* pArgList = new(std::nothrow) ArrayList();
1541 if (pArgList == NULL)
1545 r = pArgList->Construct();
1548 pArgList->Add(*pNewWindowInfo);
1549 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1555 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1560 case IDA_SMALLFONT_BTN_CLICKED:
1562 WebSetting setting = __pWebReader->GetSetting();
1563 setting.SetFontSize(15);
1564 __pWebReader->SetSetting(setting);
1567 case IDA_LARGEFONT_BTN_CLICKED:
1569 WebSetting setting = __pWebReader->GetSetting();
1570 setting.SetFontSize(25);
1571 __pWebReader->SetSetting(setting);
1574 case IDA_READER_CLOSE_CLICKED:
1576 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1578 //__pArticleReaderPanel->SetShowState(false);
1579 //__pArticleReaderPanel->Show();
1580 RemoveControl(*__pBlankPanel);
1581 //RemoveControl(*__pArticleReaderPanel);
1582 __pArticleReaderPanel = null;
1583 __pBlankPanel = null;
1584 __pArticleReaderLabel = null;
1586 //if (__pAddressbar)
1587 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1588 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1591 case IDA_FINDWORD_CANCEL_CLICKED:
1593 __currentSearchStr = L"";
1594 __currentWordIndex = 0;
1595 __maxOccurrances = 0;
1596 __pFindWordEditField->SetText(L"");
1597 __pFindWordNext->SetEnabled(false);
1598 __pFindWordPrev->SetEnabled(false);
1599 __pFindWordCountLabel->SetText(L"0/0");
1600 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1601 ShowFindWordPanel(false);
1604 case IDA_FINDWORD_SEARCH_CLICKED:
1606 __currentSearchStr = __pFindWordEditField->GetText();
1607 if (__currentSearchStr.GetLength() > 0)
1613 AppLogDebug("Enter something");
1617 case IDA_FINDWORD_CLEAR_CLICKED:
1619 __pFindWordCountLabel->SetText(L"0/0");
1620 __pFindWordEditField->SetText(L"");
1621 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1623 __pFindWordNext->SetEnabled(false);
1624 __pFindWordPrev->SetEnabled(false);
1625 __pFindWordPanel->Invalidate(true);
1628 case IDA_FINDWORD_NEXT_CLICKED:
1633 case IDA_FINDWORD_PREV_CLICKED:
1635 FindNextWord(false);
1638 case IDA_BRIGHTNESS_BTN_CLICKED:
1640 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1641 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1644 case IDA_COPY_IMAGE_CLICKED:
1646 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1647 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1649 const Bitmap* pBitmap = null;
1650 if (__pHitElementResult != null)
1652 pBitmap = __pHitElementResult->GetImage();
1655 String resourcePath = App::GetInstance()->GetAppResourcePath();
1656 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1658 // copying the item to clipboard
1659 Clipboard* pClipboard = Clipboard::GetInstance();
1660 if (pClipboard != null)
1662 pClipboard->CopyItem(item);
1666 case IDA_VIEW_IMAGE_CLICKED:
1668 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1669 WindowInfo* pNewWindowInfo = null;
1670 if (__pHitElementResult != null)
1672 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1673 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1679 case IDA_SAVE_IMAGE_CLICKED:
1681 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1682 const Bitmap* pSaveBitmap = null;
1683 String imageName = GetImagePath();
1684 AppLog("Content manager image name %ls",imageName.GetPointer());
1687 imagePath.Append(imageName);
1688 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1689 AppLog("Content manager image path %ls",imagePath.GetPointer());
1690 if (__pHitElementResult != null)
1692 pSaveBitmap = __pHitElementResult->GetImage();
1694 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1698 UpdateImageContent(pBuffer, imageName);
1700 NotificationPanel *pNotification = new NotificationPanel(*this);
1702 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1703 msg.Append(imagePath);
1704 if (pNotification != null)
1706 pNotification->SetText(msg);
1707 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1708 pNotification->ShowNotification();
1713 int __modalMsgBoxResult;
1714 MessageBox* pMsgBox = new MessageBox();
1715 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1716 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1719 __modalMsgBoxResult = 0;
1723 case IDA_SHARE_IMAGE_CLICKED:
1725 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1726 if (__pPopUp != null)
1731 __pPopUp = new(std::nothrow) SharePopup();
1732 __pPopUp->Initialize();
1733 if (__pHitElementResult != null)
1735 const Bitmap* pSaveBitmap = null;
1736 String imageName = GetImagePath();
1737 AppLog("Content manager image name %ls",imageName.GetPointer());
1740 imagePath.Append(imageName);
1741 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1742 AppLog("Content manager image path %ls",imagePath.GetPointer());
1743 if (__pHitElementResult != null)
1745 pSaveBitmap = __pHitElementResult->GetImage();
1747 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1749 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1750 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1752 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1753 pShareInfo->SetPageTitle(L"");
1754 pShareInfo->SetPageUrl(srcUrl);
1755 pShareInfo->SetImageAttached(true);
1756 pShareInfo->SetImagePath(imagePath);
1757 __pPopUp->RemoveAllShareInfo();
1758 __pPopUp->AddShareInfo(pShareInfo);
1759 __pPopUp->SetShowState(true);
1764 case IDA_FIND_TEXT__CLICKED:
1766 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1767 __currentSearchStr.Clear();
1768 __currentSearchStr.Append(__currentSelectedStr);
1769 InitFindWordPanel();
1772 __pMenu->SetShowState(false);
1773 __pMenu->Invalidate(false);
1776 __adressPanelPosition.y = 0;
1778 if (__pAddressbar != null && __pWebViewer != NULL)
1780 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1781 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1782 __pAddressbar->Invalidate(true);
1783 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
1785 if(__pFooterPanel->GetShowState() == false)
1786 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
1788 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1789 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1790 __pWebViewer->Invalidate(true);
1793 ShowFindWordPanel(true);
1794 if (__currentSearchStr.GetLength() > 0)
1800 AppLogDebug("Enter something");
1803 if (__pWebViewer != null)
1805 // releasing the set block
1806 __pWebViewer->ReleaseBlock();
1811 case IDA_SHARE_TEXT_CLICKED:
1813 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1814 if(__pPopUp != null)
1819 __pPopUp = new(std::nothrow) SharePopup();
1820 __pPopUp->Initialize();
1821 if (__pHitElementResult != null)
1823 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1824 pShareInfo->SetPageTitle(L"");
1825 pShareInfo->SetPageUrl(__currentSelectedStr);
1826 pShareInfo->SetImageAttached(false);
1827 __pPopUp->RemoveAllShareInfo();
1828 __pPopUp->AddShareInfo(pShareInfo);
1829 __pPopUp->SetShowState(true);
1834 case IDA_COPY_TEXT_CLICKED:
1836 // need to implement
1837 //__currentSelectedStr
1838 // Sets data to a clip board item
1840 String resourcePath = App::GetInstance()->GetAppResourcePath();
1841 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1843 // copying the item to clipboard
1844 Clipboard* pClipboard = Clipboard::GetInstance();
1845 if (pClipboard != null)
1847 pClipboard->CopyItem(item);
1851 case IDA_PASTE_TEXT_CLICKED:
1853 Clipboard* pClipboard = Clipboard::GetInstance();
1855 if(pClipboard == null)
1859 // Retrieves a latest item
1860 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1866 //Gets data from the clipboard item
1867 String* pString = dynamic_cast<String*>(pItem->GetData());
1869 if (pString != null)
1871 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1872 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1873 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1874 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; } } ";
1875 if(idElement.GetLength() != 0)
1877 script.Append("insertAtCursor(");
1878 script.Append(idElement);
1880 script.Append("\"");
1881 script.Append(*pString);
1882 script.Append("\");");
1884 else if (nameElement.GetLength() != 0)
1886 script.Append("insertAtCursor(document.getElementsByName('");
1887 script.Append(nameElement);
1888 script.Append("')[0],");
1889 script.Append("\"");
1890 script.Append(*pString);
1891 script.Append("\");");
1893 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1894 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1905 case IDA_GO_FORWARD:
1910 case IDA_REFRESH_BTN_CLICKED:
1912 __isLoadingCompleted = false;
1913 __isLoadingData = true;
1914 __progressPercentage = 0;
1915 __displayUrl = __pFooterUrlField->GetText();
1917 String url = __pFooterUrlField->GetText();
1918 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1922 UpdateProgressBitmap();
1925 case IDA_STOP_BTN_CLICKED:
1927 __isLoadingCompleted = false;
1928 __isLoadingData = false;
1929 __progressPercentage = 0;
1930 __pFooterUrlField->HideKeypad();
1931 __displayUrl = __pFooterUrlField->GetText();
1935 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1936 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1937 __pWebViewer->StopLoading();
1938 RequestRedraw(true);
1941 UpdateProgressBitmap();
1946 if (__pFooterUrlField->GetText().IsEmpty() == false)
1948 //__displayUrl = __pUrlField->GetText();
1949 __pFooterUrlField->Clear();
1959 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1962 UiApp* pApp = UiApp::GetInstance();
1971 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1972 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1974 String* pSelectedScene = NULL;
1975 Object* pValue = NULL;
1976 String* pUrl = null;
1977 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1978 pSelectedScene = (String*) pValue;
1980 if (pSelectedScene != null)
1982 delete pSelectedScene;
1984 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1985 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1986 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1987 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1989 // setting the current scene ID
1990 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1992 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1994 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1996 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1997 if(__pWindowInfo == null)
1999 // if(__pWindowInfo == null)
2001 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2004 else if ( pArgs != null && pArgs->GetCount() == 1)
2006 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2012 // hiding the address bar
2013 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2014 __pAddressbar->SetShowState(false);
2015 if(__pWebViewer != null)
2017 __pWebViewer->Resume();
2020 if(pUrl != null && pUrl->GetLength() > 0)
2024 else if(__pWindowInfo != null)
2026 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)
2028 LoadUrl(__pWindowInfo->pageUrl);
2030 else if (__pWindowInfo->isJavascriptInitiated == true)
2034 __pWindowInfo->pCurrentWeb = __pWebViewer;
2038 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2039 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2040 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2042 InitMostVisitedSitesView(GetOrientationStatus());
2045 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2047 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2049 if (pBookmarkUrl == null)
2051 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2052 //__pAddressbar->SetUrl(*pBookmarkUrl);
2053 SetUrl(*pBookmarkUrl);
2055 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2056 __pWebViewer->LoadUrl(*pBookmarkUrl);
2057 delete pBookmarkUrl;
2060 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2061 Bitmap* pBitmap = null;
2062 if (isPrivateBrowsing == true)
2064 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2066 if (__pWebViewer != null)
2068 __pWebViewer->SetPrivateBrowsingEnabled(true);
2071 if (__pAddressbar != null)
2073 // __pAddressbar->UpdateFaviconBitmap(true);
2079 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2081 if (__pWebViewer != null)
2083 __pWebViewer->SetPrivateBrowsingEnabled(false);
2086 if (__pAddressbar != null)
2088 // __pAddressbar->UpdateFaviconBitmap(false);
2092 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2094 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2096 else if (__pMenu != null )
2098 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2101 if (pBitmap != null)
2106 AppLog("ABC: OnSceneActivatedN started exit");
2111 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2112 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2114 Canvas* pWebCanvas = null;
2115 if (__pWebViewer != null)
2117 pWebCanvas = __pWebViewer->GetCanvasN();
2118 __pWebViewer->Pause();
2121 if (pWebCanvas == null)
2125 if (__pWindowInfo != null)
2127 if (__pWindowInfo->pWebCanvasBitmap != null)
2129 delete __pWindowInfo->pWebCanvasBitmap;
2131 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2132 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2133 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2135 Bitmap* pBitmap = GetCapturedBitmapN();
2136 AppLog("Coming here");
2137 Canvas* pCanvas = new(std::nothrow) Canvas();
2138 pCanvas->Construct(GetClientAreaBounds());
2141 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2144 if(__pWebViewer != null && __pWindowInfo != null)
2145 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2147 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2148 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2150 AppLog("Coming here");
2154 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2155 const Tizen::Base::String& realm,
2156 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2162 MainForm::OnHttpAuthenticationCanceled(void)
2167 MainForm::OnLoadingStarted(void)
2169 AppLogDebug("MainForm::OnLoadingStarted entered");
2171 if(__pAddressbar == NULL)
2175 String url = __pWebViewer->GetUrl();
2176 if(url.Contains(IDS_TIZEN_SERVICE))
2179 String delim(L":;");
2181 // Creates a StringTokenizer instance
2182 StringTokenizer strTok(url, delim);
2184 int count = strTok.GetTokenCount(); // count == 4
2186 HashMap *pMap = new HashMap();
2191 while (strTok.HasMoreTokens())
2193 AppLog("Token: %ls", token.GetPointer());
2194 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2195 if(token.Contains(IDS_APPID))
2197 token.SubString(6, appId);
2198 AppLog("AppID:%ls", appId.GetPointer());
2200 else if(token.Contains("="))
2202 String *pKey = new String();
2203 String *pValue = new String();
2205 token.IndexOf("=", 0, index);
2208 token.SubString(0, index, *pKey);
2209 token.SubString(index + 1, *pValue);
2210 pMap->Add(pKey, pValue);
2216 AppControl *pAppControl = null;
2217 String operationId = L"http://tizen.org/appcontrol/operation/main";
2218 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2221 AppLog("Starting AppControl");
2222 result r = pAppControl->Start(null, null, pMap, null);
2223 AppLog("Result of Start %s", GetErrorMessage(r));
2227 AppLogException("AppControl not found");
2232 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2233 __pAddressbar->SetFaviconBitmap(*pBitmap);
2235 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2237 // updating the address bar position with respect to web control
2238 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2239 __distanceMoved = 0;
2243 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2244 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2247 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2248 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2249 SetUrl(__pWebViewer->GetUrl());
2250 if (__pWindowInfo != NULL)
2252 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2254 __pAddressbar->Invalidate(true);
2260 MainForm::OnLoadingCanceled(void)
2267 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2269 AppLog("MainForm::OnKeypadWillOpen");
2270 if (__pAddressbar != null)
2272 OnAddressBarKeypadOpened(*__pAddressbar);
2275 //__pAddressbar->SetAddressbarURLFocus();
2280 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2282 if(__pAddressbar != null)
2284 OnAddressBarKeypadClosed(*__pAddressbar, false);
2290 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2292 if (__pAddressbar != null)
2294 OnAddressBarKeypadClosed(*__pAddressbar);
2299 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2300 const Tizen::Base::String& reason)
2302 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2306 MainForm::OnLoadingCompleted(void)
2308 AppLog("MainForm::OnLoadingCompleted start");
2310 result r = E_SUCCESS;
2312 if (__pWebViewer == null)
2317 if (__pAddressbar == null)
2321 if (__pWebViewer->CanGoForward())
2323 //__pAddressbar->SetForwardButtonEnabled(true);
2324 SetForwardButtonEnabled(true);
2328 //__pAddressbar->SetForwardButtonEnabled(false);
2329 SetForwardButtonEnabled(false);
2332 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2334 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2336 //__pAddressbar->UpdateProgress(0);
2340 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2342 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2346 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2347 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2348 if (isPrivateBrowsing == false)
2350 History* pHistory = new(std::nothrow) History;
2352 HistoryPresentationModel::GetCurrentDateTime(date);
2355 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2356 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2358 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2359 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2361 pHistory->SetVisitedTime(date);
2364 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2365 pHistory->SetFaviconId(id);*/
2367 if (__pWebViewer != null)
2369 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2371 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2372 if (pTempBitmap != null)
2374 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2375 pHistory->SetFavIconBitmap(*pTempBitmap);
2378 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2381 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2382 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2383 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2385 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2386 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2387 pHistory->SetThumbnail(pBitmap);
2389 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2392 pHistory->SetFavIconBitmap(*pFavIcon);
2396 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2403 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2405 // temperary fixed (webpage can be not loaded)
2408 AppLog("MainForm::OnLoadingCompleted done");
2412 MainForm::OnEstimatedProgress(int progress)
2414 AppLogDebug("MainForm::OnEstimatedProgress entered");
2415 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2416 progress = DEFAULT_PROGRESS_PERCENTAGE;
2418 // __pAddressbar->UpdateProgress(progress);
2419 UpdateProgress(progress);
2422 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2424 AppLog("MainForm::OnFaviconReceived");
2425 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2427 if (pFavIconBitmap != null)
2429 pFavIconBitmap->GetWidth();
2430 pFavIconBitmap->GetHeight();
2431 AppLog("MainForm::OnFaviconReceived width = %d",pFavIconBitmap->GetWidth());
2432 AppLog("MainForm::OnFaviconReceived height = %d",pFavIconBitmap->GetHeight());
2437 MainForm::OnUrlSubmitted(Addressbar& addBar)
2439 AppLog("MainForm::OnUrlSubmitted");
2440 String url = addBar.GetUrl();
2441 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2444 __pFooterPanel->SetShowState(true);
2445 __pFooterPanel->Invalidate(true);
2446 RequestRedraw(true);
2450 MainForm::LoadUrl(String& url)
2453 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2454 AppLogDebug("MainForm::LoadUrl enter");
2456 if (__pWebViewer != null)
2458 __pWebViewer->SetShowState(true);
2459 __pWebViewer->Invalidate(true);
2462 if (encodedUrl.CompareTo(L"") == 0)
2466 if(__pFooterPanel != null)
2468 __pFooterPanel->SetShowState(true);
2469 __pFooterPanel->Invalidate(true);
2476 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2477 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)
2479 RegularExpression firstRegex;
2480 RegularExpression secondRegex;
2482 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2483 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2486 ret = firstRegex.Match(encodedUrl, false); // This returns true value
2487 flag = secondRegex.Match(encodedUrl, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2489 if (ret == true && __pWebViewer != null)
2491 __pWebViewer->LoadUrl(encodedUrl);
2493 else if(__pWebViewer != null)
2495 String tempUrl = L"http://";
2496 tempUrl.Append(encodedUrl);
2500 __pWebViewer->LoadUrl(tempUrl);
2504 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2507 if (__pAddressbar != null)
2509 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2510 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2513 AppLogDebug("MainForm::LoadUrl exit");
2520 MainForm::OnStopClicked(Addressbar& addBar)
2522 AppLogDebug("MainForm::OnStopClicked called");
2525 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2526 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2527 __pWebViewer->StopLoading();
2528 RequestRedraw(true);
2533 MainForm::OnReaderClicked(const Addressbar& addBar)
2535 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2537 CreateReaderPanel();
2538 AppLogDebug("MainScene::OnReaderClicked entered");
2541 /*if (__pArticleReaderPanel)
2543 AppLogDebug("showstate true for reader panel");
2544 __pArticleReaderPanel->SetShowState(true);
2545 __pArticleReaderPanel->Show();
2547 int xPos = __pArticleReaderPanel->GetX();
2548 int yPos = __pArticleReaderPanel->GetY();
2549 AppLog("OnReaderClicked() xPos = %d",xPos);
2550 AppLog("OnReaderClicked() yPos = %d",yPos);
2552 if (__pReaderData == null)
2557 String loadData = L"<html>\
2559 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2564 background-color: transparent;\
2583 <body style='width:'";
2584 loadData.Append(bodyWidth);
2585 loadData.Append(L"px'>");
2586 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2587 loadData.Append(*__pReaderData);
2588 loadData.Append(L"</body></html>");
2591 buf.Construct(loadData.GetLength());
2592 AppLogDebug("data->GetLength %d",loadData.GetLength());
2593 for (int z=0;z<loadData.GetLength();z++)
2596 loadData.GetCharAt(z,b);
2597 buf.SetByte((byte)b);
2601 if (__pWebReader != null)
2603 __pWebReader->LoadData(L"",buf,L"text/html");
2604 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2608 AppLogDebug("cannot LoadData __pWebReader is null");
2614 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2616 AppLog("MainForm::OnBackClicked");
2617 result r = E_FAILURE;
2619 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2621 __pWebViewer->GoBack();
2626 pApp = UiApp::GetInstance();
2629 r = pApp->Terminate();
2639 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2641 AppLog("MainForm::OnForwardClicked");
2642 if (__pWebViewer == null)
2645 if (__pWebViewer->CanGoForward())
2647 __pWebViewer->GoForward();
2652 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2654 result r = E_SUCCESS;
2655 // hiding the address bar
2656 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2657 __pAddressbar->SetShowState(false);
2659 if (__pMostVisitedListView != null && __pMostVisitedListView->GetShowState() == true)
2661 AppLog("MainForm::OnAddressCancelledClicked 1");
2662 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2663 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()/*GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14*/));
2665 if (__pMostVisitedListView != null)
2666 __pMostVisitedListView->Invalidate(true);
2669 __pFooterPanel->SetShowState(true);
2670 __pFooterPanel->Invalidate(false);
2674 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2676 __prevAddressBarMode = __curAddressBarMode;
2678 if (__pAddressbar != null)
2680 //__curAddressBarMode = __pAddressbar->GetAddressbarMode();
2681 __curAddressBarMode = GetAddressbarMode();
2684 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2686 __adressPanelPosition.y = 0;
2687 if (__pAddressbar != null)
2689 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2690 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2691 __pAddressbar->Invalidate(true);
2693 if (__pWebViewer != null)
2695 __pWebViewer->StopLoading();
2698 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2700 __adressPanelPosition.y = 0;
2701 if (__pAddressbar != null)
2704 __webControlPosition.y = 0;//__pAddressbar->GetHeight() - 12;
2705 __pAddressbar->SetBounds(Rectangle(0,__pAddressbar->GetY() - __pAddressbar->GetHeight(),GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2706 __pAddressbar->Invalidate(true);
2709 if (__pWebViewer != null)
2711 if(__pFooterPanel->GetShowState() == false)
2712 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2714 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2715 __pWebViewer->Invalidate(true);
2720 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2723 if(__pFooterPanel != null)
2725 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2726 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2728 InitMostVisitedSitesView(GetOrientationStatus());
2730 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
2731 __pFooterPanel->SetShowState(footerState);
2732 __pFooterPanel->Invalidate(false);
2737 //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");
2739 if (__pWebViewer != null && __pFooterPanel != null)
2741 AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2742 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2744 if(__pFooterPanel->GetShowState() == false)
2745 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2747 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2748 __pWebViewer->Invalidate(false);
2749 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2751 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2752 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2757 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2759 AppLog("MainForm::OnAddressBarKeypadOpened");
2761 if (__pFindWordPanel && __pFindWordPanel->GetShowState() == true)
2763 __pAddressbar->SetShowState(false);
2764 __pAddressbar->Invalidate(true);
2768 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2770 __pAddressbar->SetShowState(true);
2771 __pAddressbar->Invalidate(true);
2772 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2773 __pAddressbar->SetAddressbarURLFocus();
2778 //__pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2781 if (__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2783 AppLog("MainForm::OnAddressBarKeypadOpened 1");
2784 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2785 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pMostVisitedListView->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2787 if(__pMostVisitedListView != null)
2788 __pMostVisitedListView->Invalidate(true);
2790 else if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
2792 AppLog("MainForm::OnAddressBarKeypadOpened 2");
2793 if (__pWebViewer != null && __pAddressbar != null && __pFooterPanel != null)
2794 __pWebViewer->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pWebViewer->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2796 if(__pWebViewer != null)
2797 __pWebViewer->Invalidate(true);
2802 if (__pWebViewer != null)
2804 __pWebViewer->SetShowState(false);
2805 __pWebViewer->Invalidate(true);
2808 __pMostVisitedListView->SetShowState(true);
2809 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2810 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2812 if(__pMostVisitedListView != null)
2813 __pMostVisitedListView->Invalidate(true);
2818 __pFooterPanel->SetShowState(false);
2819 __pFooterPanel->Invalidate(true);
2823 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2825 __pFooterPanel->SetShowState(false);
2826 __pFooterPanel->Invalidate(false);
2830 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2834 __pWindowInfo->pageTitle = title;
2835 if (__pWebViewer != null)
2837 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2840 if (__pAddressbar != null && __pWebViewer != null)
2842 SetUrl(__pWebViewer->GetUrl());
2843 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2844 //__pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2845 __pAddressbar->Invalidate(true);
2851 MainForm::UpdateFavicon(void)
2853 bool urlImageType = false;
2854 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();");
2855 Bitmap* pBitmap = null;
2857 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2859 if (__pWindowInfo != null)
2862 url.SetUri(*tempPath);
2863 if (url.GetHost().GetLength() == 0)
2866 webUrl.SetUri(__pWebViewer->GetUrl());
2867 result r = url.SetHost(webUrl.GetHost());
2874 if (url.GetScheme().GetLength() == 0)
2877 webUrl.SetUri(__pWebViewer->GetUrl());
2878 url.SetScheme(webUrl.GetScheme());
2880 __pWindowInfo->faviconUrl = url.ToString();
2882 pBitmap = __pWebViewer->GetFaviconN();
2884 if (pBitmap != null)
2886 if (__pWindowInfo->pFavicon != NULL)
2888 // delete __pWindowInfo->pFavicon;
2889 __pWindowInfo->pFavicon = null;
2891 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2892 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2893 //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();
2895 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2897 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2899 else if(__pWindowInfo->pFavicon != null)
2901 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2905 __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());
2908 AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());
2915 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2922 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2923 Tizen::Web::Controls::WebNavigationType type)
2925 // when load new page if find word panel is open its show state is false
2926 ShowFindWordPanel(false);
2927 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
2929 __pFooterPanel->Invalidate(true);
2932 uriInfo.SetUri(url);
2934 if(url.Contains(IDS_TIZEN_SERVICE))
2937 String delim(L":;");
2939 // Creates a StringTokenizer instance
2940 StringTokenizer strTok(url, delim);
2942 int count = strTok.GetTokenCount(); // count == 4
2944 HashMap *pMap = new HashMap();
2950 while (strTok.HasMoreTokens())
2952 AppLog("Token: %ls", token.GetPointer());
2953 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2954 if(token.Contains(IDS_APPID))
2956 token.SubString(6, appId);
2957 AppLog("AppID:%ls", appId.GetPointer());
2959 else if(token.Contains("="))
2961 String *pKey = new String();
2962 String *pValue = new String();
2964 token.IndexOf("=", 0, index);
2967 token.SubString(0, index, *pKey);
2968 token.SubString(index + 1, *pValue);
2969 pMap->Add(pKey, pValue);
2975 AppControl *pAppControl = null;
2976 String operationId = L"http://tizen.org/appcontrol/operation/main";
2977 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2980 AppLog("Starting AppControl");
2981 result r = pAppControl->Start(null, null, pMap, null);
2982 AppLog("Result of Start %s", GetErrorMessage(r));
2986 AppLogException("AppControl not found");
2992 if (__pWebViewer && __pAddressbar)
2994 __pAddressbar->SetShowState(false);
2995 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2996 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2997 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
3001 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
3002 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3003 __pWindowInfo->faviconUrl = "";
3004 __pWindowInfo->faviconFilePath = "";
3006 if (__pWindowInfo->pFavicon != NULL)
3008 // delete __pWindowInfo->pFavicon;
3009 __pWindowInfo->pFavicon = null ;
3011 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
3015 __pAddressbar->Invalidate(true);
3021 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3022 const Tizen::Net::Http::HttpHeader& httpHeader)
3024 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3029 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3031 AppLog("MainForm::OnWebPageBlockSelected");
3032 if (__pHitElementResult != null)
3034 delete __pHitElementResult;
3035 __pHitElementResult = null;
3038 if (__pWebViewer != null)
3040 AppLog("MainForm::OnWebPageBlockSelected web not null");
3041 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3044 if (__pHitElementResult == null)
3049 if (__pHitElementResult->HasImage() != true)
3051 String tagName = __pHitElementResult->GetTagName();
3052 String type = __pHitElementResult->GetAttributeValue("type");
3054 __currentSelectedStr.Clear();
3055 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3056 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3057 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3059 if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)
3061 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3063 InitSelectTextContextMenu(endPoint,true);
3064 __pImageMenu->SetShowState(true);
3065 __pImageMenu->Show();
3066 __pImageMenu->Invalidate(true);
3068 else /*if (__pHitElementResult->HasUrl() == true )*/
3070 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3072 if(__pHitElementResult->GetUrl().GetLength() > 0)
3074 __currentSelectedStr.Clear();
3075 __currentSelectedStr = __pHitElementResult->GetUrl();
3077 InitSelectTextContextMenu(endPoint,false);
3078 __pImageMenu->SetShowState(true);
3079 __pImageMenu->Show();
3080 __pImageMenu->Invalidate(true);
3083 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3084 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3085 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3091 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3097 MainForm::OnWebWindowCreateRequested(void)
3099 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3101 if (pNewWindowInfo == null)
3105 result r = E_SUCCESS;
3106 SceneManager* pSceneManager = SceneManager::GetInstance();
3107 if (pSceneManager == NULL)
3111 ArrayList* pArgList = new(std::nothrow) ArrayList();
3112 if (pArgList == NULL)
3116 r = pArgList->Construct();
3119 pNewWindowInfo->isJavascriptInitiated = true;
3120 pArgList->Add(*pNewWindowInfo);
3121 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3125 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3132 return pNewWindowInfo->pCurrentWeb;
3136 MainForm::RelayoutControls(bool showAddressbar)
3138 if (showAddressbar == false)
3140 __pAddressbar->SetShowState(false);
3141 __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);
3142 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3146 __pAddressbar->SetShowState(true);
3147 __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);
3148 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3150 RequestRedraw(true);
3153 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3155 if (__pFindWordPanel == null)
3161 InitFindWordPanel();
3162 __pFindWordEditField->SetText(__currentSearchStr);
3163 //__pFindWordCountLabel->SetText(L"");
3164 __pFindWordCountLabel->SetText(L"0/0");
3167 AppLog("MainForm::ShowFindWordPanel %d",show);
3168 if (show && !isTouchPressed)
3170 if (__pFindWordEditField)
3172 __pFindWordEditField->SetFocus();
3173 __pFindWordEditField->ShowKeypad();
3178 if (__pFindWordEditField)
3179 __pFindWordEditField->HideKeypad();
3182 if (__pAddressbar != null)
3184 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3185 __pAddressbar->SetShowState(false);
3186 __pAddressbar->Invalidate(true);
3188 if (__pFindWordPanel != null)
3190 __pFindWordPanel->SetShowState(show);
3191 __pFindWordPanel->Invalidate(true);
3197 MainForm::StartWordSearch()
3199 //Get the count of occurances of the word in the current page
3200 __maxOccurrances = 0;
3201 __currentWordIndex = 0;
3203 __pFindWordPrev->SetEnabled(false);
3204 String *pCountStr = null;
3205 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3206 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3207 if (pCountStr != null)
3209 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3213 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3218 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3220 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3221 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3223 if(totalCount == -1 || totalCount == 0)
3225 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight());
3226 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3229 else if(totalCount > 100)
3231 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3232 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3235 __maxOccurrances = totalCount;
3236 __currentWordIndex = currentOrdinal;
3238 //Reset the UI controls as per the maxOccurrance value
3239 if (totalCount <= 0)
3241 AppLog("Word not found");
3242 //Show error notification to user
3243 __pFindWordNext->SetEnabled(false);
3244 __pFindWordCountLabel->SetText(L"0/0");
3245 __pFindWordNext->Invalidate(false);
3246 __pFindWordPrev->Invalidate(false);
3247 __pFindWordCountLabel->Invalidate(false);
3251 if (totalCount == 1)
3253 __pFindWordNext->SetEnabled(false);
3257 __pFindWordNext->SetEnabled(true);
3260 String countStr = L"";
3261 countStr.Append(__currentWordIndex);
3262 countStr.Append(L"/");
3263 countStr.Append(__maxOccurrances);
3264 __pFindWordCountLabel->SetText(countStr);
3265 // __pFindWordCountLabel->SetShowState(true);
3266 __pFindWordCountLabel->Invalidate(false);
3268 //FindNextWord(true);
3269 //Update the controls
3270 __pFindWordNext->Invalidate(false);
3271 __pFindWordPrev->Invalidate(false);
3272 __pFindWordCountLabel->Invalidate(false);
3276 MainForm::FindNextWord(bool next)
3280 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3282 if(__currentWordIndex < __maxOccurrances)
3284 __currentWordIndex++;
3290 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3292 if(__currentWordIndex > 1)
3294 __currentWordIndex--;
3299 String countStr = L"";
3300 countStr.Append(__currentWordIndex);
3301 countStr.Append(L"/");
3302 countStr.Append(__maxOccurrances);
3303 __pFindWordCountLabel->SetText(countStr);
3304 // __pFindWordCountLabel->SetShowState(true);
3305 __pFindWordCountLabel->Invalidate(false);
3306 if (__currentWordIndex >= __maxOccurrances)
3308 __pFindWordNext->SetEnabled(false);
3312 __pFindWordNext->SetEnabled(true);
3314 if (__currentWordIndex <= 1)
3316 __pFindWordPrev->SetEnabled(false);
3320 __pFindWordPrev->SetEnabled(true);
3322 __pFindWordPrev->Invalidate(false);
3323 __pFindWordNext->Invalidate(false);
3324 __pFindWordCountLabel->Invalidate(false);
3325 __pFindWordPanel->Invalidate(true);
3328 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3330 AppLog("MainForm::OnWebKeypadWillOpen");
3331 // OnAddressBarKeypadOpened(*__pAddressbar);
3335 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3338 if (__pWebViewer != null && __pFooterPanel != null)
3340 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3342 // __pFooterPanel->SetShowState(false);
3343 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3346 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3351 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3353 OnAddressBarKeypadClosed(*__pAddressbar);
3357 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3359 Control* temp = const_cast< Control* >(&source);
3360 Header* pHeader = dynamic_cast< Header* >(temp);
3361 if (pHeader != null)
3363 //Header double - clicked
3364 AppLog("Header double clicked");
3366 if(__pFindWordPanel)
3368 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3369 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3373 AppLog("MainScene::OnTouchDoublePressed");
3374 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3375 if (isReaderEnabled == true)
3379 delete __pReaderData;
3380 __pReaderData = null;
3382 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3383 filePath.Append(L"data/reader.js");
3389 result r = E_SUCCESS;
3390 FileAttributes attr;
3392 File::GetAttributes(filePath,attr);
3394 r = file.Construct(filePath, L"r+");
3397 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3400 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3403 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3406 file.Read(pScript,attr.GetFileSize());
3408 AppLogDebug("scipt length %d",strlen(pScript));
3409 String strScript = L"";
3410 strScript.Append(pScript);
3411 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3414 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3417 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3418 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3420 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3421 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3427 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3429 AppLog("MainForm::OnTouchLongPressed");
3431 if (__pHitElementResult != null)
3433 delete __pHitElementResult;
3434 __pHitElementResult = null;
3437 if (__pWebViewer != null)
3439 AppLog("MainForm::OnTouchLongPressed web not null");
3440 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3443 if (__pHitElementResult == null)
3448 if (__pHitElementResult->HasImage() == true)
3450 InitImageContextMenu(currentPosition);
3451 __pImageMenu->SetShowState(true);
3452 __pImageMenu->Show();
3453 __pImageMenu->Invalidate(true);
3457 String tagName = __pHitElementResult->GetTagName();
3458 String type = __pHitElementResult->GetAttributeValue("type");
3459 String value = __pHitElementResult->GetAttributeValue(L"value");
3460 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3462 __currentSelectedStr.Clear();
3463 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3465 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3467 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3469 InitSelectTextContextMenu(currentPosition,true, true);
3470 __pImageMenu->SetShowState(true);
3471 __pImageMenu->Show();
3472 __pImageMenu->Invalidate(true);
3474 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3479 __inputEventToBeSupressed = true;
3483 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3485 AppLog("MainForm::OnTouchReleased");
3487 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3488 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3490 __pWebViewer->ConsumeInputEvent();
3492 if(pHitElement != null)
3496 __inputEventToBeSupressed = false;
3500 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3502 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3503 int widthContextItem = 0;
3505 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3506 if (pBitmap != null && __pFooterLabel != null)
3508 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3513 __pMenu->SetShowState(false);
3514 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3517 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3521 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3524 if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3526 __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());
3527 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
3528 __pFindWordControl->SetShowState(true);
3529 __pFindWordControl->Invalidate(true);
3530 __pFindWordPanel->SetShowState(true);
3531 __pFindWordPanel->Invalidate(true);
3534 if (__pWebViewer != null && __pFooterPanel != null)
3536 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3537 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3539 if(__pFooterPanel->GetShowState() == false)
3540 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3542 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3543 __pWebViewer->Invalidate(true);
3545 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3547 if (__pAddressbar != null)
3549 if(__pAddressbar->GetShowState() == false)
3551 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3555 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3557 //__pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3558 //__pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());
3559 SetAddressbarMode(GetAddressbarMode());
3560 // __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
3562 if (__pFindWordBgLabel != null)
3564 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3565 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3566 if (pBitmap != null)
3568 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3572 if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)
3574 AppLog("__pFooterPanel->GetShowState() is true");
3576 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3577 __pFooterPanel->Invalidate(true);
3581 if(__pMoreButton && __pMenu)
3583 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3584 __pMenu->SetAnchorPosition(p);
3585 __pMenu->Invalidate(true);
3590 __pFooterPanel->Invalidate(true);
3592 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3593 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3595 InitMostVisitedSitesView(orientationStatus);
3598 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3600 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3602 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight());
3604 else if(__pAddressbar != null && __pAddressbar->GetShowState() == false)
3606 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight());
3609 if (__pArticleReaderPanel != null)
3611 if (__pArticleReaderPanel->GetShowState() == true)
3613 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3615 if (__pBlankPanel != null)
3616 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3618 if (__pWebReader != null)
3620 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3622 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3623 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3625 if ( pBitmap != null && pSrcBitmap != null)
3627 AppLog("CreateReaderPanel ninepatchbitmap found");
3628 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3631 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3632 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3633 if (pBitmap != null)
3638 if (pSrcBitmap != null)
3646 if(__pAddressbar != null)
3648 __pAddressbar->OrientationChanged();
3653 MainForm::OnSettingsChange(int settingvalue)
3655 AppLogDebug("MainForm::OnSettingsChange entered");
3656 if (__pWebViewer == null)
3658 AppLogDebug("Webviewer is not initialized yet.");
3661 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3663 WebSetting settings = __pWebViewer->GetSetting();
3664 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3666 settings.SetAutoFittingEnabled(true);
3668 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3670 settings.SetAutoFittingEnabled(false);
3672 __pWebViewer->SetSetting(settings);
3674 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3676 WebSetting settings = __pWebViewer->GetSetting();
3677 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3678 __pWebViewer->SetSetting(settings);
3680 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3682 WebSetting settings = __pWebViewer->GetSetting();
3683 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3684 __pWebViewer->SetSetting(settings);
3686 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3688 WebSetting settings = __pWebViewer->GetSetting();
3689 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3690 __pWebViewer->SetSetting(settings);
3692 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3696 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3700 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3702 WebSetting settings = __pWebViewer->GetSetting();
3703 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3705 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3709 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3711 __pWebViewer->SetSetting(settings);
3713 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3717 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3718 WebSetting settings = __pWebReader->GetSetting();
3719 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3720 __pWebReader->SetSetting(settings);
3726 MainForm::OnSettingsReset()
3730 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3731 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3736 MainForm::OnClearCache()
3738 result r = E_SUCCESS;
3740 if (__pWebViewer != NULL)
3742 r = __pWebViewer->ClearCache();
3745 AppLogDebug("Cache cleared success");
3749 AppLogDebug("Cache cleared fail");
3755 MainForm::OnClearCookie()
3757 result r = E_SUCCESS;
3759 if (__pWebViewer != NULL)
3761 __pWebViewer->ClearCookie();
3765 AppLogDebug("Cookie cleared success");
3769 AppLogDebug("Cache cleared fail");
3774 MainForm::findDistance(int x1,int y1,int x2, int y2)
3776 int deltaX = Math::Abs(x2 - x1);
3777 int deltaY = Math::Abs(y2 - y1);
3778 double num = deltaX*deltaX + deltaY*deltaY;
3784 for (i = 0; i < 20; i++)
3786 x = (((x*x)+ num)/(2*x));
3797 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3799 if(__pFindWordPanel)
3801 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3802 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3806 IList* pList = null;
3807 pList = touch.GetTouchInfoListN(source);
3811 int count = pList->GetCount();
3814 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3815 __touchPoint1 = pTouchInfo->position;
3817 /*if (__pAddressbar != null)
3819 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3821 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3823 __pAddressbar->SaveAddressbarEditText();
3825 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3828 __pAddressbar->Invalidate(true);
3830 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3832 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3834 //__pAddressbar->SaveAddressbarEditText();
3836 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3839 else if (count == 2)
3841 AppLogDebug("MainForm::OnTouchPressed count is two");
3842 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3843 __touchPoint1 = pTouchInfo->position;
3845 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3846 __touchPoint2 = pTouchInfo->position;
3852 pList->RemoveAll(true);
3859 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3861 __pWebViewer->ReleaseBlock();
3862 __currentWordIndex = 0;
3863 AppLog("Start MainForm::OnTouchMoved MoveUiControls");
3864 if(__pFindWordPanel)
3866 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3867 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3870 if (__pFindWordEditField != null)
3872 __pFindWordEditField->HideKeypad();
3875 /*if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3879 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3885 IList* pList = null;
3886 pList = touch.GetTouchInfoListN(source);
3890 int count = pList->GetCount();
3893 AppLogDebug("MainForm::OnTouchMoved count 1");
3894 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3896 if( pTouchInfo == NULL )
3900 pTouchInfo->position.y += __pWebViewer->GetY();
3901 AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);
3903 if (__isLoaded == false)
3906 __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;
3907 __touchPoint1 = pTouchInfo->position;
3909 // move the address bar and web control according to distance moved
3912 else if (count == 2)
3914 AppLogDebug("MainForm::OnTouchMoved count 2");
3918 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3920 if( pTouchInfo == NULL )
3924 Point firstPoint = pTouchInfo->position;
3926 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3927 if( pTouchInfo == NULL )
3931 Point secondPoint = pTouchInfo->position;
3933 if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))
3935 __touchPoint1 = firstPoint;
3936 __touchPoint2 = secondPoint;
3941 int currX1 = firstPoint.x;
3942 int currY1 = firstPoint.y;
3943 int currX2 = secondPoint.x;
3944 int currY2 = secondPoint.y;
3946 double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);
3947 double dist = findDistance(currX1, currY1, currX2, currY2);
3948 __distanceMoved = prevDist - dist;
3950 __touchPoint1 = firstPoint;
3951 __touchPoint2 = secondPoint;
3963 MainForm::MoveUiControls()
3968 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3970 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
3972 if(__pFooterUrlField->GetTextLength() == 0)
3974 __pFooterUrlField->SetKeypadActionEnabled(false);
3978 __pFooterUrlField->SetKeypadActionEnabled(true);
3981 if (__pFindWordEditField != null)
3983 __currentSearchStr = __pFindWordEditField->GetText();
3984 __pFindWordNext->SetEnabled(false);
3985 __pFindWordPrev->SetEnabled(false);
3986 __pFindWordNext->Invalidate(true);
3987 __pFindWordPrev->Invalidate(true);
3988 __pFindWordCountLabel->SetText(L"0/0");
3989 __pFindWordCountLabel->Invalidate(true);
3991 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3992 if (__currentSearchStr.GetLength() > 0)
3998 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4000 AppLogDebug("Enter something");
4005 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4012 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4014 if(__pWebViewer != null)
4017 AppLog("MainForm::InitMostVisitedSitesView");
4018 result r = E_SUCCESS;
4021 if (__pWebViewer != null && __pMostVisitedListView != null)
4026 if (__pMostVisitedListView != null)
4028 RemoveControl(*__pMostVisitedListView);
4030 if(__pMostVisitedSites != null)
4032 __pMostVisitedSites->RemoveAll(true);
4035 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4037 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4038 __pMostVisitedListView = new(std::nothrow) ListView();
4039 if(__pFooterPanel->GetShowState() == false)
4041 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);
4045 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);
4050 delete __pMostVisitedListView;
4051 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4054 __pMostVisitedListView->SetItemProvider(*this);
4055 __pMostVisitedListView->AddListViewItemEventListener(*this);
4056 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4057 AddControl(*__pMostVisitedListView);
4058 AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));
4059 if(__pFooterPanel->GetShowState() == false)
4060 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));
4062 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
4064 __pMostVisitedListView->UpdateList();
4071 MainForm::GetImagePath(void)
4075 String formattedTime;
4076 DateTime currentTime;
4077 LocaleManager localManager;
4078 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4080 localManager.Construct();
4081 Locale locale = localManager.GetSystemLocale();
4082 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4084 // Get date formatter
4085 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4089 pTimeFormatter->Format(currentTime, formattedTime);
4092 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4093 String delim(L" :");
4094 StringTokenizer strTok(formattedTime, delim);
4097 String str1("GMT+00");
4098 while (strTok.HasMoreTokens())
4100 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4101 if(token.Equals(str1))
4103 AppLog("token is %ls", token.GetPointer());
4104 imageName.Append(token);
4110 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4112 result r = E_FAILURE;
4113 AppLog("Content manager 1");
4114 ContentId contentId;
4115 ContentManager contentManager;
4116 r = contentManager.Construct();
4119 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4122 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4123 contentPath.Append(imageName);
4124 contentPath.Append(".jpg");
4125 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4126 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4130 MainForm::SetForwardButtonEnabled(bool isEnabled)
4132 __pGoForwardBtn->SetEnabled(isEnabled);
4133 __pGoBackBtn->Invalidate(true);
4137 MainForm::SetBackButtonEnabled(bool isEnabled)
4139 __pGoBackBtn->SetEnabled(isEnabled);
4140 __pGoBackBtn->Invalidate(true);
4144 MainForm::UpdateProgress(int percentage)
4146 __progressPercentage = percentage;
4147 if (percentage == 0 || percentage == 100)
4149 __isLoadingData = false;
4150 if (percentage == 100)
4152 __isLoadingCompleted = true;
4153 __progressPercentage = 0;
4157 __isLoadingCompleted = false;
4162 __isLoadingData = true;
4164 UpdateProgressBitmap();
4168 MainForm::GetProgress(void)
4170 return __progressPercentage;
4174 MainForm::UpdateProgressBitmap(void)
4176 result r = E_SUCCESS;
4177 if (__pProgressbarLabel == null)
4179 int w = __pProgressbarLabel->GetWidth();
4180 int h = __pProgressbarLabel->GetHeight();
4182 int progressWidth = 0;
4183 Bitmap* pRetBitmap = null;
4185 if (__progressPercentage == 0 || __progressPercentage == 100)
4187 __pProgressbarLabel->SetShowState(false);
4188 __pProgressbarLabel->Invalidate(false);
4193 __pProgressbarLabel->SetShowState(true);
4194 __pProgressbarLabel->Invalidate(false);
4197 r = canvas.Construct(Rectangle(0, 0, w, h));
4201 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4206 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4210 pBgBmp->Scale(Dimension(w, h));
4211 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4215 progressWidth = (double) (w) * __progressPercentage / 100;
4216 AppLogDebug("progressWidth: %d", progressWidth);
4217 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4219 if (pProgressBmp != null)
4221 pProgressBmp->Scale(Dimension(progressWidth, h));
4222 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4223 delete pProgressBmp;
4226 pRetBitmap = new (std::nothrow) Bitmap();
4228 if (pRetBitmap == null)
4230 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4234 pRetBitmap->Construct(canvas, canvas.GetBounds());
4236 if (__pProgressbarLabel != null && pRetBitmap != null)
4238 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4239 __pProgressbarLabel->Invalidate(false);
4242 if (pRetBitmap != null)
4250 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4252 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4254 __currentAddMode = addMode;
4258 case ADDRESSBAR_MODE_INVALID:
4263 case ADDRESSBAR_MODE_READER:
4265 __pStopBtn->SetShowState(false);
4266 __pClearBtn->SetShowState(false);
4269 case ADDRESSBAR_MODE_LOADING:
4271 __pRefreshBtn->SetShowState(false);
4272 __pStopBtn->SetShowState(true);
4273 __pClearBtn->SetShowState(false);
4276 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4278 SetUrl(__pAddressbar->GetUrl());
4280 __pRefreshBtn->SetShowState(true);
4281 __pStopBtn->SetShowState(false);
4282 __pClearBtn->SetShowState(false);
4285 case ADDRESSBAR_MODE_EDIT:
4287 __pRefreshBtn->SetShowState(false);
4288 __pStopBtn->SetShowState(false);
4289 __pClearBtn->SetShowState(true);
4296 OnAddressBarModeChanged();
4299 AddressBarMode MainForm::GetAddressbarMode(void)
4301 return __currentAddMode;
4304 void MainForm::SetUrl(const String& url)
4308 if (__pFooterUrlField != NULL)
4310 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4311 if (removedHttpUrl.IsEmpty() == false)
4313 __pFooterUrlField->SetText(removedHttpUrl);
4314 __pAddressbar->SetUrl(__displayUrl);
4318 __pFooterUrlField->SetText(__displayUrl);
4319 __pAddressbar->SetUrl(__displayUrl);
4322 __pFooterUrlField->Invalidate(false);
4323 __pAddressbar->Invalidate(true);
4324 __pFooterUrlField->SetCursorPosition(0);
4329 MainForm::RemoveHttpTextFromDisplayURL(void)
4331 bool isHttpText = __displayUrl.Contains(L"http://");
4332 String updatedDisplayUrl;
4333 updatedDisplayUrl.Clear();
4335 if (isHttpText == true)
4337 __displayUrl.SubString(7,updatedDisplayUrl);
4339 return updatedDisplayUrl;