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;
280 __pItemContextLandscape= new(std::nothrow) ListContextItem();
281 __pItemContextLandscape->Construct();
282 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
283 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
285 if (pBitmapNormal != null && pBitmapPressed != null)
287 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
290 if (pBitmapNormal != null)
292 delete pBitmapNormal;
295 if (pBitmapPressed != null)
297 delete pBitmapPressed;
304 MainForm::InitAddressbar(void)
306 AppLogDebug("MainForm::InitAddressbar entered");
308 result r = E_SUCCESS;
310 if (__pAddressbar != null)
314 __pAddressbar = new(std::nothrow) Addressbar();
315 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
316 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
319 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
322 __pAddressbar->SetAddressbarEventListener(this);
323 AddControl(*__pAddressbar);
324 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
325 SetControlAlwaysOnTop(*__pAddressbar, true);
326 __adressPanelPosition = __pAddressbar->GetPosition();
328 AppLogDebug("MainForm::InitAddressbar exit");
334 MainForm::CreateReaderPanel(void)
336 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
337 result r = E_FAILURE;
339 Button *pSmallFontBtn = null;
340 Button *pLargeFontBtn = null;
342 __pBlankPanel = new (std::nothrow) Panel();
343 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
345 __pArticleReaderPanel = new (std::nothrow) Panel();
346 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
348 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
349 if (__pReaderCloseBtn)
351 AppLogDebug("CreateReaderPanel() 6");
352 __pReaderCloseBtn->AddActionEventListener(*this);
353 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
356 __pWebReader = new (std::nothrow) Web();
357 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
359 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
360 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
362 r = __pWebReader->SetSetting(settings);
364 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
367 __pArticleReaderLabel = new Label();
368 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
370 __pBlankPanel->AddControl(*__pArticleReaderLabel);
371 __pBlankPanel->AddControl(*__pArticleReaderPanel);
372 AddControl(*__pBlankPanel);
374 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
375 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
376 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
378 __pArticleReaderPanel->AddControl(*__pWebReader);
379 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
380 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
381 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
383 if (pBitmap != null && pSrcBitmap != null)
385 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
387 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
389 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
392 pSmallFontBtn->AddActionEventListener(*this);
393 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
396 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
399 pLargeFontBtn->AddActionEventListener(*this);
400 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
409 if (pSrcBitmap != null)
415 SetControlAlwaysOnTop(*__pBlankPanel, true);
416 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
423 MainForm::InitWebControl()
425 AppLogDebug("MainForm::InitWebControl enter");
426 result r = E_SUCCESS;
427 AppLogDebug("InitWebControl");
429 if (__pAddressbar == null || __pFooterPanel == null)
432 const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12;
433 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
434 if (__pMostVisitedListView)
436 __pMostVisitedListView->SetShowState(false);
438 if (__pWebViewer != null)
440 AppLogDebug("Already initialized");
443 __pWebViewer = new(std::nothrow) Web();
444 if(__pWebViewer == NULL)
446 AppLogDebug("Initialization failed");
449 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
453 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
458 r = AddControl(*__pWebViewer);
462 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
465 __webControlPosition = __pWebViewer->GetPosition();
466 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
469 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
473 __pWebViewer->SetLoadingListener(this);
474 __pWebViewer->SetWebUiEventListener(this);
475 __pWebViewer->SetWebKeypadEventListener(this);
476 __pWebViewer->SetFocus();
477 __pWebViewer->AddTouchEventListener(*this);
479 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
480 __pWebViewer->SetTextSearchListener(this);
483 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
484 AppLogDebug("MainForm :before return");
486 AppLogDebug("MainForm::InitWebControl Exit");
492 MainForm::SetJavascriptEnabled()
494 WebSetting settings = __pWebViewer->GetSetting();
495 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
496 __pWebViewer->SetSetting(settings);
500 MainForm::SetImageLoadEnabled()
502 WebSetting settings = __pWebViewer->GetSetting();
503 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
504 __pWebViewer->SetSetting(settings);
508 MainForm::InitFooter(void)
510 AppLogDebug("MainForm::InitFooter entered");
511 Button* pBackButton = null;
512 Button* pBookmarkButton = null;
513 Button* pMultiWindowButton = null;
514 Bitmap *pIconBitmap = null;
515 Bitmap *pBGBitmap = null;
516 Label *pBGLabel = null;
518 if (__pFooterPanel == null)
520 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
523 if (__pFooterPanel == null)
528 SetControlAlwaysOnTop(*__pFooterPanel, true);
530 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
531 if ( __pFooterLabel == NULL )
535 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
536 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
539 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
543 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
545 if ( __pMultiWindowButton == NULL )
550 /*pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true));
552 if ( pBackButton == NULL )
557 pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true));
559 if ( pBookmarkButton == NULL )
564 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
566 if ( __pMoreButton == NULL )
571 /*__pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true));
573 if ( __pNewWindowButton == NULL )
578 if (__pMultiWindowButton != null)
580 Bitmap* pBitmap = null;
581 Bitmap* pPressedBitmap = null;
582 String imagePath = "I01_toolbar_icon_windows_manager_0";
583 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
584 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
585 imagePath.Append(totalCount);
586 imagePath.Append(".png");
588 pressedImagePath.Append(totalCount);
589 pressedImagePath.Append("_press.png");
591 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
592 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
593 if ( pBitmap == null )
598 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
601 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
602 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
607 __pMultiWindowButton->AddActionEventListener(*this);
608 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
614 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK);
615 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK_PRESS);
618 // pBitmap->Scale(Dimension(56,56));
620 Point startPoint((pBackButton->GetWidth() - pBitmap->GetWidth())/2,(pBackButton->GetHeight() - pBitmap->GetHeight())/2 );
621 AppLog("startPoint %d,%d pBitmap width height %d %d",startPoint.x,startPoint.y,pBitmap->GetWidth(),pBitmap->GetHeight());
622 pBackButton->SetNormalBitmap(startPoint, *pBitmap);
623 pBackButton->SetPressedBitmap(startPoint, *pPressedBitmap);
626 pBackButton->AddActionEventListener(*this);
627 pBackButton->SetActionId(IDA_BACKBTN_CLICKED);
630 /*if (pBookmarkButton)
632 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK);
633 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK_PRESS);
636 Point startPoint((pBookmarkButton->GetWidth() - pBitmap->GetWidth())/2,(pBookmarkButton->GetHeight() - pBitmap->GetHeight())/2 );
637 pBookmarkButton->SetNormalBitmap(startPoint, *pBitmap);
638 pBookmarkButton->SetPressedBitmap(startPoint, *pPressedBitmap);
641 pBookmarkButton->AddActionEventListener(*this);
642 pBookmarkButton->SetActionId(IDA_BOOKMARKBTN_CLICKED);
647 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
648 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
651 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
652 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
653 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
657 __pMoreButton->AddActionEventListener(*this);
658 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
661 //Add the editfield for url
662 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
663 if (__pFooterUrlField == NULL)
665 AppLogDebug("__pFooterUrlField Control not found returning E_INVALID_KEY");
666 return E_INVALID_KEY;
669 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
670 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
671 //__pFooterUrlField->AddFocusEventListener(*this);
672 __pFooterUrlField->AddKeypadEventListener(*this);
674 /*if (__pNewWindowButton)
676 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW);
677 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS);
680 Point startPoint((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
681 __pNewWindowButton->SetNormalBitmap(startPoint, *pBitmap);
682 __pNewWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
685 __pNewWindowButton->AddActionEventListener(*this);
686 __pNewWindowButton->SetActionId(IDA_NEWWINDOWBTN_CLICKED);
687 __pNewWindowButton->SetEnabled(true);
688 // __pNewWindowButton->Invalidate(true);
691 AppLog("checkingwindow count %d",MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount());
693 /*if (__pNewWindowButton != null && MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
695 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTROLBAR_ICON_CREATE_DISABLE);
698 Point startPoint = Point((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
699 __pNewWindowButton->SetDisabledBitmap(startPoint,*pBitmap);
702 __pNewWindowButton->SetEnabled(false);
705 //Add the go Back Button
706 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
707 if (__pGoBackBtn == NULL)
709 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
710 return E_INVALID_KEY;
712 __pGoBackBtn->SetActionId(IDA_GO_BACK);
713 __pGoBackBtn->AddActionEventListener(*this);
715 //Add the go forward Button
716 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
717 if (__pGoForwardBtn == NULL)
719 AppLogDebug("Control not found returning E_INVALID_KEY");
720 return E_INVALID_KEY;
722 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
723 __pGoForwardBtn->AddActionEventListener(*this);
724 __pGoForwardBtn->SetEnabled(false);
726 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
727 if (__pRefreshBtn == NULL)
729 AppLogDebug("Control not found returning E_INVALID_KEY");
730 return E_INVALID_KEY;
733 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
734 __pRefreshBtn->AddActionEventListener(*this);
735 __pRefreshBtn->SetShowState(true);
737 //Add the backround label for displaying progressbar
738 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
739 if (__pProgressbarLabel == NULL)
741 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
742 return E_INVALID_KEY;
744 __pProgressbarLabel->SetShowState(false);
746 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
747 if (__pStopBtn == NULL)
749 AppLogDebug("Control not found returning E_INVALID_KEY");
750 return E_INVALID_KEY;
752 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
753 __pStopBtn->AddActionEventListener(*this);
754 __pStopBtn->SetShowState(false);
756 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
757 if (__pClearBtn == NULL)
759 AppLogDebug("Control not found returning E_INVALID_KEY");
760 return E_INVALID_KEY;
762 __pClearBtn->SetActionId(IDA_CLEAR_URL);
763 __pClearBtn->AddActionEventListener(*this);
764 __pClearBtn->SetShowState(false);
766 // __pFooterPanel->Invalidate(true);
767 AppLogDebug("MainForm::InitFooter exit");
773 MainForm::InitContextMenu(Point& p)
775 result r = E_SUCCESS;
776 bool isPrivateBrowsing = false;
777 Bitmap* pBitmap = null;
781 __pMenu->SetAnchorPosition(p);
782 __pMenu->Invalidate(true);
786 __pMenu = new(std::nothrow) ContextMenu();
787 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
788 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
790 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
793 if (isPrivateBrowsing == true)
795 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
799 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
802 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
804 if ( pBitmap != NULL)
806 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
809 r = __pMenu->AddItem(L"History"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_HISTORY_CLICKED);
810 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
811 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
814 __pMenu->SetMaxVisibleItemsCount(6);
815 __pMenu->SetShowState(false);
816 __pMenu->AddActionEventListener(*this);
817 SetControlAlwaysOnTop(*__pMenu, true);
823 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
825 result r = E_SUCCESS;
826 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
828 AppLog("MainForm::InitImageContextMenu clicked on image");
829 if (__pImageMenu != null)
835 p.y = p.y + __pAddressbar->GetHeight() + 12;
838 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
842 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
844 __pImageMenu = new (std::nothrow) ContextMenu();
845 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
846 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
848 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
849 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
850 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
851 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
852 __pImageMenu->SetMaxVisibleItemsCount(4);
853 __pImageMenu->AddActionEventListener(*this);
854 SetControlAlwaysOnTop(*__pImageMenu, true);
859 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
861 result r = E_SUCCESS;
862 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
864 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
865 if (__pImageMenu != null)
870 p.y = p.y + __pAddressbar->GetHeight() + 12;
873 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
877 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
879 __pImageMenu = new (std::nothrow) ContextMenu();
880 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
881 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
883 if(onlyPasteOption == false)
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
887 if (pasteOption || onlyPasteOption)
889 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
891 if(onlyPasteOption == false)
893 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
894 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
897 __pImageMenu->SetMaxVisibleItemsCount(3);
898 __pImageMenu->AddActionEventListener(*this);
899 SetControlAlwaysOnTop(*__pImageMenu, true);
906 MainForm::InitFindWordPanel(void)
908 result r = E_SUCCESS;
909 Bitmap *pIconBitmap = null;
911 if (__pFindWordPanel != null)
913 AppLogDebug("Findword panel already initialized");
914 if (__pFindWordBgLabel != null)
916 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
919 AppLogDebug("InitFindWordPanel: Coming here");
920 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
927 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
928 if (__pFindWordPanel == null)
930 AppLogException("There is some problem in the xml file. Please check.");
934 __pFindWordControl = new (std::nothrow) Panel();
935 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
938 AppLogException("There is some problem in the xml file. Please check.");
941 __pFindWordPanel->AddControl(*__pFindWordControl);
942 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
943 SetControlAlwaysOnTop(*__pFindWordPanel,true);
944 __pFindWordPanel->SetShowState(false);
945 __pFindWordPanel->Invalidate(false);
947 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
948 if (__pFindWordBgLabel != null)
950 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
951 Rectangle pRect = pPanel1->GetBounds();
952 pRect.x = pRect.y = 0;
953 __pFindWordBgLabel->SetBounds(pRect);
954 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
957 AppLogDebug("InitFindWordPanel: Coming here");
958 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
963 AppLogDebug("InitFindWordPanel: shouldn't Come here");
967 Button* pfindWordCancel = null;
968 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
969 if (pfindWordCancel == null)
971 AppLogException("There is some problem in the xml file. Please check.");
974 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
975 pfindWordCancel->AddActionEventListener(*this);
977 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
978 if (__pFindWordClear == null)
980 AppLogException("There is some problem in the xml file. Please check.");
984 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
985 __pFindWordClear->AddActionEventListener(*this);
987 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
988 if (__pFindWordNext == null)
990 AppLogException("There is some problem in the xml file. Please check.");
994 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
995 __pFindWordNext->AddActionEventListener(*this);
997 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
998 if (__pFindWordPrev == null)
1000 AppLogException("There is some problem in the xml file. Please check.");
1004 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1005 __pFindWordPrev->AddActionEventListener(*this);
1007 __pFindWordNext->SetEnabled(false);
1008 __pFindWordPrev->SetEnabled(false);
1010 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1011 if (__pFindWordCountLabel == null)
1013 AppLogException("There is some problem in the xml file. Please check.");
1017 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1018 if (__pFindWordEditField == null)
1020 AppLogException("There is some problem in the xml file. Please check.");
1023 __pFindWordEditField->AddTextEventListener(*this);
1024 __pFindWordEditField->AddKeypadEventListener(*this);
1025 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1031 MainForm::CreateItem (int index, int itemWidth)
1033 Rectangle listImageRect;
1034 Rectangle pagetTitleRect;
1035 Rectangle pageURLRect;
1036 Rectangle deleteImageRect;
1037 String pageTitle(L"");
1038 String pageURL(L"");
1039 result r = E_SUCCESS;
1040 Bitmap* pListIconImage = null;
1043 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1044 if(pHistory == null)
1048 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1049 if ( pAppResource == NULL )
1053 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1055 CustomItem* pItem = new(std::nothrow) CustomItem();
1056 pageTitle = pHistory->GetHistoryTitle();
1057 pageURL = pHistory->GetHistoryUrl();
1059 if (pageURL.GetLength() == 0)
1062 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1063 pageURL = L"<"+ nourl +">";
1067 Rectangle screenBounds = GetBounds();
1070 r = pItem->Construct(Dimension(itemWidth, 128), style);
1079 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1081 if ( pBitmap != NULL)
1083 pListIconImage = new Bitmap();
1084 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1088 if(pListIconImage == null)
1090 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1093 if ( pListIconImage != NULL)
1095 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1096 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1097 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1100 if (pItem != null && pListIconImage != NULL)
1102 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1106 if (pageTitle.CompareTo(L"") != 0)
1110 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1114 if (pageURL.CompareTo(L"") != 0)
1118 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1123 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1125 if ( __pItemContext!= NULL)
1129 pItem->SetContextItem(__pItemContext);
1135 if ( __pItemContextLandscape!= NULL)
1139 pItem->SetContextItem(__pItemContextLandscape);
1143 if( pListIconImage != NULL)
1145 delete pListIconImage;
1146 pListIconImage = null;
1153 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1160 MainForm::GetItemCount (void)
1162 if(__pMostVisitedSites != null)
1164 __pMostVisitedSites->RemoveAll(true);
1166 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1167 if(__pMostVisitedSites != null)
1169 return __pMostVisitedSites->GetCount();
1176 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1178 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1179 String url = pHistory->GetHistoryUrl();
1180 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1181 __pMostVisitedListView->UpdateList();
1185 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1187 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1188 String url = pHistory->GetHistoryUrl();
1196 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1202 MainForm::OnTerminating(void)
1204 result r = E_SUCCESS;
1207 delete __pItemContext;
1209 if(__pItemContextLandscape)
1211 delete __pItemContextLandscape;
1217 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1219 result r = E_SUCCESS;
1221 AppLogDebug("Clicked : %d", actionId);
1224 case IDA_BACKBTN_CLICKED:
1226 if (__pWebViewer && __pWebViewer->CanGoBack())
1228 __pWebViewer->GoBack();
1233 pApp = UiApp::GetInstance();
1236 r = pApp->Terminate();
1239 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1247 case IDA_FORWARD_CLICKED:
1248 if (__pWebViewer == null)
1251 if (__pWebViewer->CanGoForward())
1253 __pWebViewer->GoForward();
1255 __pMenu->SetShowState(false);
1256 __pMenu->Invalidate(false);
1259 case IDA_FINDONPAGE_CLICKED:
1261 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1262 __currentSearchStr.Clear();
1264 InitFindWordPanel();
1265 __pMenu->SetShowState(false);
1266 __pMenu->Invalidate(false);
1268 /*__adressPanelPosition.y = 0 ;
1270 if (__pAddressbar != null && __pWebViewer != NULL)
1272 __webControlPosition.y = __pAddressbar->GetHeight();
1273 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1274 //__pAddressbar->Invalidate(true);
1275 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1276 __pWebViewer->Invalidate(true);
1278 if (__pWebViewer != null)
1280 // releasing the set block
1281 __pWebViewer->ReleaseBlock();
1283 ShowFindWordPanel(true);
1286 case IDA_PRIVATEON_CLICKED:
1288 result r = E_SUCCESS;
1290 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1291 Bitmap* pBitmap = null;
1292 if (isPrivateBrowsing == true)
1294 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1297 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1301 if (__pWebViewer != NULL)
1303 __pWebViewer->SetPrivateBrowsingEnabled(false);
1306 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1308 if (__pAddressbar != null)
1310 __pAddressbar->UpdateFaviconBitmap(false);
1316 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1319 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1323 if (__pWebViewer != NULL)
1325 __pWebViewer->SetPrivateBrowsingEnabled(true);
1328 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1330 if (__pAddressbar != null)
1332 __pAddressbar->UpdateFaviconBitmap(true);
1337 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1338 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1339 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1340 __pMenu->Invalidate(true);
1342 if ( pBitmap != NULL )
1349 case IDA_SETTINGS_CLICKED:
1352 ArrayList* pArgList = new(std::nothrow) ArrayList();
1355 pArgList->Construct();
1356 pArgList->Add(*__pWindowInfo);
1357 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1359 __pMenu->SetShowState(false);
1360 __pMenu->Invalidate(false);
1361 if (pArgList != null)
1370 case IDA_ADDTOBOOKMARK_CLICKED:
1373 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1375 int bookmarkCount=0;
1378 url=__pWindowInfo->pageUrl;
1379 result r = E_SUCCESS;
1380 Bitmap* pBitmap = null;
1381 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1389 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1390 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1391 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1393 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1394 if (pNotification != null)
1396 pNotification->SetText(message);
1397 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1398 pNotification->ShowNotification();
1403 String title=__pWindowInfo->pageTitle;
1404 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1405 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1407 pBookmark->SetBookmarkTitle(title);
1408 pBookmark->SetUrl(url);
1409 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1411 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1413 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1414 pBookmark->SetFaviconId(id);
1415 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1416 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1419 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1420 if (pNotification != null)
1422 pNotification->SetText(message);
1423 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1424 pNotification->ShowNotification();
1425 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1428 if (pBitmap != null)
1430 r = __pMenu->SetItemAt(0,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1434 __pMenu->Invalidate(true);
1438 case IDA_SHARE_CLICKED:
1440 if(__pPopUp != null)
1445 __pPopUp = new(std::nothrow) SharePopup();
1446 __pPopUp->Initialize();
1447 if (__pWindowInfo != null)
1449 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1450 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1451 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1452 pShareInfo->SetImageAttached(false);
1453 __pPopUp->RemoveAllShareInfo();
1454 __pPopUp->AddShareInfo(pShareInfo);
1456 __pPopUp->SetShowState(true);
1460 case IDA_BOOKMARKBTN_CLICKED:
1462 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1463 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1466 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1471 case IDA_MOREBTN_CLICKED:
1473 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1474 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1475 AppLog("Anchot pos: %d %d", p.x, p.y);
1477 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1479 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1480 int bookmarkCount=0;
1483 url=__pWindowInfo->pageUrl;
1484 result r = E_SUCCESS;
1485 Bitmap* pBitmap = null;
1487 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1490 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1495 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1499 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1501 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1503 if (__pMenu->GetItemCount() == 12)
1505 r = __pMenu->SetItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1509 r = __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK")*/, IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1514 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1518 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1519 if (__pMenu->GetItemCount() != 12)
1521 __pMenu->InsertItemAt(1,L"Add to Bookmarks"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADDTOBOOKMARK_CLICKED);
1523 __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1524 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1525 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1526 __pMenu->SetMaxVisibleItemsCount(6);
1528 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1530 AppLog(" Orientation landscape");
1531 __pMenu->SetMaxVisibleItemsCount(5);
1535 AppLog(" Orientation potrait");
1536 __pMenu->SetMaxVisibleItemsCount(6);
1539 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1542 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1543 __pMenu->SetShowState(true);
1544 __pMenu->Invalidate(true);
1548 case IDA_HISTORY_CLICKED:
1550 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1551 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1554 case IDA_SAVED_PAGES_CLICKED:
1559 case IDA_DESKTOP_VIEW_CLICKED:
1564 case IDA_SAVE_CLICKED:
1569 case IDA_MULTIWINDOWBTN_CLICKED:
1571 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1572 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1576 case IDA_NEWWINDOWBTN_CLICKED:
1578 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1580 if (pNewWindowInfo == null)
1584 result r = E_SUCCESS;
1585 SceneManager* pSceneManager = SceneManager::GetInstance();
1587 if (pSceneManager == NULL)
1591 ArrayList* pArgList = new(std::nothrow) ArrayList();
1592 if (pArgList == NULL)
1596 r = pArgList->Construct();
1599 pArgList->Add(*pNewWindowInfo);
1600 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1606 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1611 case IDA_SMALLFONT_BTN_CLICKED:
1613 WebSetting setting = __pWebReader->GetSetting();
1614 setting.SetFontSize(15);
1615 __pWebReader->SetSetting(setting);
1618 case IDA_LARGEFONT_BTN_CLICKED:
1620 WebSetting setting = __pWebReader->GetSetting();
1621 setting.SetFontSize(25);
1622 __pWebReader->SetSetting(setting);
1625 case IDA_READER_CLOSE_CLICKED:
1627 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1629 //__pArticleReaderPanel->SetShowState(false);
1630 //__pArticleReaderPanel->Show();
1631 RemoveControl(*__pBlankPanel);
1632 //RemoveControl(*__pArticleReaderPanel);
1633 __pArticleReaderPanel = null;
1634 __pBlankPanel = null;
1635 __pArticleReaderLabel = null;
1637 //if (__pAddressbar)
1638 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1639 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1642 case IDA_FINDWORD_CANCEL_CLICKED:
1644 __currentSearchStr = L"";
1645 __currentWordIndex = 0;
1646 __maxOccurrances = 0;
1647 __pFindWordEditField->SetText(L"");
1648 __pFindWordNext->SetEnabled(false);
1649 __pFindWordPrev->SetEnabled(false);
1650 __pFindWordCountLabel->SetText(L"0/0");
1651 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1652 ShowFindWordPanel(false);
1655 case IDA_FINDWORD_SEARCH_CLICKED:
1657 __currentSearchStr = __pFindWordEditField->GetText();
1658 if (__currentSearchStr.GetLength() > 0)
1664 AppLogDebug("Enter something");
1668 case IDA_FINDWORD_CLEAR_CLICKED:
1670 __pFindWordCountLabel->SetText(L"0/0");
1671 __pFindWordEditField->SetText(L"");
1672 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1674 __pFindWordNext->SetEnabled(false);
1675 __pFindWordPrev->SetEnabled(false);
1676 __pFindWordPanel->Invalidate(true);
1679 case IDA_FINDWORD_NEXT_CLICKED:
1684 case IDA_FINDWORD_PREV_CLICKED:
1686 FindNextWord(false);
1689 case IDA_BRIGHTNESS_BTN_CLICKED:
1691 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1692 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1695 case IDA_COPY_IMAGE_CLICKED:
1697 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1698 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1700 const Bitmap* pBitmap = null;
1701 if (__pHitElementResult != null)
1703 pBitmap = __pHitElementResult->GetImage();
1706 String resourcePath = App::GetInstance()->GetAppResourcePath();
1707 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1709 // copying the item to clipboard
1710 Clipboard* pClipboard = Clipboard::GetInstance();
1711 if (pClipboard != null)
1713 pClipboard->CopyItem(item);
1717 case IDA_VIEW_IMAGE_CLICKED:
1719 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1720 WindowInfo* pNewWindowInfo = null;
1721 if (__pHitElementResult != null)
1723 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1724 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1730 case IDA_SAVE_IMAGE_CLICKED:
1732 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1733 const Bitmap* pSaveBitmap = null;
1734 String imageName = GetImagePath();
1735 AppLog("Content manager image name %ls",imageName.GetPointer());
1738 imagePath.Append(imageName);
1739 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1740 AppLog("Content manager image path %ls",imagePath.GetPointer());
1741 if (__pHitElementResult != null)
1743 pSaveBitmap = __pHitElementResult->GetImage();
1745 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1749 UpdateImageContent(pBuffer, imageName);
1751 NotificationPanel *pNotification = new NotificationPanel(*this);
1753 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1754 msg.Append(imagePath);
1755 if (pNotification != null)
1757 pNotification->SetText(msg);
1758 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1759 pNotification->ShowNotification();
1764 int __modalMsgBoxResult;
1765 MessageBox* pMsgBox = new MessageBox();
1766 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1767 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1770 __modalMsgBoxResult = 0;
1774 case IDA_SHARE_IMAGE_CLICKED:
1776 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1777 if (__pPopUp != null)
1782 __pPopUp = new(std::nothrow) SharePopup();
1783 __pPopUp->Initialize();
1784 if (__pHitElementResult != null)
1786 const Bitmap* pSaveBitmap = null;
1787 String imageName = GetImagePath();
1788 AppLog("Content manager image name %ls",imageName.GetPointer());
1791 imagePath.Append(imageName);
1792 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1793 AppLog("Content manager image path %ls",imagePath.GetPointer());
1794 if (__pHitElementResult != null)
1796 pSaveBitmap = __pHitElementResult->GetImage();
1798 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1800 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1801 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1803 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1804 pShareInfo->SetPageTitle(L"");
1805 pShareInfo->SetPageUrl(srcUrl);
1806 pShareInfo->SetImageAttached(true);
1807 pShareInfo->SetImagePath(imagePath);
1808 __pPopUp->RemoveAllShareInfo();
1809 __pPopUp->AddShareInfo(pShareInfo);
1810 __pPopUp->SetShowState(true);
1815 case IDA_FIND_TEXT__CLICKED:
1817 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1818 __currentSearchStr.Clear();
1819 __currentSearchStr.Append(__currentSelectedStr);
1820 InitFindWordPanel();
1823 __pMenu->SetShowState(false);
1824 __pMenu->Invalidate(false);
1827 __adressPanelPosition.y = 0;
1829 if (__pAddressbar != null && __pWebViewer != NULL)
1831 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1832 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1833 __pAddressbar->Invalidate(true);
1834 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
1836 if(__pFooterPanel->GetShowState() == false)
1837 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
1839 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
1840 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1841 __pWebViewer->Invalidate(true);
1844 ShowFindWordPanel(true);
1845 if (__currentSearchStr.GetLength() > 0)
1851 AppLogDebug("Enter something");
1854 if (__pWebViewer != null)
1856 // releasing the set block
1857 __pWebViewer->ReleaseBlock();
1862 case IDA_SHARE_TEXT_CLICKED:
1864 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1865 if(__pPopUp != null)
1870 __pPopUp = new(std::nothrow) SharePopup();
1871 __pPopUp->Initialize();
1872 if (__pHitElementResult != null)
1874 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1875 pShareInfo->SetPageTitle(L"");
1876 pShareInfo->SetPageUrl(__currentSelectedStr);
1877 pShareInfo->SetImageAttached(false);
1878 __pPopUp->RemoveAllShareInfo();
1879 __pPopUp->AddShareInfo(pShareInfo);
1880 __pPopUp->SetShowState(true);
1885 case IDA_COPY_TEXT_CLICKED:
1887 // need to implement
1888 //__currentSelectedStr
1889 // Sets data to a clip board item
1891 String resourcePath = App::GetInstance()->GetAppResourcePath();
1892 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1894 // copying the item to clipboard
1895 Clipboard* pClipboard = Clipboard::GetInstance();
1896 if (pClipboard != null)
1898 pClipboard->CopyItem(item);
1902 case IDA_PASTE_TEXT_CLICKED:
1904 Clipboard* pClipboard = Clipboard::GetInstance();
1906 if(pClipboard == null)
1910 // Retrieves a latest item
1911 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1917 //Gets data from the clipboard item
1918 String* pString = dynamic_cast<String*>(pItem->GetData());
1920 if (pString != null)
1922 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1923 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
1924 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1925 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; } } ";
1926 if(idElement.GetLength() != 0)
1928 script.Append("insertAtCursor(");
1929 script.Append(idElement);
1931 script.Append("\"");
1932 script.Append(*pString);
1933 script.Append("\");");
1935 else if (nameElement.GetLength() != 0)
1937 script.Append("insertAtCursor(document.getElementsByName('");
1938 script.Append(nameElement);
1939 script.Append("')[0],");
1940 script.Append("\"");
1941 script.Append(*pString);
1942 script.Append("\");");
1944 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1945 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1956 case IDA_GO_FORWARD:
1961 case IDA_REFRESH_BTN_CLICKED:
1963 __isLoadingCompleted = false;
1964 __isLoadingData = true;
1965 __progressPercentage = 0;
1966 __displayUrl = __pFooterUrlField->GetText();
1968 String url = __pFooterUrlField->GetText();
1969 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
1973 UpdateProgressBitmap();
1976 case IDA_STOP_BTN_CLICKED:
1978 __isLoadingCompleted = false;
1979 __isLoadingData = false;
1980 __progressPercentage = 0;
1981 __pFooterUrlField->HideKeypad();
1982 __displayUrl = __pFooterUrlField->GetText();
1986 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1987 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1988 __pWebViewer->StopLoading();
1989 RequestRedraw(true);
1992 UpdateProgressBitmap();
1997 if (__pFooterUrlField->GetText().IsEmpty() == false)
1999 //__displayUrl = __pUrlField->GetText();
2000 __pFooterUrlField->Clear();
2010 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2013 UiApp* pApp = UiApp::GetInstance();
2022 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2023 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2025 String* pSelectedScene = NULL;
2026 Object* pValue = NULL;
2027 String* pUrl = null;
2028 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2029 pSelectedScene = (String*) pValue;
2031 if (pSelectedScene != null)
2033 delete pSelectedScene;
2035 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2036 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2037 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2038 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2040 // setting the current scene ID
2041 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2043 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2045 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2047 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2048 if(__pWindowInfo == null)
2050 // if(__pWindowInfo == null)
2052 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2055 else if ( pArgs != null && pArgs->GetCount() == 1)
2057 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2063 // hiding the address bar
2064 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2065 __pAddressbar->SetShowState(false);
2066 if(__pWebViewer != null)
2068 __pWebViewer->Resume();
2071 if(pUrl != null && pUrl->GetLength() > 0)
2075 else if(__pWindowInfo != null)
2077 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)
2079 LoadUrl(__pWindowInfo->pageUrl);
2081 else if (__pWindowInfo->isJavascriptInitiated == true)
2085 __pWindowInfo->pCurrentWeb = __pWebViewer;
2089 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2090 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2091 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2093 InitMostVisitedSitesView(GetOrientationStatus());
2096 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2098 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2100 if (pBookmarkUrl == null)
2102 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2103 //__pAddressbar->SetUrl(*pBookmarkUrl);
2104 SetUrl(*pBookmarkUrl);
2106 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2107 __pWebViewer->LoadUrl(*pBookmarkUrl);
2108 delete pBookmarkUrl;
2111 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2112 Bitmap* pBitmap = null;
2113 if (isPrivateBrowsing == true)
2115 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2117 if (__pWebViewer != null)
2119 __pWebViewer->SetPrivateBrowsingEnabled(true);
2122 if (__pAddressbar != null)
2124 // __pAddressbar->UpdateFaviconBitmap(true);
2130 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2132 if (__pWebViewer != null)
2134 __pWebViewer->SetPrivateBrowsingEnabled(false);
2137 if (__pAddressbar != null)
2139 // __pAddressbar->UpdateFaviconBitmap(false);
2143 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2145 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2147 else if (__pMenu != null )
2149 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2152 if (pBitmap != null)
2157 AppLog("ABC: OnSceneActivatedN started exit");
2162 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2163 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2165 Canvas* pWebCanvas = null;
2166 if (__pWebViewer != null)
2168 pWebCanvas = __pWebViewer->GetCanvasN();
2169 __pWebViewer->Pause();
2172 if (pWebCanvas == null)
2176 if (__pWindowInfo != null)
2178 if (__pWindowInfo->pWebCanvasBitmap != null)
2180 delete __pWindowInfo->pWebCanvasBitmap;
2182 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2183 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2184 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2186 Bitmap* pBitmap = GetCapturedBitmapN();
2187 AppLog("Coming here");
2188 Canvas* pCanvas = new(std::nothrow) Canvas();
2189 pCanvas->Construct(GetClientAreaBounds());
2192 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2195 if(__pWebViewer != null && __pWindowInfo != null)
2196 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2198 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2199 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2201 AppLog("Coming here");
2205 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2206 const Tizen::Base::String& realm,
2207 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2213 MainForm::OnHttpAuthenticationCanceled(void)
2218 MainForm::OnLoadingStarted(void)
2220 AppLogDebug("MainForm::OnLoadingStarted entered");
2222 if(__pAddressbar == NULL)
2226 String url = __pWebViewer->GetUrl();
2227 if(url.Contains(IDS_TIZEN_SERVICE))
2230 String delim(L":;");
2232 // Creates a StringTokenizer instance
2233 StringTokenizer strTok(url, delim);
2235 int count = strTok.GetTokenCount(); // count == 4
2237 HashMap *pMap = new HashMap();
2242 while (strTok.HasMoreTokens())
2244 AppLog("Token: %ls", token.GetPointer());
2245 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2246 if(token.Contains(IDS_APPID))
2248 token.SubString(6, appId);
2249 AppLog("AppID:%ls", appId.GetPointer());
2251 else if(token.Contains("="))
2253 String *pKey = new String();
2254 String *pValue = new String();
2256 token.IndexOf("=", 0, index);
2259 token.SubString(0, index, *pKey);
2260 token.SubString(index + 1, *pValue);
2261 pMap->Add(pKey, pValue);
2267 AppControl *pAppControl = null;
2268 String operationId = L"http://tizen.org/appcontrol/operation/main";
2269 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2272 AppLog("Starting AppControl");
2273 result r = pAppControl->Start(null, null, pMap, null);
2274 AppLog("Result of Start %s", GetErrorMessage(r));
2278 AppLogException("AppControl not found");
2283 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2284 __pAddressbar->SetFaviconBitmap(*pBitmap);
2286 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2288 // updating the address bar position with respect to web control
2289 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2290 __distanceMoved = 0;
2294 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2295 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2298 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2299 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2300 SetUrl(__pWebViewer->GetUrl());
2301 if (__pWindowInfo != NULL)
2303 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2305 __pAddressbar->Invalidate(true);
2311 MainForm::OnLoadingCanceled(void)
2318 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2320 AppLog("MainForm::OnKeypadWillOpen");
2321 if (__pAddressbar != null)
2323 OnAddressBarKeypadOpened(*__pAddressbar);
2326 //__pAddressbar->SetAddressbarURLFocus();
2331 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2333 if(__pAddressbar != null)
2335 OnAddressBarKeypadClosed(*__pAddressbar, false);
2341 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2343 if (__pAddressbar != null)
2345 OnAddressBarKeypadClosed(*__pAddressbar);
2350 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2351 const Tizen::Base::String& reason)
2353 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2357 MainForm::OnLoadingCompleted(void)
2359 AppLog("MainForm::OnLoadingCompleted start");
2361 result r = E_SUCCESS;
2363 if (__pWebViewer == null)
2368 if (__pAddressbar == null)
2372 if (__pWebViewer->CanGoForward())
2374 //__pAddressbar->SetForwardButtonEnabled(true);
2375 SetForwardButtonEnabled(true);
2379 //__pAddressbar->SetForwardButtonEnabled(false);
2380 SetForwardButtonEnabled(false);
2383 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2385 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2387 //__pAddressbar->UpdateProgress(0);
2391 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2393 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2397 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2398 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2399 if (isPrivateBrowsing == false)
2401 History* pHistory = new(std::nothrow) History;
2403 HistoryPresentationModel::GetCurrentDateTime(date);
2406 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2407 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2409 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2410 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2412 pHistory->SetVisitedTime(date);
2415 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2416 pHistory->SetFaviconId(id);*/
2418 if (__pWebViewer != null)
2420 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2422 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2423 if (pTempBitmap != null)
2425 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2426 pHistory->SetFavIconBitmap(*pTempBitmap);
2429 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2432 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2433 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2434 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2436 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2437 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2438 pHistory->SetThumbnail(pBitmap);
2440 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2443 pHistory->SetFavIconBitmap(*pFavIcon);
2447 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2454 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2456 // temperary fixed (webpage can be not loaded)
2459 AppLog("MainForm::OnLoadingCompleted done");
2463 MainForm::OnEstimatedProgress(int progress)
2465 AppLogDebug("MainForm::OnEstimatedProgress entered");
2466 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2467 progress = DEFAULT_PROGRESS_PERCENTAGE;
2469 // __pAddressbar->UpdateProgress(progress);
2470 UpdateProgress(progress);
2473 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2475 AppLog("MainForm::OnFaviconReceived");
2476 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2478 if (pFavIconBitmap != null)
2480 pFavIconBitmap->GetWidth();
2481 pFavIconBitmap->GetHeight();
2482 AppLog("MainForm::OnFaviconReceived width = %d",pFavIconBitmap->GetWidth());
2483 AppLog("MainForm::OnFaviconReceived height = %d",pFavIconBitmap->GetHeight());
2488 MainForm::OnUrlSubmitted(Addressbar& addBar)
2490 AppLog("MainForm::OnUrlSubmitted");
2491 String url = addBar.GetUrl();
2492 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2495 __pFooterPanel->SetShowState(true);
2496 __pFooterPanel->Invalidate(true);
2497 RequestRedraw(true);
2501 MainForm::LoadUrl(String& url)
2504 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2505 AppLogDebug("MainForm::LoadUrl enter");
2507 if (__pWebViewer != null)
2509 __pWebViewer->SetShowState(true);
2510 __pWebViewer->Invalidate(true);
2513 if (encodedUrl.CompareTo(L"") == 0)
2517 if(__pFooterPanel != null)
2519 __pFooterPanel->SetShowState(true);
2520 __pFooterPanel->Invalidate(true);
2527 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2528 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)
2530 RegularExpression firstRegex;
2531 RegularExpression secondRegex;
2533 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2534 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2537 ret = firstRegex.Match(encodedUrl, false); // This returns true value
2538 flag = secondRegex.Match(encodedUrl, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2540 if (ret == true && __pWebViewer != null)
2542 __pWebViewer->LoadUrl(encodedUrl);
2544 else if(__pWebViewer != null)
2546 String tempUrl = L"http://";
2547 tempUrl.Append(encodedUrl);
2551 __pWebViewer->LoadUrl(tempUrl);
2555 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2558 if (__pAddressbar != null)
2560 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2561 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2564 AppLogDebug("MainForm::LoadUrl exit");
2571 MainForm::OnStopClicked(Addressbar& addBar)
2573 AppLogDebug("MainForm::OnStopClicked called");
2576 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2577 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2578 __pWebViewer->StopLoading();
2579 RequestRedraw(true);
2584 MainForm::OnReaderClicked(const Addressbar& addBar)
2586 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2588 CreateReaderPanel();
2589 AppLogDebug("MainScene::OnReaderClicked entered");
2592 /*if (__pArticleReaderPanel)
2594 AppLogDebug("showstate true for reader panel");
2595 __pArticleReaderPanel->SetShowState(true);
2596 __pArticleReaderPanel->Show();
2598 int xPos = __pArticleReaderPanel->GetX();
2599 int yPos = __pArticleReaderPanel->GetY();
2600 AppLog("OnReaderClicked() xPos = %d",xPos);
2601 AppLog("OnReaderClicked() yPos = %d",yPos);
2603 if (__pReaderData == null)
2608 String loadData = L"<html>\
2610 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2615 background-color: transparent;\
2634 <body style='width:'";
2635 loadData.Append(bodyWidth);
2636 loadData.Append(L"px'>");
2637 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2638 loadData.Append(*__pReaderData);
2639 loadData.Append(L"</body></html>");
2642 buf.Construct(loadData.GetLength());
2643 AppLogDebug("data->GetLength %d",loadData.GetLength());
2644 for (int z=0;z<loadData.GetLength();z++)
2647 loadData.GetCharAt(z,b);
2648 buf.SetByte((byte)b);
2652 if (__pWebReader != null)
2654 __pWebReader->LoadData(L"",buf,L"text/html");
2655 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2659 AppLogDebug("cannot LoadData __pWebReader is null");
2665 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2667 AppLog("MainForm::OnBackClicked");
2668 result r = E_FAILURE;
2670 if (__pWebViewer != null && __pWebViewer->CanGoBack())
2672 __pWebViewer->GoBack();
2677 pApp = UiApp::GetInstance();
2680 r = pApp->Terminate();
2690 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
2692 AppLog("MainForm::OnForwardClicked");
2693 if (__pWebViewer == null)
2696 if (__pWebViewer->CanGoForward())
2698 __pWebViewer->GoForward();
2703 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2705 result r = E_SUCCESS;
2706 // hiding the address bar
2707 __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2708 __pAddressbar->SetShowState(false);
2710 if (__pMostVisitedListView != null && __pMostVisitedListView->GetShowState() == true)
2712 AppLog("MainForm::OnAddressCancelledClicked 1");
2713 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2714 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()/*GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14*/));
2716 if (__pMostVisitedListView != null)
2717 __pMostVisitedListView->Invalidate(true);
2719 /*else if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
2721 if (__pWebViewer != null && __pAddressbar != null && __pFooterPanel != null)
2723 AppLog("MainForm::OnAddressCancelledClicked 2");
2724 r = __pWebViewer->SetBounds(Rectangle(0,0__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __webControlHeightGetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2727 AppLog("MainForm::OnAddressCancelledClicked success");
2731 AppLog("MainForm::OnAddressCancelledClicked failure");
2735 int yOfWebViewer = __pWebViewer->GetY();
2736 int heightOfWebViewer = __pWebViewer->GetHeight();
2737 AppLog("MainForm::OnAddressCancelledClicked yOfWebViewer is %d",yOfWebViewer);
2738 AppLog("MainForm::OnAddressCancelledClicked heightOfWebViewer is %d",heightOfWebViewer);
2740 __pWebViewer->Invalidate(true);
2743 __pFooterPanel->SetShowState(true);
2744 __pFooterPanel->Invalidate(false);
2748 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
2750 __prevAddressBarMode = __curAddressBarMode;
2752 if (__pAddressbar != null)
2754 //__curAddressBarMode = __pAddressbar->GetAddressbarMode();
2755 __curAddressBarMode = GetAddressbarMode();
2758 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2760 __adressPanelPosition.y = 0;
2761 if (__pAddressbar != null)
2763 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2764 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2765 __pAddressbar->Invalidate(true);
2767 if (__pWebViewer != null)
2769 __pWebViewer->StopLoading();
2772 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
2774 __adressPanelPosition.y = 0;
2775 if (__pAddressbar != null)
2778 __webControlPosition.y = 0;//__pAddressbar->GetHeight() - 12;
2779 __pAddressbar->SetBounds(Rectangle(0,__pAddressbar->GetY() - __pAddressbar->GetHeight(),GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2780 __pAddressbar->Invalidate(true);
2783 if (__pWebViewer != null)
2785 if(__pFooterPanel->GetShowState() == false)
2786 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2788 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2789 __pWebViewer->Invalidate(true);
2794 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
2797 if(__pFooterPanel != null)
2799 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2800 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2802 InitMostVisitedSitesView(GetOrientationStatus());
2804 __pFooterPanel->SetShowState(footerState);
2805 __pFooterPanel->Invalidate(false);
2810 //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");
2812 if (__pWebViewer != null && __pFooterPanel != null)
2814 AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2815 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2817 if(__pFooterPanel->GetShowState() == false)
2818 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2820 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2821 __pWebViewer->Invalidate(false);
2822 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2824 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2825 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2830 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2832 AppLog("MainForm::OnAddressBarKeypadOpened");
2834 if (__pFindWordPanel && __pFindWordPanel->GetShowState() == true)
2836 __pAddressbar->SetShowState(false);
2837 __pAddressbar->Invalidate(true);
2841 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
2843 __pAddressbar->SetShowState(true);
2844 __pAddressbar->Invalidate(true);
2845 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2846 __pAddressbar->SetAddressbarURLFocus();
2851 //__pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2854 if (__pMostVisitedListView && __pMostVisitedListView->GetShowState() == true)
2856 AppLog("MainForm::OnAddressBarKeypadOpened 1");
2857 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2858 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pMostVisitedListView->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2860 if(__pMostVisitedListView != null)
2861 __pMostVisitedListView->Invalidate(true);
2863 else if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
2865 AppLog("MainForm::OnAddressBarKeypadOpened 2");
2866 if (__pWebViewer != null && __pAddressbar != null && __pFooterPanel != null)
2867 __pWebViewer->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, /*__pWebViewer->GetHeight()*/GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2869 if(__pWebViewer != null)
2870 __pWebViewer->Invalidate(true);
2875 if (__pWebViewer != null)
2877 __pWebViewer->SetShowState(false);
2878 __pWebViewer->Invalidate(true);
2881 __pMostVisitedListView->SetShowState(true);
2882 if (__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2883 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, __pMostVisitedListView->GetHeight()GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2885 if(__pMostVisitedListView != null)
2886 __pMostVisitedListView->Invalidate(true);
2891 __pFooterPanel->SetShowState(false);
2892 __pFooterPanel->Invalidate(true);
2896 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2898 __pFooterPanel->SetShowState(false);
2899 __pFooterPanel->Invalidate(false);
2903 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2907 __pWindowInfo->pageTitle = title;
2908 if (__pWebViewer != null)
2910 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2913 if (__pAddressbar != null && __pWebViewer != null)
2915 SetUrl(__pWebViewer->GetUrl());
2916 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2917 //__pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2918 __pAddressbar->Invalidate(true);
2924 MainForm::UpdateFavicon(void)
2926 bool urlImageType = false;
2927 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();");
2928 Bitmap* pBitmap = null;
2930 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2932 if (__pWindowInfo != null)
2935 url.SetUri(*tempPath);
2936 if (url.GetHost().GetLength() == 0)
2939 webUrl.SetUri(__pWebViewer->GetUrl());
2940 result r = url.SetHost(webUrl.GetHost());
2947 if (url.GetScheme().GetLength() == 0)
2950 webUrl.SetUri(__pWebViewer->GetUrl());
2951 url.SetScheme(webUrl.GetScheme());
2953 __pWindowInfo->faviconUrl = url.ToString();
2955 pBitmap = __pWebViewer->GetFaviconN();
2957 if (pBitmap != null)
2959 if (__pWindowInfo->pFavicon != NULL)
2961 // delete __pWindowInfo->pFavicon;
2962 __pWindowInfo->pFavicon = null;
2964 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2965 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2966 //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();
2968 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2970 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2972 else if(__pWindowInfo->pFavicon != null)
2974 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2978 __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());
2981 AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());
2988 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2995 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2996 Tizen::Web::Controls::WebNavigationType type)
2998 // when load new page if find word panel is open its show state is false
2999 ShowFindWordPanel(false);
3000 AppLog("__pAddressbar->GetAddressbarURL() is %ls",__pAddressbar->GetAddressbarURL().GetPointer());
3002 __pFooterUrlField->SetText(__pAddressbar->GetAddressbarURL());
3003 __pFooterPanel->Invalidate(true);
3006 uriInfo.SetUri(url);
3008 if(url.Contains(IDS_TIZEN_SERVICE))
3011 String delim(L":;");
3013 // Creates a StringTokenizer instance
3014 StringTokenizer strTok(url, delim);
3016 int count = strTok.GetTokenCount(); // count == 4
3018 HashMap *pMap = new HashMap();
3024 while (strTok.HasMoreTokens())
3026 AppLog("Token: %ls", token.GetPointer());
3027 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3028 if(token.Contains(IDS_APPID))
3030 token.SubString(6, appId);
3031 AppLog("AppID:%ls", appId.GetPointer());
3033 else if(token.Contains("="))
3035 String *pKey = new String();
3036 String *pValue = new String();
3038 token.IndexOf("=", 0, index);
3041 token.SubString(0, index, *pKey);
3042 token.SubString(index + 1, *pValue);
3043 pMap->Add(pKey, pValue);
3049 AppControl *pAppControl = null;
3050 String operationId = L"http://tizen.org/appcontrol/operation/main";
3051 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3054 AppLog("Starting AppControl");
3055 result r = pAppControl->Start(null, null, pMap, null);
3056 AppLog("Result of Start %s", GetErrorMessage(r));
3060 AppLogException("AppControl not found");
3066 if (__pWebViewer && __pAddressbar)
3068 __pAddressbar->SetShowState(false);
3069 /*AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
3070 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
3071 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
3075 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
3076 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3077 __pWindowInfo->faviconUrl = "";
3078 __pWindowInfo->faviconFilePath = "";
3080 if (__pWindowInfo->pFavicon != NULL)
3082 // delete __pWindowInfo->pFavicon;
3083 __pWindowInfo->pFavicon = null ;
3085 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
3089 __pAddressbar->Invalidate(true);
3095 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3096 const Tizen::Net::Http::HttpHeader& httpHeader)
3098 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3103 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3105 AppLog("MainForm::OnWebPageBlockSelected");
3106 if (__pHitElementResult != null)
3108 delete __pHitElementResult;
3109 __pHitElementResult = null;
3112 if (__pWebViewer != null)
3114 AppLog("MainForm::OnWebPageBlockSelected web not null");
3115 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3118 if (__pHitElementResult == null)
3123 if (__pHitElementResult->HasImage() != true)
3125 String tagName = __pHitElementResult->GetTagName();
3126 String type = __pHitElementResult->GetAttributeValue("type");
3128 __currentSelectedStr.Clear();
3129 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3130 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3131 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3133 if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)
3135 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3137 InitSelectTextContextMenu(endPoint,true);
3138 __pImageMenu->SetShowState(true);
3139 __pImageMenu->Show();
3140 __pImageMenu->Invalidate(true);
3142 else /*if (__pHitElementResult->HasUrl() == true )*/
3144 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3146 if(__pHitElementResult->GetUrl().GetLength() > 0)
3148 __currentSelectedStr.Clear();
3149 __currentSelectedStr = __pHitElementResult->GetUrl();
3151 InitSelectTextContextMenu(endPoint,false);
3152 __pImageMenu->SetShowState(true);
3153 __pImageMenu->Show();
3154 __pImageMenu->Invalidate(true);
3157 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3158 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3159 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3165 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3171 MainForm::OnWebWindowCreateRequested(void)
3173 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3175 if (pNewWindowInfo == null)
3179 result r = E_SUCCESS;
3180 SceneManager* pSceneManager = SceneManager::GetInstance();
3181 if (pSceneManager == NULL)
3185 ArrayList* pArgList = new(std::nothrow) ArrayList();
3186 if (pArgList == NULL)
3190 r = pArgList->Construct();
3193 pNewWindowInfo->isJavascriptInitiated = true;
3194 pArgList->Add(*pNewWindowInfo);
3195 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3199 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3206 return pNewWindowInfo->pCurrentWeb;
3210 MainForm::RelayoutControls(bool showAddressbar)
3212 if (showAddressbar == false)
3214 __pAddressbar->SetShowState(false);
3215 __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);
3216 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3220 __pAddressbar->SetShowState(true);
3221 __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);
3222 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3224 RequestRedraw(true);
3227 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3229 if (__pFindWordPanel == null)
3235 InitFindWordPanel();
3236 __pFindWordEditField->SetText(__currentSearchStr);
3237 //__pFindWordCountLabel->SetText(L"");
3238 __pFindWordCountLabel->SetText(L"0/0");
3241 AppLog("MainForm::ShowFindWordPanel %d",show);
3242 if (show && !isTouchPressed)
3244 if (__pFindWordEditField)
3246 __pFindWordEditField->SetFocus();
3247 __pFindWordEditField->ShowKeypad();
3252 if (__pFindWordEditField)
3253 __pFindWordEditField->HideKeypad();
3256 if (__pAddressbar != null)
3258 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3259 __pAddressbar->SetShowState(false);
3260 __pAddressbar->Invalidate(true);
3262 if (__pFindWordPanel != null)
3264 __pFindWordPanel->SetShowState(show);
3265 __pFindWordPanel->Invalidate(true);
3271 MainForm::StartWordSearch()
3273 //Get the count of occurances of the word in the current page
3274 __maxOccurrances = 0;
3275 __currentWordIndex = 0;
3277 __pFindWordPrev->SetEnabled(false);
3278 String *pCountStr = null;
3279 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3280 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3281 if (pCountStr != null)
3283 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3287 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3292 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3294 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3295 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3297 if(totalCount == -1 || totalCount == 0)
3299 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight());
3300 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3303 else if(totalCount > 100)
3305 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3306 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3309 __maxOccurrances = totalCount;
3310 __currentWordIndex = currentOrdinal;
3312 //Reset the UI controls as per the maxOccurrance value
3313 if (totalCount <= 0)
3315 AppLog("Word not found");
3316 //Show error notification to user
3317 __pFindWordNext->SetEnabled(false);
3318 __pFindWordCountLabel->SetText(L"0/0");
3319 __pFindWordNext->Invalidate(false);
3320 __pFindWordPrev->Invalidate(false);
3321 __pFindWordCountLabel->Invalidate(false);
3325 if (totalCount == 1)
3327 __pFindWordNext->SetEnabled(false);
3331 __pFindWordNext->SetEnabled(true);
3334 String countStr = L"";
3335 countStr.Append(__currentWordIndex);
3336 countStr.Append(L"/");
3337 countStr.Append(__maxOccurrances);
3338 __pFindWordCountLabel->SetText(countStr);
3339 // __pFindWordCountLabel->SetShowState(true);
3340 __pFindWordCountLabel->Invalidate(false);
3342 //FindNextWord(true);
3343 //Update the controls
3344 __pFindWordNext->Invalidate(false);
3345 __pFindWordPrev->Invalidate(false);
3346 __pFindWordCountLabel->Invalidate(false);
3350 MainForm::FindNextWord(bool next)
3354 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3356 if(__currentWordIndex < __maxOccurrances)
3358 __currentWordIndex++;
3364 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3366 if(__currentWordIndex > 1)
3368 __currentWordIndex--;
3373 String countStr = L"";
3374 countStr.Append(__currentWordIndex);
3375 countStr.Append(L"/");
3376 countStr.Append(__maxOccurrances);
3377 __pFindWordCountLabel->SetText(countStr);
3378 // __pFindWordCountLabel->SetShowState(true);
3379 __pFindWordCountLabel->Invalidate(false);
3380 if (__currentWordIndex >= __maxOccurrances)
3382 __pFindWordNext->SetEnabled(false);
3386 __pFindWordNext->SetEnabled(true);
3388 if (__currentWordIndex <= 1)
3390 __pFindWordPrev->SetEnabled(false);
3394 __pFindWordPrev->SetEnabled(true);
3396 __pFindWordPrev->Invalidate(false);
3397 __pFindWordNext->Invalidate(false);
3398 __pFindWordCountLabel->Invalidate(false);
3399 __pFindWordPanel->Invalidate(true);
3402 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3404 AppLog("MainForm::OnWebKeypadWillOpen");
3405 // OnAddressBarKeypadOpened(*__pAddressbar);
3409 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3412 if (__pWebViewer != null && __pFooterPanel != null)
3414 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3416 // __pFooterPanel->SetShowState(false);
3417 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3420 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3425 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3427 OnAddressBarKeypadClosed(*__pAddressbar);
3431 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3433 Control* temp = const_cast< Control* >(&source);
3434 Header* pHeader = dynamic_cast< Header* >(temp);
3435 if (pHeader != null)
3437 //Header double - clicked
3438 AppLog("Header double clicked");
3440 if(__pFindWordPanel)
3442 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3443 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3447 AppLog("MainScene::OnTouchDoublePressed");
3448 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3449 if (isReaderEnabled == true)
3453 delete __pReaderData;
3454 __pReaderData = null;
3456 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3457 filePath.Append(L"data/reader.js");
3463 result r = E_SUCCESS;
3464 FileAttributes attr;
3466 File::GetAttributes(filePath,attr);
3468 r = file.Construct(filePath, L"r+");
3471 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3474 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3477 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3480 file.Read(pScript,attr.GetFileSize());
3482 AppLogDebug("scipt length %d",strlen(pScript));
3483 String strScript = L"";
3484 strScript.Append(pScript);
3485 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3488 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3491 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3492 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3494 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3495 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3501 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3503 AppLog("MainForm::OnTouchLongPressed");
3505 if (__pHitElementResult != null)
3507 delete __pHitElementResult;
3508 __pHitElementResult = null;
3511 if (__pWebViewer != null)
3513 AppLog("MainForm::OnTouchLongPressed web not null");
3514 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3517 if (__pHitElementResult == null)
3522 if (__pHitElementResult->HasImage() == true)
3524 InitImageContextMenu(currentPosition);
3525 __pImageMenu->SetShowState(true);
3526 __pImageMenu->Show();
3527 __pImageMenu->Invalidate(true);
3531 String tagName = __pHitElementResult->GetTagName();
3532 String type = __pHitElementResult->GetAttributeValue("type");
3533 String value = __pHitElementResult->GetAttributeValue(L"value");
3534 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3536 __currentSelectedStr.Clear();
3537 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3539 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3541 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3543 InitSelectTextContextMenu(currentPosition,true, true);
3544 __pImageMenu->SetShowState(true);
3545 __pImageMenu->Show();
3546 __pImageMenu->Invalidate(true);
3548 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3553 __inputEventToBeSupressed = true;
3557 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3559 AppLog("MainForm::OnTouchReleased");
3561 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3562 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3564 __pWebViewer->ConsumeInputEvent();
3566 if(pHitElement != null)
3570 __inputEventToBeSupressed = false;
3574 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3576 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3577 int widthContextItem = 0;
3579 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3580 if (pBitmap != null && __pFooterLabel != null)
3582 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3587 __pMenu->SetShowState(false);
3588 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3591 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3595 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3598 if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3600 __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());
3601 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
3602 __pFindWordControl->SetShowState(true);
3603 __pFindWordControl->Invalidate(true);
3604 __pFindWordPanel->SetShowState(true);
3605 __pFindWordPanel->Invalidate(true);
3608 if (__pWebViewer != null && __pFooterPanel != null)
3610 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3611 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3613 if(__pFooterPanel->GetShowState() == false)
3614 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
3616 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3617 __pWebViewer->Invalidate(true);
3619 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3621 if (__pAddressbar != null)
3623 if(__pAddressbar->GetShowState() == false)
3625 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0 - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3629 __pAddressbar->SetBounds(__pAddressbar->GetX(), 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3631 //__pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3632 //__pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());
3633 SetAddressbarMode(GetAddressbarMode());
3634 // __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
3636 if (__pFindWordBgLabel != null)
3638 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3639 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3640 if (pBitmap != null)
3642 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3646 if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)
3648 AppLog("__pFooterPanel->GetShowState() is true");
3653 if(__pMoreButton && __pMenu)
3655 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3656 __pMenu->SetAnchorPosition(p);
3657 __pMenu->Invalidate(true);
3662 __pFooterPanel->Invalidate(true);
3664 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3665 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3667 InitMostVisitedSitesView(orientationStatus);
3670 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3672 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3674 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight());
3676 else if(__pAddressbar != null && __pAddressbar->GetShowState() == false)
3678 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight());
3681 if (__pArticleReaderPanel != null)
3683 if (__pArticleReaderPanel->GetShowState() == true)
3685 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3687 if (__pBlankPanel != null)
3688 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3690 if (__pWebReader != null)
3692 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3694 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3695 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3697 if ( pBitmap != null && pSrcBitmap != null)
3699 AppLog("CreateReaderPanel ninepatchbitmap found");
3700 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3703 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3704 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3705 if (pBitmap != null)
3710 if (pSrcBitmap != null)
3718 if(__pAddressbar != null)
3720 __pAddressbar->OrientationChanged();
3725 MainForm::OnSettingsChange(int settingvalue)
3727 AppLogDebug("MainForm::OnSettingsChange entered");
3728 if (__pWebViewer == null)
3730 AppLogDebug("Webviewer is not initialized yet.");
3733 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3735 WebSetting settings = __pWebViewer->GetSetting();
3736 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3738 settings.SetAutoFittingEnabled(true);
3740 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3742 settings.SetAutoFittingEnabled(false);
3744 __pWebViewer->SetSetting(settings);
3746 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3748 WebSetting settings = __pWebViewer->GetSetting();
3749 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3750 __pWebViewer->SetSetting(settings);
3752 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3754 WebSetting settings = __pWebViewer->GetSetting();
3755 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3756 __pWebViewer->SetSetting(settings);
3758 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3760 WebSetting settings = __pWebViewer->GetSetting();
3761 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3762 __pWebViewer->SetSetting(settings);
3764 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3768 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3772 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3774 WebSetting settings = __pWebViewer->GetSetting();
3775 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3777 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3781 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3783 __pWebViewer->SetSetting(settings);
3785 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3789 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3790 WebSetting settings = __pWebReader->GetSetting();
3791 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3792 __pWebReader->SetSetting(settings);
3798 MainForm::OnSettingsReset()
3802 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3803 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3808 MainForm::OnClearCache()
3810 result r = E_SUCCESS;
3812 if (__pWebViewer != NULL)
3814 r = __pWebViewer->ClearCache();
3817 AppLogDebug("Cache cleared success");
3821 AppLogDebug("Cache cleared fail");
3827 MainForm::OnClearCookie()
3829 result r = E_SUCCESS;
3831 if (__pWebViewer != NULL)
3833 __pWebViewer->ClearCookie();
3837 AppLogDebug("Cookie cleared success");
3841 AppLogDebug("Cache cleared fail");
3846 MainForm::findDistance(int x1,int y1,int x2, int y2)
3848 int deltaX = Math::Abs(x2 - x1);
3849 int deltaY = Math::Abs(y2 - y1);
3850 double num = deltaX*deltaX + deltaY*deltaY;
3856 for (i = 0; i < 20; i++)
3858 x = (((x*x)+ num)/(2*x));
3869 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3871 if(__pFindWordPanel)
3873 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3874 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3878 IList* pList = null;
3879 pList = touch.GetTouchInfoListN(source);
3883 int count = pList->GetCount();
3886 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3887 __touchPoint1 = pTouchInfo->position;
3889 /*if (__pAddressbar != null)
3891 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3893 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3895 __pAddressbar->SaveAddressbarEditText();
3897 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3900 __pAddressbar->Invalidate(true);
3902 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3904 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3906 //__pAddressbar->SaveAddressbarEditText();
3908 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3911 else if (count == 2)
3913 AppLogDebug("MainForm::OnTouchPressed count is two");
3914 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3915 __touchPoint1 = pTouchInfo->position;
3917 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3918 __touchPoint2 = pTouchInfo->position;
3924 pList->RemoveAll(true);
3931 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3933 __pWebViewer->ReleaseBlock();
3934 __currentWordIndex = 0;
3935 AppLog("Start MainForm::OnTouchMoved MoveUiControls");
3936 if(__pFindWordPanel)
3938 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3939 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3942 if (__pFindWordEditField != null)
3944 __pFindWordEditField->HideKeypad();
3947 /*if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3951 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3957 IList* pList = null;
3958 pList = touch.GetTouchInfoListN(source);
3962 int count = pList->GetCount();
3965 AppLogDebug("MainForm::OnTouchMoved count 1");
3966 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3968 if( pTouchInfo == NULL )
3972 pTouchInfo->position.y += __pWebViewer->GetY();
3973 AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);
3975 if (__isLoaded == false)
3978 __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;
3979 __touchPoint1 = pTouchInfo->position;
3981 // move the address bar and web control according to distance moved
3984 else if (count == 2)
3986 AppLogDebug("MainForm::OnTouchMoved count 2");
3990 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3992 if( pTouchInfo == NULL )
3996 Point firstPoint = pTouchInfo->position;
3998 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3999 if( pTouchInfo == NULL )
4003 Point secondPoint = pTouchInfo->position;
4005 if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))
4007 __touchPoint1 = firstPoint;
4008 __touchPoint2 = secondPoint;
4013 int currX1 = firstPoint.x;
4014 int currY1 = firstPoint.y;
4015 int currX2 = secondPoint.x;
4016 int currY2 = secondPoint.y;
4018 double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);
4019 double dist = findDistance(currX1, currY1, currX2, currY2);
4020 __distanceMoved = prevDist - dist;
4022 __touchPoint1 = firstPoint;
4023 __touchPoint2 = secondPoint;
4035 MainForm::MoveUiControls()
4037 if(__pAddressbar == NULL || __pAddressbar->GetShowState() == false)
4041 __adressPanelPosition.y = __adressPanelPosition.y + __distanceMoved;
4042 if (__adressPanelPosition.y > 0)
4044 __adressPanelPosition.y = 0;
4045 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
4047 else if (__adressPanelPosition.y < (0-(__pAddressbar->GetHeight() - 12))) // -12 is for the progress label
4049 __adressPanelPosition.y = 0-(__pAddressbar->GetHeight() - 12);
4050 __webControlPosition.y = 0;
4054 __webControlPosition.y = __adressPanelPosition.y + (__pAddressbar->GetHeight() - 12);
4057 AppLogDebug("__adressPanelPosition.y = %d, __webControlPosition.y = %d", __adressPanelPosition.y, __webControlPosition.y);
4059 __pAddressbar->SetBounds(0,__adressPanelPosition.y,__pAddressbar->GetWidth(),__pAddressbar->GetHeight());
4060 __pAddressbar->Invalidate(false);
4062 if (__pWebViewer != NULL)
4064 if(__pFooterPanel->GetShowState() == true)
4065 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4067 __webControlHeight = GetClientAreaBounds().height;
4068 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
4069 __pWebViewer->Invalidate(false);
4074 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4076 if (__pFindWordEditField != null)
4078 __currentSearchStr = __pFindWordEditField->GetText();
4079 __pFindWordNext->SetEnabled(false);
4080 __pFindWordPrev->SetEnabled(false);
4081 __pFindWordNext->Invalidate(true);
4082 __pFindWordPrev->Invalidate(true);
4083 __pFindWordCountLabel->SetText(L"0/0");
4084 __pFindWordCountLabel->Invalidate(true);
4086 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4087 if (__currentSearchStr.GetLength() > 0)
4093 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4095 AppLogDebug("Enter something");
4100 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4107 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4109 if(__pWebViewer != null)
4112 AppLog("MainForm::InitMostVisitedSitesView");
4113 result r = E_SUCCESS;
4116 if (__pWebViewer != null && __pMostVisitedListView != null)
4121 if (__pMostVisitedListView != null)
4123 RemoveControl(*__pMostVisitedListView);
4125 if(__pMostVisitedSites != null)
4127 __pMostVisitedSites->RemoveAll(true);
4130 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4132 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4133 __pMostVisitedListView = new(std::nothrow) ListView();
4134 if(__pFooterPanel->GetShowState() == false)
4136 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);
4140 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);
4145 delete __pMostVisitedListView;
4146 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4149 __pMostVisitedListView->SetItemProvider(*this);
4150 __pMostVisitedListView->AddListViewItemEventListener(*this);
4151 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4152 AddControl(*__pMostVisitedListView);
4153 AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));
4154 if(__pFooterPanel->GetShowState() == false)
4155 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));
4157 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,0, GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
4159 __pMostVisitedListView->UpdateList();
4166 MainForm::GetImagePath(void)
4170 String formattedTime;
4171 DateTime currentTime;
4172 LocaleManager localManager;
4173 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4175 localManager.Construct();
4176 Locale locale = localManager.GetSystemLocale();
4177 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4179 // Get date formatter
4180 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4184 pTimeFormatter->Format(currentTime, formattedTime);
4187 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4188 String delim(L" :");
4189 StringTokenizer strTok(formattedTime, delim);
4192 String str1("GMT+00");
4193 while (strTok.HasMoreTokens())
4195 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4196 if(token.Equals(str1))
4198 AppLog("token is %ls", token.GetPointer());
4199 imageName.Append(token);
4205 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4207 result r = E_FAILURE;
4208 AppLog("Content manager 1");
4209 ContentId contentId;
4210 ContentManager contentManager;
4211 r = contentManager.Construct();
4214 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4217 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4218 contentPath.Append(imageName);
4219 contentPath.Append(".jpg");
4220 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4221 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4225 MainForm::SetForwardButtonEnabled(bool isEnabled)
4227 __pGoForwardBtn->SetEnabled(isEnabled);
4228 __pGoBackBtn->Invalidate(true);
4232 MainForm::SetBackButtonEnabled(bool isEnabled)
4234 __pGoBackBtn->SetEnabled(isEnabled);
4235 __pGoBackBtn->Invalidate(true);
4239 MainForm::UpdateProgress(int percentage)
4241 __progressPercentage = percentage;
4242 if (percentage == 0 || percentage == 100)
4244 __isLoadingData = false;
4245 if (percentage == 100)
4247 __isLoadingCompleted = true;
4248 __progressPercentage = 0;
4252 __isLoadingCompleted = false;
4257 __isLoadingData = true;
4259 UpdateProgressBitmap();
4263 MainForm::GetProgress(void)
4265 return __progressPercentage;
4269 MainForm::UpdateProgressBitmap(void)
4271 result r = E_SUCCESS;
4272 if (__pProgressbarLabel == null)
4274 int w = __pProgressbarLabel->GetWidth();
4275 int h = __pProgressbarLabel->GetHeight();
4277 int progressWidth = 0;
4278 Bitmap* pRetBitmap = null;
4280 if (__progressPercentage == 0 || __progressPercentage == 100)
4282 __pProgressbarLabel->SetShowState(false);
4283 __pProgressbarLabel->Invalidate(false);
4288 __pProgressbarLabel->SetShowState(true);
4289 __pProgressbarLabel->Invalidate(false);
4292 r = canvas.Construct(Rectangle(0, 0, w, h));
4296 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4301 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4305 pBgBmp->Scale(Dimension(w, h));
4306 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4310 progressWidth = (double) (w) * __progressPercentage / 100;
4311 AppLogDebug("progressWidth: %d", progressWidth);
4312 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4314 if (pProgressBmp != null)
4316 pProgressBmp->Scale(Dimension(progressWidth, h));
4317 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4318 delete pProgressBmp;
4321 pRetBitmap = new (std::nothrow) Bitmap();
4323 if (pRetBitmap == null)
4325 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4329 pRetBitmap->Construct(canvas, canvas.GetBounds());
4331 if (__pProgressbarLabel != null && pRetBitmap != null)
4333 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4334 __pProgressbarLabel->Invalidate(false);
4337 if (pRetBitmap != null)
4345 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4347 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4349 __currentAddMode = addMode;
4353 case ADDRESSBAR_MODE_INVALID:
4358 case ADDRESSBAR_MODE_READER:
4360 // __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
4361 // __pSearchLabel->SetShowState(false);
4362 // __pFaviconLabel->SetShowState(true);
4363 // __pCancelBtn->SetShowState(false);
4364 // __pRefreshBtn->SetShowState(false);
4365 __pStopBtn->SetShowState(false);
4366 // __pReaderBtn->SetShowState(true);
4367 // __pReaderBtn->Invalidate(true);
4368 // __pGoForwardBtn->SetShowState(true);
4369 // __pGoBackBtn->SetShowState(true);
4370 __pClearBtn->SetShowState(false);
4373 case ADDRESSBAR_MODE_LOADING:
4375 // __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
4376 // __pSearchLabel->SetShowState(false);
4377 // __pFaviconLabel->SetShowState(true);
4378 // __pCancelBtn->SetShowState(false);
4379 __pRefreshBtn->SetShowState(false);
4380 __pStopBtn->SetShowState(true);
4381 // __pReaderBtn->SetShowState(false);
4382 // __pGoForwardBtn->SetShowState(true);
4383 // __pGoBackBtn->SetShowState(true);
4384 __pClearBtn->SetShowState(false);
4387 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4389 // __pBgPanel->SetPosition(__pGoBackBtn->GetPosition().x + 2* __pGoBackBtn->GetWidth() + 13,__pBgPanel->GetPosition().y);
4390 // __pCancelBtn->SetShowState(false);
4392 if (__pFooterUrlField && __pFooterUrlField->GetText().IsEmpty() == false)
4394 // __pSearchLabel->SetShowState(false);
4395 // __pFaviconLabel->SetShowState(true);
4399 // __pSearchLabel->SetShowState(true);
4400 // __pFaviconLabel->SetShowState(false);
4403 if (__pFooterUrlField != NULL)
4405 __pFooterUrlField->SetText(__displayUrl);
4406 __pFooterUrlField->HideKeypad();
4409 __pRefreshBtn->SetShowState(true);
4410 __pStopBtn->SetShowState(false);
4411 // __pReaderBtn->SetShowState(false);
4412 // __pGoForwardBtn->SetShowState(true);
4413 // __pGoBackBtn->SetShowState(true);
4414 __pClearBtn->SetShowState(false);
4417 case ADDRESSBAR_MODE_EDIT:
4419 __pRefreshBtn->SetShowState(false);
4420 __pStopBtn->SetShowState(false);
4421 __pClearBtn->SetShowState(true);
4428 OnAddressBarModeChanged();
4431 AddressBarMode MainForm::GetAddressbarMode(void)
4433 return __currentAddMode;
4436 void MainForm::SetUrl(const String& url)
4440 String updatedDisplayUrl;
4441 updatedDisplayUrl.Clear();
4443 if (__pFooterUrlField != NULL)
4445 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4446 if (removedHttpUrl.IsEmpty() == false)
4448 __pFooterUrlField->SetText(removedHttpUrl);
4452 __pFooterUrlField->SetText(__displayUrl);
4455 __pFooterUrlField->Invalidate(false);
4456 __pFooterUrlField->SetCursorPosition(0);
4462 MainForm::RemoveHttpTextFromDisplayURL(void)
4464 bool isHttpText = __displayUrl.Contains(L"http://");
4465 String updatedDisplayUrl;
4466 updatedDisplayUrl.Clear();
4468 if (isHttpText == true)
4470 __displayUrl.SubString(7,updatedDisplayUrl);
4472 return updatedDisplayUrl;