2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
98 const int IDA_FINDWORD_NEXT_CLICKED = 202;
99 const int IDA_FINDWORD_PREV_CLICKED = 203;
100 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
101 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
103 const int IDA_COPY_IMAGE_CLICKED = 206;
104 const int IDA_VIEW_IMAGE_CLICKED = 207;
105 const int IDA_SAVE_IMAGE_CLICKED = 208;
106 const int IDA_SHARE_IMAGE_CLICKED = 209;
108 const int IDA_COPY_TEXT_CLICKED = 210;
109 const int IDA_PASTE_TEXT_CLICKED = 211;
110 const int IDA_FIND_TEXT__CLICKED = 212;
111 const int IDA_SHARE_TEXT_CLICKED = 213;
113 const int IDA_GO_BACK = 214;
114 const int IDA_GO_FORWARD = 215;
115 const int IDA_REFRESH_BTN_CLICKED = 216;
116 const int IDA_STOP_BTN_CLICKED = 217;
117 const int IDA_CLEAR_URL = 218;
119 const int IDA_HYPERLINK_OPEN_CLICKED = 219;
120 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220;
121 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
122 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
124 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
126 const int MainForm::IDA_FORMAT_BITMAP = 500;
127 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
128 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
129 const int MainForm::IDA_FORMAT_URL_STRING = 503;
130 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
132 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
133 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
134 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
136 MainForm::MainForm(void)
138 __isLongPressedDone = false;
139 __pAddressbar = null;
140 // __pMostVisitedSitesPanel = null;
141 __pMostVisitedListView = null;
142 __pFooterPanel = null;
143 __pHitElementResult = null;
144 __pWindowInfo = null;
148 __pFindWordControl = null;
150 __pFindWordBgLabel = null;
151 __pFindWordEditField = null;
152 __pFindWordClear = null;
153 __pFindWordCountLabel = null;
154 __pFindWordNext = null;
155 __pFindWordPrev = null;
156 __previousZoomLevel = 1.0;
158 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
161 __currentSearchStr = L"";
162 __currentSelectedStr = L"";
163 __maxOccurrances = 0;
164 __currentWordIndex = 0;
167 __inputEventToBeSupressed = false;
168 __isLoadingData = false;
169 __isLoadingCompleted = false;
170 __progressPercentage = 0;
171 __touchPoint1 = Point(-1,-1);
172 __touchPoint2 = Point(-1,-1);
174 // __pReaderPopup = null;
175 __pReaderData = null;
177 __pReaderCloseBtn = null;
178 //__pNewWindowButton = null;
179 __pMoreButton = null;
180 __pMultiWindowButton = null;
181 __pArticleReaderPanel = null;
182 __pBlankPanel = null;
183 __pArticleReaderLabel = null;
184 __webControlHeight = 0;
185 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
186 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
187 __pMostVisitedSites = null;
188 __pFooterUrlField = null;
190 __pGoForwardBtn = null;
191 __pRefreshBtn = null;
192 __pProgressbarLabel = null;
193 __pFooterLabel = null;
196 __isWebKeypadOpened = false;
199 MainForm::~MainForm(void)
201 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
205 __pAddressbar->SetAddressbarEventListener(null);
207 if (__pReaderData != null)
209 delete __pReaderData;
210 __pReaderData = null;
213 if (__pPopUp != null)
219 if (__pHitElementResult != null)
221 delete __pHitElementResult;
222 __pHitElementResult = null;
225 String* pSelectedScene = NULL;
226 Object* pValue = NULL;
227 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
228 pSelectedScene = (String*) pValue;
230 /*if (pSelectedScene != null)
232 delete pSelectedScene;
234 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
238 MainForm::Initialize(void)
240 Construct(L"IDL_FORM");
245 MainForm::OnInitializing(void)
247 AppLog("get client area width = %d",GetClientAreaBounds().width);
248 AppLog("get client area height = %d",GetClientAreaBounds().height);
249 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
250 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
252 Panel* pFooterPanel = null;
254 __pSaveImage = new Image();
255 __pSaveImage->Construct();
257 // Setup back event listener
258 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
259 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
260 AddOrientationEventListener(*this);
261 AppLogDebug(" MainForm::OnInitializing ended");
262 if (__pMostVisitedSites == null)
264 __pMostVisitedSites = new(std::nothrow) ArrayList();
265 __pMostVisitedSites->Construct();
267 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
269 __pItemContext= new(std::nothrow) ListContextItem();
270 __pItemContext->Construct();
271 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
272 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
274 if (pBitmapNormal != null && pBitmapPressed != null)
276 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
279 if (pBitmapNormal != null)
281 delete pBitmapNormal;
284 if (pBitmapPressed != null)
286 delete pBitmapPressed;
289 __pItemContextLandscape= new(std::nothrow) ListContextItem();
290 __pItemContextLandscape->Construct();
291 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
292 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
294 if (pBitmapNormal != null && pBitmapPressed != null)
296 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
299 if (pBitmapNormal != null)
301 delete pBitmapNormal;
304 if (pBitmapPressed != null)
306 delete pBitmapPressed;
313 MainForm::InitAddressbar(void)
315 AppLogDebug("MainForm::InitAddressbar entered");
317 result r = E_SUCCESS;
319 if (__pAddressbar != null)
323 __pAddressbar = new(std::nothrow) Addressbar();
324 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
325 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
328 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
331 __pAddressbar->SetAddressbarEventListener(this);
332 AddControl(*__pAddressbar);
333 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
334 SetControlAlwaysOnTop(*__pAddressbar, true);
335 __adressPanelPosition = __pAddressbar->GetPosition();
337 AppLogDebug("MainForm::InitAddressbar exit");
343 MainForm::CreateReaderPanel(void)
345 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
346 result r = E_FAILURE;
348 Button *pSmallFontBtn = null;
349 Button *pLargeFontBtn = null;
351 __pBlankPanel = new (std::nothrow) Panel();
352 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
354 __pArticleReaderPanel = new (std::nothrow) Panel();
355 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
357 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
358 if (__pReaderCloseBtn)
360 AppLogDebug("CreateReaderPanel() 6");
361 __pReaderCloseBtn->AddActionEventListener(*this);
362 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
365 __pWebReader = new (std::nothrow) Web();
366 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
368 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
369 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
371 r = __pWebReader->SetSetting(settings);
373 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
376 __pArticleReaderLabel = new Label();
377 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
379 __pBlankPanel->AddControl(*__pArticleReaderLabel);
380 __pBlankPanel->AddControl(*__pArticleReaderPanel);
381 AddControl(*__pBlankPanel);
383 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
384 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
385 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
387 __pArticleReaderPanel->AddControl(*__pWebReader);
388 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
389 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
390 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
392 if (pBitmap != null && pSrcBitmap != null)
394 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
396 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
398 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
401 pSmallFontBtn->AddActionEventListener(*this);
402 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
405 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
408 pLargeFontBtn->AddActionEventListener(*this);
409 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
418 if (pSrcBitmap != null)
424 SetControlAlwaysOnTop(*__pBlankPanel, true);
425 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
432 MainForm::InitWebControl()
434 AppLogDebug("MainForm::InitWebControl enter");
435 result r = E_SUCCESS;
436 AppLogDebug("InitWebControl");
438 if (__pAddressbar == null || __pFooterPanel == null)
441 const int Y_WEBCONTROL_POSITION = 0;
442 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
443 if (__pMostVisitedListView)
445 __pMostVisitedListView->SetShowState(false);
447 if (__pWebViewer != null)
449 AppLogDebug("Already initialized");
452 __pWebViewer = new(std::nothrow) Web();
453 if(__pWebViewer == NULL)
455 AppLogDebug("Initialization failed");
458 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
462 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
469 r = AddControl(*__pWebViewer);
475 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
478 __webControlPosition = __pWebViewer->GetPosition();
479 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
482 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
486 __pWebViewer->SetLoadingListener(this);
487 __pWebViewer->SetWebUiEventListener(this);
488 __pWebViewer->SetWebKeypadEventListener(this);
489 __pWebViewer->SetFocus();
490 __pWebViewer->AddTouchEventListener(*this);
492 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
493 __pWebViewer->SetTextSearchListener(this);
496 AppLogDebug("MainForm :before return");
498 AppLogDebug("MainForm::InitWebControl Exit");
504 MainForm::OnFocusGained(const Control& source)
506 AppLog("MainForm::OnFocusGained");
510 MainForm::OnFocusLost(const Control& source)
512 AppLog("MainForm::OnFocusLost");
516 MainForm::SetJavascriptEnabled()
518 WebSetting settings = __pWebViewer->GetSetting();
519 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
520 __pWebViewer->SetSetting(settings);
524 MainForm::SetImageLoadEnabled()
526 WebSetting settings = __pWebViewer->GetSetting();
527 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
528 __pWebViewer->SetSetting(settings);
532 MainForm::InitFooter(void)
534 AppLogDebug("MainForm::InitFooter entered");
535 Button* pBackButton = null;
536 Button* pBookmarkButton = null;
537 Button* pMultiWindowButton = null;
538 Bitmap *pIconBitmap = null;
539 Bitmap *pBGBitmap = null;
540 Label *pBGLabel = null;
542 if (__pFooterPanel == null)
544 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
547 if (__pFooterPanel == null)
552 SetControlAlwaysOnTop(*__pFooterPanel, true);
554 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
555 if ( __pFooterLabel == NULL )
559 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
560 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
563 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
567 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
569 if ( __pMultiWindowButton == NULL )
574 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
576 if ( __pMoreButton == NULL )
581 if (__pMultiWindowButton != null)
583 Bitmap* pBitmap = null;
584 Bitmap* pPressedBitmap = null;
585 String imagePath = "I01_toolbar_icon_windows_manager_0";
586 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
587 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
588 imagePath.Append(totalCount);
589 imagePath.Append(".png");
591 pressedImagePath.Append(totalCount);
592 pressedImagePath.Append("_press.png");
594 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
595 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
596 if ( pBitmap == null )
601 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
604 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
605 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
610 __pMultiWindowButton->AddActionEventListener(*this);
611 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
616 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
617 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
620 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
621 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
622 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
626 __pMoreButton->AddActionEventListener(*this);
627 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
630 //Add the editfield for url
631 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
632 if (__pFooterUrlField == NULL)
634 return E_INVALID_KEY;
637 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
638 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
639 //__pFooterUrlField->AddFocusEventListener(*this);
640 __pFooterUrlField->AddKeypadEventListener(*this);
641 //__pFooterUrlField->AddFocusEventListener(*this);
642 __pFooterUrlField->SetPropagatedTouchEventListener(this);
644 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
648 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
650 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
654 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
655 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
659 //Add the go Back Button
660 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
661 if (__pGoBackBtn == NULL)
663 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
664 return E_INVALID_KEY;
666 __pGoBackBtn->SetActionId(IDA_GO_BACK);
667 __pGoBackBtn->AddActionEventListener(*this);
669 //Add the go forward Button
670 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
671 if (__pGoForwardBtn == NULL)
673 AppLogDebug("Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
676 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
677 __pGoForwardBtn->AddActionEventListener(*this);
678 __pGoForwardBtn->SetEnabled(false);
680 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
681 if (__pRefreshBtn == NULL)
683 AppLogDebug("Control not found returning E_INVALID_KEY");
684 return E_INVALID_KEY;
687 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
688 __pRefreshBtn->AddActionEventListener(*this);
689 __pRefreshBtn->SetShowState(true);
691 //Add the backround label for displaying progressbar
692 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
693 if (__pProgressbarLabel == NULL)
695 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
696 return E_INVALID_KEY;
698 __pProgressbarLabel->SetShowState(false);
700 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
701 if (__pStopBtn == NULL)
703 AppLogDebug("Control not found returning E_INVALID_KEY");
704 return E_INVALID_KEY;
706 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
707 __pStopBtn->AddActionEventListener(*this);
708 __pStopBtn->SetShowState(false);
710 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
711 if (__pClearBtn == NULL)
713 AppLogDebug("Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
716 __pClearBtn->SetActionId(IDA_CLEAR_URL);
717 __pClearBtn->AddActionEventListener(*this);
718 __pClearBtn->SetShowState(false);
720 // __pFooterPanel->Invalidate(true);
721 AppLogDebug("MainForm::InitFooter exit");
727 MainForm::InitContextMenu(Point& p)
729 result r = E_SUCCESS;
730 bool isPrivateBrowsing = false;
731 Bitmap* pBitmap = null;
735 __pMenu->SetAnchorPosition(p);
736 __pMenu->Invalidate(true);
740 __pMenu = new(std::nothrow) ContextMenu();
741 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, 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() + 12;
830 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
834 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
836 __pImageMenu = new (std::nothrow) ContextMenu();
837 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
838 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
840 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
841 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
842 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
843 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
845 __pImageMenu->SetMaxVisibleItemsCount(3);
846 __pImageMenu->AddActionEventListener(*this);
847 SetControlAlwaysOnTop(*__pImageMenu, true);
853 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
855 result r = E_SUCCESS;
856 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
857 if(onlyPasteOption == true)
860 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
861 if (__pImageMenu != null)
866 // p.y = p.y + __pAddressbar->GetHeight() + 12;
871 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
876 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
878 __pImageMenu = new (std::nothrow) ContextMenu();
879 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
880 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
882 if(onlyPasteOption == false)
884 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
886 if (pasteOption || onlyPasteOption)
888 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
890 if(onlyPasteOption == false)
892 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
893 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
896 __pImageMenu->SetMaxVisibleItemsCount(3);
897 __pImageMenu->AddActionEventListener(*this);
898 SetControlAlwaysOnTop(*__pImageMenu, true);
905 MainForm::InitFindWordPanel(void)
907 result r = E_SUCCESS;
908 Bitmap *pIconBitmap = null;
910 if (__pFindWordControl != null)
912 AppLogDebug("Findword panel already initialized");
913 if (__pFindWordBgLabel != null)
915 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
918 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
925 __pFindWordControl = new (std::nothrow) Panel();
926 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
929 AppLogException("There is some problem in the xml file. Please check.");
932 AddControl(*__pFindWordControl);
933 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
934 SetControlAlwaysOnTop(*__pFindWordControl,true);
935 __pFindWordControl->SetShowState(false);
936 __pFindWordControl->Invalidate(false);
938 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
939 if (__pFindWordBgLabel != null)
941 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
942 Rectangle pRect = pPanel1->GetBounds();
943 pRect.x = pRect.y = 0;
944 __pFindWordBgLabel->SetBounds(pRect);
945 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
948 AppLogDebug("InitFindWordPanel: Coming here");
949 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
954 AppLogDebug("InitFindWordPanel: shouldn't Come here");
958 Button* pfindWordCancel = null;
959 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
960 if (pfindWordCancel == null)
962 AppLogException("There is some problem in the xml file. Please check.");
965 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
966 pfindWordCancel->AddActionEventListener(*this);
968 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
969 if (__pFindWordClear == null)
971 AppLogException("There is some problem in the xml file. Please check.");
975 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
976 __pFindWordClear->AddActionEventListener(*this);
978 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
979 if (__pFindWordNext == null)
981 AppLogException("There is some problem in the xml file. Please check.");
985 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
986 __pFindWordNext->AddActionEventListener(*this);
988 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
989 if (__pFindWordPrev == null)
991 AppLogException("There is some problem in the xml file. Please check.");
995 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
996 __pFindWordPrev->AddActionEventListener(*this);
998 __pFindWordNext->SetEnabled(false);
999 __pFindWordPrev->SetEnabled(false);
1001 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1002 if (__pFindWordCountLabel == null)
1004 AppLogException("There is some problem in the xml file. Please check.");
1008 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1009 if (__pFindWordEditField == null)
1011 AppLogException("There is some problem in the xml file. Please check.");
1014 __pFindWordEditField->AddTextEventListener(*this);
1015 __pFindWordEditField->AddKeypadEventListener(*this);
1016 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1022 MainForm::CreateItem (int index, int itemWidth)
1024 Rectangle listImageRect;
1025 Rectangle pagetTitleRect;
1026 Rectangle pageURLRect;
1027 Rectangle deleteImageRect;
1028 String pageTitle(L"");
1029 String pageURL(L"");
1030 result r = E_SUCCESS;
1031 Bitmap* pListIconImage = null;
1034 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1035 if(pHistory == null)
1039 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1040 if ( pAppResource == NULL )
1044 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1046 CustomItem* pItem = new(std::nothrow) CustomItem();
1047 pageTitle = pHistory->GetHistoryTitle();
1048 pageURL = pHistory->GetHistoryUrl();
1050 if (pageURL.GetLength() == 0)
1053 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1054 pageURL = L"<"+ nourl +">";
1058 Rectangle screenBounds = GetBounds();
1061 r = pItem->Construct(Dimension(itemWidth, 128), style);
1070 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1072 if ( pBitmap != NULL)
1074 pListIconImage = new Bitmap();
1075 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1079 if(pListIconImage == null)
1081 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1084 if ( pListIconImage != NULL)
1086 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1087 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1088 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1091 if (pItem != null && pListIconImage != NULL)
1093 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1097 if (pageTitle.CompareTo(L"") != 0)
1101 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1105 if (pageURL.CompareTo(L"") != 0)
1109 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1114 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1116 if ( __pItemContext!= NULL)
1120 pItem->SetContextItem(__pItemContext);
1126 if ( __pItemContextLandscape!= NULL)
1130 pItem->SetContextItem(__pItemContextLandscape);
1134 if( pListIconImage != NULL)
1136 delete pListIconImage;
1137 pListIconImage = null;
1144 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1151 MainForm::GetItemCount (void)
1153 if(__pMostVisitedSites != null)
1155 __pMostVisitedSites->RemoveAll(true);
1157 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1158 if(__pMostVisitedSites != null)
1160 return __pMostVisitedSites->GetCount();
1167 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1169 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1170 String url = pHistory->GetHistoryUrl();
1171 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1172 __pMostVisitedListView->UpdateList();
1176 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1178 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1179 String url = pHistory->GetHistoryUrl();
1187 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1193 MainForm::OnTerminating(void)
1195 result r = E_SUCCESS;
1198 delete __pItemContext;
1200 if(__pItemContextLandscape)
1202 delete __pItemContextLandscape;
1208 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1210 result r = E_SUCCESS;
1212 AppLogDebug("Clicked : %d", actionId);
1215 // case IDA_BACKBTN_CLICKED:
1217 // if (__pWebViewer && __pWebViewer->CanGoBack())
1219 // __pWebViewer->GoBack();
1223 // UiApp* pApp = null;
1224 // pApp = UiApp::GetInstance();
1225 // if (pApp != null)
1227 // r = pApp->Terminate();
1230 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1238 case IDA_BACKBTN_CLICKED:
1240 if (__pWebViewer && __pWebViewer->CanGoBack())
1242 __pWebViewer->GoBack();
1244 else if(__pWindowInfo->isJavascriptInitiated == false)
1247 pApp = UiApp::GetInstance();
1250 r = pApp->Terminate();
1253 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1261 WindowInfo* pWindowInfo = null;
1263 SceneManager* pSceneManager = SceneManager::GetInstance();
1264 if (pSceneManager == null)
1268 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1269 if (pAllWindowList == NULL)
1271 pApp = UiApp::GetInstance();
1274 r = pApp->Terminate();
1277 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1282 if (pAllWindowList != null)
1284 totalCount = pAllWindowList->GetCount();
1286 for (int count = 0; count < totalCount; count++)
1288 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1289 if (pWindowInfo == null)
1291 pApp = UiApp::GetInstance();
1294 r = pApp->Terminate();
1297 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1302 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1304 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1307 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1310 r = pAllWindowList->RemoveAt(count, true);
1311 __pWindowInfo = null;
1314 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1319 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1323 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1325 if (pWindowInfo == null)
1327 pApp = UiApp::GetInstance();
1330 r = pApp->Terminate();
1336 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1339 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1352 case IDA_FORWARD_CLICKED:
1353 if (__pWebViewer == null)
1356 if (__pWebViewer->CanGoForward())
1358 __pWebViewer->GoForward();
1360 __pMenu->SetShowState(false);
1361 __pMenu->Invalidate(false);
1364 case IDA_FINDONPAGE_CLICKED:
1366 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1367 __currentSearchStr.Clear();
1369 InitFindWordPanel();
1370 __pMenu->SetShowState(false);
1371 __pMenu->Invalidate(false);
1373 __pFindWordEditField->SetFocus();
1375 if (__pWebViewer != null)
1377 // releasing the set block
1378 __pWebViewer->ReleaseBlock();
1381 ShowFindWordPanel(true);
1384 case IDA_PRIVATEON_CLICKED:
1386 result r = E_SUCCESS;
1388 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1389 Bitmap* pBitmap = null;
1390 if (isPrivateBrowsing == true)
1392 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1395 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1399 if (__pWebViewer != NULL)
1401 __pWebViewer->SetPrivateBrowsingEnabled(false);
1404 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1406 if (__pAddressbar != null)
1408 __pAddressbar->UpdateFaviconBitmap(false);
1414 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1417 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1421 if (__pWebViewer != NULL)
1423 __pWebViewer->SetPrivateBrowsingEnabled(true);
1426 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1428 if (__pAddressbar != null)
1430 __pAddressbar->UpdateFaviconBitmap(true);
1435 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1436 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1437 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1438 __pMenu->Invalidate(true);
1440 if ( pBitmap != NULL )
1447 case IDA_SETTINGS_CLICKED:
1450 ArrayList* pArgList = new(std::nothrow) ArrayList();
1453 pArgList->Construct();
1454 pArgList->Add(*__pWindowInfo);
1455 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1457 __pMenu->SetShowState(false);
1458 __pMenu->Invalidate(false);
1459 if (pArgList != null)
1468 case IDA_ADDTOBOOKMARK_CLICKED:
1471 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1473 int bookmarkCount=0;
1476 url=__pWindowInfo->pageUrl;
1477 result r = E_SUCCESS;
1478 Bitmap* pBitmap = null;
1479 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1487 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1488 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1489 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1491 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1492 if (pNotification != null)
1494 pNotification->SetText(message);
1495 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1496 pNotification->ShowNotification();
1501 String title=__pWindowInfo->pageTitle;
1502 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1503 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1505 pBookmark->SetBookmarkTitle(title);
1506 pBookmark->SetUrl(url);
1507 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1509 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1511 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1512 pBookmark->SetFaviconId(id);
1513 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1514 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1517 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1518 if (pNotification != null)
1520 pNotification->SetText(message);
1521 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1522 pNotification->ShowNotification();
1523 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1526 if (pBitmap != null)
1528 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1532 __pMenu->Invalidate(true);
1536 case IDA_SHARE_CLICKED:
1538 if(__pPopUp != null)
1543 __pPopUp = new(std::nothrow) SharePopup();
1544 __pPopUp->Initialize();
1545 if (__pWindowInfo != null)
1547 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1548 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1549 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1550 pShareInfo->SetImageAttached(false);
1551 __pPopUp->RemoveAllShareInfo();
1552 __pPopUp->AddShareInfo(pShareInfo);
1554 __pPopUp->SetShowState(true);
1558 case IDA_BOOKMARKBTN_CLICKED:
1560 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1561 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1564 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1569 case IDA_MOREBTN_CLICKED:
1571 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1572 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1573 AppLog("Anchot pos: %d %d", p.x, p.y);
1575 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1577 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1578 int bookmarkCount=0;
1581 url=__pWindowInfo->pageUrl;
1582 result r = E_SUCCESS;
1583 Bitmap* pBitmap = null;
1585 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1588 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1593 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1597 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1599 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1601 if (__pMenu->GetItemCount() == 8)
1603 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1607 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1612 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1616 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1617 if (__pMenu->GetItemCount() != 8)
1619 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1621 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1622 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1623 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1624 __pMenu->SetMaxVisibleItemsCount(6);
1626 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1628 AppLog(" Orientation landscape");
1629 __pMenu->SetMaxVisibleItemsCount(5);
1633 AppLog(" Orientation potrait");
1634 __pMenu->SetMaxVisibleItemsCount(6);
1637 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1640 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1641 __pMenu->SetShowState(true);
1642 __pMenu->Invalidate(true);
1646 case IDA_HISTORY_CLICKED:
1648 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1649 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1652 case IDA_SAVED_PAGES_CLICKED:
1657 case IDA_DESKTOP_VIEW_CLICKED:
1662 case IDA_SAVE_CLICKED:
1667 case IDA_MULTIWINDOWBTN_CLICKED:
1669 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1670 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1674 case IDA_NEWWINDOWBTN_CLICKED:
1676 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1678 if (pNewWindowInfo == null)
1682 result r = E_SUCCESS;
1683 SceneManager* pSceneManager = SceneManager::GetInstance();
1685 if (pSceneManager == NULL)
1689 ArrayList* pArgList = new(std::nothrow) ArrayList();
1690 if (pArgList == NULL)
1694 r = pArgList->Construct();
1697 pArgList->Add(*pNewWindowInfo);
1698 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1704 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1709 case IDA_SMALLFONT_BTN_CLICKED:
1711 WebSetting setting = __pWebReader->GetSetting();
1712 setting.SetFontSize(15);
1713 __pWebReader->SetSetting(setting);
1716 case IDA_LARGEFONT_BTN_CLICKED:
1718 WebSetting setting = __pWebReader->GetSetting();
1719 setting.SetFontSize(25);
1720 __pWebReader->SetSetting(setting);
1723 case IDA_READER_CLOSE_CLICKED:
1725 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1727 //__pArticleReaderPanel->SetShowState(false);
1728 //__pArticleReaderPanel->Show();
1729 RemoveControl(*__pBlankPanel);
1730 //RemoveControl(*__pArticleReaderPanel);
1731 __pArticleReaderPanel = null;
1732 __pBlankPanel = null;
1733 __pArticleReaderLabel = null;
1735 //if (__pAddressbar)
1736 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1737 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1740 case IDA_FINDWORD_CANCEL_CLICKED:
1742 __currentSearchStr = L"";
1743 __currentWordIndex = 0;
1744 __maxOccurrances = 0;
1745 __pFindWordEditField->SetText(L"");
1746 __pFindWordNext->SetEnabled(false);
1747 __pFindWordPrev->SetEnabled(false);
1748 __pFindWordCountLabel->SetText(L"0/0");
1749 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1750 ShowFindWordPanel(false);
1753 case IDA_FINDWORD_SEARCH_CLICKED:
1755 __currentSearchStr = __pFindWordEditField->GetText();
1756 if (__currentSearchStr.GetLength() > 0)
1762 AppLogDebug("Enter something");
1766 case IDA_FINDWORD_CLEAR_CLICKED:
1768 __pFindWordCountLabel->SetText(L"0/0");
1769 __pFindWordEditField->SetText(L"");
1770 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1772 __currentSearchStr = L"";
1773 __pFindWordNext->SetEnabled(false);
1774 __pFindWordPrev->SetEnabled(false);
1775 __pFindWordControl->Invalidate(true);
1778 case IDA_FINDWORD_NEXT_CLICKED:
1783 case IDA_FINDWORD_PREV_CLICKED:
1785 FindNextWord(false);
1788 case IDA_BRIGHTNESS_BTN_CLICKED:
1790 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1791 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1794 case IDA_COPY_IMAGE_CLICKED:
1796 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1797 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1799 const Bitmap* pBitmap = null;
1800 if (__pHitElementResult != null)
1802 pBitmap = __pHitElementResult->GetImage();
1805 String resourcePath = App::GetInstance()->GetAppResourcePath();
1806 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1808 // copying the item to clipboard
1809 Clipboard* pClipboard = Clipboard::GetInstance();
1810 if (pClipboard != null)
1812 pClipboard->CopyItem(item);
1816 case IDA_VIEW_IMAGE_CLICKED:
1818 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1819 WindowInfo* pNewWindowInfo = null;
1820 if (__pHitElementResult != null)
1822 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1823 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1829 case IDA_SAVE_IMAGE_CLICKED:
1831 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1832 const Bitmap* pSaveBitmap = null;
1833 String imageName = GetImagePath();
1834 AppLog("Content manager image name %ls",imageName.GetPointer());
1837 imagePath.Append(imageName);
1838 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1839 AppLog("Content manager image path %ls",imagePath.GetPointer());
1840 if (__pHitElementResult != null)
1842 pSaveBitmap = __pHitElementResult->GetImage();
1844 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1848 UpdateImageContent(pBuffer, imageName);
1850 NotificationPanel *pNotification = new NotificationPanel(*this);
1852 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1853 msg.Append(imagePath);
1854 if (pNotification != null)
1856 pNotification->SetText(msg);
1857 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1858 pNotification->ShowNotification();
1863 int __modalMsgBoxResult;
1864 MessageBox* pMsgBox = new MessageBox();
1865 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1866 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1869 __modalMsgBoxResult = 0;
1873 case IDA_SHARE_IMAGE_CLICKED:
1875 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1876 if (__pPopUp != null)
1881 __pPopUp = new(std::nothrow) SharePopup();
1882 __pPopUp->Initialize();
1883 if (__pHitElementResult != null)
1885 const Bitmap* pSaveBitmap = null;
1886 String imageName = GetImagePath();
1887 AppLog("Content manager image name %ls",imageName.GetPointer());
1890 imagePath.Append(imageName);
1891 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1892 AppLog("Content manager image path %ls",imagePath.GetPointer());
1893 if (__pHitElementResult != null)
1895 pSaveBitmap = __pHitElementResult->GetImage();
1897 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1899 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1900 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1902 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1903 pShareInfo->SetPageTitle(L"");
1904 pShareInfo->SetPageUrl(srcUrl);
1905 pShareInfo->SetImageAttached(true);
1906 pShareInfo->SetImagePath(imagePath);
1907 __pPopUp->RemoveAllShareInfo();
1908 __pPopUp->AddShareInfo(pShareInfo);
1909 __pPopUp->SetShowState(true);
1914 case IDA_HYPERLINK_OPEN_CLICKED:
1916 if (__pHitElementResult != null)
1918 String srcUrl = __pHitElementResult->GetUrl();
1920 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
1922 if (pNewWindowInfo == null)
1926 result r = E_SUCCESS;
1927 SceneManager* pSceneManager = SceneManager::GetInstance();
1928 if (pSceneManager == NULL)
1932 ArrayList* pArgList = new(std::nothrow) ArrayList();
1933 if (pArgList == NULL)
1937 pArgList->Construct();
1939 pArgList->Add(*pNewWindowInfo);
1940 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1941 if (pArgList != null)
1948 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
1954 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
1956 if (__pHitElementResult == null)
1961 if(__pPopUp != null)
1966 __pPopUp = new(std::nothrow) SharePopup();
1967 __pPopUp->Initialize();
1969 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1970 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
1971 pShareInfo->SetImageAttached(false);
1972 __pPopUp->RemoveAllShareInfo();
1973 __pPopUp->AddShareInfo(pShareInfo);
1975 __pPopUp->SetShowState(true);
1979 case IDA_HYPERLINK_COPY_LINK_CLICKED:
1983 if (__pHitElementResult != null)
1985 url = __pHitElementResult->GetUrl();
1988 String resourcePath = App::GetInstance()->GetAppResourcePath();
1989 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
1991 // copying the item to clipboard
1992 Clipboard* pClipboard = Clipboard::GetInstance();
1993 if (pClipboard != null)
1995 pClipboard->CopyItem(item);
1999 case IDA_FIND_TEXT__CLICKED:
2001 OnAddressCancelledClicked(*__pAddressbar);
2002 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2003 __currentSearchStr.Clear();
2004 __currentSearchStr.Append(__currentSelectedStr);
2005 InitFindWordPanel();
2006 __pFindWordEditField->SetText(__currentSearchStr);
2009 __pMenu->SetShowState(false);
2010 __pMenu->Invalidate(false);
2013 __adressPanelPosition.y = 0;
2015 if (__pAddressbar != null && __pWebViewer != NULL)
2017 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2018 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2019 //__pAddressbar->Invalidate(true);
2020 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2022 if (__pFooterPanel->GetShowState() == false)
2023 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2025 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2026 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2027 __pWebViewer->Invalidate(true);
2030 ShowFindWordPanel(true);
2031 __pFindWordEditField->SetFocus();
2032 if (__currentSearchStr.GetLength() > 0)
2038 AppLogDebug("Enter something");
2041 if (__pWebViewer != null)
2043 // releasing the set block
2044 __pWebViewer->ReleaseBlock();
2049 case IDA_SHARE_TEXT_CLICKED:
2051 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2052 if(__pPopUp != null)
2057 __pPopUp = new(std::nothrow) SharePopup();
2058 __pPopUp->Initialize();
2059 if (__pHitElementResult != null)
2061 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2062 pShareInfo->SetPageTitle(L"");
2063 pShareInfo->SetPageUrl(__currentSelectedStr);
2064 pShareInfo->SetImageAttached(false);
2065 __pPopUp->RemoveAllShareInfo();
2066 __pPopUp->AddShareInfo(pShareInfo);
2067 __pPopUp->SetShowState(true);
2072 case IDA_COPY_TEXT_CLICKED:
2074 __pWebViewer->ReleaseBlock();
2075 // need to implement
2076 //__currentSelectedStr
2077 // Sets data to a clip board item
2079 String resourcePath = App::GetInstance()->GetAppResourcePath();
2080 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2082 // copying the item to clipboard
2083 Clipboard* pClipboard = Clipboard::GetInstance();
2084 if (pClipboard != null)
2086 pClipboard->CopyItem(item);
2090 case IDA_PASTE_TEXT_CLICKED:
2092 Clipboard* pClipboard = Clipboard::GetInstance();
2094 if(pClipboard == null)
2098 // Retrieves a latest item
2099 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2105 //Gets data from the clipboard item
2106 String* pString = dynamic_cast<String*>(pItem->GetData());
2108 if (pString != null)
2110 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2111 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2112 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2113 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; } } ";
2114 if(idElement.GetLength() != 0)
2116 script.Append("insertAtCursor(");
2117 script.Append(idElement);
2119 script.Append("\"");
2120 script.Append(*pString);
2121 script.Append("\");");
2123 else if (nameElement.GetLength() != 0)
2125 script.Append("insertAtCursor(document.getElementsByName('");
2126 script.Append(nameElement);
2127 script.Append("')[0],");
2128 script.Append("\"");
2129 script.Append(*pString);
2130 script.Append("\");");
2132 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2133 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2144 case IDA_GO_FORWARD:
2149 case IDA_REFRESH_BTN_CLICKED:
2151 __isLoadingCompleted = false;
2152 __isLoadingData = true;
2153 __progressPercentage = 0;
2154 __displayUrl = __pFooterUrlField->GetText();
2156 String url = __pFooterUrlField->GetText();
2157 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2161 UpdateProgressBitmap();
2164 case IDA_STOP_BTN_CLICKED:
2166 __isLoadingCompleted = false;
2167 __isLoadingData = false;
2168 __progressPercentage = 0;
2169 __pFooterUrlField->HideKeypad();
2170 __displayUrl = __pFooterUrlField->GetText();
2174 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2175 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2176 __pWebViewer->StopLoading();
2177 RequestRedraw(true);
2180 UpdateProgressBitmap();
2185 if (__pFooterUrlField->GetText().IsEmpty() == false)
2187 //__displayUrl = __pUrlField->GetText();
2188 __pFooterUrlField->Clear();
2199 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2202 UiApp* pApp = UiApp::GetInstance();
2211 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2212 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2214 AppLog("MainForm::OnSceneActivatedN called");
2215 String* pSelectedScene = NULL;
2216 Object* pValue = NULL;
2217 String* pUrl = null;
2218 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2219 pSelectedScene = (String*) pValue;
2221 if (pSelectedScene != null)
2223 delete pSelectedScene;
2225 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2226 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2227 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2228 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2230 // setting the current scene ID
2231 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2233 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2235 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2237 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2238 if(__pWindowInfo == null)
2240 // if(__pWindowInfo == null)
2242 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2245 else if ( pArgs != null && pArgs->GetCount() == 1)
2247 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2253 // hiding the address bar
2254 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2255 __pAddressbar->SetShowState(false);
2256 if(__pWebViewer != null)
2258 __pWebViewer->Resume();
2261 if(pUrl != null && pUrl->GetLength() > 0)
2265 else if(__pWindowInfo != null)
2267 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)
2269 LoadUrl(__pWindowInfo->pageUrl);
2271 else if (__pWindowInfo->isJavascriptInitiated == true)
2275 __pWindowInfo->pCurrentWeb = __pWebViewer;
2279 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2280 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2281 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2283 InitMostVisitedSitesView(GetOrientationStatus());
2286 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2288 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2290 if (pBookmarkUrl == null)
2292 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2293 //__pAddressbar->SetUrl(*pBookmarkUrl);
2294 SetUrl(*pBookmarkUrl);
2296 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2297 __pWebViewer->LoadUrl(*pBookmarkUrl);
2298 delete pBookmarkUrl;
2301 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2302 Bitmap* pBitmap = null;
2303 if (isPrivateBrowsing == true)
2305 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2307 if (__pWebViewer != null)
2309 __pWebViewer->SetPrivateBrowsingEnabled(true);
2312 if (__pAddressbar != null)
2314 // __pAddressbar->UpdateFaviconBitmap(true);
2320 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2322 if (__pWebViewer != null)
2324 __pWebViewer->SetPrivateBrowsingEnabled(false);
2327 if (__pAddressbar != null)
2329 // __pAddressbar->UpdateFaviconBitmap(false);
2333 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2335 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2337 else if (__pMenu != null )
2339 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2342 if (pBitmap != null)
2347 AppLog("ABC: OnSceneActivatedN started exit");
2352 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2353 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2355 Canvas* pWebCanvas = null;
2356 if (__pWebViewer != null)
2358 pWebCanvas = __pWebViewer->GetCanvasN();
2359 __pWebViewer->Pause();
2362 if (pWebCanvas == null)
2366 if (__pWindowInfo != null)
2368 if (__pWindowInfo->pWebCanvasBitmap != null)
2370 delete __pWindowInfo->pWebCanvasBitmap;
2372 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2373 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2374 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2376 Bitmap* pBitmap = GetCapturedBitmapN();
2377 AppLog("Coming here");
2378 Canvas* pCanvas = new(std::nothrow) Canvas();
2379 pCanvas->Construct(GetClientAreaBounds());
2382 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2385 if(__pWebViewer != null && __pWindowInfo != null)
2386 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2388 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2389 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2391 AppLog("Coming here");
2395 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2396 const Tizen::Base::String& realm,
2397 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2403 MainForm::OnHttpAuthenticationCanceled(void)
2408 MainForm::OnLoadingStarted(void)
2410 AppLogDebug("MainForm::OnLoadingStarted entered");
2412 if(__pAddressbar == NULL || __pWebViewer == null)
2416 String url = __pWebViewer->GetUrl();
2417 if(url.Contains(IDS_TIZEN_SERVICE))
2420 String delim(L":;");
2422 // Creates a StringTokenizer instance
2423 StringTokenizer strTok(url, delim);
2425 int count = strTok.GetTokenCount(); // count == 4
2427 HashMap *pMap = new HashMap();
2432 while (strTok.HasMoreTokens())
2434 AppLog("Token: %ls", token.GetPointer());
2435 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2436 if(token.Contains(IDS_APPID))
2438 token.SubString(6, appId);
2439 AppLog("AppID:%ls", appId.GetPointer());
2441 else if(token.Contains("="))
2443 String *pKey = new String();
2444 String *pValue = new String();
2446 token.IndexOf("=", 0, index);
2449 token.SubString(0, index, *pKey);
2450 token.SubString(index + 1, *pValue);
2451 pMap->Add(pKey, pValue);
2457 AppControl *pAppControl = null;
2458 String operationId = L"http://tizen.org/appcontrol/operation/main";
2459 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2462 AppLog("Starting AppControl");
2463 result r = pAppControl->Start(null, null, pMap, null);
2464 AppLog("Result of Start %s", GetErrorMessage(r));
2468 AppLogException("AppControl not found");
2473 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2476 __pAddressbar->SetFaviconBitmap(*pBitmap);
2479 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2481 // updating the address bar position with respect to web control
2482 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2483 __distanceMoved = 0;
2487 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2488 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2489 if (__pWebViewer != null)
2491 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2492 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2493 SetUrl(__pWebViewer->GetUrl());
2494 if (__pWindowInfo != NULL)
2496 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2498 __pAddressbar->Invalidate(true);
2504 MainForm::OnLoadingCanceled(void)
2511 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2513 AppLog("MainForm::OnKeypadWillOpen");
2514 if (__pAddressbar != null)
2516 OnAddressBarKeypadWillOpen(*__pAddressbar);
2522 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2524 if(__pAddressbar != null)
2526 OnAddressBarKeypadOpened(*__pAddressbar);
2532 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2536 if (__pAddressbar != null)
2538 OnAddressBarKeypadClosed(*__pAddressbar);
2543 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2545 AppLog("KeypadBoundsChanged");
2546 RelayoutControls(false);
2550 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2551 const Tizen::Base::String& reason)
2553 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2557 MainForm::OnLoadingCompleted(void)
2559 AppLog("MainForm::OnLoadingCompleted start");
2561 result r = E_SUCCESS;
2563 if (__pWebViewer == null)
2568 if (__pAddressbar == null)
2572 if (__pWebViewer->CanGoForward())
2574 //__pAddressbar->SetForwardButtonEnabled(true);
2575 SetForwardButtonEnabled(true);
2579 //__pAddressbar->SetForwardButtonEnabled(false);
2580 SetForwardButtonEnabled(false);
2583 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2585 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2587 //__pAddressbar->UpdateProgress(0);
2591 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2593 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2597 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2598 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2599 if (isPrivateBrowsing == false)
2601 History* pHistory = new(std::nothrow) History;
2603 HistoryPresentationModel::GetCurrentDateTime(date);
2606 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2607 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2609 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2610 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2612 pHistory->SetVisitedTime(date);
2615 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2616 pHistory->SetFaviconId(id);*/
2618 if (__pWebViewer != null)
2620 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2622 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2623 if (pTempBitmap != null)
2625 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2626 pHistory->SetFavIconBitmap(*pTempBitmap);
2629 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2632 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2633 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2634 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2636 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2637 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2638 pHistory->SetThumbnail(pBitmap);
2640 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2643 pHistory->SetFavIconBitmap(*pFavIcon);
2647 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2654 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2656 // temperary fixed (webpage can be not loaded)
2659 AppLog("MainForm::OnLoadingCompleted done");
2663 MainForm::OnEstimatedProgress(int progress)
2665 AppLogDebug("MainForm::OnEstimatedProgress entered");
2666 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2667 progress = DEFAULT_PROGRESS_PERCENTAGE;
2669 // __pAddressbar->UpdateProgress(progress);
2670 UpdateProgress(progress);
2673 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2675 AppLog("MainForm::OnFaviconReceived");
2676 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2678 if (pFavIconBitmap != null)
2680 pFavIconBitmap->GetWidth();
2681 pFavIconBitmap->GetHeight();
2686 MainForm::OnUrlValueChanged(Addressbar&)
2692 MainForm::OnUrlSubmitted(Addressbar& addBar)
2694 AppLog("MainForm::OnUrlSubmitted");
2695 String url = addBar.GetUrl();
2696 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2698 // __pFooterPanel->SetShowState(true);
2699 if(__pFooterUrlField)
2700 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2701 OnAddressCancelledClicked(*__pAddressbar);
2702 // __pAddressbar->SetShowState(false);
2703 // RelayoutControls(false);
2708 MainForm::LoadUrl(String& url)
2712 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2713 AppLogDebug("MainForm::LoadUrl enter");
2715 if (__pWebViewer != null)
2717 __pWebViewer->SetShowState(true);
2718 __pWebViewer->Invalidate(true);
2721 if (url.CompareTo(L"") == 0)
2725 if(__pFooterPanel != null)
2727 __pFooterPanel->SetShowState(true);
2728 __pFooterPanel->Invalidate(true);
2735 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2736 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)
2738 RegularExpression firstRegex;
2739 RegularExpression secondRegex;
2741 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2742 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2745 ret = firstRegex.Match(url, false); // This returns true value
2746 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2748 if (ret == true && __pWebViewer != null)
2750 __pWebViewer->LoadUrl(url);
2752 else if(__pWebViewer != null)
2754 String tempUrl = L"http://";
2755 tempUrl.Append(url);
2759 __pWebViewer->LoadUrl(tempUrl);
2763 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2764 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2767 if (__pAddressbar != null)
2769 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2770 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2773 AppLogDebug("MainForm::LoadUrl exit");
2780 MainForm::OnStopClicked(Addressbar& addBar)
2782 AppLogDebug("MainForm::OnStopClicked called");
2785 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2786 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2787 __pWebViewer->StopLoading();
2788 RequestRedraw(true);
2793 MainForm::OnReaderClicked(const Addressbar& addBar)
2795 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2797 CreateReaderPanel();
2798 AppLogDebug("MainScene::OnReaderClicked entered");
2801 /*if (__pArticleReaderPanel)
2803 AppLogDebug("showstate true for reader panel");
2804 __pArticleReaderPanel->SetShowState(true);
2805 __pArticleReaderPanel->Show();
2807 int xPos = __pArticleReaderPanel->GetX();
2808 int yPos = __pArticleReaderPanel->GetY();
2809 AppLog("OnReaderClicked() xPos = %d",xPos);
2810 AppLog("OnReaderClicked() yPos = %d",yPos);
2812 if (__pReaderData == null)
2817 String loadData = L"<html>\
2819 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2824 background-color: transparent;\
2843 <body style='width:'";
2844 loadData.Append(bodyWidth);
2845 loadData.Append(L"px'>");
2846 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2847 loadData.Append(*__pReaderData);
2848 loadData.Append(L"</body></html>");
2851 buf.Construct(loadData.GetLength());
2852 AppLogDebug("data->GetLength %d",loadData.GetLength());
2853 for (int z=0;z<loadData.GetLength();z++)
2856 loadData.GetCharAt(z,b);
2857 buf.SetByte((byte)b);
2861 if (__pWebReader != null)
2863 __pWebReader->LoadData(L"",buf,L"text/html");
2864 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2868 AppLogDebug("cannot LoadData __pWebReader is null");
2874 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2876 // AppLog("MainForm::OnBackClicked");
2877 result r = E_FAILURE;
2879 if (__pWebViewer && __pWebViewer->CanGoBack())
2881 __pWebViewer->GoBack();
2883 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2886 pApp = UiApp::GetInstance();
2889 r = pApp->Terminate();
2892 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2900 WindowInfo* pWindowInfo = null;
2902 SceneManager* pSceneManager = SceneManager::GetInstance();
2903 if (pSceneManager == null)
2907 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2908 if (pAllWindowList == NULL)
2910 pApp = UiApp::GetInstance();
2913 r = pApp->Terminate();
2916 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2921 if (pAllWindowList != null)
2923 totalCount = pAllWindowList->GetCount();
2925 for (int count = 0; count < totalCount; count++)
2927 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2928 if (pWindowInfo == null)
2930 pApp = UiApp::GetInstance();
2933 r = pApp->Terminate();
2936 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2941 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2943 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2946 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2949 r = pAllWindowList->RemoveAt(count, true);
2950 __pWindowInfo = null;
2953 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2958 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2962 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2964 if (pWindowInfo == null)
2966 pApp = UiApp::GetInstance();
2969 r = pApp->Terminate();
2975 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2978 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2992 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2994 AppLog("MainForm::OnForwardClicked");
2995 if (__pWebViewer == null)
2998 if (__pWebViewer->CanGoForward())
3000 __pWebViewer->GoForward();
3005 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3007 result r = E_SUCCESS;
3009 __pFooterPanel->SetShowState(true);
3010 __pFooterUrlField->SetFocusable(true);
3013 __pWebViewer->SetFocus();
3014 else if(__pMostVisitedListView)
3015 __pMostVisitedListView->SetFocus();
3016 else if(__pMultiWindowButton)
3017 __pMultiWindowButton->SetFocus();
3018 __pMoreButton->SetFocus();
3020 __pAddressbar->SetShowState(false);
3022 RelayoutControls(false);
3027 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3029 __prevAddressBarMode = __curAddressBarMode;
3031 if (__pAddressbar != null)
3033 __curAddressBarMode = GetAddressbarMode();
3036 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3038 __adressPanelPosition.y = 0;
3039 if (__pAddressbar != null)
3041 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3042 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3043 __pAddressbar->Invalidate(true);
3045 if (__pWebViewer != null)
3047 __pWebViewer->StopLoading();
3050 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3052 __adressPanelPosition.y = 0;
3053 if (__pAddressbar != null)
3055 __webControlPosition.y = 0;
3056 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3057 __pAddressbar->Invalidate(true);
3063 MainForm::OnClipboardClosed(const Addressbar& addBar)
3065 RelayoutControls(false);
3069 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3072 __pAddressbar->SetShowState(false);
3074 __pFooterPanel->SetShowState(true);
3076 // __pWebViewer->SetFocus();
3077 if(__pFooterUrlField)
3079 __pFooterUrlField->SetFocusable(true);
3081 RelayoutControls(false);
3085 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3087 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3089 __pAddressbar->SetShowState(false);
3093 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3095 __pAddressbar->SetShowState(true);
3096 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3097 __pAddressbar->SetAddressbarURLFocus();
3101 RelayoutControls(false);
3105 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3107 __pFooterPanel->SetShowState(false);
3111 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3113 AppLog("KeypadBoundsChanged");
3114 RelayoutControls(false);
3118 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3122 __pWindowInfo->pageTitle = title;
3123 if (__pWebViewer != null)
3125 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3128 if (__pAddressbar != null && __pWebViewer != null)
3130 SetUrl(__pWebViewer->GetUrl());
3131 __pAddressbar->Invalidate(true);
3136 MainForm::UpdateFavicon(void)
3138 bool urlImageType = false;
3139 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();");
3140 Bitmap* pBitmap = null;
3142 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3144 if (__pWindowInfo != null)
3147 url.SetUri(*tempPath);
3148 if (url.GetHost().GetLength() == 0)
3151 webUrl.SetUri(__pWebViewer->GetUrl());
3152 result r = url.SetHost(webUrl.GetHost());
3159 if (url.GetScheme().GetLength() == 0)
3162 webUrl.SetUri(__pWebViewer->GetUrl());
3163 url.SetScheme(webUrl.GetScheme());
3165 __pWindowInfo->faviconUrl = url.ToString();
3167 pBitmap = __pWebViewer->GetFaviconN();
3169 if (pBitmap != null)
3171 if (__pWindowInfo->pFavicon != NULL)
3173 __pWindowInfo->pFavicon = null;
3175 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3176 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3178 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3180 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3182 else if(__pWindowInfo->pFavicon != null)
3184 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3188 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3189 if(pDefaultBmp != null)
3191 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3200 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3207 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3208 Tizen::Web::Controls::WebNavigationType type)
3210 // when load new page if find word panel is open its show state is false
3211 ShowFindWordPanel(false);
3213 __pFooterPanel->Invalidate(true);
3216 uriInfo.SetUri(url);
3218 if(url.Contains(IDS_TIZEN_SERVICE))
3221 String delim(L":;,");
3223 // Creates a StringTokenizer instance
3224 StringTokenizer strTok(url, delim);
3226 int count = strTok.GetTokenCount(); // count == 4
3228 HashMap *pMap = new HashMap();
3234 while (strTok.HasMoreTokens())
3236 AppLog("Token: %ls", token.GetPointer());
3237 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3238 if(token.Contains(IDS_APPID))
3240 token.SubString(6, appId);
3241 AppLog("AppID:%ls", appId.GetPointer());
3243 else if(token.Contains("="))
3245 String *pKey = new String();
3246 String *pValue = new String();
3248 token.IndexOf("=", 0, index);
3251 token.SubString(0, index, *pKey);
3252 token.SubString(index + 1, *pValue);
3253 pMap->Add(pKey, pValue);
3259 AppControl *pAppControl = null;
3260 String operationId = L"http://tizen.org/appcontrol/operation/main";
3261 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3264 result r = pAppControl->Start(null, null, pMap, null);
3268 AppLogException("AppControl not found");
3274 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3276 __pAddressbar->SetShowState(false);
3277 OnAddressCancelledClicked(*__pAddressbar);
3278 __pAddressbar->Invalidate(true);
3284 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3285 const Tizen::Net::Http::HttpHeader& httpHeader)
3287 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3292 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3294 AppLog("MainForm::OnWebPageBlockSelected");
3295 if (__pHitElementResult != null)
3297 delete __pHitElementResult;
3298 __pHitElementResult = null;
3301 if (__pWebViewer != null)
3303 AppLog("MainForm::OnWebPageBlockSelected web not null");
3304 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3307 if (__pHitElementResult == null)
3312 if (__pHitElementResult->HasImage() != true)
3314 String tagName = __pHitElementResult->GetTagName();
3315 String type = __pHitElementResult->GetAttributeValue("type");
3317 __currentSelectedStr.Clear();
3318 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3319 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3320 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3322 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3324 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3326 InitSelectTextContextMenu(endPoint,true);
3327 __pImageMenu->SetShowState(true);
3328 __pImageMenu->Show();
3329 __pImageMenu->Invalidate(true);
3331 else if(__isLongPressedDone == true)
3333 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3335 if(__pHitElementResult->GetUrl().GetLength() > 0)
3337 __currentSelectedStr.Clear();
3338 __currentSelectedStr = __pHitElementResult->GetUrl();
3340 InitSelectTextContextMenu(endPoint,false);
3341 __pImageMenu->SetShowState(true);
3342 __pImageMenu->Show();
3343 __pImageMenu->Invalidate(true);
3346 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3347 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3348 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3354 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3360 MainForm::OnWebWindowCreateRequested(void)
3362 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3364 if (pNewWindowInfo == null)
3368 result r = E_SUCCESS;
3369 SceneManager* pSceneManager = SceneManager::GetInstance();
3370 if (pSceneManager == NULL)
3374 ArrayList* pArgList = new(std::nothrow) ArrayList();
3375 if (pArgList == NULL)
3379 r = pArgList->Construct();
3382 pNewWindowInfo->isJavascriptInitiated = true;
3383 pArgList->Add(*pNewWindowInfo);
3384 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3388 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3395 return pNewWindowInfo->pCurrentWeb;
3399 MainForm::RelayoutControls(bool showAddressbar)
3401 __webControlPosition.y = 0;
3402 __webControlHeight = GetClientAreaBounds().height;
3403 AppLog("Client area height: %d", __webControlHeight);
3405 AppLog("Client area height: %d", __webControlHeight);
3406 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3408 __webControlPosition.y += __pAddressbar->GetHeight();
3409 __webControlHeight -= __pAddressbar->GetHeight();
3410 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3412 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3414 __webControlPosition.y += __pFindWordControl->GetHeight();
3415 __webControlHeight -= __pFindWordControl->GetHeight();
3416 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3419 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3421 __webControlHeight -= __pFooterPanel->GetHeight();
3422 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3424 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3426 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3427 __pWebViewer->Invalidate(false);
3429 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3431 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3438 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3440 if (__pFindWordControl == null)
3446 InitFindWordPanel();
3447 // __pFindWordEditField->SetText(__currentSearchStr);
3448 //__pFindWordCountLabel->SetText(L"");
3449 // __pFindWordCountLabel->SetText(L"0/0");
3450 __pFindWordControl->SetShowState(true);
3454 if(__pFindWordControl != null)
3456 __pFindWordControl->SetShowState(false);
3460 AppLog("MainForm::ShowFindWordPanel %d",show);
3461 if (show && !isTouchPressed)
3463 if (__pFindWordEditField)
3465 __pFindWordEditField->SetFocus();
3466 __pFindWordEditField->ShowKeypad();
3471 if (__pFindWordEditField)
3472 __pFindWordEditField->HideKeypad();
3475 RelayoutControls(false);
3479 MainForm::StartWordSearch()
3481 //Get the count of occurances of the word in the current page
3482 __maxOccurrances = 0;
3483 __currentWordIndex = 0;
3485 __pFindWordPrev->SetEnabled(false);
3486 String *pCountStr = null;
3487 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3488 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3489 if (pCountStr != null)
3491 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3495 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3500 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3502 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3503 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3505 if(totalCount == -1 || totalCount == 0)
3507 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3508 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3511 else if(totalCount > 100)
3513 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3514 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3518 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3519 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3522 __maxOccurrances = totalCount;
3523 __currentWordIndex = currentOrdinal;
3525 //Reset the UI controls as per the maxOccurrance value
3526 if (totalCount <= 0)
3528 AppLog("Word not found");
3529 //Show error notification to user
3530 __pFindWordNext->SetEnabled(false);
3531 __pFindWordCountLabel->SetText(L"0/0");
3532 __pFindWordNext->Invalidate(false);
3533 __pFindWordPrev->Invalidate(false);
3534 __pFindWordCountLabel->Invalidate(false);
3538 if (totalCount == 1)
3540 __pFindWordNext->SetEnabled(false);
3544 __pFindWordNext->SetEnabled(true);
3547 String countStr = L"";
3548 countStr.Append(__currentWordIndex);
3549 countStr.Append(L"/");
3550 countStr.Append(__maxOccurrances);
3551 __pFindWordCountLabel->SetText(countStr);
3552 // __pFindWordCountLabel->SetShowState(true);
3553 __pFindWordCountLabel->Invalidate(false);
3555 //FindNextWord(true);
3556 //Update the controls
3557 __pFindWordNext->Invalidate(false);
3558 __pFindWordPrev->Invalidate(false);
3559 __pFindWordCountLabel->Invalidate(false);
3563 MainForm::FindNextWord(bool next)
3567 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3569 if(__currentWordIndex < __maxOccurrances)
3571 __currentWordIndex++;
3577 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3579 if(__currentWordIndex > 1)
3581 __currentWordIndex--;
3586 String countStr = L"";
3587 countStr.Append(__currentWordIndex);
3588 countStr.Append(L"/");
3589 countStr.Append(__maxOccurrances);
3590 __pFindWordCountLabel->SetText(countStr);
3591 // __pFindWordCountLabel->SetShowState(true);
3592 __pFindWordCountLabel->Invalidate(false);
3593 if (__currentWordIndex >= __maxOccurrances)
3595 __pFindWordNext->SetEnabled(false);
3599 __pFindWordNext->SetEnabled(true);
3601 if (__currentWordIndex <= 1)
3603 __pFindWordPrev->SetEnabled(false);
3607 __pFindWordPrev->SetEnabled(true);
3609 __pFindWordPrev->Invalidate(false);
3610 __pFindWordNext->Invalidate(false);
3611 __pFindWordCountLabel->Invalidate(false);
3612 __pFindWordControl->Invalidate(true);
3615 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3617 AppLog("MainForm::OnWebKeypadWillOpen");
3618 __isWebKeypadOpened = true;
3619 // OnAddressBarKeypadOpened(*__pAddressbar);
3623 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3626 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3628 __currentSearchStr = L"";
3629 __currentWordIndex = 0;
3630 __maxOccurrances = 0;
3631 __pFindWordEditField->SetText(L"");
3632 __pFindWordNext->SetEnabled(false);
3633 __pFindWordPrev->SetEnabled(false);
3634 __pFindWordCountLabel->SetText(L"0/0");
3635 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3636 __pFindWordControl->SetShowState(false);
3637 if (__pFindWordEditField)
3638 __pFindWordEditField->HideKeypad();
3642 if (__pWebViewer != null && __pFooterPanel != null)
3644 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3645 if(__pAddressbar != null)
3647 __pAddressbar->SetShowState(false);
3649 if(__pFindWordControl != null)
3651 __pFindWordControl->SetShowState(false);
3653 __pFooterPanel->SetShowState(false);
3654 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3660 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3662 __pFooterPanel->SetShowState(true);
3663 OnAddressBarKeypadClosed(*__pAddressbar);
3664 __isWebKeypadOpened = false;
3668 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3670 Control* temp = const_cast< Control* >(&source);
3671 Header* pHeader = dynamic_cast< Header* >(temp);
3672 if (pHeader != null)
3674 //Header double - clicked
3675 AppLog("Header double clicked");
3677 if(__pFindWordControl)
3679 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3680 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3684 AppLog("MainScene::OnTouchDoublePressed");
3685 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3686 if (isReaderEnabled == true)
3690 delete __pReaderData;
3691 __pReaderData = null;
3693 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3694 filePath.Append(L"data/reader.js");
3700 result r = E_SUCCESS;
3701 FileAttributes attr;
3703 File::GetAttributes(filePath,attr);
3705 r = file.Construct(filePath, L"r+");
3708 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3711 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3714 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3717 file.Read(pScript,attr.GetFileSize());
3719 AppLogDebug("scipt length %d",strlen(pScript));
3720 String strScript = L"";
3721 strScript.Append(pScript);
3722 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3725 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3728 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3729 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3731 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3732 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3738 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3740 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3742 if (__pHitElementResult != null)
3744 delete __pHitElementResult;
3745 __pHitElementResult = null;
3748 if (__pWebViewer != null)
3750 AppLog("MainForm::OnTouchLongPressed web not null");
3751 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3754 if (__pHitElementResult == null)
3759 if (__pHitElementResult->HasImage() == true)
3761 InitImageContextMenu(currentPosition);
3762 __pImageMenu->SetShowState(true);
3763 __pImageMenu->Show();
3764 __pImageMenu->Invalidate(true);
3766 else if(__pHitElementResult->HasUrl() == true)
3768 String tempURl = __pHitElementResult->GetUrl();
3769 AppLog("tempURl is %ls", tempURl.GetPointer());
3770 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3771 if (pBitmap != null)
3779 InitImageLinkContextMenu(currentPosition);
3780 __pImageMenu->SetShowState(true);
3781 __pImageMenu->Show();
3782 __pImageMenu->Invalidate(true);
3786 String tagName = __pHitElementResult->GetTagName();
3787 String type = __pHitElementResult->GetAttributeValue("type");
3788 String value = __pHitElementResult->GetAttributeValue(L"value");
3789 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3791 __currentSelectedStr.Clear();
3792 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3794 AppLog("tag name is %ls", tagName.GetPointer());
3795 AppLog("type is %ls", type.GetPointer());
3796 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3798 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3800 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3802 InitSelectTextContextMenu(currentPosition,true, true);
3805 // __pImageMenu->SetShowState(true);
3806 // __pImageMenu->Show();
3807 // __pImageMenu->Invalidate(true);
3810 __isLongPressedDone = true;
3811 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3812 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3815 __inputEventToBeSupressed = true;
3819 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3821 AppLog("MainForm::OnTouchReleased");
3823 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3824 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3826 __pWebViewer->ConsumeInputEvent();
3828 if(pHitElement != null)
3832 __inputEventToBeSupressed = false;
3836 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3843 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3845 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3847 __currentSearchStr = L"";
3848 __currentWordIndex = 0;
3849 __maxOccurrances = 0;
3850 __pFindWordEditField->SetText(L"");
3851 __pFindWordNext->SetEnabled(false);
3852 __pFindWordPrev->SetEnabled(false);
3853 __pFindWordCountLabel->SetText(L"0/0");
3854 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3855 __pFindWordControl->SetShowState(false);
3856 __pFindWordEditField->HideKeypad();
3858 if(__pAddressbar->GetShowState() == false)
3860 __pAddressbar->SetShowState(true);
3861 __pAddressbar->SetAddressbarURLFocus();
3862 __pFooterUrlField->SetFocusable(false);
3863 __pFooterPanel->SetShowState(false);
3870 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3876 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3882 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3888 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3894 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3900 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3902 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3903 int widthContextItem = 0;
3904 if(__pFindWordControl != null)
3905 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3906 if ( __pFooterLabel != null)
3908 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3911 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3916 if (__pFindWordBgLabel != null)
3918 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3919 if (pBitmap != null)
3921 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3927 __pMenu->SetShowState(false);
3928 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3930 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3934 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3939 AppLog("__pFooterPanel->GetShowState() is true");
3941 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3942 __pFooterPanel->Invalidate(true);
3946 if(__pMoreButton && __pMenu)
3948 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3949 __pMenu->SetAnchorPosition(p);
3950 __pMenu->Invalidate(true);
3953 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3954 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3956 InitMostVisitedSitesView(orientationStatus);
3959 RelayoutControls(false);
3960 if (__pArticleReaderPanel != null)
3962 if (__pArticleReaderPanel->GetShowState() == true)
3964 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3966 if (__pBlankPanel != null)
3967 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3969 if (__pWebReader != null)
3971 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3973 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3974 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3976 if ( pBitmap != null && pSrcBitmap != null)
3978 AppLog("CreateReaderPanel ninepatchbitmap found");
3979 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3982 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3983 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3984 if (pBitmap != null)
3989 if (pSrcBitmap != null)
3998 if (__pAddressbar != null)
4000 int width = GetClientAreaBounds().width;
4001 __pAddressbar->OrientationChanged(width);
4006 MainForm::OnSettingsChange(int settingvalue)
4008 AppLogDebug("MainForm::OnSettingsChange entered");
4010 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4012 __pAddressbar->ResetGuideText();
4014 if (__pWebViewer == null)
4016 AppLogDebug("Webviewer is not initialized yet.");
4020 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4022 WebSetting settings = __pWebViewer->GetSetting();
4023 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4025 settings.SetAutoFittingEnabled(true);
4027 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4029 settings.SetAutoFittingEnabled(false);
4031 __pWebViewer->SetSetting(settings);
4033 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4035 WebSetting settings = __pWebViewer->GetSetting();
4036 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4037 __pWebViewer->SetSetting(settings);
4039 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4041 WebSetting settings = __pWebViewer->GetSetting();
4042 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4043 __pWebViewer->SetSetting(settings);
4045 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4047 WebSetting settings = __pWebViewer->GetSetting();
4048 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4049 __pWebViewer->SetSetting(settings);
4051 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4055 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4059 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4061 WebSetting settings = __pWebViewer->GetSetting();
4062 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4064 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4068 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4070 __pWebViewer->SetSetting(settings);
4072 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4076 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4077 WebSetting settings = __pWebReader->GetSetting();
4078 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4079 __pWebReader->SetSetting(settings);
4085 MainForm::OnSettingsReset()
4089 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4090 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4095 MainForm::OnClearCache()
4097 result r = E_SUCCESS;
4099 if (__pWebViewer != NULL)
4101 r = __pWebViewer->ClearCache();
4104 AppLogDebug("Cache cleared success");
4108 AppLogDebug("Cache cleared fail");
4114 MainForm::OnClearCookie()
4116 result r = E_SUCCESS;
4118 if (__pWebViewer != NULL)
4120 __pWebViewer->ClearCookie();
4124 AppLogDebug("Cookie cleared success");
4128 AppLogDebug("Cache cleared fail");
4133 MainForm::OnClearFormData()
4135 result r = E_SUCCESS;
4137 if (__pWebViewer != NULL)
4139 __pWebViewer->ClearFormData();
4143 AppLogDebug("Cookie cleared success");
4147 AppLogDebug("Cache cleared fail");
4152 MainForm::OnClearPasswords()
4154 result r = E_SUCCESS;
4156 if (__pWebViewer != NULL)
4158 __pWebViewer->ClearLoginFormData();
4162 AppLogDebug("Cookie cleared success");
4166 AppLogDebug("Cache cleared fail");
4172 MainForm::findDistance(int x1,int y1,int x2, int y2)
4174 int deltaX = Math::Abs(x2 - x1);
4175 int deltaY = Math::Abs(y2 - y1);
4176 double num = deltaX*deltaX + deltaY*deltaY;
4182 for (i = 0; i < 20; i++)
4184 x = (((x*x)+ num)/(2*x));
4195 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4197 if(__pFindWordControl)
4199 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4200 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4202 __isLongPressedDone = false;
4205 IList* pList = null;
4206 pList = touch.GetTouchInfoListN(source);
4210 int count = pList->GetCount();
4213 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4214 __touchPoint1 = pTouchInfo->position;
4216 /*if (__pAddressbar != null)
4218 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4220 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4222 __pAddressbar->SaveAddressbarEditText();
4224 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4227 __pAddressbar->Invalidate(true);
4229 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4231 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4233 //__pAddressbar->SaveAddressbarEditText();
4235 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4238 else if (count == 2)
4240 AppLogDebug("MainForm::OnTouchPressed count is two");
4241 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4242 __touchPoint1 = pTouchInfo->position;
4244 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4245 __touchPoint2 = pTouchInfo->position;
4251 pList->RemoveAll(true);
4258 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4260 __currentWordIndex = 0;
4261 __isLongPressedDone = false;
4266 MainForm::MoveUiControls()
4271 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4273 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4275 if(__pFooterUrlField->GetTextLength() == 0)
4277 __pFooterUrlField->SetKeypadActionEnabled(false);
4281 __pFooterUrlField->SetKeypadActionEnabled(true);
4284 if (__pFindWordEditField != null)
4286 __currentSearchStr = __pFindWordEditField->GetText();
4287 __pFindWordNext->SetEnabled(false);
4288 __pFindWordPrev->SetEnabled(false);
4289 __pFindWordNext->Invalidate(true);
4290 __pFindWordPrev->Invalidate(true);
4291 __pFindWordCountLabel->SetText(L"0/0");
4292 __pFindWordCountLabel->Invalidate(true);
4294 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4295 if (__currentSearchStr.GetLength() > 0)
4301 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4303 __currentSearchStr = L"";
4304 AppLogDebug("Enter something");
4309 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4316 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4318 if(__pWebViewer != null)
4321 AppLog("MainForm::InitMostVisitedSitesView");
4322 result r = E_SUCCESS;
4325 if (__pWebViewer != null && __pMostVisitedListView != null)
4330 if (__pMostVisitedListView != null)
4332 RemoveControl(*__pMostVisitedListView);
4334 if(__pMostVisitedSites != null)
4336 __pMostVisitedSites->RemoveAll(true);
4339 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4341 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4342 __pMostVisitedListView = new(std::nothrow) ListView();
4344 int height = GetClientAreaBounds().height;
4346 if(__pFooterPanel->GetShowState() == true)
4348 height = height - __pFooterPanel->GetHeight();
4350 if(__pAddressbar->GetShowState() == true)
4352 height -= __pAddressbar->GetHeight();
4355 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4359 delete __pMostVisitedListView;
4360 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4363 __pMostVisitedListView->SetItemProvider(*this);
4364 __pMostVisitedListView->AddListViewItemEventListener(*this);
4365 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4366 AddControl(*__pMostVisitedListView);
4367 __pMostVisitedListView->UpdateList();
4374 MainForm::GetImagePath(void)
4378 String formattedTime;
4379 DateTime currentTime;
4380 LocaleManager localManager;
4381 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4383 localManager.Construct();
4384 Locale locale = localManager.GetSystemLocale();
4385 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4387 // Get date formatter
4388 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4392 pTimeFormatter->Format(currentTime, formattedTime);
4395 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4396 String delim(L" :");
4397 StringTokenizer strTok(formattedTime, delim);
4400 String str1("GMT+00");
4401 while (strTok.HasMoreTokens())
4403 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4404 if(token.Equals(str1))
4406 AppLog("token is %ls", token.GetPointer());
4407 imageName.Append(token);
4413 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4415 result r = E_FAILURE;
4416 AppLog("Content manager 1");
4417 ContentId contentId;
4418 ContentManager contentManager;
4419 r = contentManager.Construct();
4422 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4425 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4426 contentPath.Append(imageName);
4427 contentPath.Append(".jpg");
4428 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4429 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4433 MainForm::SetForwardButtonEnabled(bool isEnabled)
4435 __pGoForwardBtn->SetEnabled(isEnabled);
4436 __pGoForwardBtn->Invalidate(true);
4440 MainForm::SetBackButtonEnabled(bool isEnabled)
4442 __pGoBackBtn->SetEnabled(isEnabled);
4443 __pGoBackBtn->Invalidate(true);
4447 MainForm::UpdateProgress(int percentage)
4449 __progressPercentage = percentage;
4450 if (percentage == 0 || percentage == 100)
4452 __isLoadingData = false;
4453 if (percentage == 100)
4455 __isLoadingCompleted = true;
4456 __progressPercentage = 0;
4460 __isLoadingCompleted = false;
4465 __isLoadingData = true;
4467 UpdateProgressBitmap();
4471 MainForm::GetProgress(void)
4473 return __progressPercentage;
4477 MainForm::UpdateProgressBitmap(void)
4479 result r = E_SUCCESS;
4480 if (__pProgressbarLabel == null)
4482 int w = __pProgressbarLabel->GetWidth();
4483 int h = __pProgressbarLabel->GetHeight();
4485 int progressWidth = 0;
4486 Bitmap* pRetBitmap = null;
4488 if (__progressPercentage == 0 || __progressPercentage == 100)
4490 __pProgressbarLabel->SetShowState(false);
4491 __pProgressbarLabel->Invalidate(false);
4496 __pProgressbarLabel->SetShowState(true);
4497 __pProgressbarLabel->Invalidate(false);
4500 r = canvas.Construct(Rectangle(0, 0, w, h));
4504 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4509 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4513 pBgBmp->Scale(Dimension(w, h));
4514 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4518 progressWidth = (double) (w) * __progressPercentage / 100;
4519 AppLogDebug("progressWidth: %d", progressWidth);
4520 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4522 if (pProgressBmp != null)
4524 pProgressBmp->Scale(Dimension(progressWidth, h));
4525 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4526 delete pProgressBmp;
4529 pRetBitmap = new (std::nothrow) Bitmap();
4531 if (pRetBitmap == null)
4533 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4537 pRetBitmap->Construct(canvas, canvas.GetBounds());
4539 if (__pProgressbarLabel != null && pRetBitmap != null)
4541 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4542 __pProgressbarLabel->Invalidate(false);
4545 if (pRetBitmap != null)
4553 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4555 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4557 __currentAddMode = addMode;
4561 case ADDRESSBAR_MODE_INVALID:
4566 case ADDRESSBAR_MODE_READER:
4568 __pStopBtn->SetShowState(false);
4569 __pClearBtn->SetShowState(false);
4572 case ADDRESSBAR_MODE_LOADING:
4574 __pRefreshBtn->SetShowState(false);
4575 __pStopBtn->SetShowState(true);
4576 __pClearBtn->SetShowState(false);
4579 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4581 // SetUrl(__pAddressbar->GetUrl());
4583 __pRefreshBtn->SetShowState(true);
4584 __pStopBtn->SetShowState(false);
4585 __pClearBtn->SetShowState(false);
4588 case ADDRESSBAR_MODE_EDIT:
4590 __pRefreshBtn->SetShowState(false);
4591 __pStopBtn->SetShowState(false);
4592 __pClearBtn->SetShowState(true);
4599 OnAddressBarModeChanged();
4602 AddressBarMode MainForm::GetAddressbarMode(void)
4604 return __currentAddMode;
4607 void MainForm::SetUrl(const String& url)
4611 if (__pFooterUrlField != NULL)
4613 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4614 if (removedHttpUrl.IsEmpty() == false)
4616 __pFooterUrlField->SetText(removedHttpUrl);
4617 __pAddressbar->SetUrl(__displayUrl);
4621 __pFooterUrlField->SetText(__displayUrl);
4622 __pAddressbar->SetUrl(__displayUrl);
4624 if(__pFooterUrlField)
4625 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4626 __pFooterUrlField->Invalidate(false);
4627 __pAddressbar->Invalidate(true);
4628 // __pFooterUrlField->SetCursorPosition(0);
4633 MainForm::RemoveHttpTextFromDisplayURL(void)
4635 bool isHttpText = __displayUrl.Contains(L"http://");
4636 String updatedDisplayUrl;
4637 updatedDisplayUrl.Clear();
4639 if (isHttpText == true)
4641 __displayUrl.SubString(7,updatedDisplayUrl);
4643 return updatedDisplayUrl;
4646 void MainForm::OnSharePopupControlStarted(void)
4648 __pWebViewer->AddTouchEventListener(*this);