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 if(__pMostVisitedSites != null)
1171 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1172 if (pHistory != null)
1174 String url = pHistory->GetHistoryUrl();
1176 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1177 __pMostVisitedListView->UpdateList();
1183 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1185 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1186 String url = pHistory->GetHistoryUrl();
1194 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1200 MainForm::OnTerminating(void)
1202 result r = E_SUCCESS;
1205 delete __pItemContext;
1207 if(__pItemContextLandscape)
1209 delete __pItemContextLandscape;
1215 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1217 result r = E_SUCCESS;
1219 AppLogDebug("Clicked : %d", actionId);
1222 // case IDA_BACKBTN_CLICKED:
1224 // if (__pWebViewer && __pWebViewer->CanGoBack())
1226 // __pWebViewer->GoBack();
1230 // UiApp* pApp = null;
1231 // pApp = UiApp::GetInstance();
1232 // if (pApp != null)
1234 // r = pApp->Terminate();
1237 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1245 case IDA_BACKBTN_CLICKED:
1247 if (__pWebViewer && __pWebViewer->CanGoBack())
1249 __pWebViewer->GoBack();
1251 else if(__pWindowInfo->isJavascriptInitiated == false)
1254 pApp = UiApp::GetInstance();
1257 r = pApp->Terminate();
1260 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1268 WindowInfo* pWindowInfo = null;
1270 SceneManager* pSceneManager = SceneManager::GetInstance();
1271 if (pSceneManager == null)
1275 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1276 if (pAllWindowList == NULL)
1278 pApp = UiApp::GetInstance();
1281 r = pApp->Terminate();
1284 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1289 if (pAllWindowList != null)
1291 totalCount = pAllWindowList->GetCount();
1293 for (int count = 0; count < totalCount; count++)
1295 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1296 if (pWindowInfo == null)
1298 pApp = UiApp::GetInstance();
1301 r = pApp->Terminate();
1304 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1309 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1311 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1314 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1317 r = pAllWindowList->RemoveAt(count, true);
1318 __pWindowInfo = null;
1321 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1326 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1330 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1332 if (pWindowInfo == null)
1334 pApp = UiApp::GetInstance();
1337 r = pApp->Terminate();
1343 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1346 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1359 case IDA_FORWARD_CLICKED:
1360 if (__pWebViewer == null)
1363 if (__pWebViewer->CanGoForward())
1365 __pWebViewer->GoForward();
1367 __pMenu->SetShowState(false);
1368 __pMenu->Invalidate(false);
1371 case IDA_FINDONPAGE_CLICKED:
1373 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1374 __currentSearchStr.Clear();
1376 InitFindWordPanel();
1377 __pMenu->SetShowState(false);
1378 __pMenu->Invalidate(false);
1380 __pFindWordEditField->SetFocus();
1382 if (__pWebViewer != null)
1384 // releasing the set block
1385 __pWebViewer->ReleaseBlock();
1388 ShowFindWordPanel(true);
1391 case IDA_PRIVATEON_CLICKED:
1393 result r = E_SUCCESS;
1395 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1396 Bitmap* pBitmap = null;
1397 if (isPrivateBrowsing == true)
1399 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1402 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1406 if (__pWebViewer != NULL)
1408 __pWebViewer->SetPrivateBrowsingEnabled(false);
1411 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1413 if (__pAddressbar != null)
1415 __pAddressbar->UpdateFaviconBitmap(false);
1421 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1424 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1428 if (__pWebViewer != NULL)
1430 __pWebViewer->SetPrivateBrowsingEnabled(true);
1433 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1435 if (__pAddressbar != null)
1437 __pAddressbar->UpdateFaviconBitmap(true);
1442 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1443 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1444 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1445 __pMenu->Invalidate(true);
1447 if ( pBitmap != NULL )
1454 case IDA_SETTINGS_CLICKED:
1457 ArrayList* pArgList = new(std::nothrow) ArrayList();
1460 pArgList->Construct();
1461 pArgList->Add(*__pWindowInfo);
1462 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1464 __pMenu->SetShowState(false);
1465 __pMenu->Invalidate(false);
1466 if (pArgList != null)
1475 case IDA_ADDTOBOOKMARK_CLICKED:
1478 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1480 int bookmarkCount=0;
1483 url=__pWindowInfo->pageUrl;
1484 result r = E_SUCCESS;
1485 Bitmap* pBitmap = null;
1486 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1494 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1495 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1496 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1498 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1499 if (pNotification != null)
1501 pNotification->SetText(message);
1502 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1503 pNotification->ShowNotification();
1508 String title=__pWindowInfo->pageTitle;
1509 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1510 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1512 pBookmark->SetBookmarkTitle(title);
1513 pBookmark->SetUrl(url);
1514 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1516 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1518 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1519 pBookmark->SetFaviconId(id);
1520 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1521 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1524 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1525 if (pNotification != null)
1527 pNotification->SetText(message);
1528 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1529 pNotification->ShowNotification();
1530 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1533 if (pBitmap != null)
1535 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1539 __pMenu->Invalidate(true);
1543 case IDA_SHARE_CLICKED:
1545 if(__pPopUp != null)
1550 __pPopUp = new(std::nothrow) SharePopup();
1551 __pPopUp->Initialize();
1552 if (__pWindowInfo != null)
1554 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1555 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1556 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1557 pShareInfo->SetImageAttached(false);
1558 __pPopUp->RemoveAllShareInfo();
1559 __pPopUp->AddShareInfo(pShareInfo);
1561 __pPopUp->SetShowState(true);
1565 case IDA_BOOKMARKBTN_CLICKED:
1567 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1568 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1571 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1576 case IDA_MOREBTN_CLICKED:
1578 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1579 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1580 AppLog("Anchot pos: %d %d", p.x, p.y);
1582 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1584 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1585 int bookmarkCount=0;
1588 url=__pWindowInfo->pageUrl;
1589 result r = E_SUCCESS;
1590 Bitmap* pBitmap = null;
1592 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1595 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1600 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1604 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1606 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1608 if (__pMenu->GetItemCount() == 8)
1610 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1614 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1619 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1623 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1624 if (__pMenu->GetItemCount() != 8)
1626 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1628 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1629 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1630 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1631 __pMenu->SetMaxVisibleItemsCount(6);
1633 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1635 AppLog(" Orientation landscape");
1636 __pMenu->SetMaxVisibleItemsCount(5);
1640 AppLog(" Orientation potrait");
1641 __pMenu->SetMaxVisibleItemsCount(6);
1644 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1647 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1648 __pMenu->SetShowState(true);
1649 __pMenu->Invalidate(true);
1653 case IDA_HISTORY_CLICKED:
1655 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1656 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1659 case IDA_SAVED_PAGES_CLICKED:
1664 case IDA_DESKTOP_VIEW_CLICKED:
1669 case IDA_SAVE_CLICKED:
1674 case IDA_MULTIWINDOWBTN_CLICKED:
1676 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1677 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1681 case IDA_NEWWINDOWBTN_CLICKED:
1683 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1685 if (pNewWindowInfo == null)
1689 result r = E_SUCCESS;
1690 SceneManager* pSceneManager = SceneManager::GetInstance();
1692 if (pSceneManager == NULL)
1696 ArrayList* pArgList = new(std::nothrow) ArrayList();
1697 if (pArgList == NULL)
1701 r = pArgList->Construct();
1704 pArgList->Add(*pNewWindowInfo);
1705 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1711 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1716 case IDA_SMALLFONT_BTN_CLICKED:
1718 WebSetting setting = __pWebReader->GetSetting();
1719 setting.SetFontSize(15);
1720 __pWebReader->SetSetting(setting);
1723 case IDA_LARGEFONT_BTN_CLICKED:
1725 WebSetting setting = __pWebReader->GetSetting();
1726 setting.SetFontSize(25);
1727 __pWebReader->SetSetting(setting);
1730 case IDA_READER_CLOSE_CLICKED:
1732 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1734 //__pArticleReaderPanel->SetShowState(false);
1735 //__pArticleReaderPanel->Show();
1736 RemoveControl(*__pBlankPanel);
1737 //RemoveControl(*__pArticleReaderPanel);
1738 __pArticleReaderPanel = null;
1739 __pBlankPanel = null;
1740 __pArticleReaderLabel = null;
1742 //if (__pAddressbar)
1743 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1744 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1747 case IDA_FINDWORD_CANCEL_CLICKED:
1749 __currentSearchStr = L"";
1750 __currentWordIndex = 0;
1751 __maxOccurrances = 0;
1752 __pFindWordEditField->SetText(L"");
1753 __pFindWordNext->SetEnabled(false);
1754 __pFindWordPrev->SetEnabled(false);
1755 __pFindWordCountLabel->SetText(L"0/0");
1756 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1757 ShowFindWordPanel(false);
1760 case IDA_FINDWORD_SEARCH_CLICKED:
1762 __currentSearchStr = __pFindWordEditField->GetText();
1763 if (__currentSearchStr.GetLength() > 0)
1769 AppLogDebug("Enter something");
1773 case IDA_FINDWORD_CLEAR_CLICKED:
1775 __pFindWordCountLabel->SetText(L"0/0");
1776 __pFindWordEditField->SetText(L"");
1777 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1779 __currentSearchStr = L"";
1780 __pFindWordNext->SetEnabled(false);
1781 __pFindWordPrev->SetEnabled(false);
1782 __pFindWordControl->Invalidate(true);
1785 case IDA_FINDWORD_NEXT_CLICKED:
1790 case IDA_FINDWORD_PREV_CLICKED:
1792 FindNextWord(false);
1795 case IDA_BRIGHTNESS_BTN_CLICKED:
1797 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1798 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1801 case IDA_COPY_IMAGE_CLICKED:
1803 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1804 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1806 const Bitmap* pBitmap = null;
1807 if (__pHitElementResult != null)
1809 pBitmap = __pHitElementResult->GetImage();
1812 String resourcePath = App::GetInstance()->GetAppResourcePath();
1813 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1815 // copying the item to clipboard
1816 Clipboard* pClipboard = Clipboard::GetInstance();
1817 if (pClipboard != null)
1819 pClipboard->CopyItem(item);
1823 case IDA_VIEW_IMAGE_CLICKED:
1825 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1826 WindowInfo* pNewWindowInfo = null;
1827 if (__pHitElementResult != null)
1829 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1830 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1836 case IDA_SAVE_IMAGE_CLICKED:
1838 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1839 const Bitmap* pSaveBitmap = null;
1840 String imageName = GetImagePath();
1841 AppLog("Content manager image name %ls",imageName.GetPointer());
1844 imagePath.Append(imageName);
1845 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1846 AppLog("Content manager image path %ls",imagePath.GetPointer());
1847 if (__pHitElementResult != null)
1849 pSaveBitmap = __pHitElementResult->GetImage();
1851 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1855 UpdateImageContent(pBuffer, imageName);
1857 NotificationPanel *pNotification = new NotificationPanel(*this);
1859 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1860 msg.Append(imagePath);
1861 if (pNotification != null)
1863 pNotification->SetText(msg);
1864 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1865 pNotification->ShowNotification();
1870 int __modalMsgBoxResult;
1871 MessageBox* pMsgBox = new MessageBox();
1872 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1873 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1876 __modalMsgBoxResult = 0;
1880 case IDA_SHARE_IMAGE_CLICKED:
1882 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1883 if (__pPopUp != null)
1888 __pPopUp = new(std::nothrow) SharePopup();
1889 __pPopUp->Initialize();
1890 if (__pHitElementResult != null)
1892 const Bitmap* pSaveBitmap = null;
1893 String imageName = GetImagePath();
1894 AppLog("Content manager image name %ls",imageName.GetPointer());
1897 imagePath.Append(imageName);
1898 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1899 AppLog("Content manager image path %ls",imagePath.GetPointer());
1900 if (__pHitElementResult != null)
1902 pSaveBitmap = __pHitElementResult->GetImage();
1904 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1906 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1907 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1909 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1910 pShareInfo->SetPageTitle(L"");
1911 pShareInfo->SetPageUrl(srcUrl);
1912 pShareInfo->SetImageAttached(true);
1913 pShareInfo->SetImagePath(imagePath);
1914 __pPopUp->RemoveAllShareInfo();
1915 __pPopUp->AddShareInfo(pShareInfo);
1916 __pPopUp->SetShowState(true);
1921 case IDA_HYPERLINK_OPEN_CLICKED:
1923 if (__pHitElementResult != null)
1925 String srcUrl = __pHitElementResult->GetUrl();
1927 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
1929 if (pNewWindowInfo == null)
1933 result r = E_SUCCESS;
1934 SceneManager* pSceneManager = SceneManager::GetInstance();
1935 if (pSceneManager == NULL)
1939 ArrayList* pArgList = new(std::nothrow) ArrayList();
1940 if (pArgList == NULL)
1944 pArgList->Construct();
1946 pArgList->Add(*pNewWindowInfo);
1947 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1948 if (pArgList != null)
1955 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
1961 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
1963 if (__pHitElementResult == null)
1968 if(__pPopUp != null)
1973 __pPopUp = new(std::nothrow) SharePopup();
1974 __pPopUp->Initialize();
1976 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1977 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
1978 pShareInfo->SetImageAttached(false);
1979 __pPopUp->RemoveAllShareInfo();
1980 __pPopUp->AddShareInfo(pShareInfo);
1982 __pPopUp->SetShowState(true);
1986 case IDA_HYPERLINK_COPY_LINK_CLICKED:
1990 if (__pHitElementResult != null)
1992 url = __pHitElementResult->GetUrl();
1995 String resourcePath = App::GetInstance()->GetAppResourcePath();
1996 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
1998 // copying the item to clipboard
1999 Clipboard* pClipboard = Clipboard::GetInstance();
2000 if (pClipboard != null)
2002 pClipboard->CopyItem(item);
2006 case IDA_FIND_TEXT__CLICKED:
2008 OnAddressCancelledClicked(*__pAddressbar);
2009 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2010 __currentSearchStr.Clear();
2011 __currentSearchStr.Append(__currentSelectedStr);
2012 InitFindWordPanel();
2013 __pFindWordEditField->SetText(__currentSearchStr);
2016 __pMenu->SetShowState(false);
2017 __pMenu->Invalidate(false);
2020 __adressPanelPosition.y = 0;
2022 if (__pAddressbar != null && __pWebViewer != NULL)
2024 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2025 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2026 //__pAddressbar->Invalidate(true);
2027 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2029 if (__pFooterPanel->GetShowState() == false)
2030 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2032 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2033 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2034 __pWebViewer->Invalidate(true);
2037 ShowFindWordPanel(true);
2038 __pFindWordEditField->SetFocus();
2039 if (__currentSearchStr.GetLength() > 0)
2045 AppLogDebug("Enter something");
2048 if (__pWebViewer != null)
2050 // releasing the set block
2051 __pWebViewer->ReleaseBlock();
2056 case IDA_SHARE_TEXT_CLICKED:
2058 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2059 if(__pPopUp != null)
2064 __pPopUp = new(std::nothrow) SharePopup();
2065 __pPopUp->Initialize();
2066 if (__pHitElementResult != null)
2068 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2069 pShareInfo->SetPageTitle(L"");
2070 pShareInfo->SetPageUrl(__currentSelectedStr);
2071 pShareInfo->SetImageAttached(false);
2072 __pPopUp->RemoveAllShareInfo();
2073 __pPopUp->AddShareInfo(pShareInfo);
2074 __pPopUp->SetShowState(true);
2079 case IDA_COPY_TEXT_CLICKED:
2081 __pWebViewer->ReleaseBlock();
2082 // need to implement
2083 //__currentSelectedStr
2084 // Sets data to a clip board item
2086 String resourcePath = App::GetInstance()->GetAppResourcePath();
2087 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2089 // copying the item to clipboard
2090 Clipboard* pClipboard = Clipboard::GetInstance();
2091 if (pClipboard != null)
2093 pClipboard->CopyItem(item);
2097 case IDA_PASTE_TEXT_CLICKED:
2099 Clipboard* pClipboard = Clipboard::GetInstance();
2101 if(pClipboard == null)
2105 // Retrieves a latest item
2106 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2112 //Gets data from the clipboard item
2113 String* pString = dynamic_cast<String*>(pItem->GetData());
2115 if (pString != null)
2117 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2118 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2119 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2120 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; } } ";
2121 if(idElement.GetLength() != 0)
2123 script.Append("insertAtCursor(");
2124 script.Append(idElement);
2126 script.Append("\"");
2127 script.Append(*pString);
2128 script.Append("\");");
2130 else if (nameElement.GetLength() != 0)
2132 script.Append("insertAtCursor(document.getElementsByName('");
2133 script.Append(nameElement);
2134 script.Append("')[0],");
2135 script.Append("\"");
2136 script.Append(*pString);
2137 script.Append("\");");
2139 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2140 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2151 case IDA_GO_FORWARD:
2156 case IDA_REFRESH_BTN_CLICKED:
2158 __isLoadingCompleted = false;
2159 __isLoadingData = true;
2160 __progressPercentage = 0;
2161 __displayUrl = __pFooterUrlField->GetText();
2163 String url = __pFooterUrlField->GetText();
2164 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2168 UpdateProgressBitmap();
2171 case IDA_STOP_BTN_CLICKED:
2173 __isLoadingCompleted = false;
2174 __isLoadingData = false;
2175 __progressPercentage = 0;
2176 __pFooterUrlField->HideKeypad();
2177 __displayUrl = __pFooterUrlField->GetText();
2181 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2182 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2183 __pWebViewer->StopLoading();
2184 RequestRedraw(true);
2187 UpdateProgressBitmap();
2192 if (__pFooterUrlField->GetText().IsEmpty() == false)
2194 //__displayUrl = __pUrlField->GetText();
2195 __pFooterUrlField->Clear();
2206 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2209 UiApp* pApp = UiApp::GetInstance();
2218 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2219 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2221 AppLog("MainForm::OnSceneActivatedN called");
2222 String* pSelectedScene = NULL;
2223 Object* pValue = NULL;
2224 String* pUrl = null;
2225 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2226 pSelectedScene = (String*) pValue;
2228 if (pSelectedScene != null)
2230 delete pSelectedScene;
2232 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2233 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2234 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2235 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2237 // setting the current scene ID
2238 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2240 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2242 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2244 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2245 if(__pWindowInfo == null)
2247 // if(__pWindowInfo == null)
2249 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2252 else if ( pArgs != null && pArgs->GetCount() == 1)
2254 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2260 // hiding the address bar
2261 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2262 __pAddressbar->SetShowState(false);
2263 if(__pWebViewer != null)
2265 __pWebViewer->Resume();
2268 if(pUrl != null && pUrl->GetLength() > 0)
2272 else if(__pWindowInfo != null)
2274 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)
2276 LoadUrl(__pWindowInfo->pageUrl);
2278 else if (__pWindowInfo->isJavascriptInitiated == true)
2282 __pWindowInfo->pCurrentWeb = __pWebViewer;
2286 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2287 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2288 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2290 InitMostVisitedSitesView(GetOrientationStatus());
2293 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2295 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2297 if (pBookmarkUrl == null)
2299 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2300 //__pAddressbar->SetUrl(*pBookmarkUrl);
2301 SetUrl(*pBookmarkUrl);
2303 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2304 __pWebViewer->LoadUrl(*pBookmarkUrl);
2305 delete pBookmarkUrl;
2308 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2309 Bitmap* pBitmap = null;
2310 if (isPrivateBrowsing == true)
2312 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2314 if (__pWebViewer != null)
2316 __pWebViewer->SetPrivateBrowsingEnabled(true);
2319 if (__pAddressbar != null)
2321 // __pAddressbar->UpdateFaviconBitmap(true);
2327 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2329 if (__pWebViewer != null)
2331 __pWebViewer->SetPrivateBrowsingEnabled(false);
2334 if (__pAddressbar != null)
2336 // __pAddressbar->UpdateFaviconBitmap(false);
2340 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2342 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2344 else if (__pMenu != null )
2346 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2349 if (pBitmap != null)
2354 AppLog("ABC: OnSceneActivatedN started exit");
2359 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2360 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2362 Canvas* pWebCanvas = null;
2363 if (__pWebViewer != null)
2365 pWebCanvas = __pWebViewer->GetCanvasN();
2366 __pWebViewer->Pause();
2369 if (pWebCanvas == null)
2373 if (__pWindowInfo != null)
2375 if (__pWindowInfo->pWebCanvasBitmap != null)
2377 delete __pWindowInfo->pWebCanvasBitmap;
2379 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2380 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2381 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2383 Bitmap* pBitmap = GetCapturedBitmapN();
2384 AppLog("Coming here");
2385 Canvas* pCanvas = new(std::nothrow) Canvas();
2386 pCanvas->Construct(GetClientAreaBounds());
2389 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2392 if(__pWebViewer != null && __pWindowInfo != null)
2393 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2395 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2396 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2398 AppLog("Coming here");
2402 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2403 const Tizen::Base::String& realm,
2404 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2410 MainForm::OnHttpAuthenticationCanceled(void)
2415 MainForm::OnLoadingStarted(void)
2417 AppLogDebug("MainForm::OnLoadingStarted entered");
2419 if(__pAddressbar == NULL || __pWebViewer == null)
2423 String url = __pWebViewer->GetUrl();
2424 if(url.Contains(IDS_TIZEN_SERVICE))
2427 String delim(L":;");
2429 // Creates a StringTokenizer instance
2430 StringTokenizer strTok(url, delim);
2432 int count = strTok.GetTokenCount(); // count == 4
2434 HashMap *pMap = new HashMap();
2439 while (strTok.HasMoreTokens())
2441 AppLog("Token: %ls", token.GetPointer());
2442 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2443 if(token.Contains(IDS_APPID))
2445 token.SubString(6, appId);
2446 AppLog("AppID:%ls", appId.GetPointer());
2448 else if(token.Contains("="))
2450 String *pKey = new String();
2451 String *pValue = new String();
2453 token.IndexOf("=", 0, index);
2456 token.SubString(0, index, *pKey);
2457 token.SubString(index + 1, *pValue);
2458 pMap->Add(pKey, pValue);
2464 AppControl *pAppControl = null;
2465 String operationId = L"http://tizen.org/appcontrol/operation/main";
2466 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2469 AppLog("Starting AppControl");
2470 result r = pAppControl->Start(null, null, pMap, null);
2471 AppLog("Result of Start %s", GetErrorMessage(r));
2475 AppLogException("AppControl not found");
2480 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2483 __pAddressbar->SetFaviconBitmap(*pBitmap);
2486 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2488 // updating the address bar position with respect to web control
2489 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2490 __distanceMoved = 0;
2494 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2495 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2496 if (__pWebViewer != null)
2498 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2499 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2500 SetUrl(__pWebViewer->GetUrl());
2501 if (__pWindowInfo != NULL)
2503 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2505 __pAddressbar->Invalidate(true);
2511 MainForm::OnLoadingCanceled(void)
2518 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2520 AppLog("MainForm::OnKeypadWillOpen");
2521 if (__pAddressbar != null)
2523 OnAddressBarKeypadWillOpen(*__pAddressbar);
2529 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2531 if(__pAddressbar != null)
2533 OnAddressBarKeypadOpened(*__pAddressbar);
2539 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2543 if (__pAddressbar != null)
2545 OnAddressBarKeypadClosed(*__pAddressbar);
2550 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2552 AppLog("KeypadBoundsChanged");
2553 RelayoutControls(false);
2557 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2558 const Tizen::Base::String& reason)
2560 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2564 MainForm::OnLoadingCompleted(void)
2566 AppLog("MainForm::OnLoadingCompleted start");
2568 result r = E_SUCCESS;
2570 if (__pWebViewer == null)
2575 if (__pAddressbar == null)
2579 if (__pWebViewer->CanGoForward())
2581 //__pAddressbar->SetForwardButtonEnabled(true);
2582 SetForwardButtonEnabled(true);
2586 //__pAddressbar->SetForwardButtonEnabled(false);
2587 SetForwardButtonEnabled(false);
2590 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2592 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2594 //__pAddressbar->UpdateProgress(0);
2598 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2600 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2604 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2605 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2606 if (isPrivateBrowsing == false)
2608 History* pHistory = new(std::nothrow) History;
2610 HistoryPresentationModel::GetCurrentDateTime(date);
2613 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2614 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2616 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2617 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2619 pHistory->SetVisitedTime(date);
2622 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2623 pHistory->SetFaviconId(id);*/
2625 if (__pWebViewer != null)
2627 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2629 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2630 if (pTempBitmap != null)
2632 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2633 pHistory->SetFavIconBitmap(*pTempBitmap);
2636 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2639 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2640 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2641 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2643 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2644 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2645 pHistory->SetThumbnail(pBitmap);
2647 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2650 pHistory->SetFavIconBitmap(*pFavIcon);
2654 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2661 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2663 // temperary fixed (webpage can be not loaded)
2666 AppLog("MainForm::OnLoadingCompleted done");
2670 MainForm::OnEstimatedProgress(int progress)
2672 AppLogDebug("MainForm::OnEstimatedProgress entered");
2673 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2674 progress = DEFAULT_PROGRESS_PERCENTAGE;
2676 // __pAddressbar->UpdateProgress(progress);
2677 UpdateProgress(progress);
2680 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2682 AppLog("MainForm::OnFaviconReceived");
2683 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2685 if (pFavIconBitmap != null)
2687 pFavIconBitmap->GetWidth();
2688 pFavIconBitmap->GetHeight();
2693 MainForm::OnUrlValueChanged(Addressbar&)
2699 MainForm::OnUrlSubmitted(Addressbar& addBar)
2701 AppLog("MainForm::OnUrlSubmitted");
2702 String url = addBar.GetUrl();
2703 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2705 // __pFooterPanel->SetShowState(true);
2706 if(__pFooterUrlField)
2707 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2708 OnAddressCancelledClicked(*__pAddressbar);
2709 // __pAddressbar->SetShowState(false);
2710 // RelayoutControls(false);
2715 MainForm::LoadUrl(String& url)
2719 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2720 AppLogDebug("MainForm::LoadUrl enter");
2722 if (__pWebViewer != null)
2724 __pWebViewer->SetShowState(true);
2725 __pWebViewer->Invalidate(true);
2728 if (url.CompareTo(L"") == 0)
2732 if(__pFooterPanel != null)
2734 __pFooterPanel->SetShowState(true);
2735 __pFooterPanel->Invalidate(true);
2742 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2743 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)
2745 RegularExpression firstRegex;
2746 RegularExpression secondRegex;
2748 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2749 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2752 ret = firstRegex.Match(url, false); // This returns true value
2753 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2755 if (ret == true && __pWebViewer != null)
2758 __pWebViewer->LoadUrl(url);
2760 else if(__pWebViewer != null)
2762 String tempUrl = L"http://";
2763 tempUrl.Append(url);
2767 __pWebViewer->LoadUrl(tempUrl);
2771 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2772 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2775 if (__pAddressbar != null)
2777 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2778 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2781 AppLogDebug("MainForm::LoadUrl exit");
2788 MainForm::OnStopClicked(Addressbar& addBar)
2790 AppLogDebug("MainForm::OnStopClicked called");
2793 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2794 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2795 __pWebViewer->StopLoading();
2796 RequestRedraw(true);
2801 MainForm::OnReaderClicked(const Addressbar& addBar)
2803 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2805 CreateReaderPanel();
2806 AppLogDebug("MainScene::OnReaderClicked entered");
2809 /*if (__pArticleReaderPanel)
2811 AppLogDebug("showstate true for reader panel");
2812 __pArticleReaderPanel->SetShowState(true);
2813 __pArticleReaderPanel->Show();
2815 int xPos = __pArticleReaderPanel->GetX();
2816 int yPos = __pArticleReaderPanel->GetY();
2817 AppLog("OnReaderClicked() xPos = %d",xPos);
2818 AppLog("OnReaderClicked() yPos = %d",yPos);
2820 if (__pReaderData == null)
2825 String loadData = L"<html>\
2827 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2832 background-color: transparent;\
2851 <body style='width:'";
2852 loadData.Append(bodyWidth);
2853 loadData.Append(L"px'>");
2854 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2855 loadData.Append(*__pReaderData);
2856 loadData.Append(L"</body></html>");
2859 buf.Construct(loadData.GetLength());
2860 AppLogDebug("data->GetLength %d",loadData.GetLength());
2861 for (int z=0;z<loadData.GetLength();z++)
2864 loadData.GetCharAt(z,b);
2865 buf.SetByte((byte)b);
2869 if (__pWebReader != null)
2871 __pWebReader->LoadData(L"",buf,L"text/html");
2872 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2876 AppLogDebug("cannot LoadData __pWebReader is null");
2882 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2884 // AppLog("MainForm::OnBackClicked");
2885 result r = E_FAILURE;
2887 if (__pWebViewer && __pWebViewer->CanGoBack())
2889 __pWebViewer->GoBack();
2891 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2894 pApp = UiApp::GetInstance();
2897 r = pApp->Terminate();
2900 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2908 WindowInfo* pWindowInfo = null;
2910 SceneManager* pSceneManager = SceneManager::GetInstance();
2911 if (pSceneManager == null)
2915 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2916 if (pAllWindowList == NULL)
2918 pApp = UiApp::GetInstance();
2921 r = pApp->Terminate();
2924 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2929 if (pAllWindowList != null)
2931 totalCount = pAllWindowList->GetCount();
2933 for (int count = 0; count < totalCount; count++)
2935 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2936 if (pWindowInfo == null)
2938 pApp = UiApp::GetInstance();
2941 r = pApp->Terminate();
2944 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2949 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2951 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2954 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2957 r = pAllWindowList->RemoveAt(count, true);
2958 __pWindowInfo = null;
2961 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2966 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2970 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2972 if (pWindowInfo == null)
2974 pApp = UiApp::GetInstance();
2977 r = pApp->Terminate();
2983 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2986 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3000 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3002 AppLog("MainForm::OnForwardClicked");
3003 if (__pWebViewer == null)
3006 if (__pWebViewer->CanGoForward())
3008 __pWebViewer->GoForward();
3013 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3015 result r = E_SUCCESS;
3017 __pFooterPanel->SetShowState(true);
3018 __pFooterUrlField->SetFocusable(true);
3021 __pWebViewer->SetFocus();
3022 else if(__pMostVisitedListView)
3023 __pMostVisitedListView->SetFocus();
3024 else if(__pMultiWindowButton)
3025 __pMultiWindowButton->SetFocus();
3026 __pMoreButton->SetFocus();
3028 __pAddressbar->SetShowState(false);
3030 RelayoutControls(false);
3035 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3037 __prevAddressBarMode = __curAddressBarMode;
3039 if (__pAddressbar != null)
3041 __curAddressBarMode = GetAddressbarMode();
3044 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3046 __adressPanelPosition.y = 0;
3047 if (__pAddressbar != null)
3049 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3050 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3051 __pAddressbar->Invalidate(true);
3053 if (__pWebViewer != null)
3055 __pWebViewer->StopLoading();
3058 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3060 __adressPanelPosition.y = 0;
3061 if (__pAddressbar != null)
3063 __webControlPosition.y = 0;
3064 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3065 __pAddressbar->Invalidate(true);
3071 MainForm::OnClipboardClosed(const Addressbar& addBar)
3073 RelayoutControls(false);
3077 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3080 __pAddressbar->SetShowState(false);
3082 __pFooterPanel->SetShowState(true);
3084 // __pWebViewer->SetFocus();
3085 if(__pFooterUrlField)
3087 __pFooterUrlField->SetFocusable(true);
3089 RelayoutControls(false);
3093 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3095 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3097 __pAddressbar->SetShowState(false);
3101 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3103 __pAddressbar->SetShowState(true);
3104 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3105 __pAddressbar->SetAddressbarURLFocus();
3109 RelayoutControls(false);
3113 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3115 __pFooterPanel->SetShowState(false);
3119 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3121 AppLog("KeypadBoundsChanged");
3122 RelayoutControls(false);
3126 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3130 __pWindowInfo->pageTitle = title;
3131 if (__pWebViewer != null)
3133 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3136 if (__pAddressbar != null && __pWebViewer != null)
3138 SetUrl(__pWebViewer->GetUrl());
3139 __pAddressbar->Invalidate(true);
3144 MainForm::UpdateFavicon(void)
3146 bool urlImageType = false;
3147 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();");
3148 Bitmap* pBitmap = null;
3150 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3152 if (__pWindowInfo != null)
3155 url.SetUri(*tempPath);
3156 if (url.GetHost().GetLength() == 0)
3159 webUrl.SetUri(__pWebViewer->GetUrl());
3160 result r = url.SetHost(webUrl.GetHost());
3167 if (url.GetScheme().GetLength() == 0)
3170 webUrl.SetUri(__pWebViewer->GetUrl());
3171 url.SetScheme(webUrl.GetScheme());
3173 __pWindowInfo->faviconUrl = url.ToString();
3175 pBitmap = __pWebViewer->GetFaviconN();
3177 if (pBitmap != null)
3179 if (__pWindowInfo->pFavicon != NULL)
3181 __pWindowInfo->pFavicon = null;
3183 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3184 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3186 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3188 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3190 else if(__pWindowInfo->pFavicon != null)
3192 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3196 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3197 if(pDefaultBmp != null)
3199 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3208 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3215 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3216 Tizen::Web::Controls::WebNavigationType type)
3218 // when load new page if find word panel is open its show state is false
3219 ShowFindWordPanel(false);
3221 __pFooterPanel->Invalidate(true);
3224 uriInfo.SetUri(url);
3226 if(url.Contains(IDS_TIZEN_SERVICE))
3229 String delim(L":;,");
3231 // Creates a StringTokenizer instance
3232 StringTokenizer strTok(url, delim);
3234 int count = strTok.GetTokenCount(); // count == 4
3236 HashMap *pMap = new HashMap();
3242 while (strTok.HasMoreTokens())
3244 AppLog("Token: %ls", token.GetPointer());
3245 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3246 if(token.Contains(IDS_APPID))
3248 token.SubString(6, appId);
3249 AppLog("AppID:%ls", appId.GetPointer());
3251 else if(token.Contains("="))
3253 String *pKey = new String();
3254 String *pValue = new String();
3256 token.IndexOf("=", 0, index);
3259 token.SubString(0, index, *pKey);
3260 token.SubString(index + 1, *pValue);
3261 pMap->Add(pKey, pValue);
3267 AppControl *pAppControl = null;
3268 String operationId = L"http://tizen.org/appcontrol/operation/main";
3269 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3272 result r = pAppControl->Start(null, null, pMap, null);
3276 AppLogException("AppControl not found");
3282 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3284 __pAddressbar->SetShowState(false);
3285 OnAddressCancelledClicked(*__pAddressbar);
3286 __pAddressbar->Invalidate(true);
3292 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3293 const Tizen::Net::Http::HttpHeader& httpHeader)
3295 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3300 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3302 AppLog("MainForm::OnWebPageBlockSelected");
3303 if (__pHitElementResult != null)
3305 delete __pHitElementResult;
3306 __pHitElementResult = null;
3309 if (__pWebViewer != null)
3311 AppLog("MainForm::OnWebPageBlockSelected web not null");
3312 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3315 if (__pHitElementResult == null)
3320 if (__pHitElementResult->HasImage() != true)
3322 String tagName = __pHitElementResult->GetTagName();
3323 String type = __pHitElementResult->GetAttributeValue("type");
3325 __currentSelectedStr.Clear();
3326 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3327 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3328 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3330 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3332 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3334 InitSelectTextContextMenu(endPoint,true);
3335 __pImageMenu->SetShowState(true);
3336 __pImageMenu->Show();
3337 __pImageMenu->Invalidate(true);
3339 else if(__isLongPressedDone == true)
3341 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3343 if(__pHitElementResult->GetUrl().GetLength() > 0)
3345 __currentSelectedStr.Clear();
3346 __currentSelectedStr = __pHitElementResult->GetUrl();
3348 InitSelectTextContextMenu(endPoint,false);
3349 __pImageMenu->SetShowState(true);
3350 __pImageMenu->Show();
3351 __pImageMenu->Invalidate(true);
3354 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3355 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3356 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3362 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3368 MainForm::OnWebWindowCreateRequested(void)
3370 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3372 if (pNewWindowInfo == null)
3376 result r = E_SUCCESS;
3377 SceneManager* pSceneManager = SceneManager::GetInstance();
3378 if (pSceneManager == NULL)
3382 ArrayList* pArgList = new(std::nothrow) ArrayList();
3383 if (pArgList == NULL)
3387 r = pArgList->Construct();
3390 pNewWindowInfo->isJavascriptInitiated = true;
3391 pArgList->Add(*pNewWindowInfo);
3392 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3396 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3403 return pNewWindowInfo->pCurrentWeb;
3407 MainForm::RelayoutControls(bool showAddressbar)
3409 __webControlPosition.y = 0;
3410 __webControlHeight = GetClientAreaBounds().height;
3411 AppLog("Client area height: %d", __webControlHeight);
3413 AppLog("Client area height: %d", __webControlHeight);
3414 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3416 __webControlPosition.y += __pAddressbar->GetHeight();
3417 __webControlHeight -= __pAddressbar->GetHeight();
3418 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3420 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3422 __webControlPosition.y += __pFindWordControl->GetHeight();
3423 __webControlHeight -= __pFindWordControl->GetHeight();
3424 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3427 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3429 __webControlHeight -= __pFooterPanel->GetHeight();
3430 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3432 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3434 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3435 __pWebViewer->Invalidate(false);
3437 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3439 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3446 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3448 if (__pFindWordControl == null)
3454 InitFindWordPanel();
3455 // __pFindWordEditField->SetText(__currentSearchStr);
3456 //__pFindWordCountLabel->SetText(L"");
3457 // __pFindWordCountLabel->SetText(L"0/0");
3458 __pFindWordControl->SetShowState(true);
3462 if(__pFindWordControl != null)
3464 __pFindWordControl->SetShowState(false);
3468 AppLog("MainForm::ShowFindWordPanel %d",show);
3469 if (show && !isTouchPressed)
3471 if (__pFindWordEditField)
3473 __pFindWordEditField->SetFocus();
3474 __pFindWordEditField->ShowKeypad();
3479 if (__pFindWordEditField)
3480 __pFindWordEditField->HideKeypad();
3483 RelayoutControls(false);
3487 MainForm::StartWordSearch()
3489 //Get the count of occurances of the word in the current page
3490 __maxOccurrances = 0;
3491 __currentWordIndex = 0;
3493 __pFindWordPrev->SetEnabled(false);
3494 String *pCountStr = null;
3495 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3496 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3497 if (pCountStr != null)
3499 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3503 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3508 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3510 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3511 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3513 if(totalCount == -1 || totalCount == 0)
3515 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),64,__pFindWordCountLabel->GetHeight());
3516 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3519 else if(totalCount > 100)
3521 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3522 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3526 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3527 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3530 __maxOccurrances = totalCount;
3531 __currentWordIndex = currentOrdinal;
3533 //Reset the UI controls as per the maxOccurrance value
3534 if (totalCount <= 0)
3536 AppLog("Word not found");
3537 //Show error notification to user
3538 __pFindWordNext->SetEnabled(false);
3539 __pFindWordCountLabel->SetText(L"0/0");
3540 __pFindWordNext->Invalidate(false);
3541 __pFindWordPrev->Invalidate(false);
3542 __pFindWordCountLabel->Invalidate(false);
3546 if (totalCount == 1)
3548 __pFindWordNext->SetEnabled(false);
3552 __pFindWordNext->SetEnabled(true);
3555 String countStr = L"";
3556 countStr.Append(__currentWordIndex);
3557 countStr.Append(L"/");
3558 countStr.Append(__maxOccurrances);
3559 __pFindWordCountLabel->SetText(countStr);
3560 // __pFindWordCountLabel->SetShowState(true);
3561 __pFindWordCountLabel->Invalidate(false);
3563 //FindNextWord(true);
3564 //Update the controls
3565 __pFindWordNext->Invalidate(false);
3566 __pFindWordPrev->Invalidate(false);
3567 __pFindWordCountLabel->Invalidate(false);
3571 MainForm::FindNextWord(bool next)
3575 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3577 if(__currentWordIndex < __maxOccurrances)
3579 __currentWordIndex++;
3585 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3587 if(__currentWordIndex > 1)
3589 __currentWordIndex--;
3594 String countStr = L"";
3595 countStr.Append(__currentWordIndex);
3596 countStr.Append(L"/");
3597 countStr.Append(__maxOccurrances);
3598 __pFindWordCountLabel->SetText(countStr);
3599 // __pFindWordCountLabel->SetShowState(true);
3600 __pFindWordCountLabel->Invalidate(false);
3601 if (__currentWordIndex >= __maxOccurrances)
3603 __pFindWordNext->SetEnabled(false);
3607 __pFindWordNext->SetEnabled(true);
3609 if (__currentWordIndex <= 1)
3611 __pFindWordPrev->SetEnabled(false);
3615 __pFindWordPrev->SetEnabled(true);
3617 __pFindWordPrev->Invalidate(false);
3618 __pFindWordNext->Invalidate(false);
3619 __pFindWordCountLabel->Invalidate(false);
3620 __pFindWordControl->Invalidate(true);
3623 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3625 AppLog("MainForm::OnWebKeypadWillOpen");
3626 __isWebKeypadOpened = true;
3627 // OnAddressBarKeypadOpened(*__pAddressbar);
3631 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3634 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3636 __currentSearchStr = L"";
3637 __currentWordIndex = 0;
3638 __maxOccurrances = 0;
3639 __pFindWordEditField->SetText(L"");
3640 __pFindWordNext->SetEnabled(false);
3641 __pFindWordPrev->SetEnabled(false);
3642 __pFindWordCountLabel->SetText(L"0/0");
3643 __pWebViewer->SearchTextAllAsync(L"",false);
3644 __pFindWordControl->SetShowState(false);
3645 __pFindWordEditField->HideKeypad();
3649 if (__pWebViewer != null && __pFooterPanel != null)
3651 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3652 if(__pAddressbar != null)
3654 __pAddressbar->SetShowState(false);
3656 if(__pFindWordControl != null)
3658 __pFindWordControl->SetShowState(false);
3660 __pFooterPanel->SetShowState(false);
3661 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3667 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3669 __pFooterPanel->SetShowState(true);
3670 OnAddressBarKeypadClosed(*__pAddressbar);
3671 __isWebKeypadOpened = false;
3675 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3677 Control* temp = const_cast< Control* >(&source);
3678 Header* pHeader = dynamic_cast< Header* >(temp);
3679 if (pHeader != null)
3681 //Header double - clicked
3682 AppLog("Header double clicked");
3684 if(__pFindWordControl)
3686 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3687 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3691 AppLog("MainScene::OnTouchDoublePressed");
3692 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3693 if (isReaderEnabled == true)
3697 delete __pReaderData;
3698 __pReaderData = null;
3700 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3701 filePath.Append(L"data/reader.js");
3707 result r = E_SUCCESS;
3708 FileAttributes attr;
3710 File::GetAttributes(filePath,attr);
3712 r = file.Construct(filePath, L"r+");
3715 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3718 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3721 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3724 file.Read(pScript,attr.GetFileSize());
3726 AppLogDebug("scipt length %d",strlen(pScript));
3727 String strScript = L"";
3728 strScript.Append(pScript);
3729 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3732 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3735 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3736 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3738 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3739 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3745 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3747 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3749 if (__pHitElementResult != null)
3751 delete __pHitElementResult;
3752 __pHitElementResult = null;
3755 if (__pWebViewer != null)
3757 AppLog("MainForm::OnTouchLongPressed web not null");
3758 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3761 if (__pHitElementResult == null)
3766 if (__pHitElementResult->HasImage() == true)
3768 InitImageContextMenu(currentPosition);
3769 __pImageMenu->SetShowState(true);
3770 __pImageMenu->Show();
3771 __pImageMenu->Invalidate(true);
3773 else if(__pHitElementResult->HasUrl() == true)
3775 String tempURl = __pHitElementResult->GetUrl();
3776 AppLog("tempURl is %ls", tempURl.GetPointer());
3777 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3778 if (pBitmap != null)
3786 InitImageLinkContextMenu(currentPosition);
3787 __pImageMenu->SetShowState(true);
3788 __pImageMenu->Show();
3789 __pImageMenu->Invalidate(true);
3793 String tagName = __pHitElementResult->GetTagName();
3794 String type = __pHitElementResult->GetAttributeValue("type");
3795 String value = __pHitElementResult->GetAttributeValue(L"value");
3796 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3798 __currentSelectedStr.Clear();
3799 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3801 AppLog("tag name is %ls", tagName.GetPointer());
3802 AppLog("type is %ls", type.GetPointer());
3803 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3805 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3807 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3809 InitSelectTextContextMenu(currentPosition,true, true);
3812 // __pImageMenu->SetShowState(true);
3813 // __pImageMenu->Show();
3814 // __pImageMenu->Invalidate(true);
3817 __isLongPressedDone = true;
3818 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3819 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3822 __inputEventToBeSupressed = true;
3826 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3828 AppLog("MainForm::OnTouchReleased");
3830 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3831 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3833 __pWebViewer->ConsumeInputEvent();
3835 if(pHitElement != null)
3839 __inputEventToBeSupressed = false;
3843 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3850 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3852 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3854 __currentSearchStr = L"";
3855 __currentWordIndex = 0;
3856 __maxOccurrances = 0;
3857 __pFindWordEditField->SetText(L"");
3858 __pFindWordNext->SetEnabled(false);
3859 __pFindWordPrev->SetEnabled(false);
3860 __pFindWordCountLabel->SetText(L"0/0");
3861 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3862 __pFindWordControl->SetShowState(false);
3863 __pFindWordEditField->HideKeypad();
3865 if(__pAddressbar->GetShowState() == false)
3867 __pAddressbar->SetShowState(true);
3868 __pAddressbar->SetAddressbarURLFocus();
3869 __pFooterUrlField->SetFocusable(false);
3870 __pFooterPanel->SetShowState(false);
3877 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3883 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3889 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3895 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3901 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3907 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3909 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3910 int widthContextItem = 0;
3912 if(__pWebViewer != null)
3914 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
3915 __pWebViewer->ReleaseBlock();
3918 if(__pFindWordControl != null)
3919 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3920 if ( __pFooterLabel != null)
3922 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3925 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3930 if (__pFindWordBgLabel != null)
3932 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3933 if (pBitmap != null)
3935 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3941 __pMenu->SetShowState(false);
3942 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3944 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3948 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3953 AppLog("__pFooterPanel->GetShowState() is true");
3955 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3956 __pFooterPanel->Invalidate(true);
3960 if(__pMoreButton && __pMenu)
3962 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3963 __pMenu->SetAnchorPosition(p);
3964 __pMenu->Invalidate(true);
3967 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3968 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3970 InitMostVisitedSitesView(orientationStatus);
3973 RelayoutControls(false);
3974 if (__pArticleReaderPanel != null)
3976 if (__pArticleReaderPanel->GetShowState() == true)
3978 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3980 if (__pBlankPanel != null)
3981 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3983 if (__pWebReader != null)
3985 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3987 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3988 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3990 if ( pBitmap != null && pSrcBitmap != null)
3992 AppLog("CreateReaderPanel ninepatchbitmap found");
3993 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3996 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3997 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3998 if (pBitmap != null)
4003 if (pSrcBitmap != null)
4012 if (__pAddressbar != null)
4014 int width = GetClientAreaBounds().width;
4015 __pAddressbar->OrientationChanged(width);
4020 MainForm::OnSettingsChange(int settingvalue)
4022 AppLogDebug("MainForm::OnSettingsChange entered");
4024 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4026 __pAddressbar->ResetGuideText();
4028 if (__pWebViewer == null)
4030 AppLogDebug("Webviewer is not initialized yet.");
4034 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4036 WebSetting settings = __pWebViewer->GetSetting();
4037 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4039 settings.SetAutoFittingEnabled(true);
4041 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4043 settings.SetAutoFittingEnabled(false);
4045 __pWebViewer->SetSetting(settings);
4047 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4049 WebSetting settings = __pWebViewer->GetSetting();
4050 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4051 __pWebViewer->SetSetting(settings);
4053 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4055 WebSetting settings = __pWebViewer->GetSetting();
4056 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4057 __pWebViewer->SetSetting(settings);
4059 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4061 WebSetting settings = __pWebViewer->GetSetting();
4062 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4063 __pWebViewer->SetSetting(settings);
4065 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4069 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4073 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4075 WebSetting settings = __pWebViewer->GetSetting();
4076 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4078 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4082 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4084 __pWebViewer->SetSetting(settings);
4086 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4090 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4091 WebSetting settings = __pWebReader->GetSetting();
4092 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4093 __pWebReader->SetSetting(settings);
4099 MainForm::OnSettingsReset()
4103 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4104 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4109 MainForm::OnClearCache()
4111 result r = E_SUCCESS;
4113 if (__pWebViewer != NULL)
4115 r = __pWebViewer->ClearCache();
4118 AppLogDebug("Cache cleared success");
4122 AppLogDebug("Cache cleared fail");
4128 MainForm::OnClearCookie()
4130 result r = E_SUCCESS;
4132 if (__pWebViewer != NULL)
4134 __pWebViewer->ClearCookie();
4138 AppLogDebug("Cookie cleared success");
4142 AppLogDebug("Cache cleared fail");
4147 MainForm::OnClearFormData()
4149 result r = E_SUCCESS;
4151 if (__pWebViewer != NULL)
4153 __pWebViewer->ClearFormData();
4157 AppLogDebug("Cookie cleared success");
4161 AppLogDebug("Cache cleared fail");
4166 MainForm::OnClearPasswords()
4168 result r = E_SUCCESS;
4170 if (__pWebViewer != NULL)
4172 __pWebViewer->ClearLoginFormData();
4176 AppLogDebug("Cookie cleared success");
4180 AppLogDebug("Cache cleared fail");
4186 MainForm::findDistance(int x1,int y1,int x2, int y2)
4188 int deltaX = Math::Abs(x2 - x1);
4189 int deltaY = Math::Abs(y2 - y1);
4190 double num = deltaX*deltaX + deltaY*deltaY;
4196 for (i = 0; i < 20; i++)
4198 x = (((x*x)+ num)/(2*x));
4209 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4211 if(__pFindWordControl)
4213 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4214 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4216 __isLongPressedDone = false;
4219 IList* pList = null;
4220 pList = touch.GetTouchInfoListN(source);
4224 int count = pList->GetCount();
4227 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4228 __touchPoint1 = pTouchInfo->position;
4230 /*if (__pAddressbar != null)
4232 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4234 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4236 __pAddressbar->SaveAddressbarEditText();
4238 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4241 __pAddressbar->Invalidate(true);
4243 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4245 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4247 //__pAddressbar->SaveAddressbarEditText();
4249 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4252 else if (count == 2)
4254 AppLogDebug("MainForm::OnTouchPressed count is two");
4255 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4256 __touchPoint1 = pTouchInfo->position;
4258 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4259 __touchPoint2 = pTouchInfo->position;
4265 pList->RemoveAll(true);
4272 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4274 __currentWordIndex = 0;
4275 __isLongPressedDone = false;
4280 MainForm::MoveUiControls()
4285 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4287 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4289 if(__pFooterUrlField->GetTextLength() == 0)
4291 __pFooterUrlField->SetKeypadActionEnabled(false);
4295 __pFooterUrlField->SetKeypadActionEnabled(true);
4298 if (__pFindWordEditField != null)
4300 __currentSearchStr = __pFindWordEditField->GetText();
4301 __pFindWordNext->SetEnabled(false);
4302 __pFindWordPrev->SetEnabled(false);
4303 __pFindWordNext->Invalidate(true);
4304 __pFindWordPrev->Invalidate(true);
4305 __pFindWordCountLabel->SetText(L"0/0");
4306 __pFindWordCountLabel->Invalidate(true);
4308 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4309 if (__currentSearchStr.GetLength() > 0)
4315 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4317 __currentSearchStr = L"";
4318 AppLogDebug("Enter something");
4323 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4330 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4332 if(__pWebViewer != null)
4335 AppLog("MainForm::InitMostVisitedSitesView");
4336 result r = E_SUCCESS;
4339 if (__pWebViewer != null && __pMostVisitedListView != null)
4344 if (__pMostVisitedListView != null)
4346 RemoveControl(*__pMostVisitedListView);
4348 if(__pMostVisitedSites != null)
4350 __pMostVisitedSites->RemoveAll(true);
4353 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4355 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4356 __pMostVisitedListView = new(std::nothrow) ListView();
4358 int height = GetClientAreaBounds().height;
4360 if(__pFooterPanel->GetShowState() == true)
4362 height = height - __pFooterPanel->GetHeight();
4364 if(__pAddressbar->GetShowState() == true)
4366 height -= __pAddressbar->GetHeight();
4369 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4373 delete __pMostVisitedListView;
4374 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4377 __pMostVisitedListView->SetItemProvider(*this);
4378 __pMostVisitedListView->AddListViewItemEventListener(*this);
4379 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4380 AddControl(*__pMostVisitedListView);
4381 __pMostVisitedListView->UpdateList();
4388 MainForm::GetImagePath(void)
4392 String formattedTime;
4393 DateTime currentTime;
4394 LocaleManager localManager;
4395 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4397 localManager.Construct();
4398 Locale locale = localManager.GetSystemLocale();
4399 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4401 // Get date formatter
4402 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4406 pTimeFormatter->Format(currentTime, formattedTime);
4409 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4410 String delim(L" :");
4411 StringTokenizer strTok(formattedTime, delim);
4414 String str1("GMT+00");
4415 while (strTok.HasMoreTokens())
4417 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4418 if(token.Equals(str1))
4420 AppLog("token is %ls", token.GetPointer());
4421 imageName.Append(token);
4427 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4429 result r = E_FAILURE;
4430 AppLog("Content manager 1");
4431 ContentId contentId;
4432 ContentManager contentManager;
4433 r = contentManager.Construct();
4436 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4439 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4440 contentPath.Append(imageName);
4441 contentPath.Append(".jpg");
4442 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4443 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4447 MainForm::SetForwardButtonEnabled(bool isEnabled)
4449 __pGoForwardBtn->SetEnabled(isEnabled);
4450 __pGoForwardBtn->Invalidate(true);
4454 MainForm::SetBackButtonEnabled(bool isEnabled)
4456 __pGoBackBtn->SetEnabled(isEnabled);
4457 __pGoBackBtn->Invalidate(true);
4461 MainForm::UpdateProgress(int percentage)
4463 __progressPercentage = percentage;
4464 if (percentage == 0 || percentage == 100)
4466 __isLoadingData = false;
4467 if (percentage == 100)
4469 __isLoadingCompleted = true;
4470 __progressPercentage = 0;
4474 __isLoadingCompleted = false;
4479 __isLoadingData = true;
4481 UpdateProgressBitmap();
4485 MainForm::GetProgress(void)
4487 return __progressPercentage;
4491 MainForm::UpdateProgressBitmap(void)
4493 result r = E_SUCCESS;
4494 if (__pProgressbarLabel == null)
4496 int w = __pProgressbarLabel->GetWidth();
4497 int h = __pProgressbarLabel->GetHeight();
4499 int progressWidth = 0;
4500 Bitmap* pRetBitmap = null;
4502 if (__progressPercentage == 0 || __progressPercentage == 100)
4504 __pProgressbarLabel->SetShowState(false);
4505 __pProgressbarLabel->Invalidate(false);
4510 __pProgressbarLabel->SetShowState(true);
4511 __pProgressbarLabel->Invalidate(false);
4514 r = canvas.Construct(Rectangle(0, 0, w, h));
4518 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4523 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4527 pBgBmp->Scale(Dimension(w, h));
4528 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4532 progressWidth = (double) (w) * __progressPercentage / 100;
4533 AppLogDebug("progressWidth: %d", progressWidth);
4534 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4536 if (pProgressBmp != null)
4538 pProgressBmp->Scale(Dimension(progressWidth, h));
4539 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4540 delete pProgressBmp;
4543 pRetBitmap = new (std::nothrow) Bitmap();
4545 if (pRetBitmap == null)
4547 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4551 pRetBitmap->Construct(canvas, canvas.GetBounds());
4553 if (__pProgressbarLabel != null && pRetBitmap != null)
4555 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4556 __pProgressbarLabel->Invalidate(false);
4559 if (pRetBitmap != null)
4567 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4569 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4571 __currentAddMode = addMode;
4575 case ADDRESSBAR_MODE_INVALID:
4580 case ADDRESSBAR_MODE_READER:
4582 __pStopBtn->SetShowState(false);
4583 __pClearBtn->SetShowState(false);
4586 case ADDRESSBAR_MODE_LOADING:
4588 __pRefreshBtn->SetShowState(false);
4589 __pStopBtn->SetShowState(true);
4590 __pClearBtn->SetShowState(false);
4593 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4595 // SetUrl(__pAddressbar->GetUrl());
4597 __pRefreshBtn->SetShowState(true);
4598 __pStopBtn->SetShowState(false);
4599 __pClearBtn->SetShowState(false);
4602 case ADDRESSBAR_MODE_EDIT:
4604 __pRefreshBtn->SetShowState(false);
4605 __pStopBtn->SetShowState(false);
4606 __pClearBtn->SetShowState(true);
4613 OnAddressBarModeChanged();
4616 AddressBarMode MainForm::GetAddressbarMode(void)
4618 return __currentAddMode;
4621 void MainForm::SetUrl(const String& url)
4625 if (__pFooterUrlField != NULL)
4627 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4628 if (removedHttpUrl.IsEmpty() == false)
4630 __pFooterUrlField->SetText(removedHttpUrl);
4631 __pAddressbar->SetUrl(__displayUrl);
4635 __pFooterUrlField->SetText(__displayUrl);
4636 __pAddressbar->SetUrl(__displayUrl);
4638 if(__pFooterUrlField)
4639 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4640 __pFooterUrlField->Invalidate(false);
4641 __pAddressbar->Invalidate(true);
4642 // __pFooterUrlField->SetCursorPosition(0);
4647 MainForm::RemoveHttpTextFromDisplayURL(void)
4649 bool isHttpText = __displayUrl.Contains(L"http://");
4650 String updatedDisplayUrl;
4651 updatedDisplayUrl.Clear();
4653 if (isHttpText == true)
4655 __displayUrl.SubString(7,updatedDisplayUrl);
4657 return updatedDisplayUrl;
4660 void MainForm::OnSharePopupControlStarted(void)
4662 __pWebViewer->AddTouchEventListener(*this);