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_BTN_BACK = L"I01_icon_Back.png";
56 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
57 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
58 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
63 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
64 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
65 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
66 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
67 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
69 const int IDA_BACKBTN_CLICKED = 101;
70 const int IDA_BOOKMARKBTN_CLICKED = 102;
71 const int IDA_MOREBTN_CLICKED = 103;
72 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
73 const int IDA_NEWWINDOWBTN_CLICKED = 105;
74 const int IDA_FORWARD_CLICKED = 106;
75 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
76 const int IDA_SHARE_CLICKED = 108;
77 const int IDA_FINDONPAGE_CLICKED = 109;
78 const int IDA_PRIVATEON_CLICKED = 110;
79 const int IDA_SETTINGS_CLICKED = 111;
80 const int IDA_READER_CLOSE_CLICKED = 112;
81 const int IDA_SMALLFONT_BTN_CLICKED = 113;
82 const int IDA_LARGEFONT_BTN_CLICKED = 114;
83 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
84 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
85 const int IDA_FINDWORD_NEXT_CLICKED = 202;
86 const int IDA_FINDWORD_PREV_CLICKED = 203;
87 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
88 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
90 const int IDA_COPY_IMAGE_CLICKED = 206;
91 const int IDA_VIEW_IMAGE_CLICKED = 207;
92 const int IDA_SAVE_IMAGE_CLICKED = 208;
93 const int IDA_SHARE_IMAGE_CLICKED = 209;
95 const int IDA_COPY_TEXT_CLICKED = 210;
96 const int IDA_PASTE_TEXT_CLICKED = 211;
97 const int IDA_FIND_TEXT__CLICKED = 212;
98 const int IDA_SHARE_TEXT_CLICKED = 213;
99 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
101 const int MainForm::IDA_FORMAT_BITMAP = 500;
102 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
103 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
104 const int MainForm::IDA_FORMAT_URL_STRING = 503;
105 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
107 MainForm::MainForm(void)
109 __pAddressbar = null;
110 // __pMostVisitedSitesPanel = null;
111 __pMostVisitedListView = null;
112 __pFooterPanel = null;
113 __pHitElementResult = null;
114 __pWindowInfo = null;
118 __pFindWordControl = null;
119 __pFindWordPanel = null;
120 __pFindWordBgLabel = null;
121 __pFindWordEditField = null;
122 __pFindWordClear = null;
123 __pFindWordCountLabel = null;
124 __pFindWordNext = null;
125 __pFindWordPrev = null;
126 __previousZoomLevel = 1.0;
128 __currentSearchStr = L"";
129 __currentSelectedStr = L"";
130 __maxOccurrances = 0;
131 __currentWordIndex = 0;
134 __inputEventToBeSupressed = false;
135 __touchPoint1 = Point(-1,-1);
136 __touchPoint2 = Point(-1,-1);
138 // __pReaderPopup = null;
139 __pReaderData = null;
141 __pReaderCloseBtn = null;
142 __pNewWindowButton = null;
143 __pMoreButton = null;
144 __pMultiWindowButton = null;
145 __pArticleReaderPanel = null;
146 __pBlankPanel = null;
147 __pArticleReaderLabel = null;
148 __webControlHeight = 0;
149 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
150 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
151 __pMostVisitedSites = null;
154 MainForm::~MainForm(void)
156 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
160 __pAddressbar->SetAddressbarEventListener(null);
162 if (__pReaderData != null)
164 delete __pReaderData;
165 __pReaderData = null;
168 if (__pPopUp != null)
173 String* pSelectedScene = NULL;
174 Object* pValue = NULL;
175 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
176 pSelectedScene = (String*) pValue;
178 /*if (pSelectedScene != null)
180 delete pSelectedScene;
182 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
186 MainForm::Initialize(void)
188 Construct(L"IDL_FORM");
193 MainForm::OnInitializing(void)
195 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
196 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
198 Panel* pFooterPanel = null;
200 __pSaveImage = new Image();
201 __pSaveImage->Construct();
203 // Setup back event listener
204 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
205 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
206 AddOrientationEventListener(*this);
207 AppLogDebug(" MainForm::OnInitializing ended");
208 if (__pMostVisitedSites == null)
210 __pMostVisitedSites = new(std::nothrow) ArrayList();
211 __pMostVisitedSites->Construct();
213 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
215 __pItemContext= new(std::nothrow) ListContextItem();
216 __pItemContext->Construct();
217 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
218 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
220 if (pBitmapNormal != null && pBitmapPressed != null)
222 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
225 if (pBitmapNormal != null)
227 delete pBitmapNormal;
230 if (pBitmapPressed != null)
232 delete pBitmapPressed;
239 MainForm::InitAddressbar(void)
241 AppLogDebug("MainForm::InitAddressbar entered");
243 result r = E_SUCCESS;
245 if (__pAddressbar != null)
249 __pAddressbar = new(std::nothrow) Addressbar();
250 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
251 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
254 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
257 __pAddressbar->SetAddressbarEventListener(this);
258 AddControl(*__pAddressbar);
259 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
260 SetControlAlwaysOnTop(*__pAddressbar, true);
261 __adressPanelPosition = __pAddressbar->GetPosition();
263 AppLogDebug("MainForm::InitAddressbar exit");
269 MainForm::CreateReaderPanel(void)
271 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
272 result r = E_FAILURE;
274 Button *pSmallFontBtn = null;
275 Button *pLargeFontBtn = null;
277 __pBlankPanel = new (std::nothrow) Panel();
278 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
280 __pArticleReaderPanel = new (std::nothrow) Panel();
281 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
283 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
284 if (__pReaderCloseBtn)
286 AppLogDebug("CreateReaderPanel() 6");
287 __pReaderCloseBtn->AddActionEventListener(*this);
288 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
291 __pWebReader = new (std::nothrow) Web();
292 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
294 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
295 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
297 r = __pWebReader->SetSetting(settings);
299 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
302 __pArticleReaderLabel = new Label();
303 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
305 __pBlankPanel->AddControl(*__pArticleReaderLabel);
306 __pBlankPanel->AddControl(*__pArticleReaderPanel);
307 AddControl(*__pBlankPanel);
309 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
310 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
311 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
313 __pArticleReaderPanel->AddControl(*__pWebReader);
314 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
315 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
316 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
318 if (pBitmap != null && pSrcBitmap != null)
320 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
322 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
324 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
327 pSmallFontBtn->AddActionEventListener(*this);
328 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
331 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
334 pLargeFontBtn->AddActionEventListener(*this);
335 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
344 if (pSrcBitmap != null)
350 SetControlAlwaysOnTop(*__pBlankPanel, true);
351 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
358 MainForm::InitWebControl()
360 AppLogDebug("MainForm::InitWebControl enter");
361 result r = E_SUCCESS;
362 AppLogDebug("InitWebControl");
364 if (__pAddressbar == null || __pFooterPanel == null)
367 const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12;
368 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
369 if (__pMostVisitedListView)
371 __pMostVisitedListView->SetShowState(false);
373 if (__pWebViewer != null)
375 AppLogDebug("Already initialized");
378 __pWebViewer = new(std::nothrow) Web();
379 if(__pWebViewer == NULL)
381 AppLogDebug("Initialization failed");
384 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
388 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
393 r = AddControl(*__pWebViewer);
397 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
400 __webControlPosition = __pWebViewer->GetPosition();
401 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
404 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
408 __pWebViewer->SetLoadingListener(this);
409 __pWebViewer->SetWebUiEventListener(this);
410 __pWebViewer->SetWebKeypadEventListener(this);
411 __pWebViewer->SetFocus();
412 __pWebViewer->AddTouchEventListener(*this);
414 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
415 __pWebViewer->SetTextSearchListener(this);
418 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
419 AppLogDebug("MainForm :before return");
421 AppLogDebug("MainForm::InitWebControl Exit");
427 MainForm::SetJavascriptEnabled()
429 WebSetting settings = __pWebViewer->GetSetting();
430 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
431 __pWebViewer->SetSetting(settings);
435 MainForm::SetImageLoadEnabled()
437 WebSetting settings = __pWebViewer->GetSetting();
438 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
439 __pWebViewer->SetSetting(settings);
443 MainForm::InitFooter(void)
445 AppLogDebug("MainForm::InitFooter entered");
446 Button* pBackButton = null;
447 Button* pBookmarkButton = null;
448 Button* pMultiWindowButton = null;
449 Bitmap *pIconBitmap = null;
450 Bitmap *pBGBitmap = null;
451 Label *pBGLabel = null;
453 if (__pFooterPanel == null)
455 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
458 if (__pFooterPanel == null)
463 SetControlAlwaysOnTop(*__pFooterPanel, true);
465 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
467 if ( __pMultiWindowButton == NULL )
472 pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true));
474 if ( pBackButton == NULL )
479 pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true));
481 if ( pBookmarkButton == NULL )
486 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
488 if ( __pMoreButton == NULL )
493 __pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true));
495 if ( __pNewWindowButton == NULL )
500 if (__pMultiWindowButton != null)
502 Bitmap* pBitmap = null;
503 Bitmap* pPressedBitmap = null;
504 String imagePath = "I01_toolbar_icon_windows_manager_0";
505 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
506 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
507 imagePath.Append(totalCount);
508 imagePath.Append(".png");
510 pressedImagePath.Append(totalCount);
511 pressedImagePath.Append("_press.png");
513 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
514 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
515 if ( pBitmap == null )
520 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
523 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
524 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
529 __pMultiWindowButton->AddActionEventListener(*this);
530 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
536 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK);
537 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK_PRESS);
540 // pBitmap->Scale(Dimension(56,56));
542 Point startPoint((pBackButton->GetWidth() - pBitmap->GetWidth())/2,(pBackButton->GetHeight() - pBitmap->GetHeight())/2 );
543 AppLog("startPoint %d,%d pBitmap width height %d %d",startPoint.x,startPoint.y,pBitmap->GetWidth(),pBitmap->GetHeight());
544 pBackButton->SetNormalBitmap(startPoint, *pBitmap);
545 pBackButton->SetPressedBitmap(startPoint, *pPressedBitmap);
548 pBackButton->AddActionEventListener(*this);
549 pBackButton->SetActionId(IDA_BACKBTN_CLICKED);
554 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK);
555 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK_PRESS);
558 Point startPoint((pBookmarkButton->GetWidth() - pBitmap->GetWidth())/2,(pBookmarkButton->GetHeight() - pBitmap->GetHeight())/2 );
559 pBookmarkButton->SetNormalBitmap(startPoint, *pBitmap);
560 pBookmarkButton->SetPressedBitmap(startPoint, *pPressedBitmap);
563 pBookmarkButton->AddActionEventListener(*this);
564 pBookmarkButton->SetActionId(IDA_BOOKMARKBTN_CLICKED);
569 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
570 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
573 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
574 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
575 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
579 __pMoreButton->AddActionEventListener(*this);
580 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
585 if (__pNewWindowButton)
587 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW);
588 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS);
591 Point startPoint((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
592 __pNewWindowButton->SetNormalBitmap(startPoint, *pBitmap);
593 __pNewWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
596 __pNewWindowButton->AddActionEventListener(*this);
597 __pNewWindowButton->SetActionId(IDA_NEWWINDOWBTN_CLICKED);
598 __pNewWindowButton->SetEnabled(true);
599 // __pNewWindowButton->Invalidate(true);
602 AppLog("checkingwindow count %d",MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount());
604 if (__pNewWindowButton != null && MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
606 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTROLBAR_ICON_CREATE_DISABLE);
609 Point startPoint = Point((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
610 __pNewWindowButton->SetDisabledBitmap(startPoint,*pBitmap);
613 __pNewWindowButton->SetEnabled(false);
616 // __pFooterPanel->Invalidate(true);
617 AppLogDebug("MainForm::InitFooter exit");
623 MainForm::InitContextMenu(Point& p)
625 result r = E_SUCCESS;
626 bool isPrivateBrowsing = false;
627 Bitmap* pBitmap = null;
631 __pMenu->SetAnchorPosition(p);
632 __pMenu->Invalidate(true);
636 __pMenu = new(std::nothrow) ContextMenu();
637 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
638 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
640 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
643 if (isPrivateBrowsing == true)
645 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
649 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
652 if ( pBitmap != NULL)
654 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
657 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
658 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
659 __pMenu->SetMaxVisibleItemsCount(3);
660 __pMenu->SetShowState(false);
661 __pMenu->AddActionEventListener(*this);
662 SetControlAlwaysOnTop(*__pMenu, true);
668 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
670 result r = E_SUCCESS;
672 AppLog("MainForm::InitImageContextMenu clicked on image");
673 if (__pImageMenu != null)
679 p.y = p.y + __pAddressbar->GetHeight() + 12;
680 __pImageMenu = new (std::nothrow) ContextMenu();
681 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
682 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
684 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
685 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
686 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
687 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
688 __pImageMenu->SetMaxVisibleItemsCount(4);
689 __pImageMenu->AddActionEventListener(*this);
690 SetControlAlwaysOnTop(*__pImageMenu, true);
695 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
697 result r = E_SUCCESS;
699 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
700 if (__pImageMenu != null)
705 p.y = p.y + __pAddressbar->GetHeight() + 12;
706 __pImageMenu = new (std::nothrow) ContextMenu();
707 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID);
708 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
710 if(onlyPasteOption == false)
712 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
714 if (pasteOption || onlyPasteOption)
716 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
718 if(onlyPasteOption == false)
720 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
721 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
724 __pImageMenu->SetMaxVisibleItemsCount(3);
725 __pImageMenu->AddActionEventListener(*this);
726 SetControlAlwaysOnTop(*__pImageMenu, true);
733 MainForm::InitFindWordPanel(void)
735 result r = E_SUCCESS;
736 Bitmap *pIconBitmap = null;
738 if (__pFindWordPanel != null)
740 AppLogDebug("Findword panel already initialized");
741 if (__pFindWordBgLabel != null)
743 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
746 AppLogDebug("InitFindWordPanel: Coming here");
747 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
754 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
755 if (__pFindWordPanel == null)
757 AppLogException("There is some problem in the xml file. Please check.");
761 __pFindWordControl = new (std::nothrow) Panel();
762 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
765 AppLogException("There is some problem in the xml file. Please check.");
768 __pFindWordPanel->AddControl(*__pFindWordControl);
769 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
770 SetControlAlwaysOnTop(*__pFindWordPanel,true);
771 __pFindWordPanel->SetShowState(false);
772 __pFindWordPanel->Invalidate(false);
774 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
775 if (__pFindWordBgLabel != null)
777 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
778 Rectangle pRect = pPanel1->GetBounds();
779 pRect.x = pRect.y = 0;
780 __pFindWordBgLabel->SetBounds(pRect);
781 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
784 AppLogDebug("InitFindWordPanel: Coming here");
785 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
790 AppLogDebug("InitFindWordPanel: shouldn't Come here");
794 Button* pfindWordCancel = null;
795 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
796 if (pfindWordCancel == null)
798 AppLogException("There is some problem in the xml file. Please check.");
801 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
802 pfindWordCancel->AddActionEventListener(*this);
804 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
805 if (__pFindWordClear == null)
807 AppLogException("There is some problem in the xml file. Please check.");
811 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
812 __pFindWordClear->AddActionEventListener(*this);
814 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
815 if (__pFindWordNext == null)
817 AppLogException("There is some problem in the xml file. Please check.");
821 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
822 __pFindWordNext->AddActionEventListener(*this);
824 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
825 if (__pFindWordPrev == null)
827 AppLogException("There is some problem in the xml file. Please check.");
831 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
832 __pFindWordPrev->AddActionEventListener(*this);
834 __pFindWordNext->SetEnabled(false);
835 __pFindWordPrev->SetEnabled(false);
837 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
838 if (__pFindWordCountLabel == null)
840 AppLogException("There is some problem in the xml file. Please check.");
844 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
845 if (__pFindWordEditField == null)
847 AppLogException("There is some problem in the xml file. Please check.");
850 __pFindWordEditField->AddTextEventListener(*this);
851 __pFindWordEditField->AddKeypadEventListener(*this);
852 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
858 MainForm::CreateItem (int index, int itemWidth)
860 Rectangle listImageRect;
861 Rectangle pagetTitleRect;
862 Rectangle pageURLRect;
863 Rectangle deleteImageRect;
864 String pageTitle(L"");
866 result r = E_SUCCESS;
867 Bitmap* pListIconImage = null;
870 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
875 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
876 if ( pAppResource == NULL )
880 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
882 CustomItem* pItem = new(std::nothrow) CustomItem();
883 pageTitle = pHistory->GetHistoryTitle();
884 pageURL = pHistory->GetHistoryUrl();
886 if (pageURL.GetLength() == 0)
889 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
890 pageURL = L"<"+ nourl +">";
894 Rectangle screenBounds = GetBounds();
897 r = pItem->Construct(Dimension(itemWidth, 128), style);
905 if (pHistory->GetFaviconId().GetLength() > 0)
907 String bitmapId = pHistory->GetFaviconId();
908 Bitmap* pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);
910 if ( pBitmap != NULL)
912 pListIconImage = new Bitmap();
913 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
918 if(pListIconImage == null)
920 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
923 if ( pListIconImage != NULL)
925 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
926 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
927 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
930 if (pItem != null && pListIconImage != NULL)
932 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
936 if (pageTitle.CompareTo(L"") != 0)
940 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
944 if (pageURL.CompareTo(L"") != 0)
948 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
953 if ( __pItemContext!= NULL)
957 pItem->SetContextItem(__pItemContext);
960 if( pListIconImage != NULL)
962 delete pListIconImage;
963 pListIconImage = null;
970 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
977 MainForm::GetItemCount (void)
979 if(__pMostVisitedSites != null)
981 __pMostVisitedSites->RemoveAll(true);
983 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
984 if(__pMostVisitedSites != null)
986 return __pMostVisitedSites->GetCount();
993 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
995 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
996 String url = pHistory->GetHistoryUrl();
997 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
998 __pMostVisitedListView->UpdateList();
1002 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1004 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1005 String url = pHistory->GetHistoryUrl();
1013 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1019 MainForm::OnTerminating(void)
1021 result r = E_SUCCESS;
1026 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1028 result r = E_SUCCESS;
1030 AppLogDebug("Clicked : %d", actionId);
1033 case IDA_BACKBTN_CLICKED:
1035 if (__pWebViewer && __pWebViewer->CanGoBack())
1037 __pWebViewer->GoBack();
1042 pApp = UiApp::GetInstance();
1045 r = pApp->Terminate();
1048 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1056 case IDA_FORWARD_CLICKED:
1057 if (__pWebViewer == null)
1060 if (__pWebViewer->CanGoForward())
1062 __pWebViewer->GoForward();
1064 __pMenu->SetShowState(false);
1065 __pMenu->Invalidate(false);
1068 case IDA_FINDONPAGE_CLICKED:
1070 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1071 __currentSearchStr.Clear();
1073 InitFindWordPanel();
1074 __pMenu->SetShowState(false);
1075 __pMenu->Invalidate(false);
1077 __adressPanelPosition.y = 0;
1079 if (__pAddressbar != null && __pWebViewer != NULL)
1081 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1082 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1083 __pAddressbar->Invalidate(true);
1084 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1085 __pWebViewer->Invalidate(true);
1088 ShowFindWordPanel(true);
1091 case IDA_PRIVATEON_CLICKED:
1093 result r = E_SUCCESS;
1095 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1096 Bitmap* pBitmap = null;
1097 if (isPrivateBrowsing == true)
1099 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1102 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1106 if (__pWebViewer != NULL)
1108 __pWebViewer->SetPrivateBrowsingEnabled(false);
1111 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1113 if (__pAddressbar != null)
1115 __pAddressbar->UpdateFaviconBitmap(false);
1121 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1124 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1128 if (__pWebViewer != NULL)
1130 __pWebViewer->SetPrivateBrowsingEnabled(true);
1133 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1135 if (__pAddressbar != null)
1137 __pAddressbar->UpdateFaviconBitmap(true);
1142 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1143 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1144 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1145 __pMenu->Invalidate(true);
1147 if ( pBitmap != NULL )
1154 case IDA_SETTINGS_CLICKED:
1157 ArrayList* pArgList = new(std::nothrow) ArrayList();
1160 pArgList->Construct();
1161 pArgList->Add(*__pWindowInfo);
1162 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1164 __pMenu->SetShowState(false);
1165 __pMenu->Invalidate(false);
1166 if (pArgList != null)
1175 case IDA_ADDTOBOOKMARK_CLICKED:
1178 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1180 int bookmarkCount=0;
1183 url=__pWindowInfo->pageUrl;
1184 result r = E_SUCCESS;
1185 Bitmap* pBitmap = null;
1186 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1194 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1195 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1196 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1198 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1199 if (pNotification != null)
1201 pNotification->SetText(message);
1202 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1203 pNotification->ShowNotification();
1208 String title=__pWindowInfo->pageTitle;
1209 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1210 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1212 pBookmark->SetBookmarkTitle(title);
1213 pBookmark->SetUrl(url);
1214 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1215 pBookmark->SetFaviconId(id);
1216 r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1219 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1220 if(pNotification != null)
1222 pNotification->SetText(message);
1223 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1224 pNotification->ShowNotification();
1225 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1228 if (pBitmap != null)
1230 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1234 __pMenu->Invalidate(true);
1238 case IDA_SHARE_CLICKED:
1240 if(__pPopUp != null)
1245 __pPopUp = new(std::nothrow) SharePopup();
1246 __pPopUp->Initialize();
1247 if (__pWindowInfo != null)
1249 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1250 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1251 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1252 pShareInfo->SetImageAttached(false);
1253 __pPopUp->RemoveAllShareInfo();
1254 __pPopUp->AddShareInfo(pShareInfo);
1256 __pPopUp->SetShowState(true);
1260 case IDA_BOOKMARKBTN_CLICKED:
1262 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1263 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1266 case IDA_MOREBTN_CLICKED:
1268 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1269 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1270 AppLog("Anchot pos: %d %d", p.x, p.y);
1272 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1274 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1275 int bookmarkCount=0;
1278 url=__pWindowInfo->pageUrl;
1279 result r = E_SUCCESS;
1280 Bitmap* pBitmap = null;
1282 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1285 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1290 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1294 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1296 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1298 if (__pMenu->GetItemCount() == 6)
1300 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1304 r = __pMenu->InsertItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1309 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1313 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1314 if (__pMenu->GetItemCount() != 6)
1316 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1317 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1318 __pMenu->SetMaxVisibleItemsCount(6);
1320 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1322 AppLog(" Orientation landscape");
1323 __pMenu->SetMaxVisibleItemsCount(5);
1327 AppLog(" Orientation potrait");
1328 __pMenu->SetMaxVisibleItemsCount(6);
1331 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1334 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1335 __pMenu->SetShowState(true);
1336 __pMenu->Invalidate(true);
1342 case IDA_MULTIWINDOWBTN_CLICKED:
1344 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1345 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1349 case IDA_NEWWINDOWBTN_CLICKED:
1351 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1353 if (pNewWindowInfo == null)
1357 result r = E_SUCCESS;
1358 SceneManager* pSceneManager = SceneManager::GetInstance();
1360 if (pSceneManager == NULL)
1364 ArrayList* pArgList = new(std::nothrow) ArrayList();
1365 if (pArgList == NULL)
1369 r = pArgList->Construct();
1372 pArgList->Add(*pNewWindowInfo);
1373 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1379 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1384 case IDA_SMALLFONT_BTN_CLICKED:
1386 WebSetting setting = __pWebReader->GetSetting();
1387 setting.SetFontSize(15);
1388 __pWebReader->SetSetting(setting);
1391 case IDA_LARGEFONT_BTN_CLICKED:
1393 WebSetting setting = __pWebReader->GetSetting();
1394 setting.SetFontSize(25);
1395 __pWebReader->SetSetting(setting);
1398 case IDA_READER_CLOSE_CLICKED:
1400 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1402 //__pArticleReaderPanel->SetShowState(false);
1403 //__pArticleReaderPanel->Show();
1404 RemoveControl(*__pBlankPanel);
1405 //RemoveControl(*__pArticleReaderPanel);
1406 __pArticleReaderPanel = null;
1407 __pBlankPanel = null;
1408 __pArticleReaderLabel = null;
1411 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1414 case IDA_FINDWORD_CANCEL_CLICKED:
1416 __currentSearchStr = L"";
1417 __currentWordIndex = 0;
1418 __maxOccurrances = 0;
1419 __pFindWordCountLabel->SetText(L" ");
1420 __pFindWordEditField->SetText(L"");
1421 __pFindWordNext->SetEnabled(false);
1422 __pFindWordPrev->SetEnabled(false);
1423 __pFindWordCountLabel->SetShowState(false);
1424 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1425 ShowFindWordPanel(false);
1428 case IDA_FINDWORD_SEARCH_CLICKED:
1430 __currentSearchStr = __pFindWordEditField->GetText();
1431 if (__currentSearchStr.GetLength() > 0)
1437 AppLogDebug("Enter something");
1441 case IDA_FINDWORD_CLEAR_CLICKED:
1443 __pFindWordCountLabel->SetText(L"");
1444 __pFindWordCountLabel->SetShowState(false);
1445 __pFindWordEditField->SetText(L"");
1446 __pFindWordNext->SetEnabled(false);
1447 __pFindWordPrev->SetEnabled(false);
1448 __pFindWordPanel->Invalidate(true);
1451 case IDA_FINDWORD_NEXT_CLICKED:
1456 case IDA_FINDWORD_PREV_CLICKED:
1458 FindNextWord(false);
1461 case IDA_BRIGHTNESS_BTN_CLICKED:
1463 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1464 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1467 case IDA_COPY_IMAGE_CLICKED:
1469 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1470 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1472 const Bitmap* pBitmap = null;
1473 if (__pHitElementResult != null)
1475 pBitmap = __pHitElementResult->GetImage();
1478 String resourcePath = App::GetInstance()->GetAppResourcePath();
1479 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1481 // copying the item to clipboard
1482 Clipboard* pClipboard = Clipboard::GetInstance();
1483 if (pClipboard != null)
1485 pClipboard->CopyItem(item);
1489 case IDA_VIEW_IMAGE_CLICKED:
1491 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1492 WindowInfo* pNewWindowInfo = null;
1493 if (__pHitElementResult != null)
1495 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1496 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1502 case IDA_SAVE_IMAGE_CLICKED:
1504 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1505 const Bitmap* pSaveBitmap = null;
1506 String imageName = GetImagePath();
1507 AppLog("Content manager image name %ls",imageName.GetPointer());
1510 imagePath.Append(imageName);
1511 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1512 AppLog("Content manager image path %ls",imagePath.GetPointer());
1513 if (__pHitElementResult != null)
1515 pSaveBitmap = __pHitElementResult->GetImage();
1517 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1521 UpdateImageContent(pBuffer, imageName);
1523 NotificationPanel *pNotification = new NotificationPanel(*this);
1525 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1526 msg.Append(imagePath);
1527 if (pNotification != null)
1529 pNotification->SetText(msg);
1530 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1531 pNotification->ShowNotification();
1536 int __modalMsgBoxResult;
1537 MessageBox* pMsgBox = new MessageBox();
1538 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1539 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1542 __modalMsgBoxResult = 0;
1546 case IDA_SHARE_IMAGE_CLICKED:
1548 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1549 if (__pPopUp != null)
1554 __pPopUp = new(std::nothrow) SharePopup();
1555 __pPopUp->Initialize();
1556 if (__pHitElementResult != null)
1558 const Bitmap* pSaveBitmap = null;
1559 String imageName = GetImagePath();
1560 AppLog("Content manager image name %ls",imageName.GetPointer());
1563 imagePath.Append(imageName);
1564 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1565 AppLog("Content manager image path %ls",imagePath.GetPointer());
1566 if (__pHitElementResult != null)
1568 pSaveBitmap = __pHitElementResult->GetImage();
1570 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1572 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1573 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1575 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1576 pShareInfo->SetPageTitle(L"");
1577 pShareInfo->SetPageUrl(srcUrl);
1578 pShareInfo->SetImageAttached(true);
1579 pShareInfo->SetImagePath(imagePath);
1580 __pPopUp->RemoveAllShareInfo();
1581 __pPopUp->AddShareInfo(pShareInfo);
1582 __pPopUp->SetShowState(true);
1587 case IDA_FIND_TEXT__CLICKED:
1589 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1590 __currentSearchStr.Clear();
1591 __currentSearchStr.Append(__currentSelectedStr);
1592 InitFindWordPanel();
1595 __pMenu->SetShowState(false);
1596 __pMenu->Invalidate(false);
1599 __adressPanelPosition.y = 0;
1601 if (__pAddressbar != null && __pWebViewer != NULL)
1603 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1604 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1605 __pAddressbar->Invalidate(true);
1606 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1607 __pWebViewer->Invalidate(true);
1610 ShowFindWordPanel(true);
1611 if (__currentSearchStr.GetLength() > 0)
1617 AppLogDebug("Enter something");
1622 case IDA_SHARE_TEXT_CLICKED:
1624 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1625 if(__pPopUp != null)
1630 __pPopUp = new(std::nothrow) SharePopup();
1631 __pPopUp->Initialize();
1632 if (__pHitElementResult != null)
1634 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1635 pShareInfo->SetPageTitle(L"");
1636 pShareInfo->SetPageUrl(__currentSelectedStr);
1637 pShareInfo->SetImageAttached(false);
1638 __pPopUp->RemoveAllShareInfo();
1639 __pPopUp->AddShareInfo(pShareInfo);
1640 __pPopUp->SetShowState(true);
1645 case IDA_COPY_TEXT_CLICKED:
1647 // need to implement
1648 //__currentSelectedStr
1649 // Sets data to a clip board item
1651 String resourcePath = App::GetInstance()->GetAppResourcePath();
1652 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1654 // copying the item to clipboard
1655 Clipboard* pClipboard = Clipboard::GetInstance();
1656 if (pClipboard != null)
1658 pClipboard->CopyItem(item);
1662 case IDA_PASTE_TEXT_CLICKED:
1664 Clipboard* pClipboard = Clipboard::GetInstance();
1666 if(pClipboard == null)
1670 // Retrieves a latest item
1671 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1677 //Gets data from the clipboard item
1678 String* pString = dynamic_cast<String*>(pItem->GetData());
1680 if (pString != null)
1682 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1683 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1684 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; } } insertAtCursor(";
1685 script.Append(idElement);
1687 script.Append("\"");
1688 script.Append(*pString);
1689 script.Append("\");");
1690 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1691 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1703 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1706 UiApp* pApp = UiApp::GetInstance();
1715 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1716 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1718 String* pSelectedScene = NULL;
1719 Object* pValue = NULL;
1720 String* pUrl = null;
1721 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1722 pSelectedScene = (String*) pValue;
1724 if (pSelectedScene != null)
1726 delete pSelectedScene;
1728 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1729 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1730 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1731 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1733 // setting the current scene ID
1734 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1736 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1738 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1740 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1741 // if(__pWindowInfo == null)
1743 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1746 else if ( pArgs != null && pArgs->GetCount() == 1)
1748 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1754 if(__pWebViewer != null)
1756 __pWebViewer->Resume();
1759 if(pUrl != null && pUrl->GetLength() > 0)
1763 else if(__pWindowInfo != null)
1765 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)
1767 LoadUrl(__pWindowInfo->pageUrl);
1769 else if (__pWindowInfo->isJavascriptInitiated == true)
1773 __pWindowInfo->pCurrentWeb = __pWebViewer;
1777 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
1778 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
1779 if(homePage.CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
1781 InitMostVisitedSitesView(GetOrientationStatus());
1784 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
1786 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
1788 if (pBookmarkUrl == null)
1790 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
1791 __pAddressbar->SetUrl(*pBookmarkUrl);
1793 if (__pWebViewer != null && homePage.CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_BLANK_PAGE")) != 0)
1794 __pWebViewer->LoadUrl(*pBookmarkUrl);
1795 delete pBookmarkUrl;
1798 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1799 Bitmap* pBitmap = null;
1800 if (isPrivateBrowsing == true)
1802 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1804 if (__pWebViewer != null)
1806 __pWebViewer->SetPrivateBrowsingEnabled(true);
1809 if (__pAddressbar != null)
1811 __pAddressbar->UpdateFaviconBitmap(true);
1817 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1819 if (__pWebViewer != null)
1821 __pWebViewer->SetPrivateBrowsingEnabled(false);
1824 if (__pAddressbar != null)
1826 __pAddressbar->UpdateFaviconBitmap(false);
1830 if (__pMenu != null && __pMenu->GetItemCount() == 3)
1832 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1834 else if (__pMenu != null )
1836 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1839 if (pBitmap != null)
1844 AppLog("ABC: OnSceneActivatedN started exit");
1849 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
1850 const Tizen::Ui::Scenes::SceneId& nextSceneId)
1852 Canvas* pWebCanvas = null;
1853 if (__pWebViewer != null)
1855 pWebCanvas = __pWebViewer->GetCanvasN();
1856 __pWebViewer->Pause();
1859 if (pWebCanvas == null)
1863 if (__pWindowInfo != null)
1865 if (__pWindowInfo->pWebCanvasBitmap != null)
1867 delete __pWindowInfo->pWebCanvasBitmap;
1869 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
1870 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
1871 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
1873 Bitmap* pBitmap = GetCapturedBitmapN();
1874 AppLog("Coming here");
1875 Canvas* pCanvas = new(std::nothrow) Canvas();
1876 pCanvas->Construct(GetClientAreaBounds());
1879 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
1882 if(__pWebViewer != null && __pWindowInfo != null)
1883 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
1885 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
1886 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
1888 AppLog("Coming here");
1892 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
1893 const Tizen::Base::String& realm,
1894 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
1900 MainForm::OnHttpAuthenticationCanceled(void)
1905 MainForm::OnLoadingStarted(void)
1907 AppLogDebug("MainForm::OnLoadingStarted entered");
1909 if(__pAddressbar == NULL)
1913 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
1914 __pAddressbar->SetFaviconBitmap(*pBitmap);
1916 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
1918 // updating the address bar position with respect to web control
1919 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
1920 __distanceMoved = 0;
1924 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
1927 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
1928 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
1929 if (__pWindowInfo != NULL)
1931 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
1933 __pAddressbar->Invalidate(true);
1939 MainForm::OnLoadingCanceled(void)
1946 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
1948 if(__pAddressbar != null)
1950 OnAddressBarKeypadOpened(*__pAddressbar);
1955 MainForm::OnKeypadClosed(Tizen::Ui::Control& source){
1956 if(__pAddressbar != null)
1958 OnAddressBarKeypadClosed(*__pAddressbar);
1963 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
1964 const Tizen::Base::String& reason)
1966 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
1970 MainForm::OnLoadingCompleted(void)
1973 result r = E_SUCCESS;
1975 if (__pWebViewer == null)
1980 if (__pAddressbar == null)
1984 if (__pWebViewer->CanGoForward())
1986 __pAddressbar->SetForwardButtonEnabled(true);
1990 __pAddressbar->SetForwardButtonEnabled(false);
1993 if (__pWebViewer->CanGoBack())
1995 __pAddressbar->SetBackButtonEnabled(true);
1999 __pAddressbar->SetBackButtonEnabled(false);
2001 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2003 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2005 __pAddressbar->UpdateProgress(0);
2008 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2009 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2010 if (isPrivateBrowsing == false)
2012 History* pHistory = new(std::nothrow) History;
2014 HistoryPresentationModel::GetCurrentDateTime(date);
2017 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2018 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2020 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2021 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2023 pHistory->SetVisitedTime(date);
2026 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2027 pHistory->SetFaviconId(id);
2028 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2029 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2030 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2032 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2033 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2034 pHistory->SetThumbnail(pBitmap);
2036 HistoryPresentationModel::GetInstance()->SaveHistory(*pHistory);
2043 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2045 // temperary fixed (webpage can be not loaded)
2051 MainForm::OnEstimatedProgress(int progress)
2053 AppLogDebug("MainForm::OnEstimatedProgress entered");
2054 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2055 progress = DEFAULT_PROGRESS_PERCENTAGE;
2057 __pAddressbar->UpdateProgress(progress);
2061 MainForm::OnUrlSubmitted(Addressbar& addBar)
2063 String url = addBar.GetUrl();
2065 __pFooterPanel->SetShowState(true);
2066 __pFooterPanel->Invalidate(true);
2067 RequestRedraw(true);
2071 MainForm::LoadUrl(String& url)
2073 AppLogDebug("MainForm::LoadUrl enter");
2075 if (url.CompareTo(L"") == 0)
2079 if(__pFooterPanel != null)
2081 __pFooterPanel->SetShowState(true);
2082 __pFooterPanel->Invalidate(true);
2089 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2090 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)
2092 RegularExpression firstRegex;
2093 RegularExpression secondRegex;
2095 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2096 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2099 ret = firstRegex.Match(url, false); // This returns true value
2100 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2102 if (ret == true && __pWebViewer != null)
2104 __pWebViewer->LoadUrl(url);
2106 else if(__pWebViewer != null)
2108 String tempUrl = L"http://";
2109 tempUrl.Append(url);
2113 __pWebViewer->LoadUrl(tempUrl);
2117 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(url));
2120 if (__pAddressbar != null)
2122 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2125 AppLogDebug("MainForm::LoadUrl exit");
2132 MainForm::OnStopClicked(Addressbar& addBar)
2134 AppLogDebug("MainForm::OnStopClicked called");
2137 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2138 __pWebViewer->StopLoading();
2139 RequestRedraw(true);
2144 MainForm::OnReaderClicked(const Addressbar& addBar)
2146 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2148 CreateReaderPanel();
2149 AppLogDebug("MainScene::OnReaderClicked entered");
2152 /*if (__pArticleReaderPanel)
2154 AppLogDebug("showstate true for reader panel");
2155 __pArticleReaderPanel->SetShowState(true);
2156 __pArticleReaderPanel->Show();
2158 int xPos = __pArticleReaderPanel->GetX();
2159 int yPos = __pArticleReaderPanel->GetY();
2160 AppLog("OnReaderClicked() xPos = %d",xPos);
2161 AppLog("OnReaderClicked() yPos = %d",yPos);
2163 if (__pReaderData == null)
2168 String loadData = L"<html>\
2170 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2175 background-color: transparent;\
2194 <body style='width:'";
2195 loadData.Append(bodyWidth);
2196 loadData.Append(L"px'>");
2197 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2198 loadData.Append(*__pReaderData);
2199 loadData.Append(L"</body></html>");
2202 buf.Construct(loadData.GetLength());
2203 AppLogDebug("data->GetLength %d",loadData.GetLength());
2204 for (int z=0;z<loadData.GetLength();z++)
2207 loadData.GetCharAt(z,b);
2208 buf.SetByte((byte)b);
2212 if (__pWebReader != null)
2214 __pWebReader->LoadData(L"",buf,L"text/html");
2215 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2219 AppLogDebug("cannot LoadData __pWebReader is null");
2225 MainForm::OnBackClicked(const Addressbar& addBar)
2227 if (__pWebViewer == null)
2230 if (__pWebViewer->CanGoBack())
2232 __pWebViewer->GoBack();
2238 MainForm::OnForwardClicked(const Addressbar& addBar)
2240 if (__pWebViewer == null)
2243 if (__pWebViewer->CanGoForward())
2245 __pWebViewer->GoForward();
2250 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2252 __pFooterPanel->SetShowState(true);
2253 __pFooterPanel->Invalidate(false);
2257 MainForm::OnAddressBarModeChanged(const Addressbar& addBar)
2259 __prevAddressBarMode = __curAddressBarMode;
2261 if (__pAddressbar != null)
2263 __curAddressBarMode = __pAddressbar->GetAddressbarMode();
2266 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2268 __adressPanelPosition.y = 0;
2269 if (__pAddressbar != null)
2271 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2272 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2273 __pAddressbar->Invalidate(true);
2275 if (__pWebViewer != null)
2277 __pWebViewer->StopLoading();
2282 if (__pWebViewer != null)
2284 if(__pFooterPanel->GetShowState() == false)
2285 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2287 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2288 __pWebViewer->Invalidate(true);
2293 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar)
2296 if(__pFooterPanel != null)
2298 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2299 if (homePage.CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2301 InitMostVisitedSitesView(GetOrientationStatus());
2303 __pFooterPanel->SetShowState(true);
2304 __pFooterPanel->Invalidate(false);
2309 //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");
2311 if (__pWebViewer != null && __pFooterPanel != null)
2313 AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2314 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2316 if(__pFooterPanel->GetShowState() == false)
2317 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2319 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2320 __pWebViewer->Invalidate(false);
2321 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2327 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2329 __pFooterPanel->SetShowState(false);
2330 __pFooterPanel->Invalidate(false);
2334 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2336 __pFooterPanel->SetShowState(false);
2337 __pFooterPanel->Invalidate(false);
2341 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2345 __pWindowInfo->pageTitle = title;
2346 if (__pWebViewer != null)
2348 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2351 if (__pAddressbar != null && __pWebViewer != null)
2353 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2354 __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2355 __pAddressbar->Invalidate(true);
2361 MainForm::UpdateFavicon(void)
2363 bool urlImageType = false;
2364 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();");
2365 Bitmap* pBitmap = null;
2367 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2369 if (__pWindowInfo != null)
2372 url.SetUri(*tempPath);
2373 if (url.GetHost().GetLength() == 0)
2376 webUrl.SetUri(__pWebViewer->GetUrl());
2377 result r = url.SetHost(webUrl.GetHost());
2384 if (url.GetScheme().GetLength() == 0)
2387 webUrl.SetUri(__pWebViewer->GetUrl());
2388 url.SetScheme(webUrl.GetScheme());
2390 __pWindowInfo->faviconUrl = url.ToString();
2392 pBitmap = __pWebViewer->GetFaviconN();
2394 if (pBitmap != null)
2396 if (__pWindowInfo->pFavicon != NULL)
2398 // delete __pWindowInfo->pFavicon;
2399 __pWindowInfo->pFavicon = null;
2401 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2402 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2403 //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();
2405 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2407 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2409 else if(__pWindowInfo->pFavicon != null)
2411 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2415 __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());
2418 AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());
2425 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2432 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2433 Tizen::Web::Controls::WebNavigationType type)
2435 if (__pWebViewer && __pAddressbar)
2437 AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2438 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2439 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2443 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2444 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2445 __pWindowInfo->faviconUrl = "";
2446 __pWindowInfo->faviconFilePath = "";
2448 if (__pWindowInfo->pFavicon != NULL)
2450 // delete __pWindowInfo->pFavicon;
2451 __pWindowInfo->pFavicon = null ;
2453 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2457 __pAddressbar->Invalidate(true);
2463 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2464 const Tizen::Net::Http::HttpHeader& httpHeader)
2466 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2471 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2473 AppLog("MainForm::OnWebPageBlockSelected");
2475 if (__pHitElementResult != null)
2477 delete __pHitElementResult;
2478 __pHitElementResult = null;
2481 if (__pWebViewer != null)
2483 AppLog("MainForm::OnWebPageBlockSelected web not null");
2484 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
2487 if (__pHitElementResult == null)
2492 if (__pHitElementResult->HasImage() != true)
2494 String tagName = __pHitElementResult->GetTagName();
2495 String type = __pHitElementResult->GetAttributeValue("type");
2497 __currentSelectedStr.Clear();
2498 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2500 if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)
2502 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2504 InitSelectTextContextMenu(startPoint,true);
2505 __pImageMenu->SetShowState(true);
2506 __pImageMenu->Show();
2507 __pImageMenu->Invalidate(true);
2509 else if (__pHitElementResult->HasUrl() == true || __currentSelectedStr.GetLength() > 0)
2511 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2513 if(__pHitElementResult->GetUrl().GetLength() > 0)
2515 __currentSelectedStr.Clear();
2516 __currentSelectedStr = __pHitElementResult->GetUrl();
2518 InitSelectTextContextMenu(startPoint,false);
2519 __pImageMenu->SetShowState(true);
2520 __pImageMenu->Show();
2521 __pImageMenu->Invalidate(true);
2524 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2525 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2526 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2531 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2537 MainForm::OnWebWindowCreateRequested(void)
2539 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
2541 if (pNewWindowInfo == null)
2545 result r = E_SUCCESS;
2546 SceneManager* pSceneManager = SceneManager::GetInstance();
2547 if (pSceneManager == NULL)
2551 ArrayList* pArgList = new(std::nothrow) ArrayList();
2552 if (pArgList == NULL)
2556 r = pArgList->Construct();
2559 pNewWindowInfo->isJavascriptInitiated = true;
2560 pArgList->Add(*pNewWindowInfo);
2561 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2565 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
2572 return pNewWindowInfo->pCurrentWeb;
2576 MainForm::RelayoutControls(bool showAddressbar)
2578 if (showAddressbar == false)
2580 __pAddressbar->SetShowState(false);
2581 __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);
2582 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
2586 __pAddressbar->SetShowState(true);
2587 __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);
2588 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
2590 RequestRedraw(true);
2593 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
2595 if (__pFindWordPanel == null)
2601 InitFindWordPanel();
2602 __pFindWordEditField->SetText(__currentSearchStr);
2603 //__pFindWordCountLabel->SetText(L"");
2604 __pFindWordCountLabel->SetShowState(false);
2608 AppLog("MainForm::ShowFindWordPanel %d",show);
2609 if (show && !isTouchPressed)
2611 if (__pFindWordEditField)
2612 __pFindWordEditField->ShowKeypad();
2616 if (__pFindWordEditField)
2617 __pFindWordEditField->HideKeypad();
2620 if (__pAddressbar != null)
2622 __pAddressbar->SetShowState(!show);
2623 __pAddressbar->Invalidate(true);
2625 if (__pFindWordPanel != null)
2627 __pFindWordPanel->SetShowState(show);
2628 __pFindWordPanel->Invalidate(true);
2634 MainForm::StartWordSearch()
2636 //Get the count of occurances of the word in the current page
2637 __maxOccurrances = 0;
2638 __currentWordIndex = 0;
2640 __pFindWordPrev->SetEnabled(false);
2641 String *pCountStr = null;
2642 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
2643 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
2644 if (pCountStr != null)
2646 Integer::Parse(*pCountStr, 10, __maxOccurrances);
2650 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
2655 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
2657 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
2658 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
2660 if(totalCount == -1 || totalCount == 0)
2665 __maxOccurrances = totalCount;
2666 __currentWordIndex = currentOrdinal;
2668 //Reset the UI controls as per the maxOccurrance value
2669 if (totalCount <= 0)
2671 AppLog("Word not found");
2672 //Show error notification to user
2673 __pFindWordNext->SetEnabled(false);
2674 __pFindWordCountLabel->SetText(L"");
2675 __pFindWordNext->Invalidate(false);
2676 __pFindWordPrev->Invalidate(false);
2677 __pFindWordCountLabel->Invalidate(false);
2681 if (totalCount == 1)
2683 __pFindWordNext->SetEnabled(false);
2687 __pFindWordNext->SetEnabled(true);
2690 String countStr = L"";
2691 countStr.Append(__currentWordIndex);
2692 countStr.Append(L"/");
2693 countStr.Append(__maxOccurrances);
2694 __pFindWordCountLabel->SetText(countStr);
2695 __pFindWordCountLabel->SetShowState(true);
2696 __pFindWordCountLabel->Invalidate(false);
2698 //FindNextWord(true);
2699 //Update the controls
2700 __pFindWordNext->Invalidate(false);
2701 __pFindWordPrev->Invalidate(false);
2702 __pFindWordCountLabel->Invalidate(false);
2706 MainForm::FindNextWord(bool next)
2710 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
2712 if(__currentWordIndex < __maxOccurrances)
2714 __currentWordIndex++;
2720 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
2722 if(__currentWordIndex > 0)
2724 __currentWordIndex--;
2729 String countStr = L"";
2730 countStr.Append(__currentWordIndex);
2731 countStr.Append(L"/");
2732 countStr.Append(__maxOccurrances);
2733 __pFindWordCountLabel->SetText(countStr);
2734 __pFindWordCountLabel->SetShowState(true);
2735 __pFindWordCountLabel->Invalidate(false);
2736 if (__currentWordIndex >= __maxOccurrances)
2738 __pFindWordNext->SetEnabled(false);
2742 __pFindWordNext->SetEnabled(true);
2744 if (__currentWordIndex <= 0)
2746 __pFindWordPrev->SetEnabled(false);
2750 __pFindWordPrev->SetEnabled(true);
2752 __pFindWordPrev->Invalidate(false);
2753 __pFindWordNext->Invalidate(false);
2754 __pFindWordCountLabel->Invalidate(false);
2755 __pFindWordPanel->Invalidate(true);
2758 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
2760 OnAddressBarKeypadOpened(*__pAddressbar);
2764 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
2767 if (__pWebViewer != null && __pFooterPanel != null)
2769 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2770 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2772 if(__pFooterPanel->GetShowState() == false)
2773 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2775 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2777 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2782 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
2784 OnAddressBarKeypadClosed(*__pAddressbar);
2788 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
2790 Control* temp = const_cast< Control* >(&source);
2791 Header* pHeader = dynamic_cast< Header* >(temp);
2792 if (pHeader != null)
2794 //Header double - clicked
2795 AppLog("Header double clicked");
2797 if(__pFindWordPanel)
2799 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
2800 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
2804 AppLog("MainScene::OnTouchDoublePressed");
2805 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2806 if (isReaderEnabled == true)
2810 delete __pReaderData;
2811 __pReaderData = null;
2813 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2814 filePath.Append(L"data/reader.js");
2820 result r = E_SUCCESS;
2821 FileAttributes attr;
2823 File::GetAttributes(filePath,attr);
2825 r = file.Construct(filePath, L"r+");
2828 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2831 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2834 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2837 file.Read(pScript,attr.GetFileSize());
2839 AppLogDebug("scipt length %d",strlen(pScript));
2840 String strScript = L"";
2841 strScript.Append(pScript);
2842 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
2845 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2848 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2849 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2851 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2857 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2859 AppLog("MainForm::OnTouchLongPressed");
2861 if (__pHitElementResult != null)
2863 delete __pHitElementResult;
2864 __pHitElementResult = null;
2867 if (__pWebViewer != null)
2869 AppLog("MainForm::OnTouchLongPressed web not null");
2870 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
2873 if (__pHitElementResult == null)
2878 if (__pHitElementResult->HasImage() == true)
2880 InitImageContextMenu(currentPosition);
2881 __pImageMenu->SetShowState(true);
2882 __pImageMenu->Show();
2883 __pImageMenu->Invalidate(true);
2887 String tagName = __pHitElementResult->GetTagName();
2888 String type = __pHitElementResult->GetAttributeValue("type");
2889 String value = __pHitElementResult->GetAttributeValue(L"value");
2890 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
2892 __currentSelectedStr.Clear();
2893 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2895 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
2897 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2899 InitSelectTextContextMenu(currentPosition,true, true);
2900 __pImageMenu->SetShowState(true);
2901 __pImageMenu->Show();
2902 __pImageMenu->Invalidate(true);
2904 __pWebViewer->SetBlockSelectionPosition(currentPosition);
2907 __inputEventToBeSupressed = true;
2911 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
2913 AppLog("MainForm::OnTouchReleased");
2915 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
2916 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
2918 __pWebViewer->ConsumeInputEvent();
2921 __inputEventToBeSupressed = false;
2925 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
2927 int widthContextItem = 0;
2928 int heightContextItem = 72;
2931 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
2933 widthContextItem = 800;
2937 widthContextItem = 336;
2940 if( __pItemContext != NULL)
2942 delete __pItemContext;
2943 __pItemContext = null;
2946 __pItemContext= new(std::nothrow) ListContextItem();
2947 __pItemContext->Construct();
2948 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", widthContextItem,heightContextItem);
2949 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", widthContextItem, heightContextItem);
2951 if (pBitmapNormal != null && pBitmapPressed != null)
2953 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
2956 if (pBitmapNormal != null)
2958 delete pBitmapNormal;
2961 if (pBitmapPressed != null)
2963 delete pBitmapPressed;
2967 if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
2969 __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());
2970 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
2971 __pFindWordControl->SetShowState(true);
2972 __pFindWordControl->Invalidate(true);
2973 __pFindWordPanel->SetShowState(true);
2974 __pFindWordPanel->Invalidate(true);
2977 if (__pWebViewer != null && __pFooterPanel != null)
2979 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2980 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
2982 if(__pFooterPanel->GetShowState() == false)
2983 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height));
2985 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2987 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2989 if (__pAddressbar != null)
2991 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2992 __pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());
2993 __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2995 if (__pFindWordBgLabel != null)
2997 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
2998 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
2999 if (pBitmap != null)
3001 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3005 if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)
3007 AppLog("__pFooterPanel->GetShowState() is true");
3012 if(__pMoreButton && __pMenu)
3014 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3015 __pMenu->SetAnchorPosition(p);
3016 __pMenu->Invalidate(true);
3021 __pFooterPanel->Invalidate(true);
3023 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3024 if (homePage.CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3026 InitMostVisitedSitesView(orientationStatus);
3029 AppLog("OnOrientationChanged 0");
3030 if (__pArticleReaderPanel != null)
3033 if (__pArticleReaderPanel->GetShowState() == true)
3035 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3037 if (__pBlankPanel != null)
3038 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3040 if (__pWebReader != null)
3042 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3044 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3045 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3047 if ( pBitmap != null && pSrcBitmap != null)
3049 AppLog("CreateReaderPanel ninepatchbitmap found");
3050 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3053 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3054 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3055 if (pBitmap != null)
3060 if (pSrcBitmap != null)
3068 if(__pAddressbar != null)
3070 __pAddressbar->OrientationChanged();
3075 MainForm::OnSettingsChange(int settingvalue)
3077 AppLogDebug("MainForm::OnSettingsChange entered");
3078 if (__pWebViewer == null)
3080 AppLogDebug("Webviewer is not initialized yet.");
3083 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3085 WebSetting settings = __pWebViewer->GetSetting();
3086 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3088 settings.SetAutoFittingEnabled(true);
3090 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3092 settings.SetAutoFittingEnabled(false);
3094 __pWebViewer->SetSetting(settings);
3096 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3098 WebSetting settings = __pWebViewer->GetSetting();
3099 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3100 __pWebViewer->SetSetting(settings);
3102 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3104 WebSetting settings = __pWebViewer->GetSetting();
3105 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3106 __pWebViewer->SetSetting(settings);
3108 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3110 WebSetting settings = __pWebViewer->GetSetting();
3111 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3112 __pWebViewer->SetSetting(settings);
3114 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3118 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3122 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3124 WebSetting settings = __pWebViewer->GetSetting();
3125 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3127 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3131 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3133 __pWebViewer->SetSetting(settings);
3135 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3139 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3140 WebSetting settings = __pWebReader->GetSetting();
3141 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3142 __pWebReader->SetSetting(settings);
3148 MainForm::OnSettingsReset()
3152 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3153 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3158 MainForm::OnClearCache()
3160 result r = E_SUCCESS;
3162 if (__pWebViewer != NULL)
3164 r = __pWebViewer->ClearCache();
3167 AppLogDebug("Cache cleared success");
3171 AppLogDebug("Cache cleared fail");
3177 MainForm::OnClearCookie()
3179 result r = E_SUCCESS;
3181 if (__pWebViewer != NULL)
3183 __pWebViewer->ClearCookie();
3187 AppLogDebug("Cookie cleared success");
3191 AppLogDebug("Cache cleared fail");
3196 MainForm::findDistance(int x1,int y1,int x2, int y2)
3198 int deltaX = Math::Abs(x2 - x1);
3199 int deltaY = Math::Abs(y2 - y1);
3200 double num = deltaX*deltaX + deltaY*deltaY;
3206 for (i = 0; i < 20; i++)
3208 x = (((x*x)+ num)/(2*x));
3219 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3221 if(__pFindWordPanel)
3223 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3224 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3227 if (__pFindWordEditField != null)
3229 // __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3230 // __pFindWordEditField->HideKeypad();
3234 IList* pList = null;
3235 pList = touch.GetTouchInfoListN(source);
3239 int count = pList->GetCount();
3242 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3243 __touchPoint1 = pTouchInfo->position;
3245 if (__pAddressbar != null)
3247 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3249 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3251 __pAddressbar->SaveAddressbarEditText();
3253 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3256 __pAddressbar->Invalidate(true);
3259 else if (count == 2)
3261 AppLogDebug("MainForm::OnTouchPressed count is two");
3262 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3263 __touchPoint1 = pTouchInfo->position;
3265 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3266 __touchPoint2 = pTouchInfo->position;
3272 pList->RemoveAll(true);
3279 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3281 AppLog("Start MainForm::OnTouchMoved MoveUiControls");
3282 if(__pFindWordPanel)
3284 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3285 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3288 if (__pFindWordEditField != null)
3290 __pFindWordEditField->HideKeypad();
3293 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3299 IList* pList = null;
3300 pList = touch.GetTouchInfoListN(source);
3304 int count = pList->GetCount();
3307 AppLogDebug("MainForm::OnTouchMoved count 1");
3308 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3310 if( pTouchInfo == NULL )
3314 pTouchInfo->position.y += __pWebViewer->GetY();
3315 AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);
3317 if (__isLoaded == false)
3320 __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;
3321 __touchPoint1 = pTouchInfo->position;
3323 // move the address bar and web control according to distance moved
3326 else if (count == 2)
3328 AppLogDebug("MainForm::OnTouchMoved count 2");
3332 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3334 if( pTouchInfo == NULL )
3338 Point firstPoint = pTouchInfo->position;
3340 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3341 if( pTouchInfo == NULL )
3345 Point secondPoint = pTouchInfo->position;
3347 if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))
3349 __touchPoint1 = firstPoint;
3350 __touchPoint2 = secondPoint;
3355 int currX1 = firstPoint.x;
3356 int currY1 = firstPoint.y;
3357 int currX2 = secondPoint.x;
3358 int currY2 = secondPoint.y;
3360 double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);
3361 double dist = findDistance(currX1, currY1, currX2, currY2);
3362 __distanceMoved = prevDist - dist;
3364 __touchPoint1 = firstPoint;
3365 __touchPoint2 = secondPoint;
3377 MainForm::MoveUiControls()
3379 __adressPanelPosition.y = __adressPanelPosition.y + __distanceMoved;
3380 if(__pAddressbar == NULL)
3385 if (__adressPanelPosition.y > 0)
3387 __adressPanelPosition.y = 0;
3388 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3390 else if (__adressPanelPosition.y < (0-(__pAddressbar->GetHeight() - 12))) // -12 is for the progress label
3392 __adressPanelPosition.y = 0-(__pAddressbar->GetHeight() - 12);
3393 __webControlPosition.y = 0;
3394 // result r = __pWebViewer->SetScrollEnabled(true);
3395 // AppLog("letmetestscrollenabled true %s pos %d,%d",GetErrorMessage(r),__adressPanelPosition.x,__adressPanelPosition.y);
3399 // result r = __pWebViewer->SetScrollEnabled(false);
3400 // __pWebViewer->Invalidate(true);
3401 // AppLog("letmetestscrollenabled false %s pos %d,%d",GetErrorMessage(r),__adressPanelPosition.x,__adressPanelPosition.y);
3402 __webControlPosition.y = __adressPanelPosition.y + (__pAddressbar->GetHeight() - 12);
3405 AppLogDebug("__adressPanelPosition.y = %d, __webControlPosition.y = %d", __adressPanelPosition.y, __webControlPosition.y);
3407 __pAddressbar->SetBounds(0,__adressPanelPosition.y,__pAddressbar->GetWidth(),__pAddressbar->GetHeight());
3408 __pAddressbar->Invalidate(false);
3410 if (__pWebViewer != NULL)
3412 if(__pFooterPanel->GetShowState() == true)
3413 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3415 __webControlHeight = GetClientAreaBounds().height;
3416 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3417 __pWebViewer->Invalidate(false);
3422 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3424 if (__pFindWordEditField != null)
3426 __currentSearchStr = __pFindWordEditField->GetText();
3427 __pFindWordNext->SetEnabled(false);
3428 __pFindWordPrev->SetEnabled(false);
3429 __pFindWordNext->Invalidate(true);
3430 __pFindWordPrev->Invalidate(true);
3431 __pFindWordCountLabel->SetText("");
3432 __pFindWordCountLabel->SetShowState(false);
3433 __pFindWordCountLabel->Invalidate(true);
3435 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3436 if (__currentSearchStr.GetLength() > 0)
3442 AppLogDebug("Enter something");
3447 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3454 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3456 if(__pWebViewer != null)
3459 AppLog("MainForm::InitMostVisitedSitesView");
3460 result r = E_SUCCESS;
3463 if (__pWebViewer != null && __pMostVisitedListView != null)
3468 if (__pMostVisitedListView != null)
3470 RemoveControl(*__pMostVisitedListView);
3472 if(__pMostVisitedSites != null)
3474 __pMostVisitedSites->RemoveAll(true);
3477 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3479 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
3480 __pMostVisitedListView = new(std::nothrow) ListView();
3481 if(__pFooterPanel->GetShowState() == false)
3483 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);
3487 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);
3492 delete __pMostVisitedListView;
3493 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3496 __pMostVisitedListView->SetItemProvider(*this);
3497 __pMostVisitedListView->AddListViewItemEventListener(*this);
3498 // __pMostVisitedListView->SetBackgroundColor(Color(0,0,0));
3499 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3500 AddControl(*__pMostVisitedListView);
3501 AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));
3502 if(__pFooterPanel->GetShowState() == false)
3503 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));
3505 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
3507 __pMostVisitedListView->UpdateList();
3508 // __pMostVisitedSitesPanel->Invalidate(true);
3510 // Invalidate(true);
3516 MainForm::GetImagePath(void)
3520 String formattedTime;
3521 DateTime currentTime;
3522 LocaleManager localManager;
3523 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3525 localManager.Construct();
3526 Locale locale = localManager.GetSystemLocale();
3527 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3529 // Get date formatter
3530 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3534 pTimeFormatter->Format(currentTime, formattedTime);
3537 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3538 String delim(L" :");
3539 StringTokenizer strTok(formattedTime, delim);
3542 String str1("GMT+00");
3543 while (strTok.HasMoreTokens())
3545 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3546 if(token.Equals(str1))
3548 AppLog("token is %ls", token.GetPointer());
3549 imageName.Append(token);
3555 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3557 result r = E_FAILURE;
3558 AppLog("Content manager 1");
3559 ContentId contentId;
3560 ContentManager contentManager;
3561 r = contentManager.Construct();
3564 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3567 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3568 contentPath.Append(imageName);
3569 contentPath.Append(".jpg");
3570 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3571 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));