2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
57 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
58 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
64 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
65 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
66 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
67 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
69 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
70 static const wchar_t* IDS_APPID = L"AppID";
71 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
74 const int IDA_BACKBTN_CLICKED = 101;
75 const int IDA_BOOKMARKBTN_CLICKED = 102;
76 const int IDA_MOREBTN_CLICKED = 103;
77 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
78 const int IDA_NEWWINDOWBTN_CLICKED = 105;
79 const int IDA_FORWARD_CLICKED = 106;
80 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
81 const int IDA_SHARE_CLICKED = 108;
82 const int IDA_FINDONPAGE_CLICKED = 109;
83 const int IDA_PRIVATEON_CLICKED = 110;
84 const int IDA_SETTINGS_CLICKED = 111;
85 const int IDA_READER_CLOSE_CLICKED = 112;
86 const int IDA_SMALLFONT_BTN_CLICKED = 113;
87 const int IDA_LARGEFONT_BTN_CLICKED = 114;
88 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
89 const int IDA_HISTORY_CLICKED = 116;
90 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
91 const int IDA_ADD_TO_HOME_CLICKED = 118;
92 const int IDA_SAVED_PAGES_CLICKED = 119;
93 const int IDA_DESKTOP_VIEW_CLICKED = 120;
94 const int IDA_SAVE_CLICKED = 121;
96 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
97 const int IDA_FINDWORD_NEXT_CLICKED = 202;
98 const int IDA_FINDWORD_PREV_CLICKED = 203;
99 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
100 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
102 const int IDA_COPY_IMAGE_CLICKED = 206;
103 const int IDA_VIEW_IMAGE_CLICKED = 207;
104 const int IDA_SAVE_IMAGE_CLICKED = 208;
105 const int IDA_SHARE_IMAGE_CLICKED = 209;
107 const int IDA_COPY_TEXT_CLICKED = 210;
108 const int IDA_PASTE_TEXT_CLICKED = 211;
109 const int IDA_FIND_TEXT__CLICKED = 212;
110 const int IDA_SHARE_TEXT_CLICKED = 213;
112 const int IDA_GO_BACK = 214;
113 const int IDA_GO_FORWARD = 215;
114 const int IDA_REFRESH_BTN_CLICKED = 216;
115 const int IDA_STOP_BTN_CLICKED = 217;
116 const int IDA_CLEAR_URL = 218;
118 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
120 const int MainForm::IDA_FORMAT_BITMAP = 500;
121 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
122 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
123 const int MainForm::IDA_FORMAT_URL_STRING = 503;
124 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
126 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
127 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
128 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
130 MainForm::MainForm(void)
132 __pAddressbar = null;
133 // __pMostVisitedSitesPanel = null;
134 __pMostVisitedListView = null;
135 __pFooterPanel = null;
136 __pHitElementResult = null;
137 __pWindowInfo = null;
141 __pFindWordControl = null;
142 __pFindWordPanel = null;
143 __pFindWordBgLabel = null;
144 __pFindWordEditField = null;
145 __pFindWordClear = null;
146 __pFindWordCountLabel = null;
147 __pFindWordNext = null;
148 __pFindWordPrev = null;
149 __previousZoomLevel = 1.0;
151 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
154 __currentSearchStr = L"";
155 __currentSelectedStr = L"";
156 __maxOccurrances = 0;
157 __currentWordIndex = 0;
160 __inputEventToBeSupressed = false;
161 __isLoadingData = false;
162 __isLoadingCompleted = false;
163 __progressPercentage = 0;
164 __touchPoint1 = Point(-1,-1);
165 __touchPoint2 = Point(-1,-1);
167 // __pReaderPopup = null;
168 __pReaderData = null;
170 __pReaderCloseBtn = null;
171 //__pNewWindowButton = null;
172 __pMoreButton = null;
173 __pMultiWindowButton = null;
174 __pArticleReaderPanel = null;
175 __pBlankPanel = null;
176 __pArticleReaderLabel = null;
177 __webControlHeight = 0;
178 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
179 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
180 __pMostVisitedSites = null;
181 __pFooterUrlField = null;
183 __pGoForwardBtn = null;
184 __pRefreshBtn = null;
185 __pProgressbarLabel = null;
186 __pFooterLabel = null;
191 MainForm::~MainForm(void)
193 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
197 __pAddressbar->SetAddressbarEventListener(null);
199 if (__pReaderData != null)
201 delete __pReaderData;
202 __pReaderData = null;
205 if (__pPopUp != null)
211 if (__pHitElementResult != null)
213 delete __pHitElementResult;
214 __pHitElementResult = null;
216 String* pSelectedScene = NULL;
217 Object* pValue = NULL;
218 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
219 pSelectedScene = (String*) pValue;
221 /*if (pSelectedScene != null)
223 delete pSelectedScene;
225 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
229 MainForm::Initialize(void)
231 Construct(L"IDL_FORM");
236 MainForm::OnInitializing(void)
238 AppLog("get client area width = %d",GetClientAreaBounds().width);
239 AppLog("get client area height = %d",GetClientAreaBounds().height);
240 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
241 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
243 Panel* pFooterPanel = null;
245 __pSaveImage = new Image();
246 __pSaveImage->Construct();
248 // Setup back event listener
249 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
250 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
251 AddOrientationEventListener(*this);
252 AppLogDebug(" MainForm::OnInitializing ended");
253 if (__pMostVisitedSites == null)
255 __pMostVisitedSites = new(std::nothrow) ArrayList();
256 __pMostVisitedSites->Construct();
258 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
260 __pItemContext= new(std::nothrow) ListContextItem();
261 __pItemContext->Construct();
262 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
263 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
265 if (pBitmapNormal != null && pBitmapPressed != null)
267 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
270 if (pBitmapNormal != null)
272 delete pBitmapNormal;
275 if (pBitmapPressed != null)
277 delete pBitmapPressed;
284 MainForm::InitAddressbar(void)
286 AppLogDebug("MainForm::InitAddressbar entered");
288 result r = E_SUCCESS;
290 if (__pAddressbar != null)
294 __pAddressbar = new(std::nothrow) Addressbar();
295 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
296 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
299 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
302 __pAddressbar->SetAddressbarEventListener(this);
303 AddControl(*__pAddressbar);
304 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
305 SetControlAlwaysOnTop(*__pAddressbar, true);
306 __adressPanelPosition = __pAddressbar->GetPosition();
308 AppLogDebug("MainForm::InitAddressbar exit");
314 MainForm::CreateReaderPanel(void)
316 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
317 result r = E_FAILURE;
319 Button *pSmallFontBtn = null;
320 Button *pLargeFontBtn = null;
322 __pBlankPanel = new (std::nothrow) Panel();
323 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
325 __pArticleReaderPanel = new (std::nothrow) Panel();
326 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
328 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
329 if (__pReaderCloseBtn)
331 AppLogDebug("CreateReaderPanel() 6");
332 __pReaderCloseBtn->AddActionEventListener(*this);
333 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
336 __pWebReader = new (std::nothrow) Web();
337 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
339 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
340 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
342 r = __pWebReader->SetSetting(settings);
344 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
347 __pArticleReaderLabel = new Label();
348 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
350 __pBlankPanel->AddControl(*__pArticleReaderLabel);
351 __pBlankPanel->AddControl(*__pArticleReaderPanel);
352 AddControl(*__pBlankPanel);
354 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
355 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
356 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
358 __pArticleReaderPanel->AddControl(*__pWebReader);
359 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
360 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
361 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
363 if (pBitmap != null && pSrcBitmap != null)
365 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
367 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
369 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
372 pSmallFontBtn->AddActionEventListener(*this);
373 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
376 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
379 pLargeFontBtn->AddActionEventListener(*this);
380 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
389 if (pSrcBitmap != null)
395 SetControlAlwaysOnTop(*__pBlankPanel, true);
396 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
403 MainForm::InitWebControl()
405 AppLogDebug("MainForm::InitWebControl enter");
406 result r = E_SUCCESS;
407 AppLogDebug("InitWebControl");
409 if (__pAddressbar == null || __pFooterPanel == null)
412 const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12;
413 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
414 if (__pMostVisitedListView)
416 __pMostVisitedListView->SetShowState(false);
418 if (__pWebViewer != null)
420 AppLogDebug("Already initialized");
423 __pWebViewer = new(std::nothrow) Web();
424 if(__pWebViewer == NULL)
426 AppLogDebug("Initialization failed");
429 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
433 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
438 r = AddControl(*__pWebViewer);
442 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
445 __webControlPosition = __pWebViewer->GetPosition();
446 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
449 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
453 __pWebViewer->SetLoadingListener(this);
454 __pWebViewer->SetWebUiEventListener(this);
455 __pWebViewer->SetWebKeypadEventListener(this);
456 __pWebViewer->SetFocus();
457 __pWebViewer->AddTouchEventListener(*this);
459 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
460 __pWebViewer->SetTextSearchListener(this);
463 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
464 AppLogDebug("MainForm :before return");
466 AppLogDebug("MainForm::InitWebControl Exit");
472 MainForm::SetJavascriptEnabled()
474 WebSetting settings = __pWebViewer->GetSetting();
475 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
476 __pWebViewer->SetSetting(settings);
480 MainForm::SetImageLoadEnabled()
482 WebSetting settings = __pWebViewer->GetSetting();
483 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
484 __pWebViewer->SetSetting(settings);
488 MainForm::InitFooter(void)
490 AppLogDebug("MainForm::InitFooter entered");
491 Button* pBackButton = null;
492 Button* pBookmarkButton = null;
493 Button* pMultiWindowButton = null;
494 Bitmap *pIconBitmap = null;
495 Bitmap *pBGBitmap = null;
496 Label *pBGLabel = null;
498 if (__pFooterPanel == null)
500 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
503 if (__pFooterPanel == null)
508 SetControlAlwaysOnTop(*__pFooterPanel, true);
510 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
511 if ( __pFooterLabel == NULL )
515 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
516 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
519 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
523 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
525 if ( __pMultiWindowButton == NULL )
530 /*pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true));
532 if ( pBackButton == NULL )
537 pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true));
539 if ( pBookmarkButton == NULL )
544 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
546 if ( __pMoreButton == NULL )
551 /*__pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true));
553 if ( __pNewWindowButton == NULL )
558 if (__pMultiWindowButton != null)
560 Bitmap* pBitmap = null;
561 Bitmap* pPressedBitmap = null;
562 String imagePath = "I01_toolbar_icon_windows_manager_0";
563 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
564 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
565 imagePath.Append(totalCount);
566 imagePath.Append(".png");
568 pressedImagePath.Append(totalCount);
569 pressedImagePath.Append("_press.png");
571 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
572 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
573 if ( pBitmap == null )
578 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
581 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
582 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
587 __pMultiWindowButton->AddActionEventListener(*this);
588 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
594 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK);
595 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK_PRESS);
598 // pBitmap->Scale(Dimension(56,56));
600 Point startPoint((pBackButton->GetWidth() - pBitmap->GetWidth())/2,(pBackButton->GetHeight() - pBitmap->GetHeight())/2 );
601 AppLog("startPoint %d,%d pBitmap width height %d %d",startPoint.x,startPoint.y,pBitmap->GetWidth(),pBitmap->GetHeight());
602 pBackButton->SetNormalBitmap(startPoint, *pBitmap);
603 pBackButton->SetPressedBitmap(startPoint, *pPressedBitmap);
606 pBackButton->AddActionEventListener(*this);
607 pBackButton->SetActionId(IDA_BACKBTN_CLICKED);
610 /*if (pBookmarkButton)
612 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK);
613 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK_PRESS);
616 Point startPoint((pBookmarkButton->GetWidth() - pBitmap->GetWidth())/2,(pBookmarkButton->GetHeight() - pBitmap->GetHeight())/2 );
617 pBookmarkButton->SetNormalBitmap(startPoint, *pBitmap);
618 pBookmarkButton->SetPressedBitmap(startPoint, *pPressedBitmap);
621 pBookmarkButton->AddActionEventListener(*this);
622 pBookmarkButton->SetActionId(IDA_BOOKMARKBTN_CLICKED);
627 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
628 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
631 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
632 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
633 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
637 __pMoreButton->AddActionEventListener(*this);
638 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
641 //Add the editfield for url
642 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
643 if (__pFooterUrlField == NULL)
645 AppLogDebug("__pFooterUrlField Control not found returning E_INVALID_KEY");
646 return E_INVALID_KEY;
649 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
650 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
651 //__pFooterUrlField->AddFocusEventListener(*this);
652 __pFooterUrlField->AddKeypadEventListener(*this);
654 /*if (__pNewWindowButton)
656 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW);
657 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS);
660 Point startPoint((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
661 __pNewWindowButton->SetNormalBitmap(startPoint, *pBitmap);
662 __pNewWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
665 __pNewWindowButton->AddActionEventListener(*this);
666 __pNewWindowButton->SetActionId(IDA_NEWWINDOWBTN_CLICKED);
667 __pNewWindowButton->SetEnabled(true);
668 // __pNewWindowButton->Invalidate(true);
671 AppLog("checkingwindow count %d",MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount());
673 /*if (__pNewWindowButton != null && MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
675 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTROLBAR_ICON_CREATE_DISABLE);
678 Point startPoint = Point((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
679 __pNewWindowButton->SetDisabledBitmap(startPoint,*pBitmap);
682 __pNewWindowButton->SetEnabled(false);
685 //Add the go Back Button
686 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
687 if (__pGoBackBtn == NULL)
689 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
690 return E_INVALID_KEY;
692 __pGoBackBtn->SetActionId(IDA_GO_BACK);
693 __pGoBackBtn->AddActionEventListener(*this);
695 //Add the go forward Button
696 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
697 if (__pGoForwardBtn == NULL)
699 AppLogDebug("Control not found returning E_INVALID_KEY");
700 return E_INVALID_KEY;
702 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
703 __pGoForwardBtn->AddActionEventListener(*this);
704 __pGoForwardBtn->SetEnabled(false);
706 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
707 if (__pRefreshBtn == NULL)
709 AppLogDebug("Control not found returning E_INVALID_KEY");
710 return E_INVALID_KEY;
713 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
714 __pRefreshBtn->AddActionEventListener(*this);
715 __pRefreshBtn->SetShowState(true);
717 //Add the backround label for displaying progressbar
718 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
719 if (__pProgressbarLabel == NULL)
721 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
722 return E_INVALID_KEY;
724 __pProgressbarLabel->SetShowState(false);
726 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
727 if (__pStopBtn == NULL)
729 AppLogDebug("Control not found returning E_INVALID_KEY");
730 return E_INVALID_KEY;
732 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
733 __pStopBtn->AddActionEventListener(*this);
734 __pStopBtn->SetShowState(false);
736 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
737 if (__pClearBtn == NULL)
739 AppLogDebug("Control not found returning E_INVALID_KEY");
740 return E_INVALID_KEY;
742 __pClearBtn->SetActionId(IDA_CLEAR_URL);
743 __pClearBtn->AddActionEventListener(*this);
744 __pClearBtn->SetShowState(false);
746 // __pFooterPanel->Invalidate(true);
747 AppLogDebug("MainForm::InitFooter exit");
753 MainForm::InitContextMenu(Point& p)
755 result r = E_SUCCESS;
756 bool isPrivateBrowsing = false;
757 Bitmap* pBitmap = null;
761 __pMenu->SetAnchorPosition(p);
762 __pMenu->Invalidate(true);
766 __pMenu = new(std::nothrow) ContextMenu();
767 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
768 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
770 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
773 if (isPrivateBrowsing == true)
775 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
779 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
782 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
784 if ( pBitmap != NULL)
786 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
789 r = __pMenu->AddItem(L"Desktop view"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_DESKTOP_VIEW_CLICKED);
790 r = __pMenu->AddItem(L"Saved Pages"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_SAVED_PAGES_CLICKED);
791 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
792 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
793 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
796 __pMenu->SetMaxVisibleItemsCount(6);
797 __pMenu->SetShowState(false);
798 __pMenu->AddActionEventListener(*this);
799 SetControlAlwaysOnTop(*__pMenu, true);
805 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
807 result r = E_SUCCESS;
808 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
810 AppLog("MainForm::InitImageContextMenu clicked on image");
811 if (__pImageMenu != null)
817 p.y = p.y + __pAddressbar->GetHeight() + 12;
820 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
824 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
826 __pImageMenu = new (std::nothrow) ContextMenu();
827 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
828 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
830 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
831 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
832 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
834 __pImageMenu->SetMaxVisibleItemsCount(4);
835 __pImageMenu->AddActionEventListener(*this);
836 SetControlAlwaysOnTop(*__pImageMenu, true);
841 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
843 result r = E_SUCCESS;
844 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
846 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
847 if (__pImageMenu != null)
852 p.y = p.y + __pAddressbar->GetHeight() + 12;
855 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
859 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
861 __pImageMenu = new (std::nothrow) ContextMenu();
862 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
863 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
865 if(onlyPasteOption == false)
867 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
869 if (pasteOption || onlyPasteOption)
871 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
873 if(onlyPasteOption == false)
875 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
876 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
879 __pImageMenu->SetMaxVisibleItemsCount(3);
880 __pImageMenu->AddActionEventListener(*this);
881 SetControlAlwaysOnTop(*__pImageMenu, true);
888 MainForm::InitFindWordPanel(void)
890 result r = E_SUCCESS;
891 Bitmap *pIconBitmap = null;
893 if (__pFindWordPanel != null)
895 AppLogDebug("Findword panel already initialized");
896 if (__pFindWordBgLabel != null)
898 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
901 AppLogDebug("InitFindWordPanel: Coming here");
902 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
909 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
910 if (__pFindWordPanel == null)
912 AppLogException("There is some problem in the xml file. Please check.");
916 __pFindWordControl = new (std::nothrow) Panel();
917 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
920 AppLogException("There is some problem in the xml file. Please check.");
923 __pFindWordPanel->AddControl(*__pFindWordControl);
924 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
925 SetControlAlwaysOnTop(*__pFindWordPanel,true);
926 __pFindWordPanel->SetShowState(false);
927 __pFindWordPanel->Invalidate(false);
929 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
930 if (__pFindWordBgLabel != null)
932 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
933 Rectangle pRect = pPanel1->GetBounds();
934 pRect.x = pRect.y = 0;
935 __pFindWordBgLabel->SetBounds(pRect);
936 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
939 AppLogDebug("InitFindWordPanel: Coming here");
940 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
945 AppLogDebug("InitFindWordPanel: shouldn't Come here");
949 Button* pfindWordCancel = null;
950 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
951 if (pfindWordCancel == null)
953 AppLogException("There is some problem in the xml file. Please check.");
956 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
957 pfindWordCancel->AddActionEventListener(*this);
959 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
960 if (__pFindWordClear == null)
962 AppLogException("There is some problem in the xml file. Please check.");
966 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
967 __pFindWordClear->AddActionEventListener(*this);
969 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
970 if (__pFindWordNext == null)
972 AppLogException("There is some problem in the xml file. Please check.");
976 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
977 __pFindWordNext->AddActionEventListener(*this);
979 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
980 if (__pFindWordPrev == null)
982 AppLogException("There is some problem in the xml file. Please check.");
986 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
987 __pFindWordPrev->AddActionEventListener(*this);
989 __pFindWordNext->SetEnabled(false);
990 __pFindWordPrev->SetEnabled(false);
992 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
993 if (__pFindWordCountLabel == null)
995 AppLogException("There is some problem in the xml file. Please check.");
999 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1000 if (__pFindWordEditField == null)
1002 AppLogException("There is some problem in the xml file. Please check.");
1005 __pFindWordEditField->AddTextEventListener(*this);
1006 __pFindWordEditField->AddKeypadEventListener(*this);
1007 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1013 MainForm::CreateItem (int index, int itemWidth)
1015 Rectangle listImageRect;
1016 Rectangle pagetTitleRect;
1017 Rectangle pageURLRect;
1018 Rectangle deleteImageRect;
1019 String pageTitle(L"");
1020 String pageURL(L"");
1021 result r = E_SUCCESS;
1022 Bitmap* pListIconImage = null;
1025 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1026 if(pHistory == null)
1030 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1031 if ( pAppResource == NULL )
1035 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1037 CustomItem* pItem = new(std::nothrow) CustomItem();
1038 pageTitle = pHistory->GetHistoryTitle();
1039 pageURL = pHistory->GetHistoryUrl();
1041 if (pageURL.GetLength() == 0)
1044 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1045 pageURL = L"<"+ nourl +">";
1049 Rectangle screenBounds = GetBounds();
1052 r = pItem->Construct(Dimension(itemWidth, 128), style);
1060 if (pHistory->GetFaviconId().GetLength() > 0)
1062 String bitmapId = pHistory->GetFaviconId();
1063 Bitmap* pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);
1065 if ( pBitmap != NULL)
1067 pListIconImage = new Bitmap();
1068 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1073 if(pListIconImage == null)
1075 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1078 if ( pListIconImage != NULL)
1080 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1081 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1082 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1085 if (pItem != null && pListIconImage != NULL)
1087 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1091 if (pageTitle.CompareTo(L"") != 0)
1095 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1099 if (pageURL.CompareTo(L"") != 0)
1103 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1108 if ( __pItemContext!= NULL)
1112 pItem->SetContextItem(__pItemContext);
1115 if( pListIconImage != NULL)
1117 delete pListIconImage;
1118 pListIconImage = null;
1125 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1132 MainForm::GetItemCount (void)
1134 if(__pMostVisitedSites != null)
1136 __pMostVisitedSites->RemoveAll(true);
1138 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1139 if(__pMostVisitedSites != null)
1141 return __pMostVisitedSites->GetCount();
1148 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1150 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1151 String url = pHistory->GetHistoryUrl();
1152 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1153 __pMostVisitedListView->UpdateList();
1157 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1159 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1160 String url = pHistory->GetHistoryUrl();
1168 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1174 MainForm::OnTerminating(void)
1176 result r = E_SUCCESS;
1179 delete __pItemContext;
1185 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1187 result r = E_SUCCESS;
1189 AppLogDebug("Clicked : %d", actionId);
1192 case IDA_BACKBTN_CLICKED:
1194 if (__pWebViewer && __pWebViewer->CanGoBack())
1196 __pWebViewer->GoBack();
1201 pApp = UiApp::GetInstance();
1204 r = pApp->Terminate();
1207 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1215 case IDA_FORWARD_CLICKED:
1216 if (__pWebViewer == null)
1219 if (__pWebViewer->CanGoForward())
1221 __pWebViewer->GoForward();
1223 __pMenu->SetShowState(false);
1224 __pMenu->Invalidate(false);
1227 case IDA_FINDONPAGE_CLICKED:
1229 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1230 __currentSearchStr.Clear();
1232 InitFindWordPanel();
1233 __pMenu->SetShowState(false);
1234 __pMenu->Invalidate(false);
1236 /*__adressPanelPosition.y = 0 ;
1238 if (__pAddressbar != null && __pWebViewer != NULL)
1240 __webControlPosition.y = __pAddressbar->GetHeight();
1241 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1242 //__pAddressbar->Invalidate(true);
1243 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1244 __pWebViewer->Invalidate(true);
1246 if (__pWebViewer != null)
1248 // releasing the set block
1249 __pWebViewer->ReleaseBlock();
1251 ShowFindWordPanel(true);
1254 case IDA_PRIVATEON_CLICKED:
1256 result r = E_SUCCESS;
1258 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1259 Bitmap* pBitmap = null;
1260 if (isPrivateBrowsing == true)
1262 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1265 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1269 if (__pWebViewer != NULL)
1271 __pWebViewer->SetPrivateBrowsingEnabled(false);
1274 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1276 if (__pAddressbar != null)
1278 __pAddressbar->UpdateFaviconBitmap(false);
1284 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1287 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1291 if (__pWebViewer != NULL)
1293 __pWebViewer->SetPrivateBrowsingEnabled(true);
1296 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1298 if (__pAddressbar != null)
1300 __pAddressbar->UpdateFaviconBitmap(true);
1305 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1306 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1307 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1308 __pMenu->Invalidate(true);
1310 if ( pBitmap != NULL )
1317 case IDA_SETTINGS_CLICKED:
1320 ArrayList* pArgList = new(std::nothrow) ArrayList();
1323 pArgList->Construct();
1324 pArgList->Add(*__pWindowInfo);
1325 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1327 __pMenu->SetShowState(false);
1328 __pMenu->Invalidate(false);
1329 if (pArgList != null)
1338 case IDA_ADDTOBOOKMARK_CLICKED:
1341 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1343 int bookmarkCount=0;
1346 url=__pWindowInfo->pageUrl;
1347 result r = E_SUCCESS;
1348 Bitmap* pBitmap = null;
1349 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1357 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1358 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1359 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1361 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1362 if (pNotification != null)
1364 pNotification->SetText(message);
1365 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1366 pNotification->ShowNotification();
1371 String title=__pWindowInfo->pageTitle;
1372 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1373 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1375 pBookmark->SetBookmarkTitle(title);
1376 pBookmark->SetUrl(url);
1377 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1378 pBookmark->SetFaviconId(id);
1379 r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1382 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1383 if(pNotification != null)
1385 pNotification->SetText(message);
1386 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1387 pNotification->ShowNotification();
1388 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1391 if (pBitmap != null)
1393 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1397 __pMenu->Invalidate(true);
1401 case IDA_SHARE_CLICKED:
1403 if(__pPopUp != null)
1408 __pPopUp = new(std::nothrow) SharePopup();
1409 __pPopUp->Initialize();
1410 if (__pWindowInfo != null)
1412 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1413 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1414 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1415 pShareInfo->SetImageAttached(false);
1416 __pPopUp->RemoveAllShareInfo();
1417 __pPopUp->AddShareInfo(pShareInfo);
1419 __pPopUp->SetShowState(true);
1423 case IDA_BOOKMARKBTN_CLICKED:
1425 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1426 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1429 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1434 case IDA_MOREBTN_CLICKED:
1436 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1437 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1438 AppLog("Anchot pos: %d %d", p.x, p.y);
1440 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1442 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1443 int bookmarkCount=0;
1446 url=__pWindowInfo->pageUrl;
1447 result r = E_SUCCESS;
1448 Bitmap* pBitmap = null;
1450 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1453 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1458 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1462 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1464 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1466 if (__pMenu->GetItemCount() == 12)
1468 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1472 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1477 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1481 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1482 if (__pMenu->GetItemCount() != 12)
1484 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1486 __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1487 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1488 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1489 __pMenu->InsertItemAt(7,L"Save"/*CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB")*/, IDA_SAVE_CLICKED);
1490 __pMenu->SetMaxVisibleItemsCount(6);
1492 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1494 AppLog(" Orientation landscape");
1495 __pMenu->SetMaxVisibleItemsCount(5);
1499 AppLog(" Orientation potrait");
1500 __pMenu->SetMaxVisibleItemsCount(6);
1503 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1506 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1507 __pMenu->SetShowState(true);
1508 __pMenu->Invalidate(true);
1512 case IDA_HISTORY_CLICKED:
1514 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1515 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1518 case IDA_SAVED_PAGES_CLICKED:
1523 case IDA_DESKTOP_VIEW_CLICKED:
1528 case IDA_SAVE_CLICKED:
1533 case IDA_MULTIWINDOWBTN_CLICKED:
1535 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1536 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1540 case IDA_NEWWINDOWBTN_CLICKED:
1542 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1544 if (pNewWindowInfo == null)
1548 result r = E_SUCCESS;
1549 SceneManager* pSceneManager = SceneManager::GetInstance();
1551 if (pSceneManager == NULL)
1555 ArrayList* pArgList = new(std::nothrow) ArrayList();
1556 if (pArgList == NULL)
1560 r = pArgList->Construct();
1563 pArgList->Add(*pNewWindowInfo);
1564 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1570 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1575 case IDA_SMALLFONT_BTN_CLICKED:
1577 WebSetting setting = __pWebReader->GetSetting();
1578 setting.SetFontSize(15);
1579 __pWebReader->SetSetting(setting);
1582 case IDA_LARGEFONT_BTN_CLICKED:
1584 WebSetting setting = __pWebReader->GetSetting();
1585 setting.SetFontSize(25);
1586 __pWebReader->SetSetting(setting);
1589 case IDA_READER_CLOSE_CLICKED:
1591 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1593 //__pArticleReaderPanel->SetShowState(false);
1594 //__pArticleReaderPanel->Show();
1595 RemoveControl(*__pBlankPanel);
1596 //RemoveControl(*__pArticleReaderPanel);
1597 __pArticleReaderPanel = null;
1598 __pBlankPanel = null;
1599 __pArticleReaderLabel = null;
1601 //if (__pAddressbar)
1602 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1603 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1606 case IDA_FINDWORD_CANCEL_CLICKED:
1608 __currentSearchStr = L"";
1609 __currentWordIndex = 0;
1610 __maxOccurrances = 0;
1611 __pFindWordEditField->SetText(L"");
1612 __pFindWordNext->SetEnabled(false);
1613 __pFindWordPrev->SetEnabled(false);
1614 __pFindWordCountLabel->SetText(L"0/0");
1615 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1616 ShowFindWordPanel(false);
1619 case IDA_FINDWORD_SEARCH_CLICKED:
1621 __currentSearchStr = __pFindWordEditField->GetText();
1622 if (__currentSearchStr.GetLength() > 0)
1628 AppLogDebug("Enter something");
1632 case IDA_FINDWORD_CLEAR_CLICKED:
1634 __pFindWordCountLabel->SetText(L"0/0");
1635 __pFindWordEditField->SetText(L"");
1636 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1638 __pFindWordNext->SetEnabled(false);
1639 __pFindWordPrev->SetEnabled(false);
1640 __pFindWordPanel->Invalidate(true);
1643 case IDA_FINDWORD_NEXT_CLICKED:
1648 case IDA_FINDWORD_PREV_CLICKED:
1650 FindNextWord(false);
1653 case IDA_BRIGHTNESS_BTN_CLICKED:
1655 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1656 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1659 case IDA_COPY_IMAGE_CLICKED:
1661 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1662 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1664 const Bitmap* pBitmap = null;
1665 if (__pHitElementResult != null)
1667 pBitmap = __pHitElementResult->GetImage();
1670 String resourcePath = App::GetInstance()->GetAppResourcePath();
1671 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1673 // copying the item to clipboard
1674 Clipboard* pClipboard = Clipboard::GetInstance();
1675 if (pClipboard != null)
1677 pClipboard->CopyItem(item);
1681 case IDA_VIEW_IMAGE_CLICKED:
1683 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1684 WindowInfo* pNewWindowInfo = null;
1685 if (__pHitElementResult != null)
1687 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1688 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1694 case IDA_SAVE_IMAGE_CLICKED:
1696 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1697 const Bitmap* pSaveBitmap = null;
1698 String imageName = GetImagePath();
1699 AppLog("Content manager image name %ls",imageName.GetPointer());
1702 imagePath.Append(imageName);
1703 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1704 AppLog("Content manager image path %ls",imagePath.GetPointer());
1705 if (__pHitElementResult != null)
1707 pSaveBitmap = __pHitElementResult->GetImage();
1709 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1713 UpdateImageContent(pBuffer, imageName);
1715 NotificationPanel *pNotification = new NotificationPanel(*this);
1717 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1718 msg.Append(imagePath);
1719 if (pNotification != null)
1721 pNotification->SetText(msg);
1722 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1723 pNotification->ShowNotification();
1728 int __modalMsgBoxResult;
1729 MessageBox* pMsgBox = new MessageBox();
1730 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1731 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1734 __modalMsgBoxResult = 0;
1738 case IDA_SHARE_IMAGE_CLICKED:
1740 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1741 if (__pPopUp != null)
1746 __pPopUp = new(std::nothrow) SharePopup();
1747 __pPopUp->Initialize();
1748 if (__pHitElementResult != null)
1750 const Bitmap* pSaveBitmap = null;
1751 String imageName = GetImagePath();
1752 AppLog("Content manager image name %ls",imageName.GetPointer());
1755 imagePath.Append(imageName);
1756 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1757 AppLog("Content manager image path %ls",imagePath.GetPointer());
1758 if (__pHitElementResult != null)
1760 pSaveBitmap = __pHitElementResult->GetImage();
1762 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1764 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1765 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1767 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1768 pShareInfo->SetPageTitle(L"");
1769 pShareInfo->SetPageUrl(srcUrl);
1770 pShareInfo->SetImageAttached(true);
1771 pShareInfo->SetImagePath(imagePath);
1772 __pPopUp->RemoveAllShareInfo();
1773 __pPopUp->AddShareInfo(pShareInfo);
1774 __pPopUp->SetShowState(true);
1779 case IDA_FIND_TEXT__CLICKED:
1781 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1782 __currentSearchStr.Clear();
1783 __currentSearchStr.Append(__currentSelectedStr);
1784 InitFindWordPanel();
1787 __pMenu->SetShowState(false);
1788 __pMenu->Invalidate(false);
1791 __adressPanelPosition.y = 0;
1793 if (__pAddressbar != null && __pWebViewer != NULL)
1795 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1796 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1797 __pAddressbar->Invalidate(true);
1798 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1799 __pWebViewer->Invalidate(true);
1802 ShowFindWordPanel(true);
1803 if (__currentSearchStr.GetLength() > 0)
1809 AppLogDebug("Enter something");
1812 if (__pWebViewer != null)
1814 // releasing the set block
1815 __pWebViewer->ReleaseBlock();
1820 case IDA_SHARE_TEXT_CLICKED:
1822 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1823 if(__pPopUp != null)
1828 __pPopUp = new(std::nothrow) SharePopup();
1829 __pPopUp->Initialize();
1830 if (__pHitElementResult != null)
1832 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1833 pShareInfo->SetPageTitle(L"");
1834 pShareInfo->SetPageUrl(__currentSelectedStr);
1835 pShareInfo->SetImageAttached(false);
1836 __pPopUp->RemoveAllShareInfo();
1837 __pPopUp->AddShareInfo(pShareInfo);
1838 __pPopUp->SetShowState(true);
1843 case IDA_COPY_TEXT_CLICKED:
1845 // need to implement
1846 //__currentSelectedStr
1847 // Sets data to a clip board item
1849 String resourcePath = App::GetInstance()->GetAppResourcePath();
1850 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1852 // copying the item to clipboard
1853 Clipboard* pClipboard = Clipboard::GetInstance();
1854 if (pClipboard != null)
1856 pClipboard->CopyItem(item);
1860 case IDA_PASTE_TEXT_CLICKED:
1862 Clipboard* pClipboard = Clipboard::GetInstance();
1864 if(pClipboard == null)
1868 // Retrieves a latest item
1869 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1875 //Gets data from the clipboard item
1876 String* pString = dynamic_cast<String*>(pItem->GetData());
1878 if (pString != null)
1880 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1881 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1882 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1883 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; } } ";
1884 if(idElement.GetLength() != 0)
1886 script.Append("insertAtCursor(");
1887 script.Append(idElement);
1889 script.Append("\"");
1890 script.Append(*pString);
1891 script.Append("\");");
1893 else if (nameElement.GetLength() != 0)
1895 script.Append("insertAtCursor(document.getElementsByName('");
1896 script.Append(nameElement);
1897 script.Append("')[0],");
1898 script.Append("\"");
1899 script.Append(*pString);
1900 script.Append("\");");
1902 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1903 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1914 case IDA_GO_FORWARD:
1919 case IDA_REFRESH_BTN_CLICKED:
1921 __isLoadingCompleted = false;
1922 __isLoadingData = true;
1923 __progressPercentage = 0;
1924 __displayUrl = __pFooterUrlField->GetText();
1926 String url = __pFooterUrlField->GetText();
1927 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1931 UpdateProgressBitmap();
1934 case IDA_STOP_BTN_CLICKED:
1936 __isLoadingCompleted = false;
1937 __isLoadingData = false;
1938 __progressPercentage = 0;
1939 __pFooterUrlField->HideKeypad();
1940 __displayUrl = __pFooterUrlField->GetText();
1944 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1945 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1946 __pWebViewer->StopLoading();
1947 RequestRedraw(true);
1950 UpdateProgressBitmap();
1955 if (__pFooterUrlField->GetText().IsEmpty() == false)
1957 //__displayUrl = __pUrlField->GetText();
1958 __pFooterUrlField->Clear();
1968 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1971 UiApp* pApp = UiApp::GetInstance();
1980 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1981 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1983 String* pSelectedScene = NULL;
1984 Object* pValue = NULL;
1985 String* pUrl = null;
1986 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1987 pSelectedScene = (String*) pValue;
1989 if (pSelectedScene != null)
1991 delete pSelectedScene;
1993 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1994 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1995 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1996 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1998 // setting the current scene ID
1999 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2001 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2003 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2005 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2006 if(__pWindowInfo == null)
2008 // if(__pWindowInfo == null)
2010 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2013 else if ( pArgs != null && pArgs->GetCount() == 1)
2015 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2021 // hiding the address bar
2022 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2023 __pAddressbar->SetShowState(false);
2024 if(__pWebViewer != null)
2026 __pWebViewer->Resume();
2029 if(pUrl != null && pUrl->GetLength() > 0)
2033 else if(__pWindowInfo != null)
2035 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)
2037 LoadUrl(__pWindowInfo->pageUrl);
2039 else if (__pWindowInfo->isJavascriptInitiated == true)
2043 __pWindowInfo->pCurrentWeb = __pWebViewer;
2047 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2048 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2049 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2051 InitMostVisitedSitesView(GetOrientationStatus());
2054 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2056 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2058 if (pBookmarkUrl == null)
2060 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2061 //__pAddressbar->SetUrl(*pBookmarkUrl);
2062 SetUrl(*pBookmarkUrl);
2064 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2065 __pWebViewer->LoadUrl(*pBookmarkUrl);
2066 delete pBookmarkUrl;
2069 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2070 Bitmap* pBitmap = null;
2071 if (isPrivateBrowsing == true)
2073 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2075 if (__pWebViewer != null)
2077 __pWebViewer->SetPrivateBrowsingEnabled(true);
2080 if (__pAddressbar != null)
2082 // __pAddressbar->UpdateFaviconBitmap(true);
2088 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2090 if (__pWebViewer != null)
2092 __pWebViewer->SetPrivateBrowsingEnabled(false);
2095 if (__pAddressbar != null)
2097 // __pAddressbar->UpdateFaviconBitmap(false);
2101 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2103 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2105 else if (__pMenu != null )
2107 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2110 if (pBitmap != null)
2115 AppLog("ABC: OnSceneActivatedN started exit");
2120 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2121 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2123 Canvas* pWebCanvas = null;
2124 if (__pWebViewer != null)
2126 pWebCanvas = __pWebViewer->GetCanvasN();
2127 __pWebViewer->Pause();
2130 if (pWebCanvas == null)
2134 if (__pWindowInfo != null)
2136 if (__pWindowInfo->pWebCanvasBitmap != null)
2138 delete __pWindowInfo->pWebCanvasBitmap;
2140 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2141 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2142 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2144 Bitmap* pBitmap = GetCapturedBitmapN();
2145 AppLog("Coming here");
2146 Canvas* pCanvas = new(std::nothrow) Canvas();
2147 pCanvas->Construct(GetClientAreaBounds());
2150 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2153 if(__pWebViewer != null && __pWindowInfo != null)
2154 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2156 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2157 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2159 AppLog("Coming here");
2163 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2164 const Tizen::Base::String& realm,
2165 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2171 MainForm::OnHttpAuthenticationCanceled(void)
2176 MainForm::OnLoadingStarted(void)
2178 AppLogDebug("MainForm::OnLoadingStarted entered");
2180 if(__pAddressbar == NULL)
2184 String url = __pWebViewer->GetUrl();
2185 if(url.Contains(IDS_TIZEN_SERVICE))
2188 String delim(L":;");
2190 // Creates a StringTokenizer instance
2191 StringTokenizer strTok(url, delim);
2193 int count = strTok.GetTokenCount(); // count == 4
2195 HashMap *pMap = new HashMap();
2200 while (strTok.HasMoreTokens())
2202 AppLog("Token: %ls", token.GetPointer());
2203 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2204 if(token.Contains(IDS_APPID))
2206 token.SubString(6, appId);
2207 AppLog("AppID:%ls", appId.GetPointer());
2209 else if(token.Contains("="))
2211 String *pKey = new String();
2212 String *pValue = new String();
2214 token.IndexOf("=", 0, index);
2217 token.SubString(0, index, *pKey);
2218 token.SubString(index + 1, *pValue);
2219 pMap->Add(pKey, pValue);
2225 AppControl *pAppControl = null;
2226 String operationId = L"http://tizen.org/appcontrol/operation/main";
2227 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2230 AppLog("Starting AppControl");
2231 result r = pAppControl->Start(null, null, pMap, null);
2232 AppLog("Result of Start %s", GetErrorMessage(r));
2236 AppLogException("AppControl not found");
2241 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2242 __pAddressbar->SetFaviconBitmap(*pBitmap);
2244 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2246 // updating the address bar position with respect to web control
2247 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2248 __distanceMoved = 0;
2252 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2253 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2256 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2257 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2258 SetUrl(__pWebViewer->GetUrl());
2259 if (__pWindowInfo != NULL)
2261 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2263 __pAddressbar->Invalidate(true);
2269 MainForm::OnLoadingCanceled(void)
2276 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2278 AppLog("MainForm::OnKeypadWillOpen");
2279 if (__pAddressbar != null)
2281 OnAddressBarKeypadOpened(*__pAddressbar);
2284 //__pAddressbar->SetAddressbarURLFocus();
2289 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2291 if (__pAddressbar != null)
2293 OnAddressBarKeypadClosed(*__pAddressbar);
2298 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2299 const Tizen::Base::String& reason)
2301 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2305 MainForm::OnLoadingCompleted(void)
2308 result r = E_SUCCESS;
2310 if (__pWebViewer == null)
2315 if (__pAddressbar == null)
2319 if (__pWebViewer->CanGoForward())
2321 //__pAddressbar->SetForwardButtonEnabled(true);
2322 SetForwardButtonEnabled(true);
2326 //__pAddressbar->SetForwardButtonEnabled(false);
2327 SetForwardButtonEnabled(false);
2330 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2332 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2334 //__pAddressbar->UpdateProgress(0);
2338 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2340 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2344 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2345 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2346 if (isPrivateBrowsing == false)
2348 History* pHistory = new(std::nothrow) History;
2350 HistoryPresentationModel::GetCurrentDateTime(date);
2353 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2354 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2356 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2357 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2359 pHistory->SetVisitedTime(date);
2362 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2363 pHistory->SetFaviconId(id);
2364 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2365 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2366 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2368 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2369 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2370 pHistory->SetThumbnail(pBitmap);
2372 HistoryPresentationModel::GetInstance()->SaveHistory(*pHistory);
2379 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2381 // temperary fixed (webpage can be not loaded)
2387 MainForm::OnEstimatedProgress(int progress)
2389 AppLogDebug("MainForm::OnEstimatedProgress entered");
2390 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2391 progress = DEFAULT_PROGRESS_PERCENTAGE;
2393 // __pAddressbar->UpdateProgress(progress);
2394 UpdateProgress(progress);
2398 MainForm::OnUrlSubmitted(Addressbar& addBar)
2400 AppLog("MainForm::OnUrlSubmitted");
2401 String url = addBar.GetUrl();
2402 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2405 __pFooterPanel->SetShowState(true);
2406 __pFooterPanel->Invalidate(true);
2407 RequestRedraw(true);
2411 MainForm::LoadUrl(String& url)
2413 AppLogDebug("MainForm::LoadUrl enter");
2415 if (__pWebViewer != null)
2417 __pWebViewer->SetShowState(true);
2418 __pWebViewer->Invalidate(true);
2421 if (url.CompareTo(L"") == 0)
2425 if(__pFooterPanel != null)
2427 __pFooterPanel->SetShowState(true);
2428 __pFooterPanel->Invalidate(true);
2435 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2436 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)
2438 RegularExpression firstRegex;
2439 RegularExpression secondRegex;
2441 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2442 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2445 ret = firstRegex.Match(url, false); // This returns true value
2446 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2448 if (ret == true && __pWebViewer != null)
2450 __pWebViewer->LoadUrl(url);
2452 else if(__pWebViewer != null)
2454 String tempUrl = L"http://";
2455 tempUrl.Append(url);
2459 __pWebViewer->LoadUrl(tempUrl);
2463 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(url));
2466 if (__pAddressbar != null)
2468 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2469 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2472 AppLogDebug("MainForm::LoadUrl exit");
2479 MainForm::OnStopClicked(Addressbar& addBar)
2481 AppLogDebug("MainForm::OnStopClicked called");
2484 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2485 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2486 __pWebViewer->StopLoading();
2487 RequestRedraw(true);
2492 MainForm::OnReaderClicked(const Addressbar& addBar)
2494 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2496 CreateReaderPanel();
2497 AppLogDebug("MainScene::OnReaderClicked entered");
2500 /*if (__pArticleReaderPanel)
2502 AppLogDebug("showstate true for reader panel");
2503 __pArticleReaderPanel->SetShowState(true);
2504 __pArticleReaderPanel->Show();
2506 int xPos = __pArticleReaderPanel->GetX();
2507 int yPos = __pArticleReaderPanel->GetY();
2508 AppLog("OnReaderClicked() xPos = %d",xPos);
2509 AppLog("OnReaderClicked() yPos = %d",yPos);
2511 if (__pReaderData == null)
2516 String loadData = L"<html>\
2518 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2523 background-color: transparent;\
2542 <body style='width:'";
2543 loadData.Append(bodyWidth);
2544 loadData.Append(L"px'>");
2545 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2546 loadData.Append(*__pReaderData);
2547 loadData.Append(L"</body></html>");
2550 buf.Construct(loadData.GetLength());
2551 AppLogDebug("data->GetLength %d",loadData.GetLength());
2552 for (int z=0;z<loadData.GetLength();z++)
2555 loadData.GetCharAt(z,b);
2556 buf.SetByte((byte)b);
2560 if (__pWebReader != null)
2562 __pWebReader->LoadData(L"",buf,L"text/html");
2563 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2567 AppLogDebug("cannot LoadData __pWebReader is null");
2573 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2575 AppLog("MainForm::OnBackClicked");
2576 result r = E_FAILURE;
2578 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2580 __pWebViewer->GoBack();
2585 pApp = UiApp::GetInstance();
2588 r = pApp->Terminate();
2598 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2600 AppLog("MainForm::OnForwardClicked");
2601 if (__pWebViewer == null)
2604 if (__pWebViewer->CanGoForward())
2606 __pWebViewer->GoForward();
2611 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2613 result r = E_SUCCESS;
2614 // hiding the address bar
2615 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2616 __pAddressbar->SetShowState(false);
2618 if (__pMostVisitedListView != null && __pMostVisitedListView->GetShowState() == true)
2620 AppLog("MainForm::OnAddressCancelledClicked 1");
2621 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2622 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()/*GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14*/));
2624 if (__pMostVisitedListView != null)
2625 __pMostVisitedListView->Invalidate(true);
2627 /*else if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
2629 if (__pWebViewer != null && __pAddressbar != null && __pFooterPanel != null)
2631 AppLog("MainForm::OnAddressCancelledClicked 2");
2632 r = __pWebViewer->SetBounds(Rectangle(0,0__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __webControlHeightGetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2635 AppLog("MainForm::OnAddressCancelledClicked success");
2639 AppLog("MainForm::OnAddressCancelledClicked failure");
2643 int yOfWebViewer = __pWebViewer->GetY();
2644 int heightOfWebViewer = __pWebViewer->GetHeight();
2645 AppLog("MainForm::OnAddressCancelledClicked yOfWebViewer is %d",yOfWebViewer);
2646 AppLog("MainForm::OnAddressCancelledClicked heightOfWebViewer is %d",heightOfWebViewer);
2648 __pWebViewer->Invalidate(true);
2651 __pFooterPanel->SetShowState(true);
2652 __pFooterPanel->Invalidate(false);
2656 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2658 __prevAddressBarMode = __curAddressBarMode;
2660 if (__pAddressbar != null)
2662 //__curAddressBarMode = __pAddressbar->GetAddressbarMode();
2663 __curAddressBarMode = GetAddressbarMode();
2666 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2668 __adressPanelPosition.y = 0;
2669 if (__pAddressbar != null)
2671 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2672 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2673 __pAddressbar->Invalidate(true);
2675 if (__pWebViewer != null)
2677 __pWebViewer->StopLoading();
2680 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2682 __adressPanelPosition.y = 0;
2683 if (__pAddressbar != null)
2686 __webControlPosition.y = 0;//__pAddressbar->GetHeight() - 12;
2687 __pAddressbar->SetBounds(Rectangle(0,__pAddressbar->GetY() - __pAddressbar->GetHeight(),GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2688 __pAddressbar->Invalidate(true);
2691 if (__pWebViewer != null)
2693 if(__pFooterPanel->GetShowState() == false)
2694 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2696 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2697 __pWebViewer->Invalidate(true);
2702 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar)
2705 if(__pFooterPanel != null)
2707 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2708 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2710 InitMostVisitedSitesView(GetOrientationStatus());
2712 __pFooterPanel->SetShowState(true);
2713 __pFooterPanel->Invalidate(false);
2718 //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");
2720 if (__pWebViewer != null && __pFooterPanel != null)
2722 AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2723 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2725 if(__pFooterPanel->GetShowState() == false)
2726 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2728 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2729 __pWebViewer->Invalidate(false);
2730 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2732 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2733 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2738 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2740 AppLog("MainForm::OnAddressBarKeypadOpened");
2742 if (__pFindWordPanel && __pFindWordPanel->GetShowState() == true)
2744 __pAddressbar->SetShowState(false);
2745 __pAddressbar->Invalidate(true);
2749 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2751 __pAddressbar->SetShowState(true);
2752 __pAddressbar->Invalidate(true);
2753 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2754 __pAddressbar->SetAddressbarURLFocus();
2759 //__pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2762 if (__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2764 AppLog("MainForm::OnAddressBarKeypadOpened 1");
2765 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2766 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pMostVisitedListView->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2768 if(__pMostVisitedListView != null)
2769 __pMostVisitedListView->Invalidate(true);
2771 else if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
2773 AppLog("MainForm::OnAddressBarKeypadOpened 2");
2774 if (__pWebViewer != null && __pAddressbar != null && __pFooterPanel != null)
2775 __pWebViewer->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pWebViewer->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2777 if(__pWebViewer != null)
2778 __pWebViewer->Invalidate(true);
2783 if (__pWebViewer != null)
2785 __pWebViewer->SetShowState(false);
2786 __pWebViewer->Invalidate(true);
2789 __pMostVisitedListView->SetShowState(true);
2790 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2791 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2793 if(__pMostVisitedListView != null)
2794 __pMostVisitedListView->Invalidate(true);
2799 __pFooterPanel->SetShowState(false);
2800 __pFooterPanel->Invalidate(true);
2804 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2806 __pFooterPanel->SetShowState(false);
2807 __pFooterPanel->Invalidate(false);
2811 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2815 __pWindowInfo->pageTitle = title;
2816 if (__pWebViewer != null)
2818 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2821 if (__pAddressbar != null && __pWebViewer != null)
2823 SetUrl(__pWebViewer->GetUrl());
2824 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2825 //__pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2826 __pAddressbar->Invalidate(true);
2832 MainForm::UpdateFavicon(void)
2834 bool urlImageType = false;
2835 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();");
2836 Bitmap* pBitmap = null;
2838 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2840 if (__pWindowInfo != null)
2843 url.SetUri(*tempPath);
2844 if (url.GetHost().GetLength() == 0)
2847 webUrl.SetUri(__pWebViewer->GetUrl());
2848 result r = url.SetHost(webUrl.GetHost());
2855 if (url.GetScheme().GetLength() == 0)
2858 webUrl.SetUri(__pWebViewer->GetUrl());
2859 url.SetScheme(webUrl.GetScheme());
2861 __pWindowInfo->faviconUrl = url.ToString();
2863 pBitmap = __pWebViewer->GetFaviconN();
2865 if (pBitmap != null)
2867 if (__pWindowInfo->pFavicon != NULL)
2869 // delete __pWindowInfo->pFavicon;
2870 __pWindowInfo->pFavicon = null;
2872 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2873 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2874 //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();
2876 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2878 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2880 else if(__pWindowInfo->pFavicon != null)
2882 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2886 __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());
2889 AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());
2896 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2903 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2904 Tizen::Web::Controls::WebNavigationType type)
2906 // when load new page if find word panel is open its show state is false
2907 ShowFindWordPanel(false);
2908 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
2910 __pFooterUrlField->SetText(__pAddressbar->GetAddressbarURL());
2911 __pFooterPanel->Invalidate(true);
2914 uriInfo.SetUri(url);
2916 if(url.Contains(IDS_TIZEN_SERVICE))
2919 String delim(L":;");
2921 // Creates a StringTokenizer instance
2922 StringTokenizer strTok(url, delim);
2924 int count = strTok.GetTokenCount(); // count == 4
2926 HashMap *pMap = new HashMap();
2932 while (strTok.HasMoreTokens())
2934 AppLog("Token: %ls", token.GetPointer());
2935 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2936 if(token.Contains(IDS_APPID))
2938 token.SubString(6, appId);
2939 AppLog("AppID:%ls", appId.GetPointer());
2941 else if(token.Contains("="))
2943 String *pKey = new String();
2944 String *pValue = new String();
2946 token.IndexOf("=", 0, index);
2949 token.SubString(0, index, *pKey);
2950 token.SubString(index + 1, *pValue);
2951 pMap->Add(pKey, pValue);
2957 AppControl *pAppControl = null;
2958 String operationId = L"http://tizen.org/appcontrol/operation/main";
2959 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2962 AppLog("Starting AppControl");
2963 result r = pAppControl->Start(null, null, pMap, null);
2964 AppLog("Result of Start %s", GetErrorMessage(r));
2968 AppLogException("AppControl not found");
2974 if (__pWebViewer && __pAddressbar)
2976 __pAddressbar->SetShowState(false);
2977 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2978 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2979 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2983 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2984 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2985 __pWindowInfo->faviconUrl = "";
2986 __pWindowInfo->faviconFilePath = "";
2988 if (__pWindowInfo->pFavicon != NULL)
2990 // delete __pWindowInfo->pFavicon;
2991 __pWindowInfo->pFavicon = null ;
2993 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2997 __pAddressbar->Invalidate(true);
3003 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3004 const Tizen::Net::Http::HttpHeader& httpHeader)
3006 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3011 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3013 AppLog("MainForm::OnWebPageBlockSelected");
3015 if (__pHitElementResult != null)
3017 delete __pHitElementResult;
3018 __pHitElementResult = null;
3021 if (__pWebViewer != null)
3023 AppLog("MainForm::OnWebPageBlockSelected web not null");
3024 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3027 if (__pHitElementResult == null)
3032 if (__pHitElementResult->HasImage() != true)
3034 String tagName = __pHitElementResult->GetTagName();
3035 String type = __pHitElementResult->GetAttributeValue("type");
3037 __currentSelectedStr.Clear();
3038 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3040 if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)
3042 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3044 InitSelectTextContextMenu(startPoint,true);
3045 __pImageMenu->SetShowState(true);
3046 __pImageMenu->Show();
3047 __pImageMenu->Invalidate(true);
3049 else if (__pHitElementResult->HasUrl() == true || __currentSelectedStr.GetLength() > 0)
3051 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3053 if(__pHitElementResult->GetUrl().GetLength() > 0)
3055 __currentSelectedStr.Clear();
3056 __currentSelectedStr = __pHitElementResult->GetUrl();
3058 InitSelectTextContextMenu(startPoint,false);
3059 __pImageMenu->SetShowState(true);
3060 __pImageMenu->Show();
3061 __pImageMenu->Invalidate(true);
3064 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3065 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3066 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3071 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3077 MainForm::OnWebWindowCreateRequested(void)
3079 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3081 if (pNewWindowInfo == null)
3085 result r = E_SUCCESS;
3086 SceneManager* pSceneManager = SceneManager::GetInstance();
3087 if (pSceneManager == NULL)
3091 ArrayList* pArgList = new(std::nothrow) ArrayList();
3092 if (pArgList == NULL)
3096 r = pArgList->Construct();
3099 pNewWindowInfo->isJavascriptInitiated = true;
3100 pArgList->Add(*pNewWindowInfo);
3101 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3105 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3112 return pNewWindowInfo->pCurrentWeb;
3116 MainForm::RelayoutControls(bool showAddressbar)
3118 if (showAddressbar == false)
3120 __pAddressbar->SetShowState(false);
3121 __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);
3122 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3126 __pAddressbar->SetShowState(true);
3127 __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);
3128 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3130 RequestRedraw(true);
3133 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3135 if (__pFindWordPanel == null)
3141 InitFindWordPanel();
3142 __pFindWordEditField->SetText(__currentSearchStr);
3143 //__pFindWordCountLabel->SetText(L"");
3144 __pFindWordCountLabel->SetText(L"0/0");
3147 AppLog("MainForm::ShowFindWordPanel %d",show);
3148 if (show && !isTouchPressed)
3150 if (__pFindWordEditField)
3152 __pFindWordEditField->SetFocus();
3153 __pFindWordEditField->ShowKeypad();
3158 if (__pFindWordEditField)
3159 __pFindWordEditField->HideKeypad();
3162 if (__pAddressbar != null)
3164 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3165 __pAddressbar->SetShowState(false);
3166 __pAddressbar->Invalidate(true);
3168 if (__pFindWordPanel != null)
3170 __pFindWordPanel->SetShowState(show);
3171 __pFindWordPanel->Invalidate(true);
3177 MainForm::StartWordSearch()
3179 //Get the count of occurances of the word in the current page
3180 __maxOccurrances = 0;
3181 __currentWordIndex = 0;
3183 __pFindWordPrev->SetEnabled(false);
3184 String *pCountStr = null;
3185 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3186 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3187 if (pCountStr != null)
3189 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3193 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3198 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3200 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3201 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3203 /* if(totalCount == -1 || totalCount == 0)
3205 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight());
3206 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3209 else if(totalCount > 100)
3211 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3212 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3215 __maxOccurrances = totalCount;
3216 __currentWordIndex = currentOrdinal;
3218 //Reset the UI controls as per the maxOccurrance value
3219 if (totalCount <= 0)
3221 AppLog("Word not found");
3222 //Show error notification to user
3223 __pFindWordNext->SetEnabled(false);
3224 __pFindWordCountLabel->SetText(L"0/0");
3225 __pFindWordNext->Invalidate(false);
3226 __pFindWordPrev->Invalidate(false);
3227 __pFindWordCountLabel->Invalidate(false);
3231 if (totalCount == 1)
3233 __pFindWordNext->SetEnabled(false);
3237 __pFindWordNext->SetEnabled(true);
3240 String countStr = L"";
3241 countStr.Append(__currentWordIndex);
3242 countStr.Append(L"/");
3243 countStr.Append(__maxOccurrances);
3244 __pFindWordCountLabel->SetText(countStr);
3245 // __pFindWordCountLabel->SetShowState(true);
3246 __pFindWordCountLabel->Invalidate(false);
3248 //FindNextWord(true);
3249 //Update the controls
3250 __pFindWordNext->Invalidate(false);
3251 __pFindWordPrev->Invalidate(false);
3252 __pFindWordCountLabel->Invalidate(false);
3256 MainForm::FindNextWord(bool next)
3260 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3262 if(__currentWordIndex < __maxOccurrances)
3264 __currentWordIndex++;
3270 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3272 if(__currentWordIndex > 1)
3274 __currentWordIndex--;
3279 String countStr = L"";
3280 countStr.Append(__currentWordIndex);
3281 countStr.Append(L"/");
3282 countStr.Append(__maxOccurrances);
3283 __pFindWordCountLabel->SetText(countStr);
3284 // __pFindWordCountLabel->SetShowState(true);
3285 __pFindWordCountLabel->Invalidate(false);
3286 if (__currentWordIndex >= __maxOccurrances)
3288 __pFindWordNext->SetEnabled(false);
3292 __pFindWordNext->SetEnabled(true);
3294 if (__currentWordIndex <= 1)
3296 __pFindWordPrev->SetEnabled(false);
3300 __pFindWordPrev->SetEnabled(true);
3302 __pFindWordPrev->Invalidate(false);
3303 __pFindWordNext->Invalidate(false);
3304 __pFindWordCountLabel->Invalidate(false);
3305 __pFindWordPanel->Invalidate(true);
3308 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3310 AppLog("MainForm::OnWebKeypadWillOpen");
3311 OnAddressBarKeypadOpened(*__pAddressbar);
3315 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3318 if (__pWebViewer != null && __pFooterPanel != null)
3320 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3321 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3323 if (__pFooterPanel->GetShowState() == false)
3324 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3326 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3328 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3333 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3335 OnAddressBarKeypadClosed(*__pAddressbar);
3339 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3341 Control* temp = const_cast< Control* >(&source);
3342 Header* pHeader = dynamic_cast< Header* >(temp);
3343 if (pHeader != null)
3345 //Header double - clicked
3346 AppLog("Header double clicked");
3348 if(__pFindWordPanel)
3350 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3351 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3355 AppLog("MainScene::OnTouchDoublePressed");
3356 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3357 if (isReaderEnabled == true)
3361 delete __pReaderData;
3362 __pReaderData = null;
3364 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3365 filePath.Append(L"data/reader.js");
3371 result r = E_SUCCESS;
3372 FileAttributes attr;
3374 File::GetAttributes(filePath,attr);
3376 r = file.Construct(filePath, L"r+");
3379 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3382 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3385 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3388 file.Read(pScript,attr.GetFileSize());
3390 AppLogDebug("scipt length %d",strlen(pScript));
3391 String strScript = L"";
3392 strScript.Append(pScript);
3393 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3396 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3399 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3400 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3402 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3403 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3409 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3411 AppLog("MainForm::OnTouchLongPressed");
3413 if (__pHitElementResult != null)
3415 delete __pHitElementResult;
3416 __pHitElementResult = null;
3419 if (__pWebViewer != null)
3421 AppLog("MainForm::OnTouchLongPressed web not null");
3422 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3425 if (__pHitElementResult == null)
3430 if (__pHitElementResult->HasImage() == true)
3432 InitImageContextMenu(currentPosition);
3433 __pImageMenu->SetShowState(true);
3434 __pImageMenu->Show();
3435 __pImageMenu->Invalidate(true);
3439 String tagName = __pHitElementResult->GetTagName();
3440 String type = __pHitElementResult->GetAttributeValue("type");
3441 String value = __pHitElementResult->GetAttributeValue(L"value");
3442 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3444 __currentSelectedStr.Clear();
3445 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3447 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3449 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3451 InitSelectTextContextMenu(currentPosition,true, true);
3452 __pImageMenu->SetShowState(true);
3453 __pImageMenu->Show();
3454 __pImageMenu->Invalidate(true);
3456 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3459 __inputEventToBeSupressed = true;
3463 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3465 AppLog("MainForm::OnTouchReleased");
3467 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3468 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3470 __pWebViewer->ConsumeInputEvent();
3472 if(pHitElement != null)
3476 __inputEventToBeSupressed = false;
3480 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3482 int widthContextItem = 0;
3484 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3487 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3491 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3494 if( __pItemContext != NULL)
3496 delete __pItemContext;
3497 __pItemContext = null;
3501 __pItemContext= new(std::nothrow) ListContextItem();
3502 __pItemContext->Construct();
3503 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", widthContextItem,HEIGHT_CONTEXT_MENU_BUTTON);
3504 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", widthContextItem, HEIGHT_CONTEXT_MENU_BUTTON);
3506 if (pBitmapNormal != null && pBitmapPressed != null)
3508 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
3511 if (pBitmapNormal != null)
3513 delete pBitmapNormal;
3516 if (pBitmapPressed != null)
3518 delete pBitmapPressed;
3522 if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3524 __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());
3525 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
3526 __pFindWordControl->SetShowState(true);
3527 __pFindWordControl->Invalidate(true);
3528 __pFindWordPanel->SetShowState(true);
3529 __pFindWordPanel->Invalidate(true);
3532 if (__pWebViewer != null && __pFooterPanel != null)
3534 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3535 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3537 if(__pFooterPanel->GetShowState() == false)
3538 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3540 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3541 __pWebViewer->Invalidate(true);
3543 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3545 if (__pAddressbar != null)
3547 if(__pAddressbar->GetShowState() == false)
3549 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3553 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3555 //__pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3556 //__pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());
3557 SetAddressbarMode(GetAddressbarMode());
3558 // __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
3560 if (__pFindWordBgLabel != null)
3562 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3563 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3564 if (pBitmap != null)
3566 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3570 if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)
3572 AppLog("__pFooterPanel->GetShowState() is true");
3577 if(__pMoreButton && __pMenu)
3579 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3580 __pMenu->SetAnchorPosition(p);
3581 __pMenu->Invalidate(true);
3586 __pFooterPanel->Invalidate(true);
3588 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3589 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3591 InitMostVisitedSitesView(orientationStatus);
3594 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3596 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3598 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight());
3600 else if(__pAddressbar != null && __pAddressbar->GetShowState() == false)
3602 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight());
3605 if (__pArticleReaderPanel != null)
3607 if (__pArticleReaderPanel->GetShowState() == true)
3609 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3611 if (__pBlankPanel != null)
3612 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3614 if (__pWebReader != null)
3616 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3618 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3619 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3621 if ( pBitmap != null && pSrcBitmap != null)
3623 AppLog("CreateReaderPanel ninepatchbitmap found");
3624 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3627 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3628 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3629 if (pBitmap != null)
3634 if (pSrcBitmap != null)
3642 if(__pAddressbar != null)
3644 __pAddressbar->OrientationChanged();
3649 MainForm::OnSettingsChange(int settingvalue)
3651 AppLogDebug("MainForm::OnSettingsChange entered");
3652 if (__pWebViewer == null)
3654 AppLogDebug("Webviewer is not initialized yet.");
3657 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3659 WebSetting settings = __pWebViewer->GetSetting();
3660 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3662 settings.SetAutoFittingEnabled(true);
3664 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3666 settings.SetAutoFittingEnabled(false);
3668 __pWebViewer->SetSetting(settings);
3670 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3672 WebSetting settings = __pWebViewer->GetSetting();
3673 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3674 __pWebViewer->SetSetting(settings);
3676 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3678 WebSetting settings = __pWebViewer->GetSetting();
3679 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3680 __pWebViewer->SetSetting(settings);
3682 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3684 WebSetting settings = __pWebViewer->GetSetting();
3685 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3686 __pWebViewer->SetSetting(settings);
3688 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3692 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3696 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3698 WebSetting settings = __pWebViewer->GetSetting();
3699 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3701 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3705 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3707 __pWebViewer->SetSetting(settings);
3709 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3713 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3714 WebSetting settings = __pWebReader->GetSetting();
3715 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3716 __pWebReader->SetSetting(settings);
3722 MainForm::OnSettingsReset()
3726 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3727 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3732 MainForm::OnClearCache()
3734 result r = E_SUCCESS;
3736 if (__pWebViewer != NULL)
3738 r = __pWebViewer->ClearCache();
3741 AppLogDebug("Cache cleared success");
3745 AppLogDebug("Cache cleared fail");
3751 MainForm::OnClearCookie()
3753 result r = E_SUCCESS;
3755 if (__pWebViewer != NULL)
3757 __pWebViewer->ClearCookie();
3761 AppLogDebug("Cookie cleared success");
3765 AppLogDebug("Cache cleared fail");
3770 MainForm::findDistance(int x1,int y1,int x2, int y2)
3772 int deltaX = Math::Abs(x2 - x1);
3773 int deltaY = Math::Abs(y2 - y1);
3774 double num = deltaX*deltaX + deltaY*deltaY;
3780 for (i = 0; i < 20; i++)
3782 x = (((x*x)+ num)/(2*x));
3793 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3795 if(__pFindWordPanel)
3797 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3798 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3802 IList* pList = null;
3803 pList = touch.GetTouchInfoListN(source);
3807 int count = pList->GetCount();
3810 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3811 __touchPoint1 = pTouchInfo->position;
3813 /*if (__pAddressbar != null)
3815 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3817 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3819 __pAddressbar->SaveAddressbarEditText();
3821 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3824 __pAddressbar->Invalidate(true);
3826 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3828 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3830 //__pAddressbar->SaveAddressbarEditText();
3832 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3835 else if (count == 2)
3837 AppLogDebug("MainForm::OnTouchPressed count is two");
3838 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3839 __touchPoint1 = pTouchInfo->position;
3841 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3842 __touchPoint2 = pTouchInfo->position;
3848 pList->RemoveAll(true);
3855 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3857 AppLog("Start MainForm::OnTouchMoved MoveUiControls");
3858 if(__pFindWordPanel)
3860 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3861 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3864 if (__pFindWordEditField != null)
3866 __pFindWordEditField->HideKeypad();
3869 /*if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3873 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3879 IList* pList = null;
3880 pList = touch.GetTouchInfoListN(source);
3884 int count = pList->GetCount();
3887 AppLogDebug("MainForm::OnTouchMoved count 1");
3888 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3890 if( pTouchInfo == NULL )
3894 pTouchInfo->position.y += __pWebViewer->GetY();
3895 AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);
3897 if (__isLoaded == false)
3900 __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;
3901 __touchPoint1 = pTouchInfo->position;
3903 // move the address bar and web control according to distance moved
3906 else if (count == 2)
3908 AppLogDebug("MainForm::OnTouchMoved count 2");
3912 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3914 if( pTouchInfo == NULL )
3918 Point firstPoint = pTouchInfo->position;
3920 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3921 if( pTouchInfo == NULL )
3925 Point secondPoint = pTouchInfo->position;
3927 if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))
3929 __touchPoint1 = firstPoint;
3930 __touchPoint2 = secondPoint;
3935 int currX1 = firstPoint.x;
3936 int currY1 = firstPoint.y;
3937 int currX2 = secondPoint.x;
3938 int currY2 = secondPoint.y;
3940 double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);
3941 double dist = findDistance(currX1, currY1, currX2, currY2);
3942 __distanceMoved = prevDist - dist;
3944 __touchPoint1 = firstPoint;
3945 __touchPoint2 = secondPoint;
3957 MainForm::MoveUiControls()
3959 if(__pAddressbar == NULL || __pAddressbar->GetShowState() == false)
3963 __adressPanelPosition.y = __adressPanelPosition.y + __distanceMoved;
3964 if (__adressPanelPosition.y > 0)
3966 __adressPanelPosition.y = 0;
3967 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3969 else if (__adressPanelPosition.y < (0-(__pAddressbar->GetHeight() - 12))) // -12 is for the progress label
3971 __adressPanelPosition.y = 0-(__pAddressbar->GetHeight() - 12);
3972 __webControlPosition.y = 0;
3976 __webControlPosition.y = __adressPanelPosition.y + (__pAddressbar->GetHeight() - 12);
3979 AppLogDebug("__adressPanelPosition.y = %d, __webControlPosition.y = %d", __adressPanelPosition.y, __webControlPosition.y);
3981 __pAddressbar->SetBounds(0,__adressPanelPosition.y,__pAddressbar->GetWidth(),__pAddressbar->GetHeight());
3982 __pAddressbar->Invalidate(false);
3984 if (__pWebViewer != NULL)
3986 if(__pFooterPanel->GetShowState() == true)
3987 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3989 __webControlHeight = GetClientAreaBounds().height;
3990 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3991 __pWebViewer->Invalidate(false);
3996 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3998 if (__pFindWordEditField != null)
4000 __currentSearchStr = __pFindWordEditField->GetText();
4001 __pFindWordNext->SetEnabled(false);
4002 __pFindWordPrev->SetEnabled(false);
4003 __pFindWordNext->Invalidate(true);
4004 __pFindWordPrev->Invalidate(true);
4005 __pFindWordCountLabel->SetText(L"0/0");
4006 __pFindWordCountLabel->Invalidate(true);
4008 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4009 if (__currentSearchStr.GetLength() > 0)
4015 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4017 AppLogDebug("Enter something");
4022 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4029 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4031 if(__pWebViewer != null)
4034 AppLog("MainForm::InitMostVisitedSitesView");
4035 result r = E_SUCCESS;
4038 if (__pWebViewer != null && __pMostVisitedListView != null)
4043 if (__pMostVisitedListView != null)
4045 RemoveControl(*__pMostVisitedListView);
4047 if(__pMostVisitedSites != null)
4049 __pMostVisitedSites->RemoveAll(true);
4052 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4054 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4055 __pMostVisitedListView = new(std::nothrow) ListView();
4056 if(__pFooterPanel->GetShowState() == false)
4058 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);
4062 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);
4067 delete __pMostVisitedListView;
4068 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4071 __pMostVisitedListView->SetItemProvider(*this);
4072 __pMostVisitedListView->AddListViewItemEventListener(*this);
4073 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4074 AddControl(*__pMostVisitedListView);
4075 AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));
4076 if(__pFooterPanel->GetShowState() == false)
4077 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));
4079 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
4081 __pMostVisitedListView->UpdateList();
4088 MainForm::GetImagePath(void)
4092 String formattedTime;
4093 DateTime currentTime;
4094 LocaleManager localManager;
4095 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4097 localManager.Construct();
4098 Locale locale = localManager.GetSystemLocale();
4099 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4101 // Get date formatter
4102 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4106 pTimeFormatter->Format(currentTime, formattedTime);
4109 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4110 String delim(L" :");
4111 StringTokenizer strTok(formattedTime, delim);
4114 String str1("GMT+00");
4115 while (strTok.HasMoreTokens())
4117 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4118 if(token.Equals(str1))
4120 AppLog("token is %ls", token.GetPointer());
4121 imageName.Append(token);
4127 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4129 result r = E_FAILURE;
4130 AppLog("Content manager 1");
4131 ContentId contentId;
4132 ContentManager contentManager;
4133 r = contentManager.Construct();
4136 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4139 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4140 contentPath.Append(imageName);
4141 contentPath.Append(".jpg");
4142 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4143 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4147 MainForm::SetForwardButtonEnabled(bool isEnabled)
4149 __pGoForwardBtn->SetEnabled(isEnabled);
4150 __pGoBackBtn->Invalidate(true);
4154 MainForm::SetBackButtonEnabled(bool isEnabled)
4156 __pGoBackBtn->SetEnabled(isEnabled);
4157 __pGoBackBtn->Invalidate(true);
4161 MainForm::UpdateProgress(int percentage)
4163 __progressPercentage = percentage;
4164 if (percentage == 0 || percentage == 100)
4166 __isLoadingData = false;
4167 if (percentage == 100)
4169 __isLoadingCompleted = true;
4170 __progressPercentage = 0;
4174 __isLoadingCompleted = false;
4179 __isLoadingData = true;
4181 UpdateProgressBitmap();
4185 MainForm::GetProgress(void)
4187 return __progressPercentage;
4191 MainForm::UpdateProgressBitmap(void)
4193 result r = E_SUCCESS;
4194 if (__pProgressbarLabel == null)
4196 int w = __pProgressbarLabel->GetWidth();
4197 int h = __pProgressbarLabel->GetHeight();
4199 int progressWidth = 0;
4200 Bitmap* pRetBitmap = null;
4202 if (__progressPercentage == 0 || __progressPercentage == 100)
4204 __pProgressbarLabel->SetShowState(false);
4205 __pProgressbarLabel->Invalidate(false);
4210 __pProgressbarLabel->SetShowState(true);
4211 __pProgressbarLabel->Invalidate(false);
4214 r = canvas.Construct(Rectangle(0, 0, w, h));
4218 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4223 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4227 pBgBmp->Scale(Dimension(w, h));
4228 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4232 progressWidth = (double) (w) * __progressPercentage / 100;
4233 AppLogDebug("progressWidth: %d", progressWidth);
4234 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4236 if (pProgressBmp != null)
4238 pProgressBmp->Scale(Dimension(progressWidth, h));
4239 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4240 delete pProgressBmp;
4243 pRetBitmap = new (std::nothrow) Bitmap();
4245 if (pRetBitmap == null)
4247 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4251 pRetBitmap->Construct(canvas, canvas.GetBounds());
4253 if (__pProgressbarLabel != null && pRetBitmap != null)
4255 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4256 __pProgressbarLabel->Invalidate(false);
4259 if (pRetBitmap != null)
4267 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4269 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4271 __currentAddMode = addMode;
4275 case ADDRESSBAR_MODE_INVALID:
4280 case ADDRESSBAR_MODE_READER:
4282 // __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
4283 // __pSearchLabel->SetShowState(false);
4284 // __pFaviconLabel->SetShowState(true);
4285 // __pCancelBtn->SetShowState(false);
4286 // __pRefreshBtn->SetShowState(false);
4287 __pStopBtn->SetShowState(false);
4288 // __pReaderBtn->SetShowState(true);
4289 // __pReaderBtn->Invalidate(true);
4290 // __pGoForwardBtn->SetShowState(true);
4291 // __pGoBackBtn->SetShowState(true);
4292 __pClearBtn->SetShowState(false);
4295 case ADDRESSBAR_MODE_LOADING:
4297 // __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
4298 // __pSearchLabel->SetShowState(false);
4299 // __pFaviconLabel->SetShowState(true);
4300 // __pCancelBtn->SetShowState(false);
4301 __pRefreshBtn->SetShowState(false);
4302 __pStopBtn->SetShowState(true);
4303 // __pReaderBtn->SetShowState(false);
4304 // __pGoForwardBtn->SetShowState(true);
4305 // __pGoBackBtn->SetShowState(true);
4306 __pClearBtn->SetShowState(false);
4309 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4311 // __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
4312 // __pCancelBtn->SetShowState(false);
4314 if (__pFooterUrlField && __pFooterUrlField->GetText().IsEmpty() == false)
4316 // __pSearchLabel->SetShowState(false);
4317 // __pFaviconLabel->SetShowState(true);
4321 // __pSearchLabel->SetShowState(true);
4322 // __pFaviconLabel->SetShowState(false);
4325 if (__pFooterUrlField != NULL)
4327 __pFooterUrlField->SetText(__displayUrl);
4328 __pFooterUrlField->HideKeypad();
4331 __pRefreshBtn->SetShowState(true);
4332 __pStopBtn->SetShowState(false);
4333 // __pReaderBtn->SetShowState(false);
4334 // __pGoForwardBtn->SetShowState(true);
4335 // __pGoBackBtn->SetShowState(true);
4336 __pClearBtn->SetShowState(false);
4339 case ADDRESSBAR_MODE_EDIT:
4341 __pRefreshBtn->SetShowState(false);
4342 __pStopBtn->SetShowState(false);
4343 __pClearBtn->SetShowState(true);
4350 OnAddressBarModeChanged();
4353 AddressBarMode MainForm::GetAddressbarMode(void)
4355 return __currentAddMode;
4358 void MainForm::SetUrl(const String& url)
4362 String updatedDisplayUrl;
4363 updatedDisplayUrl.Clear();
4365 if (__pFooterUrlField != NULL)
4367 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4368 if (removedHttpUrl.IsEmpty() == false)
4370 __pFooterUrlField->SetText(removedHttpUrl);
4374 __pFooterUrlField->SetText(__displayUrl);
4377 __pFooterUrlField->Invalidate(false);
4378 __pFooterUrlField->SetCursorPosition(0);
4384 MainForm::RemoveHttpTextFromDisplayURL(void)
4386 bool isHttpText = __displayUrl.Contains(L"http://");
4387 String updatedDisplayUrl;
4388 updatedDisplayUrl.Clear();
4390 if (isHttpText == true)
4392 __displayUrl.SubString(7,updatedDisplayUrl);
4394 return updatedDisplayUrl;