2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
98 const int IDA_FINDWORD_NEXT_CLICKED = 202;
99 const int IDA_FINDWORD_PREV_CLICKED = 203;
100 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
101 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
103 const int IDA_COPY_IMAGE_CLICKED = 206;
104 const int IDA_VIEW_IMAGE_CLICKED = 207;
105 const int IDA_SAVE_IMAGE_CLICKED = 208;
106 const int IDA_SHARE_IMAGE_CLICKED = 209;
108 const int IDA_COPY_TEXT_CLICKED = 210;
109 const int IDA_PASTE_TEXT_CLICKED = 211;
110 const int IDA_FIND_TEXT__CLICKED = 212;
111 const int IDA_SHARE_TEXT_CLICKED = 213;
113 const int IDA_GO_BACK = 214;
114 const int IDA_GO_FORWARD = 215;
115 const int IDA_REFRESH_BTN_CLICKED = 216;
116 const int IDA_STOP_BTN_CLICKED = 217;
117 const int IDA_CLEAR_URL = 218;
119 const int IDA_HYPERLINK_OPEN_CLICKED = 219;
120 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220;
121 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
122 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
124 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
126 const int MainForm::IDA_FORMAT_BITMAP = 500;
127 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
128 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
129 const int MainForm::IDA_FORMAT_URL_STRING = 503;
130 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
132 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
133 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
134 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
136 MainForm::MainForm(void)
138 __isLongPressedDone = false;
139 __pAddressbar = null;
140 // __pMostVisitedSitesPanel = null;
141 __pMostVisitedListView = null;
142 __pFooterPanel = null;
143 __pHitElementResult = null;
144 __pWindowInfo = null;
148 __pFindWordControl = null;
150 __pFindWordBgLabel = null;
151 __pFindWordEditField = null;
152 __pFindWordClear = null;
153 __pFindWordCountLabel = null;
154 __pFindWordNext = null;
155 __pFindWordPrev = null;
156 __previousZoomLevel = 1.0;
158 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
161 __currentSearchStr = L"";
162 __currentSelectedStr = L"";
163 __maxOccurrances = 0;
164 __currentWordIndex = 0;
167 __inputEventToBeSupressed = false;
168 __isLoadingData = false;
169 __isLoadingCompleted = false;
170 __progressPercentage = 0;
171 __touchPoint1 = Point(-1,-1);
172 __touchPoint2 = Point(-1,-1);
174 // __pReaderPopup = null;
175 __pReaderData = null;
177 __pReaderCloseBtn = null;
178 //__pNewWindowButton = null;
179 __pMoreButton = null;
180 __pMultiWindowButton = null;
181 __pArticleReaderPanel = null;
182 __pBlankPanel = null;
183 __pArticleReaderLabel = null;
184 __webControlHeight = 0;
185 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
186 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
187 __pMostVisitedSites = null;
188 __pFooterUrlField = null;
190 __pGoForwardBtn = null;
191 __pRefreshBtn = null;
192 __pProgressbarLabel = null;
193 __pFooterLabel = null;
196 __isWebKeypadOpened = false;
199 MainForm::~MainForm(void)
201 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
205 __pAddressbar->SetAddressbarEventListener(null);
207 if (__pReaderData != null)
209 delete __pReaderData;
210 __pReaderData = null;
213 if (__pPopUp != null)
219 if (__pHitElementResult != null)
221 delete __pHitElementResult;
222 __pHitElementResult = null;
225 String* pSelectedScene = NULL;
226 Object* pValue = NULL;
227 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
228 pSelectedScene = (String*) pValue;
230 /*if (pSelectedScene != null)
232 delete pSelectedScene;
234 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
238 MainForm::Initialize(void)
240 Construct(L"IDL_FORM");
245 MainForm::OnInitializing(void)
247 AppLog("get client area width = %d",GetClientAreaBounds().width);
248 AppLog("get client area height = %d",GetClientAreaBounds().height);
249 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
250 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
252 Panel* pFooterPanel = null;
254 __pSaveImage = new Image();
255 __pSaveImage->Construct();
257 // Setup back event listener
258 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
259 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
260 AddOrientationEventListener(*this);
261 AppLogDebug(" MainForm::OnInitializing ended");
262 if (__pMostVisitedSites == null)
264 __pMostVisitedSites = new(std::nothrow) ArrayList();
265 __pMostVisitedSites->Construct();
267 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
269 __pItemContext= new(std::nothrow) ListContextItem();
270 __pItemContext->Construct();
271 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
272 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
274 if (pBitmapNormal != null && pBitmapPressed != null)
276 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
279 if (pBitmapNormal != null)
281 delete pBitmapNormal;
284 if (pBitmapPressed != null)
286 delete pBitmapPressed;
289 __pItemContextLandscape= new(std::nothrow) ListContextItem();
290 __pItemContextLandscape->Construct();
291 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
292 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
294 if (pBitmapNormal != null && pBitmapPressed != null)
296 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
299 if (pBitmapNormal != null)
301 delete pBitmapNormal;
304 if (pBitmapPressed != null)
306 delete pBitmapPressed;
313 MainForm::InitAddressbar(void)
315 AppLogDebug("MainForm::InitAddressbar entered");
317 result r = E_SUCCESS;
319 if (__pAddressbar != null)
323 __pAddressbar = new(std::nothrow) Addressbar();
324 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
325 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
328 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
331 __pAddressbar->SetAddressbarEventListener(this);
332 AddControl(*__pAddressbar);
333 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
334 SetControlAlwaysOnTop(*__pAddressbar, true);
335 __adressPanelPosition = __pAddressbar->GetPosition();
337 AppLogDebug("MainForm::InitAddressbar exit");
343 MainForm::CreateReaderPanel(void)
345 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
346 result r = E_FAILURE;
348 Button *pSmallFontBtn = null;
349 Button *pLargeFontBtn = null;
351 __pBlankPanel = new (std::nothrow) Panel();
352 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
354 __pArticleReaderPanel = new (std::nothrow) Panel();
355 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
357 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
358 if (__pReaderCloseBtn)
360 AppLogDebug("CreateReaderPanel() 6");
361 __pReaderCloseBtn->AddActionEventListener(*this);
362 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
365 __pWebReader = new (std::nothrow) Web();
366 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
368 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
369 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
371 r = __pWebReader->SetSetting(settings);
373 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
376 __pArticleReaderLabel = new Label();
377 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
379 __pBlankPanel->AddControl(*__pArticleReaderLabel);
380 __pBlankPanel->AddControl(*__pArticleReaderPanel);
381 AddControl(*__pBlankPanel);
383 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
384 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
385 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
387 __pArticleReaderPanel->AddControl(*__pWebReader);
388 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
389 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
390 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
392 if (pBitmap != null && pSrcBitmap != null)
394 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
396 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
398 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
401 pSmallFontBtn->AddActionEventListener(*this);
402 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
405 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
408 pLargeFontBtn->AddActionEventListener(*this);
409 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
418 if (pSrcBitmap != null)
424 SetControlAlwaysOnTop(*__pBlankPanel, true);
425 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
432 MainForm::InitWebControl()
434 AppLogDebug("MainForm::InitWebControl enter");
435 result r = E_SUCCESS;
436 AppLogDebug("InitWebControl");
438 if (__pAddressbar == null || __pFooterPanel == null)
441 const int Y_WEBCONTROL_POSITION = 0;
442 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
443 if (__pMostVisitedListView)
445 __pMostVisitedListView->SetShowState(false);
447 if (__pWebViewer != null)
449 AppLogDebug("Already initialized");
452 __pWebViewer = new(std::nothrow) Web();
453 if(__pWebViewer == NULL)
455 AppLogDebug("Initialization failed");
458 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
462 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
469 r = AddControl(*__pWebViewer);
475 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
478 __webControlPosition = __pWebViewer->GetPosition();
479 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
482 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
486 __pWebViewer->SetLoadingListener(this);
487 __pWebViewer->SetWebUiEventListener(this);
488 __pWebViewer->SetWebKeypadEventListener(this);
489 __pWebViewer->SetFocus();
490 __pWebViewer->AddTouchEventListener(*this);
492 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
493 __pWebViewer->SetTextSearchListener(this);
496 AppLogDebug("MainForm :before return");
498 AppLogDebug("MainForm::InitWebControl Exit");
504 MainForm::OnFocusGained(const Control& source)
506 AppLog("MainForm::OnFocusGained");
510 MainForm::OnFocusLost(const Control& source)
512 AppLog("MainForm::OnFocusLost");
516 MainForm::SetJavascriptEnabled()
518 WebSetting settings = __pWebViewer->GetSetting();
519 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
520 __pWebViewer->SetSetting(settings);
524 MainForm::SetImageLoadEnabled()
526 WebSetting settings = __pWebViewer->GetSetting();
527 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
528 __pWebViewer->SetSetting(settings);
532 MainForm::InitFooter(void)
534 AppLogDebug("MainForm::InitFooter entered");
535 Button* pBackButton = null;
536 Button* pBookmarkButton = null;
537 Button* pMultiWindowButton = null;
538 Bitmap *pIconBitmap = null;
539 Bitmap *pBGBitmap = null;
540 Label *pBGLabel = null;
542 if (__pFooterPanel == null)
544 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
547 if (__pFooterPanel == null)
552 SetControlAlwaysOnTop(*__pFooterPanel, true);
554 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
555 if ( __pFooterLabel == NULL )
559 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
560 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
563 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
567 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
569 if ( __pMultiWindowButton == NULL )
574 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
576 if ( __pMoreButton == NULL )
581 if (__pMultiWindowButton != null)
583 Bitmap* pBitmap = null;
584 Bitmap* pPressedBitmap = null;
585 String imagePath = "I01_toolbar_icon_windows_manager_0";
586 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
587 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
588 imagePath.Append(totalCount);
589 imagePath.Append(".png");
591 pressedImagePath.Append(totalCount);
592 pressedImagePath.Append("_press.png");
594 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
595 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
596 if ( pBitmap == null )
601 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
604 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
605 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
610 __pMultiWindowButton->AddActionEventListener(*this);
611 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
616 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
617 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
620 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
621 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
622 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
626 __pMoreButton->AddActionEventListener(*this);
627 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
630 //Add the editfield for url
631 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
632 if (__pFooterUrlField == NULL)
634 return E_INVALID_KEY;
637 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
638 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
639 //__pFooterUrlField->AddFocusEventListener(*this);
640 __pFooterUrlField->AddKeypadEventListener(*this);
641 //__pFooterUrlField->AddFocusEventListener(*this);
642 __pFooterUrlField->SetPropagatedTouchEventListener(this);
644 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
648 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
650 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
654 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
655 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
659 //Add the go Back Button
660 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
661 if (__pGoBackBtn == NULL)
663 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
664 return E_INVALID_KEY;
666 __pGoBackBtn->SetActionId(IDA_GO_BACK);
667 __pGoBackBtn->AddActionEventListener(*this);
669 //Add the go forward Button
670 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
671 if (__pGoForwardBtn == NULL)
673 AppLogDebug("Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
676 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
677 __pGoForwardBtn->AddActionEventListener(*this);
678 __pGoForwardBtn->SetEnabled(false);
680 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
681 if (__pRefreshBtn == NULL)
683 AppLogDebug("Control not found returning E_INVALID_KEY");
684 return E_INVALID_KEY;
687 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
688 __pRefreshBtn->AddActionEventListener(*this);
689 __pRefreshBtn->SetShowState(true);
691 //Add the backround label for displaying progressbar
692 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
693 if (__pProgressbarLabel == NULL)
695 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
696 return E_INVALID_KEY;
698 __pProgressbarLabel->SetShowState(false);
700 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
701 if (__pStopBtn == NULL)
703 AppLogDebug("Control not found returning E_INVALID_KEY");
704 return E_INVALID_KEY;
706 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
707 __pStopBtn->AddActionEventListener(*this);
708 __pStopBtn->SetShowState(false);
710 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
711 if (__pClearBtn == NULL)
713 AppLogDebug("Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
716 __pClearBtn->SetActionId(IDA_CLEAR_URL);
717 __pClearBtn->AddActionEventListener(*this);
718 __pClearBtn->SetShowState(false);
720 // __pFooterPanel->Invalidate(true);
721 AppLogDebug("MainForm::InitFooter exit");
727 MainForm::InitContextMenu(Point& p)
729 result r = E_SUCCESS;
730 bool isPrivateBrowsing = false;
731 Bitmap* pBitmap = null;
735 __pMenu->SetAnchorPosition(p);
736 __pMenu->Invalidate(true);
740 __pMenu = new(std::nothrow) ContextMenu();
741 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
742 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
744 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
747 if (isPrivateBrowsing == true)
749 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
753 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
756 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
758 if ( pBitmap != NULL)
760 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
763 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
764 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
765 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
768 __pMenu->SetMaxVisibleItemsCount(6);
769 __pMenu->SetShowState(false);
770 __pMenu->AddActionEventListener(*this);
771 SetControlAlwaysOnTop(*__pMenu, true);
777 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
779 result r = E_SUCCESS;
780 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
782 AppLog("MainForm::InitImageContextMenu clicked on image");
783 if (__pImageMenu != null)
789 // p.y = p.y + __pAddressbar->GetHeight() + 12;
790 // AppLog("vinaypy %d",p.y);
793 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
797 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
799 __pImageMenu = new (std::nothrow) ContextMenu();
800 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
801 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
803 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
804 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
805 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
806 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
807 __pImageMenu->SetMaxVisibleItemsCount(4);
808 __pImageMenu->AddActionEventListener(*this);
809 SetControlAlwaysOnTop(*__pImageMenu, true);
815 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
817 result r = E_SUCCESS;
818 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
820 AppLog("MainForm::InitImageContextMenu clicked on image");
821 if (__pImageMenu != null)
827 p.y = p.y + __pAddressbar->GetHeight() + 12;
830 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
834 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
836 __pImageMenu = new (std::nothrow) ContextMenu();
837 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
838 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
840 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
841 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
842 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
843 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
845 __pImageMenu->SetMaxVisibleItemsCount(3);
846 __pImageMenu->AddActionEventListener(*this);
847 SetControlAlwaysOnTop(*__pImageMenu, true);
853 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
855 result r = E_SUCCESS;
856 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
857 if(onlyPasteOption == true)
860 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
861 if (__pImageMenu != null)
866 p.y = p.y + __pAddressbar->GetHeight() + 12;
869 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
873 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
875 __pImageMenu = new (std::nothrow) ContextMenu();
876 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
877 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
879 if(onlyPasteOption == false)
881 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
883 if (pasteOption || onlyPasteOption)
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
887 if(onlyPasteOption == false)
889 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
890 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
893 __pImageMenu->SetMaxVisibleItemsCount(3);
894 __pImageMenu->AddActionEventListener(*this);
895 SetControlAlwaysOnTop(*__pImageMenu, true);
902 MainForm::InitFindWordPanel(void)
904 result r = E_SUCCESS;
905 Bitmap *pIconBitmap = null;
907 if (__pFindWordControl != null)
909 AppLogDebug("Findword panel already initialized");
910 if (__pFindWordBgLabel != null)
912 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
915 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
922 __pFindWordControl = new (std::nothrow) Panel();
923 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
926 AppLogException("There is some problem in the xml file. Please check.");
929 AddControl(*__pFindWordControl);
930 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
931 SetControlAlwaysOnTop(*__pFindWordControl,true);
932 __pFindWordControl->SetShowState(false);
933 __pFindWordControl->Invalidate(false);
935 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
936 if (__pFindWordBgLabel != null)
938 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
939 Rectangle pRect = pPanel1->GetBounds();
940 pRect.x = pRect.y = 0;
941 __pFindWordBgLabel->SetBounds(pRect);
942 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
945 AppLogDebug("InitFindWordPanel: Coming here");
946 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
951 AppLogDebug("InitFindWordPanel: shouldn't Come here");
955 Button* pfindWordCancel = null;
956 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
957 if (pfindWordCancel == null)
959 AppLogException("There is some problem in the xml file. Please check.");
962 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
963 pfindWordCancel->AddActionEventListener(*this);
965 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
966 if (__pFindWordClear == null)
968 AppLogException("There is some problem in the xml file. Please check.");
972 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
973 __pFindWordClear->AddActionEventListener(*this);
975 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
976 if (__pFindWordNext == null)
978 AppLogException("There is some problem in the xml file. Please check.");
982 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
983 __pFindWordNext->AddActionEventListener(*this);
985 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
986 if (__pFindWordPrev == null)
988 AppLogException("There is some problem in the xml file. Please check.");
992 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
993 __pFindWordPrev->AddActionEventListener(*this);
995 __pFindWordNext->SetEnabled(false);
996 __pFindWordPrev->SetEnabled(false);
998 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
999 if (__pFindWordCountLabel == null)
1001 AppLogException("There is some problem in the xml file. Please check.");
1005 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1006 if (__pFindWordEditField == null)
1008 AppLogException("There is some problem in the xml file. Please check.");
1011 __pFindWordEditField->AddTextEventListener(*this);
1012 __pFindWordEditField->AddKeypadEventListener(*this);
1013 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1019 MainForm::CreateItem (int index, int itemWidth)
1021 Rectangle listImageRect;
1022 Rectangle pagetTitleRect;
1023 Rectangle pageURLRect;
1024 Rectangle deleteImageRect;
1025 String pageTitle(L"");
1026 String pageURL(L"");
1027 result r = E_SUCCESS;
1028 Bitmap* pListIconImage = null;
1031 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1032 if(pHistory == null)
1036 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1037 if ( pAppResource == NULL )
1041 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1043 CustomItem* pItem = new(std::nothrow) CustomItem();
1044 pageTitle = pHistory->GetHistoryTitle();
1045 pageURL = pHistory->GetHistoryUrl();
1047 if (pageURL.GetLength() == 0)
1050 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1051 pageURL = L"<"+ nourl +">";
1055 Rectangle screenBounds = GetBounds();
1058 r = pItem->Construct(Dimension(itemWidth, 128), style);
1067 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1069 if ( pBitmap != NULL)
1071 pListIconImage = new Bitmap();
1072 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1076 if(pListIconImage == null)
1078 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1081 if ( pListIconImage != NULL)
1083 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1084 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1085 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1088 if (pItem != null && pListIconImage != NULL)
1090 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1094 if (pageTitle.CompareTo(L"") != 0)
1098 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1102 if (pageURL.CompareTo(L"") != 0)
1106 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1111 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1113 if ( __pItemContext!= NULL)
1117 pItem->SetContextItem(__pItemContext);
1123 if ( __pItemContextLandscape!= NULL)
1127 pItem->SetContextItem(__pItemContextLandscape);
1131 if( pListIconImage != NULL)
1133 delete pListIconImage;
1134 pListIconImage = null;
1141 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1148 MainForm::GetItemCount (void)
1150 if(__pMostVisitedSites != null)
1152 __pMostVisitedSites->RemoveAll(true);
1154 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1155 if(__pMostVisitedSites != null)
1157 return __pMostVisitedSites->GetCount();
1164 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1166 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1167 String url = pHistory->GetHistoryUrl();
1168 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1169 __pMostVisitedListView->UpdateList();
1173 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1175 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1176 String url = pHistory->GetHistoryUrl();
1184 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1190 MainForm::OnTerminating(void)
1192 result r = E_SUCCESS;
1195 delete __pItemContext;
1197 if(__pItemContextLandscape)
1199 delete __pItemContextLandscape;
1205 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1207 result r = E_SUCCESS;
1209 AppLogDebug("Clicked : %d", actionId);
1212 // case IDA_BACKBTN_CLICKED:
1214 // if (__pWebViewer && __pWebViewer->CanGoBack())
1216 // __pWebViewer->GoBack();
1220 // UiApp* pApp = null;
1221 // pApp = UiApp::GetInstance();
1222 // if (pApp != null)
1224 // r = pApp->Terminate();
1227 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1235 case IDA_BACKBTN_CLICKED:
1237 if (__pWebViewer && __pWebViewer->CanGoBack())
1239 __pWebViewer->GoBack();
1241 else if(__pWindowInfo->isJavascriptInitiated == false)
1244 pApp = UiApp::GetInstance();
1247 r = pApp->Terminate();
1250 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1258 WindowInfo* pWindowInfo = null;
1260 SceneManager* pSceneManager = SceneManager::GetInstance();
1261 if (pSceneManager == null)
1265 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1266 if (pAllWindowList == NULL)
1268 pApp = UiApp::GetInstance();
1271 r = pApp->Terminate();
1274 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1279 if (pAllWindowList != null)
1281 totalCount = pAllWindowList->GetCount();
1283 for (int count = 0; count < totalCount; count++)
1285 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1286 if (pWindowInfo == null)
1288 pApp = UiApp::GetInstance();
1291 r = pApp->Terminate();
1294 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1299 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1301 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1304 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1307 r = pAllWindowList->RemoveAt(count, true);
1308 __pWindowInfo = null;
1311 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1316 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1320 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1322 if (pWindowInfo == null)
1324 pApp = UiApp::GetInstance();
1327 r = pApp->Terminate();
1333 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1336 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1349 case IDA_FORWARD_CLICKED:
1350 if (__pWebViewer == null)
1353 if (__pWebViewer->CanGoForward())
1355 __pWebViewer->GoForward();
1357 __pMenu->SetShowState(false);
1358 __pMenu->Invalidate(false);
1361 case IDA_FINDONPAGE_CLICKED:
1363 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1364 __currentSearchStr.Clear();
1366 InitFindWordPanel();
1367 __pMenu->SetShowState(false);
1368 __pMenu->Invalidate(false);
1370 __pFindWordEditField->SetFocus();
1372 if (__pWebViewer != null)
1374 // releasing the set block
1375 __pWebViewer->ReleaseBlock();
1378 ShowFindWordPanel(true);
1381 case IDA_PRIVATEON_CLICKED:
1383 result r = E_SUCCESS;
1385 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1386 Bitmap* pBitmap = null;
1387 if (isPrivateBrowsing == true)
1389 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1392 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1396 if (__pWebViewer != NULL)
1398 __pWebViewer->SetPrivateBrowsingEnabled(false);
1401 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1403 if (__pAddressbar != null)
1405 __pAddressbar->UpdateFaviconBitmap(false);
1411 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1414 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1418 if (__pWebViewer != NULL)
1420 __pWebViewer->SetPrivateBrowsingEnabled(true);
1423 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1425 if (__pAddressbar != null)
1427 __pAddressbar->UpdateFaviconBitmap(true);
1432 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1433 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1434 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1435 __pMenu->Invalidate(true);
1437 if ( pBitmap != NULL )
1444 case IDA_SETTINGS_CLICKED:
1447 ArrayList* pArgList = new(std::nothrow) ArrayList();
1450 pArgList->Construct();
1451 pArgList->Add(*__pWindowInfo);
1452 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1454 __pMenu->SetShowState(false);
1455 __pMenu->Invalidate(false);
1456 if (pArgList != null)
1465 case IDA_ADDTOBOOKMARK_CLICKED:
1468 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1470 int bookmarkCount=0;
1473 url=__pWindowInfo->pageUrl;
1474 result r = E_SUCCESS;
1475 Bitmap* pBitmap = null;
1476 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1484 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1485 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1486 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1488 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1489 if (pNotification != null)
1491 pNotification->SetText(message);
1492 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1493 pNotification->ShowNotification();
1498 String title=__pWindowInfo->pageTitle;
1499 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1500 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1502 pBookmark->SetBookmarkTitle(title);
1503 pBookmark->SetUrl(url);
1504 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1506 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1508 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1509 pBookmark->SetFaviconId(id);
1510 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1511 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1514 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1515 if (pNotification != null)
1517 pNotification->SetText(message);
1518 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1519 pNotification->ShowNotification();
1520 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1523 if (pBitmap != null)
1525 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1529 __pMenu->Invalidate(true);
1533 case IDA_SHARE_CLICKED:
1535 if(__pPopUp != null)
1540 __pPopUp = new(std::nothrow) SharePopup();
1541 __pPopUp->Initialize();
1542 if (__pWindowInfo != null)
1544 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1545 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1546 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1547 pShareInfo->SetImageAttached(false);
1548 __pPopUp->RemoveAllShareInfo();
1549 __pPopUp->AddShareInfo(pShareInfo);
1551 __pPopUp->SetShowState(true);
1555 case IDA_BOOKMARKBTN_CLICKED:
1557 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1558 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1561 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1566 case IDA_MOREBTN_CLICKED:
1568 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1569 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1570 AppLog("Anchot pos: %d %d", p.x, p.y);
1572 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1574 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1575 int bookmarkCount=0;
1578 url=__pWindowInfo->pageUrl;
1579 result r = E_SUCCESS;
1580 Bitmap* pBitmap = null;
1582 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1585 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1590 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1594 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1596 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1598 if (__pMenu->GetItemCount() == 8)
1600 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1604 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1609 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1613 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1614 if (__pMenu->GetItemCount() != 8)
1616 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1618 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1619 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1620 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1621 __pMenu->SetMaxVisibleItemsCount(6);
1623 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1625 AppLog(" Orientation landscape");
1626 __pMenu->SetMaxVisibleItemsCount(5);
1630 AppLog(" Orientation potrait");
1631 __pMenu->SetMaxVisibleItemsCount(6);
1634 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1637 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1638 __pMenu->SetShowState(true);
1639 __pMenu->Invalidate(true);
1643 case IDA_HISTORY_CLICKED:
1645 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1646 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1649 case IDA_SAVED_PAGES_CLICKED:
1654 case IDA_DESKTOP_VIEW_CLICKED:
1659 case IDA_SAVE_CLICKED:
1664 case IDA_MULTIWINDOWBTN_CLICKED:
1666 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1667 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1671 case IDA_NEWWINDOWBTN_CLICKED:
1673 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1675 if (pNewWindowInfo == null)
1679 result r = E_SUCCESS;
1680 SceneManager* pSceneManager = SceneManager::GetInstance();
1682 if (pSceneManager == NULL)
1686 ArrayList* pArgList = new(std::nothrow) ArrayList();
1687 if (pArgList == NULL)
1691 r = pArgList->Construct();
1694 pArgList->Add(*pNewWindowInfo);
1695 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1701 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1706 case IDA_SMALLFONT_BTN_CLICKED:
1708 WebSetting setting = __pWebReader->GetSetting();
1709 setting.SetFontSize(15);
1710 __pWebReader->SetSetting(setting);
1713 case IDA_LARGEFONT_BTN_CLICKED:
1715 WebSetting setting = __pWebReader->GetSetting();
1716 setting.SetFontSize(25);
1717 __pWebReader->SetSetting(setting);
1720 case IDA_READER_CLOSE_CLICKED:
1722 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1724 //__pArticleReaderPanel->SetShowState(false);
1725 //__pArticleReaderPanel->Show();
1726 RemoveControl(*__pBlankPanel);
1727 //RemoveControl(*__pArticleReaderPanel);
1728 __pArticleReaderPanel = null;
1729 __pBlankPanel = null;
1730 __pArticleReaderLabel = null;
1732 //if (__pAddressbar)
1733 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1734 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1737 case IDA_FINDWORD_CANCEL_CLICKED:
1739 __currentSearchStr = L"";
1740 __currentWordIndex = 0;
1741 __maxOccurrances = 0;
1742 __pFindWordEditField->SetText(L"");
1743 __pFindWordNext->SetEnabled(false);
1744 __pFindWordPrev->SetEnabled(false);
1745 __pFindWordCountLabel->SetText(L"0/0");
1746 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1747 ShowFindWordPanel(false);
1750 case IDA_FINDWORD_SEARCH_CLICKED:
1752 __currentSearchStr = __pFindWordEditField->GetText();
1753 if (__currentSearchStr.GetLength() > 0)
1759 AppLogDebug("Enter something");
1763 case IDA_FINDWORD_CLEAR_CLICKED:
1765 __pFindWordCountLabel->SetText(L"0/0");
1766 __pFindWordEditField->SetText(L"");
1767 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1769 __currentSearchStr = L"";
1770 __pFindWordNext->SetEnabled(false);
1771 __pFindWordPrev->SetEnabled(false);
1772 __pFindWordControl->Invalidate(true);
1775 case IDA_FINDWORD_NEXT_CLICKED:
1780 case IDA_FINDWORD_PREV_CLICKED:
1782 FindNextWord(false);
1785 case IDA_BRIGHTNESS_BTN_CLICKED:
1787 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1788 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1791 case IDA_COPY_IMAGE_CLICKED:
1793 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1794 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1796 const Bitmap* pBitmap = null;
1797 if (__pHitElementResult != null)
1799 pBitmap = __pHitElementResult->GetImage();
1802 String resourcePath = App::GetInstance()->GetAppResourcePath();
1803 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1805 // copying the item to clipboard
1806 Clipboard* pClipboard = Clipboard::GetInstance();
1807 if (pClipboard != null)
1809 pClipboard->CopyItem(item);
1813 case IDA_VIEW_IMAGE_CLICKED:
1815 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1816 WindowInfo* pNewWindowInfo = null;
1817 if (__pHitElementResult != null)
1819 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1820 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1826 case IDA_SAVE_IMAGE_CLICKED:
1828 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1829 const Bitmap* pSaveBitmap = null;
1830 String imageName = GetImagePath();
1831 AppLog("Content manager image name %ls",imageName.GetPointer());
1834 imagePath.Append(imageName);
1835 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1836 AppLog("Content manager image path %ls",imagePath.GetPointer());
1837 if (__pHitElementResult != null)
1839 pSaveBitmap = __pHitElementResult->GetImage();
1841 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1845 UpdateImageContent(pBuffer, imageName);
1847 NotificationPanel *pNotification = new NotificationPanel(*this);
1849 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1850 msg.Append(imagePath);
1851 if (pNotification != null)
1853 pNotification->SetText(msg);
1854 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1855 pNotification->ShowNotification();
1860 int __modalMsgBoxResult;
1861 MessageBox* pMsgBox = new MessageBox();
1862 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1863 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1866 __modalMsgBoxResult = 0;
1870 case IDA_SHARE_IMAGE_CLICKED:
1872 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1873 if (__pPopUp != null)
1878 __pPopUp = new(std::nothrow) SharePopup();
1879 __pPopUp->Initialize();
1880 if (__pHitElementResult != null)
1882 const Bitmap* pSaveBitmap = null;
1883 String imageName = GetImagePath();
1884 AppLog("Content manager image name %ls",imageName.GetPointer());
1887 imagePath.Append(imageName);
1888 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1889 AppLog("Content manager image path %ls",imagePath.GetPointer());
1890 if (__pHitElementResult != null)
1892 pSaveBitmap = __pHitElementResult->GetImage();
1894 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1896 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1897 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1899 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1900 pShareInfo->SetPageTitle(L"");
1901 pShareInfo->SetPageUrl(srcUrl);
1902 pShareInfo->SetImageAttached(true);
1903 pShareInfo->SetImagePath(imagePath);
1904 __pPopUp->RemoveAllShareInfo();
1905 __pPopUp->AddShareInfo(pShareInfo);
1906 __pPopUp->SetShowState(true);
1911 case IDA_HYPERLINK_OPEN_CLICKED:
1913 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1914 WindowInfo* pNewWindowInfo = null;
1915 if (__pHitElementResult != null)
1917 String srcUrl = __pHitElementResult->GetUrl();
1918 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1923 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
1925 if (__pHitElementResult == null)
1930 if(__pPopUp != null)
1935 __pPopUp = new(std::nothrow) SharePopup();
1936 __pPopUp->Initialize();
1938 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1939 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
1940 pShareInfo->SetImageAttached(false);
1941 __pPopUp->RemoveAllShareInfo();
1942 __pPopUp->AddShareInfo(pShareInfo);
1944 __pPopUp->SetShowState(true);
1948 case IDA_HYPERLINK_COPY_LINK_CLICKED:
1952 if (__pHitElementResult != null)
1954 url = __pHitElementResult->GetUrl();
1957 String resourcePath = App::GetInstance()->GetAppResourcePath();
1958 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
1960 // copying the item to clipboard
1961 Clipboard* pClipboard = Clipboard::GetInstance();
1962 if (pClipboard != null)
1964 pClipboard->CopyItem(item);
1968 case IDA_FIND_TEXT__CLICKED:
1970 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1971 __currentSearchStr.Clear();
1972 __currentSearchStr.Append(__currentSelectedStr);
1973 InitFindWordPanel();
1974 __pFindWordEditField->SetText(__currentSearchStr);
1977 __pMenu->SetShowState(false);
1978 __pMenu->Invalidate(false);
1981 __adressPanelPosition.y = 0;
1983 if (__pAddressbar != null && __pWebViewer != NULL)
1985 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1986 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1987 //__pAddressbar->Invalidate(true);
1988 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
1990 if (__pFooterPanel->GetShowState() == false)
1991 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
1993 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1994 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1995 __pWebViewer->Invalidate(true);
1998 ShowFindWordPanel(true);
1999 __pFindWordEditField->SetFocus();
2000 if (__currentSearchStr.GetLength() > 0)
2006 AppLogDebug("Enter something");
2009 if (__pWebViewer != null)
2011 // releasing the set block
2012 __pWebViewer->ReleaseBlock();
2017 case IDA_SHARE_TEXT_CLICKED:
2019 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2020 if(__pPopUp != null)
2025 __pPopUp = new(std::nothrow) SharePopup();
2026 __pPopUp->Initialize();
2027 if (__pHitElementResult != null)
2029 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2030 pShareInfo->SetPageTitle(L"");
2031 pShareInfo->SetPageUrl(__currentSelectedStr);
2032 pShareInfo->SetImageAttached(false);
2033 __pPopUp->RemoveAllShareInfo();
2034 __pPopUp->AddShareInfo(pShareInfo);
2035 __pPopUp->SetShowState(true);
2040 case IDA_COPY_TEXT_CLICKED:
2042 __pWebViewer->ReleaseBlock();
2043 // need to implement
2044 //__currentSelectedStr
2045 // Sets data to a clip board item
2047 String resourcePath = App::GetInstance()->GetAppResourcePath();
2048 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2050 // copying the item to clipboard
2051 Clipboard* pClipboard = Clipboard::GetInstance();
2052 if (pClipboard != null)
2054 pClipboard->CopyItem(item);
2058 case IDA_PASTE_TEXT_CLICKED:
2060 Clipboard* pClipboard = Clipboard::GetInstance();
2062 if(pClipboard == null)
2066 // Retrieves a latest item
2067 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2073 //Gets data from the clipboard item
2074 String* pString = dynamic_cast<String*>(pItem->GetData());
2076 if (pString != null)
2078 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2079 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2080 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2081 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; } } ";
2082 if(idElement.GetLength() != 0)
2084 script.Append("insertAtCursor(");
2085 script.Append(idElement);
2087 script.Append("\"");
2088 script.Append(*pString);
2089 script.Append("\");");
2091 else if (nameElement.GetLength() != 0)
2093 script.Append("insertAtCursor(document.getElementsByName('");
2094 script.Append(nameElement);
2095 script.Append("')[0],");
2096 script.Append("\"");
2097 script.Append(*pString);
2098 script.Append("\");");
2100 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2101 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2112 case IDA_GO_FORWARD:
2117 case IDA_REFRESH_BTN_CLICKED:
2119 __isLoadingCompleted = false;
2120 __isLoadingData = true;
2121 __progressPercentage = 0;
2122 __displayUrl = __pFooterUrlField->GetText();
2124 String url = __pFooterUrlField->GetText();
2125 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2129 UpdateProgressBitmap();
2132 case IDA_STOP_BTN_CLICKED:
2134 __isLoadingCompleted = false;
2135 __isLoadingData = false;
2136 __progressPercentage = 0;
2137 __pFooterUrlField->HideKeypad();
2138 __displayUrl = __pFooterUrlField->GetText();
2142 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2143 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2144 __pWebViewer->StopLoading();
2145 RequestRedraw(true);
2148 UpdateProgressBitmap();
2153 if (__pFooterUrlField->GetText().IsEmpty() == false)
2155 //__displayUrl = __pUrlField->GetText();
2156 __pFooterUrlField->Clear();
2166 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2169 UiApp* pApp = UiApp::GetInstance();
2178 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2179 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2181 String* pSelectedScene = NULL;
2182 Object* pValue = NULL;
2183 String* pUrl = null;
2184 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2185 pSelectedScene = (String*) pValue;
2187 if (pSelectedScene != null)
2189 delete pSelectedScene;
2191 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2192 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2193 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2194 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2196 // setting the current scene ID
2197 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2199 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2201 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2203 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2204 if(__pWindowInfo == null)
2206 // if(__pWindowInfo == null)
2208 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2211 else if ( pArgs != null && pArgs->GetCount() == 1)
2213 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2219 // hiding the address bar
2220 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2221 __pAddressbar->SetShowState(false);
2222 if(__pWebViewer != null)
2224 __pWebViewer->Resume();
2227 if(pUrl != null && pUrl->GetLength() > 0)
2231 else if(__pWindowInfo != null)
2233 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)
2235 LoadUrl(__pWindowInfo->pageUrl);
2237 else if (__pWindowInfo->isJavascriptInitiated == true)
2241 __pWindowInfo->pCurrentWeb = __pWebViewer;
2245 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2246 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2247 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2249 InitMostVisitedSitesView(GetOrientationStatus());
2252 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2254 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2256 if (pBookmarkUrl == null)
2258 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2259 //__pAddressbar->SetUrl(*pBookmarkUrl);
2260 SetUrl(*pBookmarkUrl);
2262 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2263 __pWebViewer->LoadUrl(*pBookmarkUrl);
2264 delete pBookmarkUrl;
2267 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2268 Bitmap* pBitmap = null;
2269 if (isPrivateBrowsing == true)
2271 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2273 if (__pWebViewer != null)
2275 __pWebViewer->SetPrivateBrowsingEnabled(true);
2278 if (__pAddressbar != null)
2280 // __pAddressbar->UpdateFaviconBitmap(true);
2286 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2288 if (__pWebViewer != null)
2290 __pWebViewer->SetPrivateBrowsingEnabled(false);
2293 if (__pAddressbar != null)
2295 // __pAddressbar->UpdateFaviconBitmap(false);
2299 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2301 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2303 else if (__pMenu != null )
2305 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2308 if (pBitmap != null)
2313 AppLog("ABC: OnSceneActivatedN started exit");
2318 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2319 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2321 Canvas* pWebCanvas = null;
2322 if (__pWebViewer != null)
2324 pWebCanvas = __pWebViewer->GetCanvasN();
2325 __pWebViewer->Pause();
2328 if (pWebCanvas == null)
2332 if (__pWindowInfo != null)
2334 if (__pWindowInfo->pWebCanvasBitmap != null)
2336 delete __pWindowInfo->pWebCanvasBitmap;
2338 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2339 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2340 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2342 Bitmap* pBitmap = GetCapturedBitmapN();
2343 AppLog("Coming here");
2344 Canvas* pCanvas = new(std::nothrow) Canvas();
2345 pCanvas->Construct(GetClientAreaBounds());
2348 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2351 if(__pWebViewer != null && __pWindowInfo != null)
2352 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2354 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2355 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2357 AppLog("Coming here");
2361 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2362 const Tizen::Base::String& realm,
2363 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2369 MainForm::OnHttpAuthenticationCanceled(void)
2374 MainForm::OnLoadingStarted(void)
2376 AppLogDebug("MainForm::OnLoadingStarted entered");
2378 if(__pAddressbar == NULL || __pWebViewer == null)
2382 String url = __pWebViewer->GetUrl();
2383 if(url.Contains(IDS_TIZEN_SERVICE))
2386 String delim(L":;");
2388 // Creates a StringTokenizer instance
2389 StringTokenizer strTok(url, delim);
2391 int count = strTok.GetTokenCount(); // count == 4
2393 HashMap *pMap = new HashMap();
2398 while (strTok.HasMoreTokens())
2400 AppLog("Token: %ls", token.GetPointer());
2401 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2402 if(token.Contains(IDS_APPID))
2404 token.SubString(6, appId);
2405 AppLog("AppID:%ls", appId.GetPointer());
2407 else if(token.Contains("="))
2409 String *pKey = new String();
2410 String *pValue = new String();
2412 token.IndexOf("=", 0, index);
2415 token.SubString(0, index, *pKey);
2416 token.SubString(index + 1, *pValue);
2417 pMap->Add(pKey, pValue);
2423 AppControl *pAppControl = null;
2424 String operationId = L"http://tizen.org/appcontrol/operation/main";
2425 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2428 AppLog("Starting AppControl");
2429 result r = pAppControl->Start(null, null, pMap, null);
2430 AppLog("Result of Start %s", GetErrorMessage(r));
2434 AppLogException("AppControl not found");
2439 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2442 __pAddressbar->SetFaviconBitmap(*pBitmap);
2445 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2447 // updating the address bar position with respect to web control
2448 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2449 __distanceMoved = 0;
2453 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2454 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2455 if (__pWebViewer != null)
2457 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2458 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2459 SetUrl(__pWebViewer->GetUrl());
2460 if (__pWindowInfo != NULL)
2462 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2464 __pAddressbar->Invalidate(true);
2470 MainForm::OnLoadingCanceled(void)
2477 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2479 AppLog("MainForm::OnKeypadWillOpen");
2480 if (__pAddressbar != null)
2482 OnAddressBarKeypadWillOpen(*__pAddressbar);
2488 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2490 if(__pAddressbar != null)
2492 OnAddressBarKeypadOpened(*__pAddressbar);
2498 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2502 if (__pAddressbar != null)
2504 OnAddressBarKeypadClosed(*__pAddressbar);
2509 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2511 AppLog("KeypadBoundsChanged");
2512 RelayoutControls(false);
2516 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2517 const Tizen::Base::String& reason)
2519 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2523 MainForm::OnLoadingCompleted(void)
2525 AppLog("MainForm::OnLoadingCompleted start");
2527 result r = E_SUCCESS;
2529 if (__pWebViewer == null)
2534 if (__pAddressbar == null)
2538 if (__pWebViewer->CanGoForward())
2540 //__pAddressbar->SetForwardButtonEnabled(true);
2541 SetForwardButtonEnabled(true);
2545 //__pAddressbar->SetForwardButtonEnabled(false);
2546 SetForwardButtonEnabled(false);
2549 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2551 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2553 //__pAddressbar->UpdateProgress(0);
2557 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2559 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2563 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2564 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2565 if (isPrivateBrowsing == false)
2567 History* pHistory = new(std::nothrow) History;
2569 HistoryPresentationModel::GetCurrentDateTime(date);
2572 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2573 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2575 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2576 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2578 pHistory->SetVisitedTime(date);
2581 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2582 pHistory->SetFaviconId(id);*/
2584 if (__pWebViewer != null)
2586 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2588 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2589 if (pTempBitmap != null)
2591 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2592 pHistory->SetFavIconBitmap(*pTempBitmap);
2595 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2598 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2599 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2600 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2602 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2603 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2604 pHistory->SetThumbnail(pBitmap);
2606 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2609 pHistory->SetFavIconBitmap(*pFavIcon);
2613 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2620 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2622 // temperary fixed (webpage can be not loaded)
2625 AppLog("MainForm::OnLoadingCompleted done");
2629 MainForm::OnEstimatedProgress(int progress)
2631 AppLogDebug("MainForm::OnEstimatedProgress entered");
2632 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2633 progress = DEFAULT_PROGRESS_PERCENTAGE;
2635 // __pAddressbar->UpdateProgress(progress);
2636 UpdateProgress(progress);
2639 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2641 AppLog("MainForm::OnFaviconReceived");
2642 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2644 if (pFavIconBitmap != null)
2646 pFavIconBitmap->GetWidth();
2647 pFavIconBitmap->GetHeight();
2652 MainForm::OnUrlValueChanged(Addressbar&)
2658 MainForm::OnUrlSubmitted(Addressbar& addBar)
2660 AppLog("MainForm::OnUrlSubmitted");
2661 String url = addBar.GetUrl();
2662 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2664 // __pFooterPanel->SetShowState(true);
2665 if(__pFooterUrlField)
2666 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2667 OnAddressCancelledClicked(*__pAddressbar);
2668 // __pAddressbar->SetShowState(false);
2669 // RelayoutControls(false);
2674 MainForm::LoadUrl(String& url)
2678 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2679 AppLogDebug("MainForm::LoadUrl enter");
2681 if (__pWebViewer != null)
2683 __pWebViewer->SetShowState(true);
2684 __pWebViewer->Invalidate(true);
2687 if (url.CompareTo(L"") == 0)
2691 if(__pFooterPanel != null)
2693 __pFooterPanel->SetShowState(true);
2694 __pFooterPanel->Invalidate(true);
2701 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2702 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)
2704 RegularExpression firstRegex;
2705 RegularExpression secondRegex;
2707 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2708 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2711 ret = firstRegex.Match(url, false); // This returns true value
2712 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2714 if (ret == true && __pWebViewer != null)
2716 __pWebViewer->LoadUrl(url);
2718 else if(__pWebViewer != null)
2720 String tempUrl = L"http://";
2721 tempUrl.Append(url);
2725 __pWebViewer->LoadUrl(tempUrl);
2729 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2730 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2733 if (__pAddressbar != null)
2735 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2736 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2739 AppLogDebug("MainForm::LoadUrl exit");
2746 MainForm::OnStopClicked(Addressbar& addBar)
2748 AppLogDebug("MainForm::OnStopClicked called");
2751 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2752 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2753 __pWebViewer->StopLoading();
2754 RequestRedraw(true);
2759 MainForm::OnReaderClicked(const Addressbar& addBar)
2761 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2763 CreateReaderPanel();
2764 AppLogDebug("MainScene::OnReaderClicked entered");
2767 /*if (__pArticleReaderPanel)
2769 AppLogDebug("showstate true for reader panel");
2770 __pArticleReaderPanel->SetShowState(true);
2771 __pArticleReaderPanel->Show();
2773 int xPos = __pArticleReaderPanel->GetX();
2774 int yPos = __pArticleReaderPanel->GetY();
2775 AppLog("OnReaderClicked() xPos = %d",xPos);
2776 AppLog("OnReaderClicked() yPos = %d",yPos);
2778 if (__pReaderData == null)
2783 String loadData = L"<html>\
2785 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2790 background-color: transparent;\
2809 <body style='width:'";
2810 loadData.Append(bodyWidth);
2811 loadData.Append(L"px'>");
2812 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2813 loadData.Append(*__pReaderData);
2814 loadData.Append(L"</body></html>");
2817 buf.Construct(loadData.GetLength());
2818 AppLogDebug("data->GetLength %d",loadData.GetLength());
2819 for (int z=0;z<loadData.GetLength();z++)
2822 loadData.GetCharAt(z,b);
2823 buf.SetByte((byte)b);
2827 if (__pWebReader != null)
2829 __pWebReader->LoadData(L"",buf,L"text/html");
2830 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2834 AppLogDebug("cannot LoadData __pWebReader is null");
2840 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2842 // AppLog("MainForm::OnBackClicked");
2843 result r = E_FAILURE;
2845 if (__pWebViewer && __pWebViewer->CanGoBack())
2847 __pWebViewer->GoBack();
2849 else if(__pWindowInfo->isJavascriptInitiated == false)
2852 pApp = UiApp::GetInstance();
2855 r = pApp->Terminate();
2858 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2866 WindowInfo* pWindowInfo = null;
2868 SceneManager* pSceneManager = SceneManager::GetInstance();
2869 if (pSceneManager == null)
2873 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2874 if (pAllWindowList == NULL)
2876 pApp = UiApp::GetInstance();
2879 r = pApp->Terminate();
2882 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2887 if (pAllWindowList != null)
2889 totalCount = pAllWindowList->GetCount();
2891 for (int count = 0; count < totalCount; count++)
2893 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2894 if (pWindowInfo == null)
2896 pApp = UiApp::GetInstance();
2899 r = pApp->Terminate();
2902 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2907 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2909 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2912 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2915 r = pAllWindowList->RemoveAt(count, true);
2916 __pWindowInfo = null;
2919 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2924 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2928 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2930 if (pWindowInfo == null)
2932 pApp = UiApp::GetInstance();
2935 r = pApp->Terminate();
2941 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2944 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2958 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2960 AppLog("MainForm::OnForwardClicked");
2961 if (__pWebViewer == null)
2964 if (__pWebViewer->CanGoForward())
2966 __pWebViewer->GoForward();
2971 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2973 result r = E_SUCCESS;
2975 __pFooterPanel->SetShowState(true);
2976 __pFooterUrlField->SetFocusable(true);
2979 __pWebViewer->SetFocus();
2980 else if(__pMostVisitedListView)
2981 __pMostVisitedListView->SetFocus();
2982 else if(__pMultiWindowButton)
2983 __pMultiWindowButton->SetFocus();
2984 __pMoreButton->SetFocus();
2986 __pAddressbar->SetShowState(false);
2988 RelayoutControls(false);
2993 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2995 __prevAddressBarMode = __curAddressBarMode;
2997 if (__pAddressbar != null)
2999 __curAddressBarMode = GetAddressbarMode();
3002 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3004 __adressPanelPosition.y = 0;
3005 if (__pAddressbar != null)
3007 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3008 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3009 __pAddressbar->Invalidate(true);
3011 if (__pWebViewer != null)
3013 __pWebViewer->StopLoading();
3016 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3018 __adressPanelPosition.y = 0;
3019 if (__pAddressbar != null)
3021 __webControlPosition.y = 0;
3022 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3023 __pAddressbar->Invalidate(true);
3029 MainForm::OnClipboardClosed(const Addressbar& addBar)
3031 RelayoutControls(false);
3035 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3038 __pAddressbar->SetShowState(false);
3040 __pFooterPanel->SetShowState(true);
3042 __pWebViewer->SetFocus();
3043 if(__pFooterUrlField)
3045 __pFooterUrlField->SetFocusable(true);
3047 RelayoutControls(false);
3051 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3053 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3055 __pAddressbar->SetShowState(false);
3059 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3061 __pAddressbar->SetShowState(true);
3062 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3063 __pAddressbar->SetAddressbarURLFocus();
3067 RelayoutControls(false);
3071 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3073 __pFooterPanel->SetShowState(false);
3077 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3079 AppLog("KeypadBoundsChanged");
3080 RelayoutControls(false);
3084 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3088 __pWindowInfo->pageTitle = title;
3089 if (__pWebViewer != null)
3091 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3094 if (__pAddressbar != null && __pWebViewer != null)
3096 SetUrl(__pWebViewer->GetUrl());
3097 __pAddressbar->Invalidate(true);
3102 MainForm::UpdateFavicon(void)
3104 bool urlImageType = false;
3105 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();");
3106 Bitmap* pBitmap = null;
3108 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3110 if (__pWindowInfo != null)
3113 url.SetUri(*tempPath);
3114 if (url.GetHost().GetLength() == 0)
3117 webUrl.SetUri(__pWebViewer->GetUrl());
3118 result r = url.SetHost(webUrl.GetHost());
3125 if (url.GetScheme().GetLength() == 0)
3128 webUrl.SetUri(__pWebViewer->GetUrl());
3129 url.SetScheme(webUrl.GetScheme());
3131 __pWindowInfo->faviconUrl = url.ToString();
3133 pBitmap = __pWebViewer->GetFaviconN();
3135 if (pBitmap != null)
3137 if (__pWindowInfo->pFavicon != NULL)
3139 __pWindowInfo->pFavicon = null;
3141 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3142 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3144 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3146 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3148 else if(__pWindowInfo->pFavicon != null)
3150 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3154 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3155 if(pDefaultBmp != null)
3157 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3166 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3173 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3174 Tizen::Web::Controls::WebNavigationType type)
3176 // when load new page if find word panel is open its show state is false
3177 ShowFindWordPanel(false);
3179 __pFooterPanel->Invalidate(true);
3182 uriInfo.SetUri(url);
3184 if(url.Contains(IDS_TIZEN_SERVICE))
3187 String delim(L":;,");
3189 // Creates a StringTokenizer instance
3190 StringTokenizer strTok(url, delim);
3192 int count = strTok.GetTokenCount(); // count == 4
3194 HashMap *pMap = new HashMap();
3200 while (strTok.HasMoreTokens())
3202 AppLog("Token: %ls", token.GetPointer());
3203 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3204 if(token.Contains(IDS_APPID))
3206 token.SubString(6, appId);
3207 AppLog("AppID:%ls", appId.GetPointer());
3209 else if(token.Contains("="))
3211 String *pKey = new String();
3212 String *pValue = new String();
3214 token.IndexOf("=", 0, index);
3217 token.SubString(0, index, *pKey);
3218 token.SubString(index + 1, *pValue);
3219 pMap->Add(pKey, pValue);
3225 AppControl *pAppControl = null;
3226 String operationId = L"http://tizen.org/appcontrol/operation/main";
3227 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3230 result r = pAppControl->Start(null, null, pMap, null);
3234 AppLogException("AppControl not found");
3240 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3242 __pAddressbar->SetShowState(false);
3243 OnAddressCancelledClicked(*__pAddressbar);
3244 __pAddressbar->Invalidate(true);
3250 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3251 const Tizen::Net::Http::HttpHeader& httpHeader)
3253 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3258 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3260 AppLog("MainForm::OnWebPageBlockSelected");
3261 if (__pHitElementResult != null)
3263 delete __pHitElementResult;
3264 __pHitElementResult = null;
3267 if (__pWebViewer != null)
3269 AppLog("MainForm::OnWebPageBlockSelected web not null");
3270 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3273 if (__pHitElementResult == null)
3278 if (__pHitElementResult->HasImage() != true)
3280 String tagName = __pHitElementResult->GetTagName();
3281 String type = __pHitElementResult->GetAttributeValue("type");
3283 __currentSelectedStr.Clear();
3284 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3285 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3286 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3288 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3290 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3292 InitSelectTextContextMenu(endPoint,true);
3293 __pImageMenu->SetShowState(true);
3294 __pImageMenu->Show();
3295 __pImageMenu->Invalidate(true);
3297 else if(__isLongPressedDone == true)
3299 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3301 if(__pHitElementResult->GetUrl().GetLength() > 0)
3303 __currentSelectedStr.Clear();
3304 __currentSelectedStr = __pHitElementResult->GetUrl();
3306 InitSelectTextContextMenu(endPoint,false);
3307 __pImageMenu->SetShowState(true);
3308 __pImageMenu->Show();
3309 __pImageMenu->Invalidate(true);
3312 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3313 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3314 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3320 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3326 MainForm::OnWebWindowCreateRequested(void)
3328 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3330 if (pNewWindowInfo == null)
3334 result r = E_SUCCESS;
3335 SceneManager* pSceneManager = SceneManager::GetInstance();
3336 if (pSceneManager == NULL)
3340 ArrayList* pArgList = new(std::nothrow) ArrayList();
3341 if (pArgList == NULL)
3345 r = pArgList->Construct();
3348 pNewWindowInfo->isJavascriptInitiated = true;
3349 pArgList->Add(*pNewWindowInfo);
3350 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3354 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3361 return pNewWindowInfo->pCurrentWeb;
3365 MainForm::RelayoutControls(bool showAddressbar)
3367 __webControlPosition.y = 0;
3368 __webControlHeight = GetClientAreaBounds().height;
3369 AppLog("Client area height: %d", __webControlHeight);
3371 AppLog("Client area height: %d", __webControlHeight);
3372 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3374 __webControlPosition.y += __pAddressbar->GetHeight();
3375 __webControlHeight -= __pAddressbar->GetHeight();
3376 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3378 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3380 __webControlPosition.y += __pFindWordControl->GetHeight();
3381 __webControlHeight -= __pFindWordControl->GetHeight();
3382 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3385 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3387 __webControlHeight -= __pFooterPanel->GetHeight();
3388 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3390 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3392 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3393 __pWebViewer->Invalidate(false);
3395 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3397 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3404 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3406 if (__pFindWordControl == null)
3412 InitFindWordPanel();
3413 // __pFindWordEditField->SetText(__currentSearchStr);
3414 //__pFindWordCountLabel->SetText(L"");
3415 // __pFindWordCountLabel->SetText(L"0/0");
3416 __pFindWordControl->SetShowState(true);
3420 if(__pFindWordControl != null)
3422 __pFindWordControl->SetShowState(false);
3426 AppLog("MainForm::ShowFindWordPanel %d",show);
3427 if (show && !isTouchPressed)
3429 if (__pFindWordEditField)
3431 __pFindWordEditField->SetFocus();
3432 __pFindWordEditField->ShowKeypad();
3437 if (__pFindWordEditField)
3438 __pFindWordEditField->HideKeypad();
3441 RelayoutControls(false);
3445 MainForm::StartWordSearch()
3447 //Get the count of occurances of the word in the current page
3448 __maxOccurrances = 0;
3449 __currentWordIndex = 0;
3451 __pFindWordPrev->SetEnabled(false);
3452 String *pCountStr = null;
3453 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3454 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3455 if (pCountStr != null)
3457 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3461 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3466 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3468 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3469 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3471 if(totalCount == -1 || totalCount == 0)
3473 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3474 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3477 else if(totalCount > 100)
3479 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3480 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3484 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3485 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3488 __maxOccurrances = totalCount;
3489 __currentWordIndex = currentOrdinal;
3491 //Reset the UI controls as per the maxOccurrance value
3492 if (totalCount <= 0)
3494 AppLog("Word not found");
3495 //Show error notification to user
3496 __pFindWordNext->SetEnabled(false);
3497 __pFindWordCountLabel->SetText(L"0/0");
3498 __pFindWordNext->Invalidate(false);
3499 __pFindWordPrev->Invalidate(false);
3500 __pFindWordCountLabel->Invalidate(false);
3504 if (totalCount == 1)
3506 __pFindWordNext->SetEnabled(false);
3510 __pFindWordNext->SetEnabled(true);
3513 String countStr = L"";
3514 countStr.Append(__currentWordIndex);
3515 countStr.Append(L"/");
3516 countStr.Append(__maxOccurrances);
3517 __pFindWordCountLabel->SetText(countStr);
3518 // __pFindWordCountLabel->SetShowState(true);
3519 __pFindWordCountLabel->Invalidate(false);
3521 //FindNextWord(true);
3522 //Update the controls
3523 __pFindWordNext->Invalidate(false);
3524 __pFindWordPrev->Invalidate(false);
3525 __pFindWordCountLabel->Invalidate(false);
3529 MainForm::FindNextWord(bool next)
3533 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3535 if(__currentWordIndex < __maxOccurrances)
3537 __currentWordIndex++;
3543 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3545 if(__currentWordIndex > 1)
3547 __currentWordIndex--;
3552 String countStr = L"";
3553 countStr.Append(__currentWordIndex);
3554 countStr.Append(L"/");
3555 countStr.Append(__maxOccurrances);
3556 __pFindWordCountLabel->SetText(countStr);
3557 // __pFindWordCountLabel->SetShowState(true);
3558 __pFindWordCountLabel->Invalidate(false);
3559 if (__currentWordIndex >= __maxOccurrances)
3561 __pFindWordNext->SetEnabled(false);
3565 __pFindWordNext->SetEnabled(true);
3567 if (__currentWordIndex <= 1)
3569 __pFindWordPrev->SetEnabled(false);
3573 __pFindWordPrev->SetEnabled(true);
3575 __pFindWordPrev->Invalidate(false);
3576 __pFindWordNext->Invalidate(false);
3577 __pFindWordCountLabel->Invalidate(false);
3578 __pFindWordControl->Invalidate(true);
3581 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3583 AppLog("MainForm::OnWebKeypadWillOpen");
3584 __isWebKeypadOpened = true;
3585 // OnAddressBarKeypadOpened(*__pAddressbar);
3589 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3592 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3594 __currentSearchStr = L"";
3595 __currentWordIndex = 0;
3596 __maxOccurrances = 0;
3597 __pFindWordEditField->SetText(L"");
3598 __pFindWordNext->SetEnabled(false);
3599 __pFindWordPrev->SetEnabled(false);
3600 __pFindWordCountLabel->SetText(L"0/0");
3601 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3602 __pFindWordControl->SetShowState(false);
3603 if (__pFindWordEditField)
3604 __pFindWordEditField->HideKeypad();
3608 if (__pWebViewer != null && __pFooterPanel != null)
3610 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3611 if(__pAddressbar != null)
3613 __pAddressbar->SetShowState(false);
3615 if(__pFindWordControl != null)
3617 __pFindWordControl->SetShowState(false);
3619 __pFooterPanel->SetShowState(false);
3620 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3626 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3628 __pFooterPanel->SetShowState(true);
3629 OnAddressBarKeypadClosed(*__pAddressbar);
3630 __isWebKeypadOpened = false;
3634 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3636 Control* temp = const_cast< Control* >(&source);
3637 Header* pHeader = dynamic_cast< Header* >(temp);
3638 if (pHeader != null)
3640 //Header double - clicked
3641 AppLog("Header double clicked");
3643 if(__pFindWordControl)
3645 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3646 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3650 AppLog("MainScene::OnTouchDoublePressed");
3651 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3652 if (isReaderEnabled == true)
3656 delete __pReaderData;
3657 __pReaderData = null;
3659 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3660 filePath.Append(L"data/reader.js");
3666 result r = E_SUCCESS;
3667 FileAttributes attr;
3669 File::GetAttributes(filePath,attr);
3671 r = file.Construct(filePath, L"r+");
3674 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3677 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3680 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3683 file.Read(pScript,attr.GetFileSize());
3685 AppLogDebug("scipt length %d",strlen(pScript));
3686 String strScript = L"";
3687 strScript.Append(pScript);
3688 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3691 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3694 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3695 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3697 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3698 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3704 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3706 AppLog("MainForm::OnTouchLongPressed");
3708 if (__pHitElementResult != null)
3710 delete __pHitElementResult;
3711 __pHitElementResult = null;
3714 if (__pWebViewer != null)
3716 AppLog("MainForm::OnTouchLongPressed web not null");
3717 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3720 if (__pHitElementResult == null)
3725 if (__pHitElementResult->HasImage() == true)
3727 InitImageContextMenu(currentPosition);
3728 __pImageMenu->SetShowState(true);
3729 __pImageMenu->Show();
3730 __pImageMenu->Invalidate(true);
3732 else if(__pHitElementResult->HasUrl() == true)
3734 String tempURl = __pHitElementResult->GetUrl();
3735 AppLog("tempURl is %ls", tempURl.GetPointer());
3736 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3737 if (pBitmap != null)
3745 InitImageLinkContextMenu(currentPosition);
3746 __pImageMenu->SetShowState(true);
3747 __pImageMenu->Show();
3748 __pImageMenu->Invalidate(true);
3752 String tagName = __pHitElementResult->GetTagName();
3753 String type = __pHitElementResult->GetAttributeValue("type");
3754 String value = __pHitElementResult->GetAttributeValue(L"value");
3755 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3757 __currentSelectedStr.Clear();
3758 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3760 AppLog("tag name is %ls", tagName.GetPointer());
3761 AppLog("type is %ls", type.GetPointer());
3762 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3764 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3766 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3768 InitSelectTextContextMenu(currentPosition,true, true);
3771 __pImageMenu->SetShowState(true);
3772 __pImageMenu->Show();
3773 __pImageMenu->Invalidate(true);
3776 __isLongPressedDone = true;
3777 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3780 __inputEventToBeSupressed = true;
3784 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3786 AppLog("MainForm::OnTouchReleased");
3788 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3789 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3791 __pWebViewer->ConsumeInputEvent();
3793 if(pHitElement != null)
3797 __inputEventToBeSupressed = false;
3801 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3808 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3810 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3812 __currentSearchStr = L"";
3813 __currentWordIndex = 0;
3814 __maxOccurrances = 0;
3815 __pFindWordEditField->SetText(L"");
3816 __pFindWordNext->SetEnabled(false);
3817 __pFindWordPrev->SetEnabled(false);
3818 __pFindWordCountLabel->SetText(L"0/0");
3819 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3820 __pFindWordControl->SetShowState(false);
3821 __pFindWordEditField->HideKeypad();
3823 if(__pAddressbar->GetShowState() == false)
3825 __pAddressbar->SetShowState(true);
3826 __pAddressbar->SetAddressbarURLFocus();
3827 __pFooterUrlField->SetFocusable(false);
3828 __pFooterPanel->SetShowState(false);
3835 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3841 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3847 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3853 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3859 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3865 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3867 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3868 int widthContextItem = 0;
3869 if(__pFindWordControl != null)
3870 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3871 if ( __pFooterLabel != null)
3873 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3876 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3881 if (__pFindWordBgLabel != null)
3883 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3884 if (pBitmap != null)
3886 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3892 __pMenu->SetShowState(false);
3893 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3895 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3899 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3904 AppLog("__pFooterPanel->GetShowState() is true");
3906 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3907 __pFooterPanel->Invalidate(true);
3911 if(__pMoreButton && __pMenu)
3913 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3914 __pMenu->SetAnchorPosition(p);
3915 __pMenu->Invalidate(true);
3918 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3919 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3921 InitMostVisitedSitesView(orientationStatus);
3924 RelayoutControls(false);
3925 if (__pArticleReaderPanel != null)
3927 if (__pArticleReaderPanel->GetShowState() == true)
3929 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3931 if (__pBlankPanel != null)
3932 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3934 if (__pWebReader != null)
3936 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3938 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3939 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3941 if ( pBitmap != null && pSrcBitmap != null)
3943 AppLog("CreateReaderPanel ninepatchbitmap found");
3944 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3947 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3948 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3949 if (pBitmap != null)
3954 if (pSrcBitmap != null)
3963 if (__pAddressbar != null)
3965 int width = GetClientAreaBounds().width;
3966 __pAddressbar->OrientationChanged(width);
3971 MainForm::OnSettingsChange(int settingvalue)
3973 AppLogDebug("MainForm::OnSettingsChange entered");
3975 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
3977 __pAddressbar->ResetGuideText();
3979 if (__pWebViewer == null)
3981 AppLogDebug("Webviewer is not initialized yet.");
3985 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3987 WebSetting settings = __pWebViewer->GetSetting();
3988 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3990 settings.SetAutoFittingEnabled(true);
3992 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3994 settings.SetAutoFittingEnabled(false);
3996 __pWebViewer->SetSetting(settings);
3998 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4000 WebSetting settings = __pWebViewer->GetSetting();
4001 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4002 __pWebViewer->SetSetting(settings);
4004 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4006 WebSetting settings = __pWebViewer->GetSetting();
4007 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4008 __pWebViewer->SetSetting(settings);
4010 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4012 WebSetting settings = __pWebViewer->GetSetting();
4013 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4014 __pWebViewer->SetSetting(settings);
4016 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4020 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4024 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4026 WebSetting settings = __pWebViewer->GetSetting();
4027 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4029 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4033 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4035 __pWebViewer->SetSetting(settings);
4037 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4041 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4042 WebSetting settings = __pWebReader->GetSetting();
4043 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4044 __pWebReader->SetSetting(settings);
4050 MainForm::OnSettingsReset()
4054 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4055 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4060 MainForm::OnClearCache()
4062 result r = E_SUCCESS;
4064 if (__pWebViewer != NULL)
4066 r = __pWebViewer->ClearCache();
4069 AppLogDebug("Cache cleared success");
4073 AppLogDebug("Cache cleared fail");
4079 MainForm::OnClearCookie()
4081 result r = E_SUCCESS;
4083 if (__pWebViewer != NULL)
4085 __pWebViewer->ClearCookie();
4089 AppLogDebug("Cookie cleared success");
4093 AppLogDebug("Cache cleared fail");
4098 MainForm::OnClearFormData()
4100 result r = E_SUCCESS;
4102 if (__pWebViewer != NULL)
4104 __pWebViewer->ClearFormData();
4108 AppLogDebug("Cookie cleared success");
4112 AppLogDebug("Cache cleared fail");
4117 MainForm::OnClearPasswords()
4119 result r = E_SUCCESS;
4121 if (__pWebViewer != NULL)
4123 __pWebViewer->ClearLoginFormData();
4127 AppLogDebug("Cookie cleared success");
4131 AppLogDebug("Cache cleared fail");
4137 MainForm::findDistance(int x1,int y1,int x2, int y2)
4139 int deltaX = Math::Abs(x2 - x1);
4140 int deltaY = Math::Abs(y2 - y1);
4141 double num = deltaX*deltaX + deltaY*deltaY;
4147 for (i = 0; i < 20; i++)
4149 x = (((x*x)+ num)/(2*x));
4160 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4162 if(__pFindWordControl)
4164 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4165 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4167 __isLongPressedDone = false;
4170 IList* pList = null;
4171 pList = touch.GetTouchInfoListN(source);
4175 int count = pList->GetCount();
4178 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4179 __touchPoint1 = pTouchInfo->position;
4181 /*if (__pAddressbar != null)
4183 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4185 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4187 __pAddressbar->SaveAddressbarEditText();
4189 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4192 __pAddressbar->Invalidate(true);
4194 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4196 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4198 //__pAddressbar->SaveAddressbarEditText();
4200 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4203 else if (count == 2)
4205 AppLogDebug("MainForm::OnTouchPressed count is two");
4206 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4207 __touchPoint1 = pTouchInfo->position;
4209 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4210 __touchPoint2 = pTouchInfo->position;
4216 pList->RemoveAll(true);
4223 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4225 __currentWordIndex = 0;
4226 __isLongPressedDone = false;
4231 MainForm::MoveUiControls()
4236 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4238 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4240 if(__pFooterUrlField->GetTextLength() == 0)
4242 __pFooterUrlField->SetKeypadActionEnabled(false);
4246 __pFooterUrlField->SetKeypadActionEnabled(true);
4249 if (__pFindWordEditField != null)
4251 __currentSearchStr = __pFindWordEditField->GetText();
4252 __pFindWordNext->SetEnabled(false);
4253 __pFindWordPrev->SetEnabled(false);
4254 __pFindWordNext->Invalidate(true);
4255 __pFindWordPrev->Invalidate(true);
4256 __pFindWordCountLabel->SetText(L"0/0");
4257 __pFindWordCountLabel->Invalidate(true);
4259 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4260 if (__currentSearchStr.GetLength() > 0)
4266 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4268 __currentSearchStr = L"";
4269 AppLogDebug("Enter something");
4274 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4281 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4283 if(__pWebViewer != null)
4286 AppLog("MainForm::InitMostVisitedSitesView");
4287 result r = E_SUCCESS;
4290 if (__pWebViewer != null && __pMostVisitedListView != null)
4295 if (__pMostVisitedListView != null)
4297 RemoveControl(*__pMostVisitedListView);
4299 if(__pMostVisitedSites != null)
4301 __pMostVisitedSites->RemoveAll(true);
4304 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4306 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4307 __pMostVisitedListView = new(std::nothrow) ListView();
4309 int height = GetClientAreaBounds().height;
4311 if(__pFooterPanel->GetShowState() == true)
4313 height = height - __pFooterPanel->GetHeight();
4315 if(__pAddressbar->GetShowState() == true)
4317 height -= __pAddressbar->GetHeight();
4320 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4324 delete __pMostVisitedListView;
4325 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4328 __pMostVisitedListView->SetItemProvider(*this);
4329 __pMostVisitedListView->AddListViewItemEventListener(*this);
4330 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4331 AddControl(*__pMostVisitedListView);
4332 __pMostVisitedListView->UpdateList();
4339 MainForm::GetImagePath(void)
4343 String formattedTime;
4344 DateTime currentTime;
4345 LocaleManager localManager;
4346 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4348 localManager.Construct();
4349 Locale locale = localManager.GetSystemLocale();
4350 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4352 // Get date formatter
4353 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4357 pTimeFormatter->Format(currentTime, formattedTime);
4360 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4361 String delim(L" :");
4362 StringTokenizer strTok(formattedTime, delim);
4365 String str1("GMT+00");
4366 while (strTok.HasMoreTokens())
4368 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4369 if(token.Equals(str1))
4371 AppLog("token is %ls", token.GetPointer());
4372 imageName.Append(token);
4378 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4380 result r = E_FAILURE;
4381 AppLog("Content manager 1");
4382 ContentId contentId;
4383 ContentManager contentManager;
4384 r = contentManager.Construct();
4387 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4390 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4391 contentPath.Append(imageName);
4392 contentPath.Append(".jpg");
4393 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4394 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4398 MainForm::SetForwardButtonEnabled(bool isEnabled)
4400 __pGoForwardBtn->SetEnabled(isEnabled);
4401 __pGoBackBtn->Invalidate(true);
4405 MainForm::SetBackButtonEnabled(bool isEnabled)
4407 __pGoBackBtn->SetEnabled(isEnabled);
4408 __pGoBackBtn->Invalidate(true);
4412 MainForm::UpdateProgress(int percentage)
4414 __progressPercentage = percentage;
4415 if (percentage == 0 || percentage == 100)
4417 __isLoadingData = false;
4418 if (percentage == 100)
4420 __isLoadingCompleted = true;
4421 __progressPercentage = 0;
4425 __isLoadingCompleted = false;
4430 __isLoadingData = true;
4432 UpdateProgressBitmap();
4436 MainForm::GetProgress(void)
4438 return __progressPercentage;
4442 MainForm::UpdateProgressBitmap(void)
4444 result r = E_SUCCESS;
4445 if (__pProgressbarLabel == null)
4447 int w = __pProgressbarLabel->GetWidth();
4448 int h = __pProgressbarLabel->GetHeight();
4450 int progressWidth = 0;
4451 Bitmap* pRetBitmap = null;
4453 if (__progressPercentage == 0 || __progressPercentage == 100)
4455 __pProgressbarLabel->SetShowState(false);
4456 __pProgressbarLabel->Invalidate(false);
4461 __pProgressbarLabel->SetShowState(true);
4462 __pProgressbarLabel->Invalidate(false);
4465 r = canvas.Construct(Rectangle(0, 0, w, h));
4469 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4474 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4478 pBgBmp->Scale(Dimension(w, h));
4479 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4483 progressWidth = (double) (w) * __progressPercentage / 100;
4484 AppLogDebug("progressWidth: %d", progressWidth);
4485 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4487 if (pProgressBmp != null)
4489 pProgressBmp->Scale(Dimension(progressWidth, h));
4490 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4491 delete pProgressBmp;
4494 pRetBitmap = new (std::nothrow) Bitmap();
4496 if (pRetBitmap == null)
4498 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4502 pRetBitmap->Construct(canvas, canvas.GetBounds());
4504 if (__pProgressbarLabel != null && pRetBitmap != null)
4506 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4507 __pProgressbarLabel->Invalidate(false);
4510 if (pRetBitmap != null)
4518 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4520 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4522 __currentAddMode = addMode;
4526 case ADDRESSBAR_MODE_INVALID:
4531 case ADDRESSBAR_MODE_READER:
4533 __pStopBtn->SetShowState(false);
4534 __pClearBtn->SetShowState(false);
4537 case ADDRESSBAR_MODE_LOADING:
4539 __pRefreshBtn->SetShowState(false);
4540 __pStopBtn->SetShowState(true);
4541 __pClearBtn->SetShowState(false);
4544 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4546 // SetUrl(__pAddressbar->GetUrl());
4548 __pRefreshBtn->SetShowState(true);
4549 __pStopBtn->SetShowState(false);
4550 __pClearBtn->SetShowState(false);
4553 case ADDRESSBAR_MODE_EDIT:
4555 __pRefreshBtn->SetShowState(false);
4556 __pStopBtn->SetShowState(false);
4557 __pClearBtn->SetShowState(true);
4564 OnAddressBarModeChanged();
4567 AddressBarMode MainForm::GetAddressbarMode(void)
4569 return __currentAddMode;
4572 void MainForm::SetUrl(const String& url)
4576 if (__pFooterUrlField != NULL)
4578 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4579 if (removedHttpUrl.IsEmpty() == false)
4581 __pFooterUrlField->SetText(removedHttpUrl);
4582 __pAddressbar->SetUrl(__displayUrl);
4586 __pFooterUrlField->SetText(__displayUrl);
4587 __pAddressbar->SetUrl(__displayUrl);
4589 if(__pFooterUrlField)
4590 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4591 __pFooterUrlField->Invalidate(false);
4592 __pAddressbar->Invalidate(true);
4593 // __pFooterUrlField->SetCursorPosition(0);
4598 MainForm::RemoveHttpTextFromDisplayURL(void)
4600 bool isHttpText = __displayUrl.Contains(L"http://");
4601 String updatedDisplayUrl;
4602 updatedDisplayUrl.Clear();
4604 if (isHttpText == true)
4606 __displayUrl.SubString(7,updatedDisplayUrl);
4608 return updatedDisplayUrl;