2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (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 + 12));
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, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
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();
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);
854 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
856 result r = E_SUCCESS;
857 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
858 if(onlyPasteOption == true)
861 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
862 if (__pImageMenu != null)
867 // p.y = p.y + __pAddressbar->GetHeight() + 12;
872 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
877 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
879 __pImageMenu = new (std::nothrow) ContextMenu();
880 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
881 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
883 if(onlyPasteOption == false)
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
887 if (pasteOption || onlyPasteOption)
889 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
891 if(onlyPasteOption == false)
893 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
894 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
897 __pImageMenu->SetMaxVisibleItemsCount(3);
898 __pImageMenu->AddActionEventListener(*this);
899 SetControlAlwaysOnTop(*__pImageMenu, true);
906 MainForm::InitFindWordPanel(void)
908 result r = E_SUCCESS;
909 Bitmap *pIconBitmap = null;
911 if (__pFindWordControl != null)
913 AppLogDebug("Findword panel already initialized");
914 if (__pFindWordBgLabel != null)
916 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
919 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
926 __pFindWordControl = new (std::nothrow) Panel();
927 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
930 AppLogException("There is some problem in the xml file. Please check.");
933 AddControl(*__pFindWordControl);
934 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
935 SetControlAlwaysOnTop(*__pFindWordControl,true);
936 __pFindWordControl->SetShowState(false);
937 __pFindWordControl->Invalidate(false);
939 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
940 if (__pFindWordBgLabel != null)
942 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
943 Rectangle pRect = pPanel1->GetBounds();
944 pRect.x = pRect.y = 0;
945 __pFindWordBgLabel->SetBounds(pRect);
946 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
949 AppLogDebug("InitFindWordPanel: Coming here");
950 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
955 AppLogDebug("InitFindWordPanel: shouldn't Come here");
959 Button* pfindWordCancel = null;
960 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
961 if (pfindWordCancel == null)
963 AppLogException("There is some problem in the xml file. Please check.");
966 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
967 pfindWordCancel->AddActionEventListener(*this);
969 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
970 if (__pFindWordClear == null)
972 AppLogException("There is some problem in the xml file. Please check.");
976 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
977 __pFindWordClear->AddActionEventListener(*this);
979 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
980 if (__pFindWordNext == null)
982 AppLogException("There is some problem in the xml file. Please check.");
986 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
987 __pFindWordNext->AddActionEventListener(*this);
989 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
990 if (__pFindWordPrev == null)
992 AppLogException("There is some problem in the xml file. Please check.");
996 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
997 __pFindWordPrev->AddActionEventListener(*this);
999 __pFindWordNext->SetEnabled(false);
1000 __pFindWordPrev->SetEnabled(false);
1002 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1003 if (__pFindWordCountLabel == null)
1005 AppLogException("There is some problem in the xml file. Please check.");
1009 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1010 if (__pFindWordEditField == null)
1012 AppLogException("There is some problem in the xml file. Please check.");
1015 __pFindWordEditField->AddTextEventListener(*this);
1016 __pFindWordEditField->AddKeypadEventListener(*this);
1017 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1023 MainForm::CreateItem (int index, int itemWidth)
1025 Rectangle listImageRect;
1026 Rectangle pagetTitleRect;
1027 Rectangle pageURLRect;
1028 Rectangle deleteImageRect;
1029 String pageTitle(L"");
1030 String pageURL(L"");
1031 result r = E_SUCCESS;
1032 Bitmap* pListIconImage = null;
1035 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1036 if(pHistory == null)
1040 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1041 if ( pAppResource == NULL )
1045 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1047 CustomItem* pItem = new(std::nothrow) CustomItem();
1048 pageTitle = pHistory->GetHistoryTitle();
1049 pageURL = pHistory->GetHistoryUrl();
1051 if (pageURL.GetLength() == 0)
1054 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1055 pageURL = L"<"+ nourl +">";
1059 Rectangle screenBounds = GetBounds();
1062 r = pItem->Construct(Dimension(itemWidth, 128), style);
1071 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1073 if ( pBitmap != NULL)
1075 pListIconImage = new Bitmap();
1076 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1080 if(pListIconImage == null)
1082 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1085 if ( pListIconImage != NULL)
1087 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1088 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1089 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1092 if (pItem != null && pListIconImage != NULL)
1094 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1098 if (pageTitle.CompareTo(L"") != 0)
1102 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1106 if (pageURL.CompareTo(L"") != 0)
1110 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1115 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1117 if ( __pItemContext!= NULL)
1121 pItem->SetContextItem(__pItemContext);
1127 if ( __pItemContextLandscape!= NULL)
1131 pItem->SetContextItem(__pItemContextLandscape);
1135 if( pListIconImage != NULL)
1137 delete pListIconImage;
1138 pListIconImage = null;
1145 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1152 MainForm::GetItemCount (void)
1154 if(__pMostVisitedSites != null)
1156 __pMostVisitedSites->RemoveAll(true);
1158 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1159 if(__pMostVisitedSites != null)
1161 return __pMostVisitedSites->GetCount();
1168 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1170 if(__pMostVisitedSites != null)
1172 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1173 if (pHistory != null)
1175 String url = pHistory->GetHistoryUrl();
1177 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1178 __pMostVisitedListView->UpdateList();
1184 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1186 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1187 String url = pHistory->GetHistoryUrl();
1195 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1201 MainForm::OnTerminating(void)
1203 result r = E_SUCCESS;
1206 delete __pItemContext;
1208 if(__pItemContextLandscape)
1210 delete __pItemContextLandscape;
1216 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1218 result r = E_SUCCESS;
1220 AppLogDebug("Clicked : %d", actionId);
1223 // case IDA_BACKBTN_CLICKED:
1225 // if (__pWebViewer && __pWebViewer->CanGoBack())
1227 // __pWebViewer->GoBack();
1231 // UiApp* pApp = null;
1232 // pApp = UiApp::GetInstance();
1233 // if (pApp != null)
1235 // r = pApp->Terminate();
1238 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1246 case IDA_BACKBTN_CLICKED:
1248 if (__pWebViewer && __pWebViewer->CanGoBack())
1250 __pWebViewer->GoBack();
1252 else if(__pWindowInfo->isJavascriptInitiated == false)
1255 pApp = UiApp::GetInstance();
1258 r = pApp->Terminate();
1261 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1269 WindowInfo* pWindowInfo = null;
1271 SceneManager* pSceneManager = SceneManager::GetInstance();
1272 if (pSceneManager == null)
1276 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1277 if (pAllWindowList == NULL)
1279 pApp = UiApp::GetInstance();
1282 r = pApp->Terminate();
1285 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1290 if (pAllWindowList != null)
1292 totalCount = pAllWindowList->GetCount();
1294 for (int count = 0; count < totalCount; count++)
1296 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1297 if (pWindowInfo == null)
1299 pApp = UiApp::GetInstance();
1302 r = pApp->Terminate();
1305 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1310 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1312 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1315 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1318 r = pAllWindowList->RemoveAt(count, true);
1319 __pWindowInfo = null;
1322 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1327 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1331 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1333 if (pWindowInfo == null)
1335 pApp = UiApp::GetInstance();
1338 r = pApp->Terminate();
1344 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1347 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1360 case IDA_FORWARD_CLICKED:
1361 if (__pWebViewer == null)
1364 if (__pWebViewer->CanGoForward())
1366 __pWebViewer->GoForward();
1368 __pMenu->SetShowState(false);
1369 __pMenu->Invalidate(false);
1372 case IDA_FINDONPAGE_CLICKED:
1374 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1375 __currentSearchStr.Clear();
1377 InitFindWordPanel();
1378 __pMenu->SetShowState(false);
1379 __pMenu->Invalidate(false);
1381 __pFindWordEditField->SetFocus();
1383 if (__pWebViewer != null)
1385 // releasing the set block
1386 __pWebViewer->ReleaseBlock();
1389 ShowFindWordPanel(true);
1392 case IDA_PRIVATEON_CLICKED:
1394 result r = E_SUCCESS;
1396 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1397 Bitmap* pBitmap = null;
1398 if (isPrivateBrowsing == true)
1400 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1403 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1407 if (__pWebViewer != NULL)
1409 __pWebViewer->SetPrivateBrowsingEnabled(false);
1412 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1414 if (__pAddressbar != null)
1416 __pAddressbar->UpdateFaviconBitmap(false);
1422 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1425 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1429 if (__pWebViewer != NULL)
1431 __pWebViewer->SetPrivateBrowsingEnabled(true);
1434 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1436 if (__pAddressbar != null)
1438 __pAddressbar->UpdateFaviconBitmap(true);
1443 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1444 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1445 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1446 __pMenu->Invalidate(true);
1448 if ( pBitmap != NULL )
1455 case IDA_SETTINGS_CLICKED:
1458 ArrayList* pArgList = new(std::nothrow) ArrayList();
1461 pArgList->Construct();
1462 pArgList->Add(*__pWindowInfo);
1463 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1465 __pMenu->SetShowState(false);
1466 __pMenu->Invalidate(false);
1467 if (pArgList != null)
1476 case IDA_ADDTOBOOKMARK_CLICKED:
1479 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1481 int bookmarkCount=0;
1484 url=__pWindowInfo->pageUrl;
1485 result r = E_SUCCESS;
1486 Bitmap* pBitmap = null;
1487 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1495 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1496 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1497 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1499 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1500 if (pNotification != null)
1502 pNotification->SetText(message);
1503 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1504 pNotification->ShowNotification();
1509 String title=__pWindowInfo->pageTitle;
1510 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1511 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1513 pBookmark->SetBookmarkTitle(title);
1514 pBookmark->SetUrl(url);
1515 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1517 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1519 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1520 pBookmark->SetFaviconId(id);
1521 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1522 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1525 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1526 if (pNotification != null)
1528 pNotification->SetText(message);
1529 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1530 pNotification->ShowNotification();
1531 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1534 if (pBitmap != null)
1536 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1540 __pMenu->Invalidate(true);
1544 case IDA_SHARE_CLICKED:
1546 if(__pPopUp != null)
1551 __pPopUp = new(std::nothrow) SharePopup();
1552 __pPopUp->Initialize();
1553 if (__pWindowInfo != null)
1555 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1556 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1557 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1558 pShareInfo->SetImageAttached(false);
1559 __pPopUp->RemoveAllShareInfo();
1560 __pPopUp->AddShareInfo(pShareInfo);
1562 __pPopUp->SetShowState(true);
1566 case IDA_BOOKMARKBTN_CLICKED:
1568 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1569 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1572 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1577 case IDA_MOREBTN_CLICKED:
1579 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1580 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1581 AppLog("Anchot pos: %d %d", p.x, p.y);
1583 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1585 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1586 int bookmarkCount=0;
1589 url=__pWindowInfo->pageUrl;
1590 result r = E_SUCCESS;
1591 Bitmap* pBitmap = null;
1593 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1596 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1601 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1605 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1607 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1609 if (__pMenu->GetItemCount() == 8)
1611 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1615 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1620 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1624 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1625 if (__pMenu->GetItemCount() != 8)
1627 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1629 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1630 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1631 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1632 __pMenu->SetMaxVisibleItemsCount(6);
1634 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1636 AppLog(" Orientation landscape");
1637 __pMenu->SetMaxVisibleItemsCount(5);
1641 AppLog(" Orientation potrait");
1642 __pMenu->SetMaxVisibleItemsCount(6);
1645 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1648 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1649 __pMenu->SetShowState(true);
1650 __pMenu->Invalidate(true);
1654 case IDA_HISTORY_CLICKED:
1656 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1657 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1660 case IDA_SAVED_PAGES_CLICKED:
1665 case IDA_DESKTOP_VIEW_CLICKED:
1670 case IDA_SAVE_CLICKED:
1675 case IDA_MULTIWINDOWBTN_CLICKED:
1677 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1678 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1682 case IDA_NEWWINDOWBTN_CLICKED:
1684 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1686 if (pNewWindowInfo == null)
1690 result r = E_SUCCESS;
1691 SceneManager* pSceneManager = SceneManager::GetInstance();
1693 if (pSceneManager == NULL)
1697 ArrayList* pArgList = new(std::nothrow) ArrayList();
1698 if (pArgList == NULL)
1702 r = pArgList->Construct();
1705 pArgList->Add(*pNewWindowInfo);
1706 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1712 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1717 case IDA_SMALLFONT_BTN_CLICKED:
1719 WebSetting setting = __pWebReader->GetSetting();
1720 setting.SetFontSize(15);
1721 __pWebReader->SetSetting(setting);
1724 case IDA_LARGEFONT_BTN_CLICKED:
1726 WebSetting setting = __pWebReader->GetSetting();
1727 setting.SetFontSize(25);
1728 __pWebReader->SetSetting(setting);
1731 case IDA_READER_CLOSE_CLICKED:
1733 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1735 //__pArticleReaderPanel->SetShowState(false);
1736 //__pArticleReaderPanel->Show();
1737 RemoveControl(*__pBlankPanel);
1738 //RemoveControl(*__pArticleReaderPanel);
1739 __pArticleReaderPanel = null;
1740 __pBlankPanel = null;
1741 __pArticleReaderLabel = null;
1743 //if (__pAddressbar)
1744 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1745 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1748 case IDA_FINDWORD_CANCEL_CLICKED:
1750 __currentSearchStr = L"";
1751 __currentWordIndex = 0;
1752 __maxOccurrances = 0;
1753 __pFindWordEditField->SetText(L"");
1754 __pFindWordNext->SetEnabled(false);
1755 __pFindWordPrev->SetEnabled(false);
1756 __pFindWordCountLabel->SetText(L"0/0");
1757 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1758 ShowFindWordPanel(false);
1761 case IDA_FINDWORD_SEARCH_CLICKED:
1763 __currentSearchStr = __pFindWordEditField->GetText();
1764 if (__currentSearchStr.GetLength() > 0)
1770 AppLogDebug("Enter something");
1774 case IDA_FINDWORD_CLEAR_CLICKED:
1776 __pFindWordCountLabel->SetText(L"0/0");
1777 __pFindWordEditField->SetText(L"");
1778 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1780 __currentSearchStr = L"";
1781 __pFindWordNext->SetEnabled(false);
1782 __pFindWordPrev->SetEnabled(false);
1783 __pFindWordControl->Invalidate(true);
1786 case IDA_FINDWORD_NEXT_CLICKED:
1791 case IDA_FINDWORD_PREV_CLICKED:
1793 FindNextWord(false);
1796 case IDA_BRIGHTNESS_BTN_CLICKED:
1798 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1799 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1802 case IDA_COPY_IMAGE_CLICKED:
1804 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1805 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1807 const Bitmap* pBitmap = null;
1808 if (__pHitElementResult != null)
1810 pBitmap = __pHitElementResult->GetImage();
1813 String resourcePath = App::GetInstance()->GetAppResourcePath();
1814 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1816 // copying the item to clipboard
1817 Clipboard* pClipboard = Clipboard::GetInstance();
1818 if (pClipboard != null)
1820 pClipboard->CopyItem(item);
1824 case IDA_VIEW_IMAGE_CLICKED:
1826 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1827 WindowInfo* pNewWindowInfo = null;
1828 if (__pHitElementResult != null)
1830 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1831 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1837 case IDA_SAVE_IMAGE_CLICKED:
1839 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1840 const Bitmap* pSaveBitmap = null;
1841 String imageName = GetImagePath();
1842 AppLog("Content manager image name %ls",imageName.GetPointer());
1845 imagePath.Append(imageName);
1846 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1847 AppLog("Content manager image path %ls",imagePath.GetPointer());
1848 if (__pHitElementResult != null)
1850 pSaveBitmap = __pHitElementResult->GetImage();
1852 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1856 UpdateImageContent(pBuffer, imageName);
1858 NotificationPanel *pNotification = new NotificationPanel(*this);
1860 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1861 msg.Append(imagePath);
1862 if (pNotification != null)
1864 pNotification->SetText(msg);
1865 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1866 pNotification->ShowNotification();
1871 int __modalMsgBoxResult;
1872 MessageBox* pMsgBox = new MessageBox();
1873 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1874 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1877 __modalMsgBoxResult = 0;
1881 case IDA_SHARE_IMAGE_CLICKED:
1883 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1884 if (__pPopUp != null)
1889 __pPopUp = new(std::nothrow) SharePopup();
1890 __pPopUp->Initialize();
1891 if (__pHitElementResult != null)
1893 const Bitmap* pSaveBitmap = null;
1894 String imageName = GetImagePath();
1895 AppLog("Content manager image name %ls",imageName.GetPointer());
1898 imagePath.Append(imageName);
1899 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1900 AppLog("Content manager image path %ls",imagePath.GetPointer());
1901 if (__pHitElementResult != null)
1903 pSaveBitmap = __pHitElementResult->GetImage();
1905 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1907 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1908 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1910 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1911 pShareInfo->SetPageTitle(L"");
1912 pShareInfo->SetPageUrl(srcUrl);
1913 pShareInfo->SetImageAttached(true);
1914 pShareInfo->SetImagePath(imagePath);
1915 __pPopUp->RemoveAllShareInfo();
1916 __pPopUp->AddShareInfo(pShareInfo);
1917 __pPopUp->SetShowState(true);
1922 case IDA_HYPERLINK_OPEN_CLICKED:
1924 if (__pHitElementResult != null)
1926 String srcUrl = __pHitElementResult->GetUrl();
1928 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
1930 if (pNewWindowInfo == null)
1934 result r = E_SUCCESS;
1935 SceneManager* pSceneManager = SceneManager::GetInstance();
1936 if (pSceneManager == NULL)
1940 ArrayList* pArgList = new(std::nothrow) ArrayList();
1941 if (pArgList == NULL)
1945 pArgList->Construct();
1947 pArgList->Add(*pNewWindowInfo);
1948 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1949 if (pArgList != null)
1956 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
1962 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
1964 if (__pHitElementResult == null)
1969 if(__pPopUp != null)
1974 __pPopUp = new(std::nothrow) SharePopup();
1975 __pPopUp->Initialize();
1977 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1978 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
1979 pShareInfo->SetImageAttached(false);
1980 __pPopUp->RemoveAllShareInfo();
1981 __pPopUp->AddShareInfo(pShareInfo);
1983 __pPopUp->SetShowState(true);
1987 case IDA_HYPERLINK_COPY_LINK_CLICKED:
1991 if (__pHitElementResult != null)
1993 url = __pHitElementResult->GetUrl();
1996 String resourcePath = App::GetInstance()->GetAppResourcePath();
1997 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
1999 // copying the item to clipboard
2000 Clipboard* pClipboard = Clipboard::GetInstance();
2001 if (pClipboard != null)
2003 pClipboard->CopyItem(item);
2007 case IDA_FIND_TEXT__CLICKED:
2009 OnAddressCancelledClicked(*__pAddressbar);
2010 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2011 __currentSearchStr.Clear();
2012 __currentSearchStr.Append(__currentSelectedStr);
2013 InitFindWordPanel();
2014 __pFindWordEditField->SetText(__currentSearchStr);
2017 __pMenu->SetShowState(false);
2018 __pMenu->Invalidate(false);
2021 __adressPanelPosition.y = 0;
2023 if (__pAddressbar != null && __pWebViewer != NULL)
2025 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2026 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2027 //__pAddressbar->Invalidate(true);
2028 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2030 if (__pFooterPanel->GetShowState() == false)
2031 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2033 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2034 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2035 __pWebViewer->Invalidate(true);
2038 ShowFindWordPanel(true);
2039 __pFindWordEditField->SetFocus();
2040 if (__currentSearchStr.GetLength() > 0)
2046 AppLogDebug("Enter something");
2049 if (__pWebViewer != null)
2051 // releasing the set block
2052 __pWebViewer->ReleaseBlock();
2057 case IDA_SHARE_TEXT_CLICKED:
2059 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2060 if(__pPopUp != null)
2065 __pPopUp = new(std::nothrow) SharePopup();
2066 __pPopUp->Initialize();
2067 if (__pHitElementResult != null)
2069 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2070 pShareInfo->SetPageTitle(L"");
2071 pShareInfo->SetPageUrl(__currentSelectedStr);
2072 pShareInfo->SetImageAttached(false);
2073 __pPopUp->RemoveAllShareInfo();
2074 __pPopUp->AddShareInfo(pShareInfo);
2075 __pPopUp->SetShowState(true);
2080 case IDA_COPY_TEXT_CLICKED:
2082 __pWebViewer->ReleaseBlock();
2083 // need to implement
2084 //__currentSelectedStr
2085 // Sets data to a clip board item
2087 String resourcePath = App::GetInstance()->GetAppResourcePath();
2088 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2090 // copying the item to clipboard
2091 Clipboard* pClipboard = Clipboard::GetInstance();
2092 if (pClipboard != null)
2094 pClipboard->CopyItem(item);
2098 case IDA_PASTE_TEXT_CLICKED:
2100 Clipboard* pClipboard = Clipboard::GetInstance();
2102 if(pClipboard == null)
2106 // Retrieves a latest item
2107 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2113 //Gets data from the clipboard item
2114 String* pString = dynamic_cast<String*>(pItem->GetData());
2116 if (pString != null)
2118 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2119 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2120 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2121 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; } } ";
2122 if(idElement.GetLength() != 0)
2124 script.Append("insertAtCursor(");
2125 script.Append(idElement);
2127 script.Append("\"");
2128 script.Append(*pString);
2129 script.Append("\");");
2131 else if (nameElement.GetLength() != 0)
2133 script.Append("insertAtCursor(document.getElementsByName('");
2134 script.Append(nameElement);
2135 script.Append("')[0],");
2136 script.Append("\"");
2137 script.Append(*pString);
2138 script.Append("\");");
2140 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2141 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2152 case IDA_GO_FORWARD:
2157 case IDA_REFRESH_BTN_CLICKED:
2159 __isLoadingCompleted = false;
2160 __isLoadingData = true;
2161 __progressPercentage = 0;
2162 __displayUrl = __pFooterUrlField->GetText();
2164 String url = __pFooterUrlField->GetText();
2165 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2169 UpdateProgressBitmap();
2172 case IDA_STOP_BTN_CLICKED:
2174 __isLoadingCompleted = false;
2175 __isLoadingData = false;
2176 __progressPercentage = 0;
2177 __pFooterUrlField->HideKeypad();
2178 __displayUrl = __pFooterUrlField->GetText();
2182 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2183 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2184 __pWebViewer->StopLoading();
2185 RequestRedraw(true);
2188 UpdateProgressBitmap();
2193 if (__pFooterUrlField->GetText().IsEmpty() == false)
2195 //__displayUrl = __pUrlField->GetText();
2196 __pFooterUrlField->Clear();
2207 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2210 UiApp* pApp = UiApp::GetInstance();
2219 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2220 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2222 AppLog("MainForm::OnSceneActivatedN called");
2223 String* pSelectedScene = NULL;
2224 Object* pValue = NULL;
2225 String* pUrl = null;
2226 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2227 pSelectedScene = (String*) pValue;
2229 if (pSelectedScene != null)
2231 delete pSelectedScene;
2233 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2234 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2235 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2236 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2238 // setting the current scene ID
2239 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2241 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2243 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2245 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2246 if(__pWindowInfo == null)
2248 // if(__pWindowInfo == null)
2250 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2253 else if ( pArgs != null && pArgs->GetCount() == 1)
2255 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2261 // hiding the address bar
2262 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2263 __pAddressbar->SetShowState(false);
2264 if(__pWebViewer != null)
2266 __pWebViewer->Resume();
2269 if(pUrl != null && pUrl->GetLength() > 0)
2273 else if(__pWindowInfo != null)
2275 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)
2277 LoadUrl(__pWindowInfo->pageUrl);
2279 else if (__pWindowInfo->isJavascriptInitiated == true)
2283 __pWindowInfo->pCurrentWeb = __pWebViewer;
2287 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2288 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2289 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2291 InitMostVisitedSitesView(GetOrientationStatus());
2294 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2296 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2298 if (pBookmarkUrl == null)
2300 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2301 //__pAddressbar->SetUrl(*pBookmarkUrl);
2302 SetUrl(*pBookmarkUrl);
2304 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2305 __pWebViewer->LoadUrl(*pBookmarkUrl);
2306 delete pBookmarkUrl;
2309 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2310 Bitmap* pBitmap = null;
2311 if (isPrivateBrowsing == true)
2313 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2315 if (__pWebViewer != null)
2317 __pWebViewer->SetPrivateBrowsingEnabled(true);
2320 if (__pAddressbar != null)
2322 // __pAddressbar->UpdateFaviconBitmap(true);
2328 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2330 if (__pWebViewer != null)
2332 __pWebViewer->SetPrivateBrowsingEnabled(false);
2335 if (__pAddressbar != null)
2337 // __pAddressbar->UpdateFaviconBitmap(false);
2341 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2343 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2345 else if (__pMenu != null )
2347 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2350 if (pBitmap != null)
2355 AppLog("ABC: OnSceneActivatedN started exit");
2360 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2361 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2363 Canvas* pWebCanvas = null;
2364 if (__pWebViewer != null)
2366 pWebCanvas = __pWebViewer->GetCanvasN();
2367 __pWebViewer->Pause();
2370 if (pWebCanvas == null)
2374 if (__pWindowInfo != null)
2376 if (__pWindowInfo->pWebCanvasBitmap != null)
2378 delete __pWindowInfo->pWebCanvasBitmap;
2380 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2381 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2382 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2384 Bitmap* pBitmap = GetCapturedBitmapN();
2385 AppLog("Coming here");
2386 Canvas* pCanvas = new(std::nothrow) Canvas();
2387 pCanvas->Construct(GetClientAreaBounds());
2390 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2393 if(__pWebViewer != null && __pWindowInfo != null)
2394 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2396 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2397 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2399 AppLog("Coming here");
2403 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2404 const Tizen::Base::String& realm,
2405 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2411 MainForm::OnHttpAuthenticationCanceled(void)
2416 MainForm::OnLoadingStarted(void)
2418 AppLogDebug("MainForm::OnLoadingStarted entered");
2420 if(__pAddressbar == NULL || __pWebViewer == null)
2424 String url = __pWebViewer->GetUrl();
2425 if(url.Contains(IDS_TIZEN_SERVICE))
2428 String delim(L":;");
2430 // Creates a StringTokenizer instance
2431 StringTokenizer strTok(url, delim);
2433 int count = strTok.GetTokenCount(); // count == 4
2435 HashMap *pMap = new HashMap();
2440 while (strTok.HasMoreTokens())
2442 AppLog("Token: %ls", token.GetPointer());
2443 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2444 if(token.Contains(IDS_APPID))
2446 token.SubString(6, appId);
2447 AppLog("AppID:%ls", appId.GetPointer());
2449 else if(token.Contains("="))
2451 String *pKey = new String();
2452 String *pValue = new String();
2454 token.IndexOf("=", 0, index);
2457 token.SubString(0, index, *pKey);
2458 token.SubString(index + 1, *pValue);
2459 pMap->Add(pKey, pValue);
2465 AppControl *pAppControl = null;
2466 String operationId = L"http://tizen.org/appcontrol/operation/main";
2467 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2470 AppLog("Starting AppControl");
2471 result r = pAppControl->Start(null, null, pMap, null);
2472 AppLog("Result of Start %s", GetErrorMessage(r));
2476 AppLogException("AppControl not found");
2481 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2484 __pAddressbar->SetFaviconBitmap(*pBitmap);
2487 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2489 // updating the address bar position with respect to web control
2490 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2491 __distanceMoved = 0;
2495 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2496 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2497 if (__pWebViewer != null)
2499 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2500 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2501 SetUrl(__pWebViewer->GetUrl());
2502 if (__pWindowInfo != NULL)
2504 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2506 __pAddressbar->Invalidate(true);
2512 MainForm::OnLoadingCanceled(void)
2519 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2521 AppLog("MainForm::OnKeypadWillOpen");
2522 if (__pAddressbar != null)
2524 OnAddressBarKeypadWillOpen(*__pAddressbar);
2530 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2532 if(__pAddressbar != null)
2534 OnAddressBarKeypadOpened(*__pAddressbar);
2540 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2544 if (__pAddressbar != null)
2546 OnAddressBarKeypadClosed(*__pAddressbar);
2551 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2553 AppLog("KeypadBoundsChanged");
2554 RelayoutControls(false);
2558 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2559 const Tizen::Base::String& reason)
2561 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2565 MainForm::OnLoadingCompleted(void)
2567 AppLog("MainForm::OnLoadingCompleted start");
2569 result r = E_SUCCESS;
2571 if (__pWebViewer == null)
2576 if (__pAddressbar == null)
2580 if (__pWebViewer->CanGoForward())
2582 //__pAddressbar->SetForwardButtonEnabled(true);
2583 SetForwardButtonEnabled(true);
2587 //__pAddressbar->SetForwardButtonEnabled(false);
2588 SetForwardButtonEnabled(false);
2591 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2593 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2595 //__pAddressbar->UpdateProgress(0);
2599 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2601 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2605 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2606 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2607 if (isPrivateBrowsing == false)
2609 History* pHistory = new(std::nothrow) History;
2611 HistoryPresentationModel::GetCurrentDateTime(date);
2614 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2615 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2617 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2618 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2620 pHistory->SetVisitedTime(date);
2623 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2624 pHistory->SetFaviconId(id);*/
2626 if (__pWebViewer != null)
2628 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2630 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2631 if (pTempBitmap != null)
2633 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2634 pHistory->SetFavIconBitmap(*pTempBitmap);
2637 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2640 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2641 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2642 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2644 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2645 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2646 pHistory->SetThumbnail(pBitmap);
2648 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2651 pHistory->SetFavIconBitmap(*pFavIcon);
2655 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2662 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2664 // temperary fixed (webpage can be not loaded)
2667 AppLog("MainForm::OnLoadingCompleted done");
2671 MainForm::OnEstimatedProgress(int progress)
2673 AppLogDebug("MainForm::OnEstimatedProgress entered");
2674 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2675 progress = DEFAULT_PROGRESS_PERCENTAGE;
2677 // __pAddressbar->UpdateProgress(progress);
2678 UpdateProgress(progress);
2681 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2683 AppLog("MainForm::OnFaviconReceived");
2684 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2686 if (pFavIconBitmap != null)
2688 pFavIconBitmap->GetWidth();
2689 pFavIconBitmap->GetHeight();
2694 MainForm::OnUrlValueChanged(Addressbar&)
2700 MainForm::OnUrlSubmitted(Addressbar& addBar)
2702 AppLog("MainForm::OnUrlSubmitted");
2703 String url = addBar.GetUrl();
2704 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2706 // __pFooterPanel->SetShowState(true);
2707 if(__pFooterUrlField)
2708 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2709 OnAddressCancelledClicked(*__pAddressbar);
2710 // __pAddressbar->SetShowState(false);
2711 // RelayoutControls(false);
2716 MainForm::LoadUrl(String& url)
2720 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2721 AppLogDebug("MainForm::LoadUrl enter");
2723 if (__pWebViewer != null)
2725 __pWebViewer->SetShowState(true);
2726 __pWebViewer->Invalidate(true);
2729 if (url.CompareTo(L"") == 0)
2733 if(__pFooterPanel != null)
2735 __pFooterPanel->SetShowState(true);
2736 __pFooterPanel->Invalidate(true);
2743 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2744 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)
2746 RegularExpression firstRegex;
2747 RegularExpression secondRegex;
2749 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2750 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2753 ret = firstRegex.Match(url, false); // This returns true value
2754 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2756 if (ret == true && __pWebViewer != null)
2759 __pWebViewer->LoadUrl(url);
2761 else if(__pWebViewer != null)
2763 String tempUrl = L"http://";
2764 tempUrl.Append(url);
2768 __pWebViewer->LoadUrl(tempUrl);
2772 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2773 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2776 if (__pAddressbar != null)
2778 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2779 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2782 AppLogDebug("MainForm::LoadUrl exit");
2789 MainForm::OnStopClicked(Addressbar& addBar)
2791 AppLogDebug("MainForm::OnStopClicked called");
2794 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2795 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2796 __pWebViewer->StopLoading();
2797 RequestRedraw(true);
2802 MainForm::OnReaderClicked(const Addressbar& addBar)
2804 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2806 CreateReaderPanel();
2807 AppLogDebug("MainScene::OnReaderClicked entered");
2810 /*if (__pArticleReaderPanel)
2812 AppLogDebug("showstate true for reader panel");
2813 __pArticleReaderPanel->SetShowState(true);
2814 __pArticleReaderPanel->Show();
2816 int xPos = __pArticleReaderPanel->GetX();
2817 int yPos = __pArticleReaderPanel->GetY();
2818 AppLog("OnReaderClicked() xPos = %d",xPos);
2819 AppLog("OnReaderClicked() yPos = %d",yPos);
2821 if (__pReaderData == null)
2826 String loadData = L"<html>\
2828 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2833 background-color: transparent;\
2852 <body style='width:'";
2853 loadData.Append(bodyWidth);
2854 loadData.Append(L"px'>");
2855 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2856 loadData.Append(*__pReaderData);
2857 loadData.Append(L"</body></html>");
2860 buf.Construct(loadData.GetLength());
2861 AppLogDebug("data->GetLength %d",loadData.GetLength());
2862 for (int z=0;z<loadData.GetLength();z++)
2865 loadData.GetCharAt(z,b);
2866 buf.SetByte((byte)b);
2870 if (__pWebReader != null)
2872 __pWebReader->LoadData(L"",buf,L"text/html");
2873 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2877 AppLogDebug("cannot LoadData __pWebReader is null");
2883 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2885 // AppLog("MainForm::OnBackClicked");
2886 result r = E_FAILURE;
2888 if (__pWebViewer && __pWebViewer->CanGoBack())
2890 __pWebViewer->GoBack();
2892 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2895 pApp = UiApp::GetInstance();
2898 r = pApp->Terminate();
2901 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2909 WindowInfo* pWindowInfo = null;
2911 SceneManager* pSceneManager = SceneManager::GetInstance();
2912 if (pSceneManager == null)
2916 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2917 if (pAllWindowList == NULL)
2919 pApp = UiApp::GetInstance();
2922 r = pApp->Terminate();
2925 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2930 if (pAllWindowList != null)
2932 totalCount = pAllWindowList->GetCount();
2934 for (int count = 0; count < totalCount; count++)
2936 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2937 if (pWindowInfo == null)
2939 pApp = UiApp::GetInstance();
2942 r = pApp->Terminate();
2945 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2950 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2952 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2955 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2958 r = pAllWindowList->RemoveAt(count, true);
2959 __pWindowInfo = null;
2962 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2967 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2971 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2973 if (pWindowInfo == null)
2975 pApp = UiApp::GetInstance();
2978 r = pApp->Terminate();
2984 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2987 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3001 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3003 AppLog("MainForm::OnForwardClicked");
3004 if (__pWebViewer == null)
3007 if (__pWebViewer->CanGoForward())
3009 __pWebViewer->GoForward();
3014 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3016 result r = E_SUCCESS;
3018 __pFooterPanel->SetShowState(true);
3019 __pFooterUrlField->SetFocusable(true);
3022 __pWebViewer->SetFocus();
3023 else if(__pMostVisitedListView)
3024 __pMostVisitedListView->SetFocus();
3025 else if(__pMultiWindowButton)
3026 __pMultiWindowButton->SetFocus();
3027 __pMoreButton->SetFocus();
3029 __pAddressbar->SetShowState(false);
3031 RelayoutControls(false);
3036 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3038 __prevAddressBarMode = __curAddressBarMode;
3040 if (__pAddressbar != null)
3042 __curAddressBarMode = GetAddressbarMode();
3045 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3047 __adressPanelPosition.y = 0;
3048 if (__pAddressbar != null)
3050 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3051 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3052 __pAddressbar->Invalidate(true);
3054 if (__pWebViewer != null)
3056 __pWebViewer->StopLoading();
3059 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3061 __adressPanelPosition.y = 0;
3062 if (__pAddressbar != null)
3064 __webControlPosition.y = 0;
3065 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3066 __pAddressbar->Invalidate(true);
3072 MainForm::OnClipboardClosed(const Addressbar& addBar)
3074 RelayoutControls(false);
3078 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3081 __pAddressbar->SetShowState(false);
3083 __pFooterPanel->SetShowState(true);
3085 // __pWebViewer->SetFocus();
3086 if(__pFooterUrlField)
3088 __pFooterUrlField->SetFocusable(true);
3090 RelayoutControls(false);
3094 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3096 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3098 __pAddressbar->SetShowState(false);
3102 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3104 __pAddressbar->SetShowState(true);
3105 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3106 __pAddressbar->SetAddressbarURLFocus();
3110 RelayoutControls(false);
3114 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3116 __pFooterPanel->SetShowState(false);
3120 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3122 AppLog("KeypadBoundsChanged");
3123 RelayoutControls(false);
3127 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3131 __pWindowInfo->pageTitle = title;
3132 if (__pWebViewer != null)
3134 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3137 if (__pAddressbar != null && __pWebViewer != null)
3139 SetUrl(__pWebViewer->GetUrl());
3140 __pAddressbar->Invalidate(true);
3145 MainForm::UpdateFavicon(void)
3147 bool urlImageType = false;
3148 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();");
3149 Bitmap* pBitmap = null;
3151 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3153 if (__pWindowInfo != null)
3156 url.SetUri(*tempPath);
3157 if (url.GetHost().GetLength() == 0)
3160 webUrl.SetUri(__pWebViewer->GetUrl());
3161 result r = url.SetHost(webUrl.GetHost());
3168 if (url.GetScheme().GetLength() == 0)
3171 webUrl.SetUri(__pWebViewer->GetUrl());
3172 url.SetScheme(webUrl.GetScheme());
3174 __pWindowInfo->faviconUrl = url.ToString();
3176 pBitmap = __pWebViewer->GetFaviconN();
3178 if (pBitmap != null)
3180 if (__pWindowInfo->pFavicon != NULL)
3182 __pWindowInfo->pFavicon = null;
3184 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3185 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3187 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3189 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3191 else if(__pWindowInfo->pFavicon != null)
3193 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3197 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3198 if(pDefaultBmp != null)
3200 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3209 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3216 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3217 Tizen::Web::Controls::WebNavigationType type)
3219 // when load new page if find word panel is open its show state is false
3220 ShowFindWordPanel(false);
3222 __pFooterPanel->Invalidate(true);
3225 uriInfo.SetUri(url);
3227 if(url.Contains(IDS_TIZEN_SERVICE))
3230 String delim(L":;,");
3232 // Creates a StringTokenizer instance
3233 StringTokenizer strTok(url, delim);
3235 int count = strTok.GetTokenCount(); // count == 4
3237 HashMap *pMap = new HashMap();
3243 while (strTok.HasMoreTokens())
3245 AppLog("Token: %ls", token.GetPointer());
3246 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3247 if(token.Contains(IDS_APPID))
3249 token.SubString(6, appId);
3250 AppLog("AppID:%ls", appId.GetPointer());
3252 else if(token.Contains("="))
3254 String *pKey = new String();
3255 String *pValue = new String();
3257 token.IndexOf("=", 0, index);
3260 token.SubString(0, index, *pKey);
3261 token.SubString(index + 1, *pValue);
3262 pMap->Add(pKey, pValue);
3268 AppControl *pAppControl = null;
3269 String operationId = L"http://tizen.org/appcontrol/operation/main";
3270 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3273 result r = pAppControl->Start(null, null, pMap, null);
3277 AppLogException("AppControl not found");
3283 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3285 __pAddressbar->SetShowState(false);
3286 OnAddressCancelledClicked(*__pAddressbar);
3287 __pAddressbar->Invalidate(true);
3293 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3294 const Tizen::Net::Http::HttpHeader& httpHeader)
3296 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3301 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3303 AppLog("MainForm::OnWebPageBlockSelected");
3304 if (__pHitElementResult != null)
3306 delete __pHitElementResult;
3307 __pHitElementResult = null;
3310 if (__pWebViewer != null)
3312 AppLog("MainForm::OnWebPageBlockSelected web not null");
3313 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3316 if (__pHitElementResult == null)
3321 if (__pHitElementResult->HasImage() != true)
3323 String tagName = __pHitElementResult->GetTagName();
3324 String type = __pHitElementResult->GetAttributeValue("type");
3326 __currentSelectedStr.Clear();
3327 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3328 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3329 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3331 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3333 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3335 InitSelectTextContextMenu(endPoint,true);
3336 __pImageMenu->SetShowState(true);
3337 __pImageMenu->Show();
3338 __pImageMenu->Invalidate(true);
3340 else if(__isLongPressedDone == true)
3342 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3344 if(__pHitElementResult->GetUrl().GetLength() > 0)
3346 __currentSelectedStr.Clear();
3347 __currentSelectedStr = __pHitElementResult->GetUrl();
3349 InitSelectTextContextMenu(endPoint,false);
3350 __pImageMenu->SetShowState(true);
3351 __pImageMenu->Show();
3352 __pImageMenu->Invalidate(true);
3355 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3356 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3357 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3363 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3369 MainForm::OnWebWindowCreateRequested(void)
3371 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3373 if (pNewWindowInfo == null)
3377 result r = E_SUCCESS;
3378 SceneManager* pSceneManager = SceneManager::GetInstance();
3379 if (pSceneManager == NULL)
3383 ArrayList* pArgList = new(std::nothrow) ArrayList();
3384 if (pArgList == NULL)
3388 r = pArgList->Construct();
3391 pNewWindowInfo->isJavascriptInitiated = true;
3392 pArgList->Add(*pNewWindowInfo);
3393 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3397 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3404 return pNewWindowInfo->pCurrentWeb;
3408 MainForm::RelayoutControls(bool showAddressbar)
3410 __webControlPosition.y = 0;
3411 __webControlHeight = GetClientAreaBounds().height;
3412 AppLog("Client area height: %d", __webControlHeight);
3414 AppLog("Client area height: %d", __webControlHeight);
3415 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3417 __webControlPosition.y += __pAddressbar->GetHeight();
3418 __webControlHeight -= __pAddressbar->GetHeight();
3419 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3421 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3423 __webControlPosition.y += __pFindWordControl->GetHeight();
3424 __webControlHeight -= __pFindWordControl->GetHeight();
3425 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3428 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3430 __webControlHeight -= __pFooterPanel->GetHeight();
3431 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3433 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3435 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3436 __pWebViewer->Invalidate(false);
3438 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3440 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3447 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3449 if (__pFindWordControl == null)
3455 InitFindWordPanel();
3456 // __pFindWordEditField->SetText(__currentSearchStr);
3457 //__pFindWordCountLabel->SetText(L"");
3458 // __pFindWordCountLabel->SetText(L"0/0");
3459 __pFindWordControl->SetShowState(true);
3463 if(__pFindWordControl != null)
3465 __pFindWordControl->SetShowState(false);
3469 AppLog("MainForm::ShowFindWordPanel %d",show);
3470 if (show && !isTouchPressed)
3472 if (__pFindWordEditField)
3474 __pFindWordEditField->SetFocus();
3475 __pFindWordEditField->ShowKeypad();
3480 if (__pFindWordEditField)
3481 __pFindWordEditField->HideKeypad();
3484 RelayoutControls(false);
3488 MainForm::StartWordSearch()
3490 //Get the count of occurances of the word in the current page
3491 __maxOccurrances = 0;
3492 __currentWordIndex = 0;
3494 __pFindWordPrev->SetEnabled(false);
3495 String *pCountStr = null;
3496 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3497 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3498 if (pCountStr != null)
3500 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3504 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3509 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3511 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3512 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3514 if(totalCount == -1 || totalCount == 0)
3516 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3517 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3520 else if(totalCount > 100)
3522 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3523 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3527 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3528 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3531 __maxOccurrances = totalCount;
3532 __currentWordIndex = currentOrdinal;
3534 //Reset the UI controls as per the maxOccurrance value
3535 if (totalCount <= 0)
3537 AppLog("Word not found");
3538 //Show error notification to user
3539 __pFindWordNext->SetEnabled(false);
3540 __pFindWordCountLabel->SetText(L"0/0");
3541 __pFindWordNext->Invalidate(false);
3542 __pFindWordPrev->Invalidate(false);
3543 __pFindWordCountLabel->Invalidate(false);
3547 if (totalCount == 1)
3549 __pFindWordNext->SetEnabled(false);
3553 __pFindWordNext->SetEnabled(true);
3556 String countStr = L"";
3557 countStr.Append(__currentWordIndex);
3558 countStr.Append(L"/");
3559 countStr.Append(__maxOccurrances);
3560 __pFindWordCountLabel->SetText(countStr);
3561 // __pFindWordCountLabel->SetShowState(true);
3562 __pFindWordCountLabel->Invalidate(false);
3564 //FindNextWord(true);
3565 //Update the controls
3566 __pFindWordNext->Invalidate(false);
3567 __pFindWordPrev->Invalidate(false);
3568 __pFindWordCountLabel->Invalidate(false);
3572 MainForm::FindNextWord(bool next)
3576 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3578 if(__currentWordIndex < __maxOccurrances)
3580 __currentWordIndex++;
3586 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3588 if(__currentWordIndex > 1)
3590 __currentWordIndex--;
3595 String countStr = L"";
3596 countStr.Append(__currentWordIndex);
3597 countStr.Append(L"/");
3598 countStr.Append(__maxOccurrances);
3599 __pFindWordCountLabel->SetText(countStr);
3600 // __pFindWordCountLabel->SetShowState(true);
3601 __pFindWordCountLabel->Invalidate(false);
3602 if (__currentWordIndex >= __maxOccurrances)
3604 __pFindWordNext->SetEnabled(false);
3608 __pFindWordNext->SetEnabled(true);
3610 if (__currentWordIndex <= 1)
3612 __pFindWordPrev->SetEnabled(false);
3616 __pFindWordPrev->SetEnabled(true);
3618 __pFindWordPrev->Invalidate(false);
3619 __pFindWordNext->Invalidate(false);
3620 __pFindWordCountLabel->Invalidate(false);
3621 __pFindWordControl->Invalidate(true);
3624 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3626 AppLog("MainForm::OnWebKeypadWillOpen");
3627 __isWebKeypadOpened = true;
3628 // OnAddressBarKeypadOpened(*__pAddressbar);
3632 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3635 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3637 __currentSearchStr = L"";
3638 __currentWordIndex = 0;
3639 __maxOccurrances = 0;
3640 __pFindWordEditField->SetText(L"");
3641 __pFindWordNext->SetEnabled(false);
3642 __pFindWordPrev->SetEnabled(false);
3643 __pFindWordCountLabel->SetText(L"0/0");
3644 __pWebViewer->SearchTextAllAsync(L"",false);
3645 __pFindWordControl->SetShowState(false);
3646 __pFindWordEditField->HideKeypad();
3650 if (__pWebViewer != null && __pFooterPanel != null)
3652 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3653 if(__pAddressbar != null)
3655 __pAddressbar->SetShowState(false);
3657 if(__pFindWordControl != null)
3659 __pFindWordControl->SetShowState(false);
3661 __pFooterPanel->SetShowState(false);
3662 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3664 if(__pImageMenu && __pImageMenu->GetShowState() == true)
3666 __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3667 AppLog("omgomgomg");
3673 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3675 __pFooterPanel->SetShowState(true);
3676 OnAddressBarKeypadClosed(*__pAddressbar);
3677 __isWebKeypadOpened = false;
3681 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3683 Control* temp = const_cast< Control* >(&source);
3684 Header* pHeader = dynamic_cast< Header* >(temp);
3685 if (pHeader != null)
3687 //Header double - clicked
3688 AppLog("Header double clicked");
3690 if(__pFindWordControl)
3692 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3693 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3697 AppLog("MainScene::OnTouchDoublePressed");
3698 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3699 if (isReaderEnabled == true)
3703 delete __pReaderData;
3704 __pReaderData = null;
3706 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3707 filePath.Append(L"data/reader.js");
3713 result r = E_SUCCESS;
3714 FileAttributes attr;
3716 File::GetAttributes(filePath,attr);
3718 r = file.Construct(filePath, L"r+");
3721 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3724 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3727 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3730 file.Read(pScript,attr.GetFileSize());
3732 AppLogDebug("scipt length %d",strlen(pScript));
3733 String strScript = L"";
3734 strScript.Append(pScript);
3735 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3738 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3741 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3742 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3744 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3745 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3751 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3753 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3755 if (__pHitElementResult != null)
3757 delete __pHitElementResult;
3758 __pHitElementResult = null;
3761 if (__pWebViewer != null)
3763 AppLog("MainForm::OnTouchLongPressed web not null");
3764 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3767 if (__pHitElementResult == null)
3772 if (__pHitElementResult->HasImage() == true)
3774 InitImageContextMenu(currentPosition);
3775 __pImageMenu->SetShowState(true);
3776 __pImageMenu->Show();
3777 __pImageMenu->Invalidate(true);
3779 else if(__pHitElementResult->HasUrl() == true)
3781 String tempURl = __pHitElementResult->GetUrl();
3782 AppLog("tempURl is %ls", tempURl.GetPointer());
3783 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3784 if (pBitmap != null)
3792 InitImageLinkContextMenu(currentPosition);
3793 __pImageMenu->SetShowState(true);
3794 __pImageMenu->Show();
3795 __pImageMenu->Invalidate(true);
3799 String tagName = __pHitElementResult->GetTagName();
3800 String type = __pHitElementResult->GetAttributeValue("type");
3801 String value = __pHitElementResult->GetAttributeValue(L"value");
3802 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3804 __currentSelectedStr.Clear();
3805 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3807 AppLog("tag name is %ls", tagName.GetPointer());
3808 AppLog("type is %ls", type.GetPointer());
3809 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3811 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3813 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3815 InitSelectTextContextMenu(currentPosition,true, true);
3818 // __pImageMenu->SetShowState(true);
3819 // __pImageMenu->Show();
3820 // __pImageMenu->Invalidate(true);
3823 __isLongPressedDone = true;
3824 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3825 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3828 __inputEventToBeSupressed = true;
3832 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3834 AppLog("MainForm::OnTouchReleased");
3836 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3837 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3839 __pWebViewer->ConsumeInputEvent();
3841 if(pHitElement != null)
3845 __inputEventToBeSupressed = false;
3849 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3856 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3858 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3860 __currentSearchStr = L"";
3861 __currentWordIndex = 0;
3862 __maxOccurrances = 0;
3863 __pFindWordEditField->SetText(L"");
3864 __pFindWordNext->SetEnabled(false);
3865 __pFindWordPrev->SetEnabled(false);
3866 __pFindWordCountLabel->SetText(L"0/0");
3867 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3868 __pFindWordControl->SetShowState(false);
3869 __pFindWordEditField->HideKeypad();
3871 if(__pAddressbar->GetShowState() == false)
3873 __pAddressbar->SetShowState(true);
3874 __pAddressbar->SetAddressbarURLFocus();
3875 __pFooterUrlField->SetFocusable(false);
3876 __pFooterPanel->SetShowState(false);
3883 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3889 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3895 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3901 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3907 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3913 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3915 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3916 int widthContextItem = 0;
3918 if(__pWebViewer != null)
3920 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
3921 __pWebViewer->ReleaseBlock();
3924 if(__pFindWordControl != null)
3925 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3926 if ( __pFooterLabel != null)
3928 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3931 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3936 if (__pFindWordBgLabel != null)
3938 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3939 if (pBitmap != null)
3941 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3947 __pMenu->SetShowState(false);
3948 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3950 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3954 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3959 AppLog("__pFooterPanel->GetShowState() is true");
3961 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3962 __pFooterPanel->Invalidate(true);
3966 if(__pMoreButton && __pMenu)
3968 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3969 __pMenu->SetAnchorPosition(p);
3970 __pMenu->Invalidate(true);
3973 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3974 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3976 InitMostVisitedSitesView(orientationStatus);
3979 RelayoutControls(false);
3980 if (__pArticleReaderPanel != null)
3982 if (__pArticleReaderPanel->GetShowState() == true)
3984 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3986 if (__pBlankPanel != null)
3987 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3989 if (__pWebReader != null)
3991 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3993 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3994 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3996 if ( pBitmap != null && pSrcBitmap != null)
3998 AppLog("CreateReaderPanel ninepatchbitmap found");
3999 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4002 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4003 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4004 if (pBitmap != null)
4009 if (pSrcBitmap != null)
4018 if (__pAddressbar != null)
4020 int width = GetClientAreaBounds().width;
4021 __pAddressbar->OrientationChanged(width);
4026 MainForm::OnSettingsChange(int settingvalue)
4028 AppLogDebug("MainForm::OnSettingsChange entered");
4030 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4032 __pAddressbar->ResetGuideText();
4034 if (__pWebViewer == null)
4036 AppLogDebug("Webviewer is not initialized yet.");
4040 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4042 WebSetting settings = __pWebViewer->GetSetting();
4043 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4045 settings.SetAutoFittingEnabled(true);
4047 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4049 settings.SetAutoFittingEnabled(false);
4051 __pWebViewer->SetSetting(settings);
4053 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4055 WebSetting settings = __pWebViewer->GetSetting();
4056 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4057 __pWebViewer->SetSetting(settings);
4059 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4061 WebSetting settings = __pWebViewer->GetSetting();
4062 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4063 __pWebViewer->SetSetting(settings);
4065 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4067 WebSetting settings = __pWebViewer->GetSetting();
4068 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4069 __pWebViewer->SetSetting(settings);
4071 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4075 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4079 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4081 WebSetting settings = __pWebViewer->GetSetting();
4082 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4084 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4088 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4090 __pWebViewer->SetSetting(settings);
4092 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4096 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4097 WebSetting settings = __pWebReader->GetSetting();
4098 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4099 __pWebReader->SetSetting(settings);
4105 MainForm::OnSettingsReset()
4109 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4110 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4115 MainForm::OnClearCache()
4117 result r = E_SUCCESS;
4119 if (__pWebViewer != NULL)
4121 r = __pWebViewer->ClearCache();
4124 AppLogDebug("Cache cleared success");
4128 AppLogDebug("Cache cleared fail");
4134 MainForm::OnClearCookie()
4136 result r = E_SUCCESS;
4138 if (__pWebViewer != NULL)
4140 __pWebViewer->ClearCookie();
4144 AppLogDebug("Cookie cleared success");
4148 AppLogDebug("Cache cleared fail");
4153 MainForm::OnClearFormData()
4155 result r = E_SUCCESS;
4157 if (__pWebViewer != NULL)
4159 __pWebViewer->ClearFormData();
4163 AppLogDebug("Cookie cleared success");
4167 AppLogDebug("Cache cleared fail");
4172 MainForm::OnClearPasswords()
4174 result r = E_SUCCESS;
4176 if (__pWebViewer != NULL)
4178 __pWebViewer->ClearLoginFormData();
4182 AppLogDebug("Cookie cleared success");
4186 AppLogDebug("Cache cleared fail");
4192 MainForm::findDistance(int x1,int y1,int x2, int y2)
4194 int deltaX = Math::Abs(x2 - x1);
4195 int deltaY = Math::Abs(y2 - y1);
4196 double num = deltaX*deltaX + deltaY*deltaY;
4202 for (i = 0; i < 20; i++)
4204 x = (((x*x)+ num)/(2*x));
4215 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4217 if(__pFindWordControl)
4219 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4220 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4222 __isLongPressedDone = false;
4225 IList* pList = null;
4226 pList = touch.GetTouchInfoListN(source);
4230 int count = pList->GetCount();
4233 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4234 __touchPoint1 = pTouchInfo->position;
4236 /*if (__pAddressbar != null)
4238 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4240 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4242 __pAddressbar->SaveAddressbarEditText();
4244 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4247 __pAddressbar->Invalidate(true);
4249 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4251 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4253 //__pAddressbar->SaveAddressbarEditText();
4255 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4258 else if (count == 2)
4260 AppLogDebug("MainForm::OnTouchPressed count is two");
4261 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4262 __touchPoint1 = pTouchInfo->position;
4264 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4265 __touchPoint2 = pTouchInfo->position;
4271 pList->RemoveAll(true);
4278 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4280 __currentWordIndex = 0;
4281 __isLongPressedDone = false;
4286 MainForm::MoveUiControls()
4291 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4293 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4295 if(__pFooterUrlField->GetTextLength() == 0)
4297 __pFooterUrlField->SetKeypadActionEnabled(false);
4301 __pFooterUrlField->SetKeypadActionEnabled(true);
4304 if (__pFindWordEditField != null)
4306 __currentSearchStr = __pFindWordEditField->GetText();
4307 __pFindWordNext->SetEnabled(false);
4308 __pFindWordPrev->SetEnabled(false);
4309 __pFindWordNext->Invalidate(true);
4310 __pFindWordPrev->Invalidate(true);
4311 __pFindWordCountLabel->SetText(L"0/0");
4312 __pFindWordCountLabel->Invalidate(true);
4314 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4315 if (__currentSearchStr.GetLength() > 0)
4321 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4323 __currentSearchStr = L"";
4324 AppLogDebug("Enter something");
4329 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4336 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4338 if(__pWebViewer != null)
4341 AppLog("MainForm::InitMostVisitedSitesView");
4342 result r = E_SUCCESS;
4345 if (__pWebViewer != null && __pMostVisitedListView != null)
4350 if (__pMostVisitedListView != null)
4352 RemoveControl(*__pMostVisitedListView);
4354 if(__pMostVisitedSites != null)
4356 __pMostVisitedSites->RemoveAll(true);
4359 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4361 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4362 __pMostVisitedListView = new(std::nothrow) ListView();
4364 int height = GetClientAreaBounds().height;
4366 if(__pFooterPanel->GetShowState() == true)
4368 height = height - __pFooterPanel->GetHeight();
4370 if(__pAddressbar->GetShowState() == true)
4372 height -= __pAddressbar->GetHeight();
4375 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4379 delete __pMostVisitedListView;
4380 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4383 __pMostVisitedListView->SetItemProvider(*this);
4384 __pMostVisitedListView->AddListViewItemEventListener(*this);
4385 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4386 AddControl(*__pMostVisitedListView);
4387 __pMostVisitedListView->UpdateList();
4394 MainForm::GetImagePath(void)
4398 String formattedTime;
4399 DateTime currentTime;
4400 LocaleManager localManager;
4401 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4403 localManager.Construct();
4404 Locale locale = localManager.GetSystemLocale();
4405 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4407 // Get date formatter
4408 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4412 pTimeFormatter->Format(currentTime, formattedTime);
4415 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4416 String delim(L" :");
4417 StringTokenizer strTok(formattedTime, delim);
4420 String str1("GMT+00");
4421 while (strTok.HasMoreTokens())
4423 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4424 if(token.Equals(str1))
4426 AppLog("token is %ls", token.GetPointer());
4427 imageName.Append(token);
4433 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4435 result r = E_FAILURE;
4436 AppLog("Content manager 1");
4437 ContentId contentId;
4438 ContentManager contentManager;
4439 r = contentManager.Construct();
4442 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4445 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4446 contentPath.Append(imageName);
4447 contentPath.Append(".jpg");
4448 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4449 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4453 MainForm::SetForwardButtonEnabled(bool isEnabled)
4455 __pGoForwardBtn->SetEnabled(isEnabled);
4456 __pGoForwardBtn->Invalidate(true);
4460 MainForm::SetBackButtonEnabled(bool isEnabled)
4462 __pGoBackBtn->SetEnabled(isEnabled);
4463 __pGoBackBtn->Invalidate(true);
4467 MainForm::UpdateProgress(int percentage)
4469 __progressPercentage = percentage;
4470 if (percentage == 0 || percentage == 100)
4472 __isLoadingData = false;
4473 if (percentage == 100)
4475 __isLoadingCompleted = true;
4476 __progressPercentage = 0;
4480 __isLoadingCompleted = false;
4485 __isLoadingData = true;
4487 UpdateProgressBitmap();
4491 MainForm::GetProgress(void)
4493 return __progressPercentage;
4497 MainForm::UpdateProgressBitmap(void)
4499 result r = E_SUCCESS;
4500 if (__pProgressbarLabel == null)
4502 int w = __pProgressbarLabel->GetWidth();
4503 int h = __pProgressbarLabel->GetHeight();
4505 int progressWidth = 0;
4506 Bitmap* pRetBitmap = null;
4508 if (__progressPercentage == 0 || __progressPercentage == 100)
4510 __pProgressbarLabel->SetShowState(false);
4511 __pProgressbarLabel->Invalidate(false);
4516 __pProgressbarLabel->SetShowState(true);
4517 __pProgressbarLabel->Invalidate(false);
4520 r = canvas.Construct(Rectangle(0, 0, w, h));
4524 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4529 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4533 pBgBmp->Scale(Dimension(w, h));
4534 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4538 progressWidth = (double) (w) * __progressPercentage / 100;
4539 AppLogDebug("progressWidth: %d", progressWidth);
4540 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4542 if (pProgressBmp != null)
4544 pProgressBmp->Scale(Dimension(progressWidth, h));
4545 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4546 delete pProgressBmp;
4549 pRetBitmap = new (std::nothrow) Bitmap();
4551 if (pRetBitmap == null)
4553 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4557 pRetBitmap->Construct(canvas, canvas.GetBounds());
4559 if (__pProgressbarLabel != null && pRetBitmap != null)
4561 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4562 __pProgressbarLabel->Invalidate(false);
4565 if (pRetBitmap != null)
4573 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4575 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4577 __currentAddMode = addMode;
4581 case ADDRESSBAR_MODE_INVALID:
4586 case ADDRESSBAR_MODE_READER:
4588 __pStopBtn->SetShowState(false);
4589 __pClearBtn->SetShowState(false);
4592 case ADDRESSBAR_MODE_LOADING:
4594 __pRefreshBtn->SetShowState(false);
4595 __pStopBtn->SetShowState(true);
4596 __pClearBtn->SetShowState(false);
4599 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4601 // SetUrl(__pAddressbar->GetUrl());
4603 __pRefreshBtn->SetShowState(true);
4604 __pStopBtn->SetShowState(false);
4605 __pClearBtn->SetShowState(false);
4608 case ADDRESSBAR_MODE_EDIT:
4610 __pRefreshBtn->SetShowState(false);
4611 __pStopBtn->SetShowState(false);
4612 __pClearBtn->SetShowState(true);
4619 OnAddressBarModeChanged();
4622 AddressBarMode MainForm::GetAddressbarMode(void)
4624 return __currentAddMode;
4627 void MainForm::SetUrl(const String& url)
4631 if (__pFooterUrlField != NULL)
4633 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4634 if (removedHttpUrl.IsEmpty() == false)
4636 __pFooterUrlField->SetText(removedHttpUrl);
4637 __pAddressbar->SetUrl(__displayUrl);
4641 __pFooterUrlField->SetText(__displayUrl);
4642 __pAddressbar->SetUrl(__displayUrl);
4644 if(__pFooterUrlField)
4645 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4646 __pFooterUrlField->Invalidate(false);
4647 __pAddressbar->Invalidate(true);
4648 // __pFooterUrlField->SetCursorPosition(0);
4653 MainForm::RemoveHttpTextFromDisplayURL(void)
4655 bool isHttpText = __displayUrl.Contains(L"http://");
4656 String updatedDisplayUrl;
4657 updatedDisplayUrl.Clear();
4659 if (isHttpText == true)
4661 __displayUrl.SubString(7,updatedDisplayUrl);
4663 return updatedDisplayUrl;
4666 void MainForm::OnSharePopupControlStarted(void)
4668 __pWebViewer->AddTouchEventListener(*this);