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";
68 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
69 static const wchar_t* IDS_APPID = L"AppID";
71 const int IDA_BACKBTN_CLICKED = 101;
72 const int IDA_BOOKMARKBTN_CLICKED = 102;
73 const int IDA_MOREBTN_CLICKED = 103;
74 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
75 const int IDA_NEWWINDOWBTN_CLICKED = 105;
76 const int IDA_FORWARD_CLICKED = 106;
77 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
78 const int IDA_SHARE_CLICKED = 108;
79 const int IDA_FINDONPAGE_CLICKED = 109;
80 const int IDA_PRIVATEON_CLICKED = 110;
81 const int IDA_SETTINGS_CLICKED = 111;
82 const int IDA_READER_CLOSE_CLICKED = 112;
83 const int IDA_SMALLFONT_BTN_CLICKED = 113;
84 const int IDA_LARGEFONT_BTN_CLICKED = 114;
85 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
86 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
87 const int IDA_FINDWORD_NEXT_CLICKED = 202;
88 const int IDA_FINDWORD_PREV_CLICKED = 203;
89 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
90 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
92 const int IDA_COPY_IMAGE_CLICKED = 206;
93 const int IDA_VIEW_IMAGE_CLICKED = 207;
94 const int IDA_SAVE_IMAGE_CLICKED = 208;
95 const int IDA_SHARE_IMAGE_CLICKED = 209;
97 const int IDA_COPY_TEXT_CLICKED = 210;
98 const int IDA_PASTE_TEXT_CLICKED = 211;
99 const int IDA_FIND_TEXT__CLICKED = 212;
100 const int IDA_SHARE_TEXT_CLICKED = 213;
101 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
103 const int MainForm::IDA_FORMAT_BITMAP = 500;
104 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
105 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
106 const int MainForm::IDA_FORMAT_URL_STRING = 503;
107 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
109 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
110 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
111 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
113 MainForm::MainForm(void)
115 __pAddressbar = null;
116 // __pMostVisitedSitesPanel = null;
117 __pMostVisitedListView = null;
118 __pFooterPanel = null;
119 __pHitElementResult = null;
120 __pWindowInfo = null;
124 __pFindWordControl = null;
125 __pFindWordPanel = null;
126 __pFindWordBgLabel = null;
127 __pFindWordEditField = null;
128 __pFindWordClear = null;
129 __pFindWordCountLabel = null;
130 __pFindWordNext = null;
131 __pFindWordPrev = null;
132 __previousZoomLevel = 1.0;
134 __currentSearchStr = L"";
135 __currentSelectedStr = L"";
136 __maxOccurrances = 0;
137 __currentWordIndex = 0;
140 __inputEventToBeSupressed = false;
141 __touchPoint1 = Point(-1,-1);
142 __touchPoint2 = Point(-1,-1);
144 // __pReaderPopup = null;
145 __pReaderData = null;
147 __pReaderCloseBtn = null;
148 __pNewWindowButton = null;
149 __pMoreButton = null;
150 __pMultiWindowButton = null;
151 __pArticleReaderPanel = null;
152 __pBlankPanel = null;
153 __pArticleReaderLabel = null;
154 __webControlHeight = 0;
155 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
156 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
157 __pMostVisitedSites = null;
160 MainForm::~MainForm(void)
162 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
166 __pAddressbar->SetAddressbarEventListener(null);
168 if (__pReaderData != null)
170 delete __pReaderData;
171 __pReaderData = null;
174 if (__pPopUp != null)
180 if (__pHitElementResult != null)
182 delete __pHitElementResult;
183 __pHitElementResult = null;
185 String* pSelectedScene = NULL;
186 Object* pValue = NULL;
187 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
188 pSelectedScene = (String*) pValue;
190 /*if (pSelectedScene != null)
192 delete pSelectedScene;
194 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
198 MainForm::Initialize(void)
200 Construct(L"IDL_FORM");
205 MainForm::OnInitializing(void)
207 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
208 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
210 Panel* pFooterPanel = null;
212 __pSaveImage = new Image();
213 __pSaveImage->Construct();
215 // Setup back event listener
216 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
217 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
218 AddOrientationEventListener(*this);
219 AppLogDebug(" MainForm::OnInitializing ended");
220 if (__pMostVisitedSites == null)
222 __pMostVisitedSites = new(std::nothrow) ArrayList();
223 __pMostVisitedSites->Construct();
225 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
227 __pItemContext= new(std::nothrow) ListContextItem();
228 __pItemContext->Construct();
229 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
230 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
232 if (pBitmapNormal != null && pBitmapPressed != null)
234 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
237 if (pBitmapNormal != null)
239 delete pBitmapNormal;
242 if (pBitmapPressed != null)
244 delete pBitmapPressed;
251 MainForm::InitAddressbar(void)
253 AppLogDebug("MainForm::InitAddressbar entered");
255 result r = E_SUCCESS;
257 if (__pAddressbar != null)
261 __pAddressbar = new(std::nothrow) Addressbar();
262 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
263 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
266 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
269 __pAddressbar->SetAddressbarEventListener(this);
270 AddControl(*__pAddressbar);
271 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
272 SetControlAlwaysOnTop(*__pAddressbar, true);
273 __adressPanelPosition = __pAddressbar->GetPosition();
275 AppLogDebug("MainForm::InitAddressbar exit");
281 MainForm::CreateReaderPanel(void)
283 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
284 result r = E_FAILURE;
286 Button *pSmallFontBtn = null;
287 Button *pLargeFontBtn = null;
289 __pBlankPanel = new (std::nothrow) Panel();
290 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
292 __pArticleReaderPanel = new (std::nothrow) Panel();
293 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
295 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
296 if (__pReaderCloseBtn)
298 AppLogDebug("CreateReaderPanel() 6");
299 __pReaderCloseBtn->AddActionEventListener(*this);
300 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
303 __pWebReader = new (std::nothrow) Web();
304 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
306 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
307 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
309 r = __pWebReader->SetSetting(settings);
311 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
314 __pArticleReaderLabel = new Label();
315 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
317 __pBlankPanel->AddControl(*__pArticleReaderLabel);
318 __pBlankPanel->AddControl(*__pArticleReaderPanel);
319 AddControl(*__pBlankPanel);
321 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
322 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
323 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
325 __pArticleReaderPanel->AddControl(*__pWebReader);
326 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
327 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
328 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
330 if (pBitmap != null && pSrcBitmap != null)
332 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
334 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
336 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
339 pSmallFontBtn->AddActionEventListener(*this);
340 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
343 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
346 pLargeFontBtn->AddActionEventListener(*this);
347 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
356 if (pSrcBitmap != null)
362 SetControlAlwaysOnTop(*__pBlankPanel, true);
363 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
370 MainForm::InitWebControl()
372 AppLogDebug("MainForm::InitWebControl enter");
373 result r = E_SUCCESS;
374 AppLogDebug("InitWebControl");
376 if (__pAddressbar == null || __pFooterPanel == null)
379 const int Y_WEBCONTROL_POSITION = __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12;
380 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - Y_WEBCONTROL_POSITION;
381 if (__pMostVisitedListView)
383 __pMostVisitedListView->SetShowState(false);
385 if (__pWebViewer != null)
387 AppLogDebug("Already initialized");
390 __pWebViewer = new(std::nothrow) Web();
391 if(__pWebViewer == NULL)
393 AppLogDebug("Initialization failed");
396 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight));
400 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
405 r = AddControl(*__pWebViewer);
409 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
412 __webControlPosition = __pWebViewer->GetPosition();
413 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
416 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
420 __pWebViewer->SetLoadingListener(this);
421 __pWebViewer->SetWebUiEventListener(this);
422 __pWebViewer->SetWebKeypadEventListener(this);
423 __pWebViewer->SetFocus();
424 __pWebViewer->AddTouchEventListener(*this);
426 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
427 __pWebViewer->SetTextSearchListener(this);
430 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
431 AppLogDebug("MainForm :before return");
433 AppLogDebug("MainForm::InitWebControl Exit");
439 MainForm::SetJavascriptEnabled()
441 WebSetting settings = __pWebViewer->GetSetting();
442 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
443 __pWebViewer->SetSetting(settings);
447 MainForm::SetImageLoadEnabled()
449 WebSetting settings = __pWebViewer->GetSetting();
450 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
451 __pWebViewer->SetSetting(settings);
455 MainForm::InitFooter(void)
457 AppLogDebug("MainForm::InitFooter entered");
458 Button* pBackButton = null;
459 Button* pBookmarkButton = null;
460 Button* pMultiWindowButton = null;
461 Bitmap *pIconBitmap = null;
462 Bitmap *pBGBitmap = null;
463 Label *pBGLabel = null;
465 if (__pFooterPanel == null)
467 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
470 if (__pFooterPanel == null)
475 SetControlAlwaysOnTop(*__pFooterPanel, true);
477 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
479 if ( __pMultiWindowButton == NULL )
484 pBackButton = static_cast< Button* >(GetControl(L"IDC_PAGEBACK_BUTTON", true));
486 if ( pBackButton == NULL )
491 pBookmarkButton = static_cast< Button* >(GetControl(L"IDC_BOOKMARK_BUTTON", true));
493 if ( pBookmarkButton == NULL )
498 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
500 if ( __pMoreButton == NULL )
505 __pNewWindowButton = static_cast< Button* >(GetControl(L"IDC_NEW_WINDOW",true));
507 if ( __pNewWindowButton == NULL )
512 if (__pMultiWindowButton != null)
514 Bitmap* pBitmap = null;
515 Bitmap* pPressedBitmap = null;
516 String imagePath = "I01_toolbar_icon_windows_manager_0";
517 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
518 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
519 imagePath.Append(totalCount);
520 imagePath.Append(".png");
522 pressedImagePath.Append(totalCount);
523 pressedImagePath.Append("_press.png");
525 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
526 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
527 if ( pBitmap == null )
532 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
535 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
536 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
541 __pMultiWindowButton->AddActionEventListener(*this);
542 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
548 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK);
549 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BTN_BACK_PRESS);
552 // pBitmap->Scale(Dimension(56,56));
554 Point startPoint((pBackButton->GetWidth() - pBitmap->GetWidth())/2,(pBackButton->GetHeight() - pBitmap->GetHeight())/2 );
555 AppLog("startPoint %d,%d pBitmap width height %d %d",startPoint.x,startPoint.y,pBitmap->GetWidth(),pBitmap->GetHeight());
556 pBackButton->SetNormalBitmap(startPoint, *pBitmap);
557 pBackButton->SetPressedBitmap(startPoint, *pPressedBitmap);
560 pBackButton->AddActionEventListener(*this);
561 pBackButton->SetActionId(IDA_BACKBTN_CLICKED);
566 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK);
567 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_BOOKMARK_PRESS);
570 Point startPoint((pBookmarkButton->GetWidth() - pBitmap->GetWidth())/2,(pBookmarkButton->GetHeight() - pBitmap->GetHeight())/2 );
571 pBookmarkButton->SetNormalBitmap(startPoint, *pBitmap);
572 pBookmarkButton->SetPressedBitmap(startPoint, *pPressedBitmap);
575 pBookmarkButton->AddActionEventListener(*this);
576 pBookmarkButton->SetActionId(IDA_BOOKMARKBTN_CLICKED);
581 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
582 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
585 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
586 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
587 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
591 __pMoreButton->AddActionEventListener(*this);
592 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
597 if (__pNewWindowButton)
599 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW);
600 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS);
603 Point startPoint((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
604 __pNewWindowButton->SetNormalBitmap(startPoint, *pBitmap);
605 __pNewWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
608 __pNewWindowButton->AddActionEventListener(*this);
609 __pNewWindowButton->SetActionId(IDA_NEWWINDOWBTN_CLICKED);
610 __pNewWindowButton->SetEnabled(true);
611 // __pNewWindowButton->Invalidate(true);
614 AppLog("checkingwindow count %d",MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount());
616 if (__pNewWindowButton != null && MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount() >= 9)
618 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTROLBAR_ICON_CREATE_DISABLE);
621 Point startPoint = Point((__pNewWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pNewWindowButton->GetHeight() - pBitmap->GetHeight())/2 );
622 __pNewWindowButton->SetDisabledBitmap(startPoint,*pBitmap);
625 __pNewWindowButton->SetEnabled(false);
628 // __pFooterPanel->Invalidate(true);
629 AppLogDebug("MainForm::InitFooter exit");
635 MainForm::InitContextMenu(Point& p)
637 result r = E_SUCCESS;
638 bool isPrivateBrowsing = false;
639 Bitmap* pBitmap = null;
643 __pMenu->SetAnchorPosition(p);
644 __pMenu->Invalidate(true);
648 __pMenu = new(std::nothrow) ContextMenu();
649 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST);
650 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
652 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
655 if (isPrivateBrowsing == true)
657 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
661 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
664 if ( pBitmap != NULL)
666 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
669 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
670 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
671 __pMenu->SetMaxVisibleItemsCount(3);
672 __pMenu->SetShowState(false);
673 __pMenu->AddActionEventListener(*this);
674 SetControlAlwaysOnTop(*__pMenu, true);
680 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
682 result r = E_SUCCESS;
683 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
685 AppLog("MainForm::InitImageContextMenu clicked on image");
686 if (__pImageMenu != null)
692 p.y = p.y + __pAddressbar->GetHeight() + 12;
695 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
699 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
701 __pImageMenu = new (std::nothrow) ContextMenu();
702 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
703 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
705 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
706 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
707 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
708 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
709 __pImageMenu->SetMaxVisibleItemsCount(4);
710 __pImageMenu->AddActionEventListener(*this);
711 SetControlAlwaysOnTop(*__pImageMenu, true);
716 result MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
718 result r = E_SUCCESS;
719 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
721 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
722 if (__pImageMenu != null)
727 p.y = p.y + __pAddressbar->GetHeight() + 12;
730 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
734 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
736 __pImageMenu = new (std::nothrow) ContextMenu();
737 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
738 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
740 if(onlyPasteOption == false)
742 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
744 if (pasteOption || onlyPasteOption)
746 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
748 if(onlyPasteOption == false)
750 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
751 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
754 __pImageMenu->SetMaxVisibleItemsCount(3);
755 __pImageMenu->AddActionEventListener(*this);
756 SetControlAlwaysOnTop(*__pImageMenu, true);
763 MainForm::InitFindWordPanel(void)
765 result r = E_SUCCESS;
766 Bitmap *pIconBitmap = null;
768 if (__pFindWordPanel != null)
770 AppLogDebug("Findword panel already initialized");
771 if (__pFindWordBgLabel != null)
773 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
776 AppLogDebug("InitFindWordPanel: Coming here");
777 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
784 __pFindWordPanel = static_cast<Panel*>(GetControl(L"IDC_FIND_ON_PAGE_PANEL"));
785 if (__pFindWordPanel == null)
787 AppLogException("There is some problem in the xml file. Please check.");
791 __pFindWordControl = new (std::nothrow) Panel();
792 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
795 AppLogException("There is some problem in the xml file. Please check.");
798 __pFindWordPanel->AddControl(*__pFindWordControl);
799 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
800 SetControlAlwaysOnTop(*__pFindWordPanel,true);
801 __pFindWordPanel->SetShowState(false);
802 __pFindWordPanel->Invalidate(false);
804 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
805 if (__pFindWordBgLabel != null)
807 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
808 Rectangle pRect = pPanel1->GetBounds();
809 pRect.x = pRect.y = 0;
810 __pFindWordBgLabel->SetBounds(pRect);
811 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
814 AppLogDebug("InitFindWordPanel: Coming here");
815 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
820 AppLogDebug("InitFindWordPanel: shouldn't Come here");
824 Button* pfindWordCancel = null;
825 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
826 if (pfindWordCancel == null)
828 AppLogException("There is some problem in the xml file. Please check.");
831 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
832 pfindWordCancel->AddActionEventListener(*this);
834 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
835 if (__pFindWordClear == null)
837 AppLogException("There is some problem in the xml file. Please check.");
841 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
842 __pFindWordClear->AddActionEventListener(*this);
844 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
845 if (__pFindWordNext == null)
847 AppLogException("There is some problem in the xml file. Please check.");
851 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
852 __pFindWordNext->AddActionEventListener(*this);
854 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
855 if (__pFindWordPrev == null)
857 AppLogException("There is some problem in the xml file. Please check.");
861 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
862 __pFindWordPrev->AddActionEventListener(*this);
864 __pFindWordNext->SetEnabled(false);
865 __pFindWordPrev->SetEnabled(false);
867 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
868 if (__pFindWordCountLabel == null)
870 AppLogException("There is some problem in the xml file. Please check.");
874 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
875 if (__pFindWordEditField == null)
877 AppLogException("There is some problem in the xml file. Please check.");
880 __pFindWordEditField->AddTextEventListener(*this);
881 __pFindWordEditField->AddKeypadEventListener(*this);
882 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
888 MainForm::CreateItem (int index, int itemWidth)
890 Rectangle listImageRect;
891 Rectangle pagetTitleRect;
892 Rectangle pageURLRect;
893 Rectangle deleteImageRect;
894 String pageTitle(L"");
896 result r = E_SUCCESS;
897 Bitmap* pListIconImage = null;
900 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
905 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
906 if ( pAppResource == NULL )
910 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
912 CustomItem* pItem = new(std::nothrow) CustomItem();
913 pageTitle = pHistory->GetHistoryTitle();
914 pageURL = pHistory->GetHistoryUrl();
916 if (pageURL.GetLength() == 0)
919 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
920 pageURL = L"<"+ nourl +">";
924 Rectangle screenBounds = GetBounds();
927 r = pItem->Construct(Dimension(itemWidth, 128), style);
935 if (pHistory->GetFaviconId().GetLength() > 0)
937 String bitmapId = pHistory->GetFaviconId();
938 Bitmap* pBitmap = FaviconManager::GetInstance()->GetFaviconN(bitmapId);
940 if ( pBitmap != NULL)
942 pListIconImage = new Bitmap();
943 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
948 if(pListIconImage == null)
950 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
953 if ( pListIconImage != NULL)
955 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
956 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
957 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
960 if (pItem != null && pListIconImage != NULL)
962 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
966 if (pageTitle.CompareTo(L"") != 0)
970 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
974 if (pageURL.CompareTo(L"") != 0)
978 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
983 if ( __pItemContext!= NULL)
987 pItem->SetContextItem(__pItemContext);
990 if( pListIconImage != NULL)
992 delete pListIconImage;
993 pListIconImage = null;
1000 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1007 MainForm::GetItemCount (void)
1009 if(__pMostVisitedSites != null)
1011 __pMostVisitedSites->RemoveAll(true);
1013 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1014 if(__pMostVisitedSites != null)
1016 return __pMostVisitedSites->GetCount();
1023 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1025 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1026 String url = pHistory->GetHistoryUrl();
1027 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1028 __pMostVisitedListView->UpdateList();
1032 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1034 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1035 String url = pHistory->GetHistoryUrl();
1043 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1049 MainForm::OnTerminating(void)
1051 result r = E_SUCCESS;
1054 delete __pItemContext;
1060 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1062 result r = E_SUCCESS;
1064 AppLogDebug("Clicked : %d", actionId);
1067 case IDA_BACKBTN_CLICKED:
1069 if (__pWebViewer && __pWebViewer->CanGoBack())
1071 __pWebViewer->GoBack();
1076 pApp = UiApp::GetInstance();
1079 r = pApp->Terminate();
1082 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1090 case IDA_FORWARD_CLICKED:
1091 if (__pWebViewer == null)
1094 if (__pWebViewer->CanGoForward())
1096 __pWebViewer->GoForward();
1098 __pMenu->SetShowState(false);
1099 __pMenu->Invalidate(false);
1102 case IDA_FINDONPAGE_CLICKED:
1104 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1105 __currentSearchStr.Clear();
1107 InitFindWordPanel();
1108 __pMenu->SetShowState(false);
1109 __pMenu->Invalidate(false);
1111 __adressPanelPosition.y = 0;
1113 if (__pAddressbar != null && __pWebViewer != NULL)
1115 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1116 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1117 __pAddressbar->Invalidate(true);
1118 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1119 __pWebViewer->Invalidate(true);
1121 if (__pWebViewer != null)
1123 // releasing the set block
1124 __pWebViewer->ReleaseBlock();
1126 ShowFindWordPanel(true);
1129 case IDA_PRIVATEON_CLICKED:
1131 result r = E_SUCCESS;
1133 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1134 Bitmap* pBitmap = null;
1135 if (isPrivateBrowsing == true)
1137 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1140 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1144 if (__pWebViewer != NULL)
1146 __pWebViewer->SetPrivateBrowsingEnabled(false);
1149 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1151 if (__pAddressbar != null)
1153 __pAddressbar->UpdateFaviconBitmap(false);
1159 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1162 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1166 if (__pWebViewer != NULL)
1168 __pWebViewer->SetPrivateBrowsingEnabled(true);
1171 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1173 if (__pAddressbar != null)
1175 __pAddressbar->UpdateFaviconBitmap(true);
1180 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1181 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1182 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1183 __pMenu->Invalidate(true);
1185 if ( pBitmap != NULL )
1192 case IDA_SETTINGS_CLICKED:
1195 ArrayList* pArgList = new(std::nothrow) ArrayList();
1198 pArgList->Construct();
1199 pArgList->Add(*__pWindowInfo);
1200 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1202 __pMenu->SetShowState(false);
1203 __pMenu->Invalidate(false);
1204 if (pArgList != null)
1213 case IDA_ADDTOBOOKMARK_CLICKED:
1216 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1218 int bookmarkCount=0;
1221 url=__pWindowInfo->pageUrl;
1222 result r = E_SUCCESS;
1223 Bitmap* pBitmap = null;
1224 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1232 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1233 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1234 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1236 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1237 if (pNotification != null)
1239 pNotification->SetText(message);
1240 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1241 pNotification->ShowNotification();
1246 String title=__pWindowInfo->pageTitle;
1247 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1248 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1250 pBookmark->SetBookmarkTitle(title);
1251 pBookmark->SetUrl(url);
1252 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1253 pBookmark->SetFaviconId(id);
1254 r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1257 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1258 if(pNotification != null)
1260 pNotification->SetText(message);
1261 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1262 pNotification->ShowNotification();
1263 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1266 if (pBitmap != null)
1268 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1272 __pMenu->Invalidate(true);
1276 case IDA_SHARE_CLICKED:
1278 if(__pPopUp != null)
1283 __pPopUp = new(std::nothrow) SharePopup();
1284 __pPopUp->Initialize();
1285 if (__pWindowInfo != null)
1287 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1288 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1289 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1290 pShareInfo->SetImageAttached(false);
1291 __pPopUp->RemoveAllShareInfo();
1292 __pPopUp->AddShareInfo(pShareInfo);
1294 __pPopUp->SetShowState(true);
1298 case IDA_BOOKMARKBTN_CLICKED:
1300 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1301 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1304 case IDA_MOREBTN_CLICKED:
1306 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1307 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1308 AppLog("Anchot pos: %d %d", p.x, p.y);
1310 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1312 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1313 int bookmarkCount=0;
1316 url=__pWindowInfo->pageUrl;
1317 result r = E_SUCCESS;
1318 Bitmap* pBitmap = null;
1320 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1323 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1328 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1332 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1334 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1336 if (__pMenu->GetItemCount() == 6)
1338 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1342 r = __pMenu->InsertItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1347 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1351 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1352 if (__pMenu->GetItemCount() != 6)
1354 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1355 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1356 __pMenu->SetMaxVisibleItemsCount(6);
1358 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1360 AppLog(" Orientation landscape");
1361 __pMenu->SetMaxVisibleItemsCount(5);
1365 AppLog(" Orientation potrait");
1366 __pMenu->SetMaxVisibleItemsCount(6);
1369 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1372 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1373 __pMenu->SetShowState(true);
1374 __pMenu->Invalidate(true);
1380 case IDA_MULTIWINDOWBTN_CLICKED:
1382 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1383 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1387 case IDA_NEWWINDOWBTN_CLICKED:
1389 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1391 if (pNewWindowInfo == null)
1395 result r = E_SUCCESS;
1396 SceneManager* pSceneManager = SceneManager::GetInstance();
1398 if (pSceneManager == NULL)
1402 ArrayList* pArgList = new(std::nothrow) ArrayList();
1403 if (pArgList == NULL)
1407 r = pArgList->Construct();
1410 pArgList->Add(*pNewWindowInfo);
1411 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1417 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1422 case IDA_SMALLFONT_BTN_CLICKED:
1424 WebSetting setting = __pWebReader->GetSetting();
1425 setting.SetFontSize(15);
1426 __pWebReader->SetSetting(setting);
1429 case IDA_LARGEFONT_BTN_CLICKED:
1431 WebSetting setting = __pWebReader->GetSetting();
1432 setting.SetFontSize(25);
1433 __pWebReader->SetSetting(setting);
1436 case IDA_READER_CLOSE_CLICKED:
1438 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1440 //__pArticleReaderPanel->SetShowState(false);
1441 //__pArticleReaderPanel->Show();
1442 RemoveControl(*__pBlankPanel);
1443 //RemoveControl(*__pArticleReaderPanel);
1444 __pArticleReaderPanel = null;
1445 __pBlankPanel = null;
1446 __pArticleReaderLabel = null;
1449 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1452 case IDA_FINDWORD_CANCEL_CLICKED:
1454 __currentSearchStr = L"";
1455 __currentWordIndex = 0;
1456 __maxOccurrances = 0;
1457 __pFindWordEditField->SetText(L"");
1458 __pFindWordNext->SetEnabled(false);
1459 __pFindWordPrev->SetEnabled(false);
1460 __pFindWordCountLabel->SetText(L"0/0");
1461 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1462 ShowFindWordPanel(false);
1465 case IDA_FINDWORD_SEARCH_CLICKED:
1467 __currentSearchStr = __pFindWordEditField->GetText();
1468 if (__currentSearchStr.GetLength() > 0)
1474 AppLogDebug("Enter something");
1478 case IDA_FINDWORD_CLEAR_CLICKED:
1480 __pFindWordCountLabel->SetText(L"0/0");
1481 __pFindWordEditField->SetText(L"");
1482 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1484 __pFindWordNext->SetEnabled(false);
1485 __pFindWordPrev->SetEnabled(false);
1486 __pFindWordPanel->Invalidate(true);
1489 case IDA_FINDWORD_NEXT_CLICKED:
1494 case IDA_FINDWORD_PREV_CLICKED:
1496 FindNextWord(false);
1499 case IDA_BRIGHTNESS_BTN_CLICKED:
1501 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1502 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1505 case IDA_COPY_IMAGE_CLICKED:
1507 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1508 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1510 const Bitmap* pBitmap = null;
1511 if (__pHitElementResult != null)
1513 pBitmap = __pHitElementResult->GetImage();
1516 String resourcePath = App::GetInstance()->GetAppResourcePath();
1517 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1519 // copying the item to clipboard
1520 Clipboard* pClipboard = Clipboard::GetInstance();
1521 if (pClipboard != null)
1523 pClipboard->CopyItem(item);
1527 case IDA_VIEW_IMAGE_CLICKED:
1529 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1530 WindowInfo* pNewWindowInfo = null;
1531 if (__pHitElementResult != null)
1533 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1534 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1540 case IDA_SAVE_IMAGE_CLICKED:
1542 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1543 const Bitmap* pSaveBitmap = null;
1544 String imageName = GetImagePath();
1545 AppLog("Content manager image name %ls",imageName.GetPointer());
1548 imagePath.Append(imageName);
1549 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1550 AppLog("Content manager image path %ls",imagePath.GetPointer());
1551 if (__pHitElementResult != null)
1553 pSaveBitmap = __pHitElementResult->GetImage();
1555 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1559 UpdateImageContent(pBuffer, imageName);
1561 NotificationPanel *pNotification = new NotificationPanel(*this);
1563 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1564 msg.Append(imagePath);
1565 if (pNotification != null)
1567 pNotification->SetText(msg);
1568 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1569 pNotification->ShowNotification();
1574 int __modalMsgBoxResult;
1575 MessageBox* pMsgBox = new MessageBox();
1576 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1577 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1580 __modalMsgBoxResult = 0;
1584 case IDA_SHARE_IMAGE_CLICKED:
1586 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1587 if (__pPopUp != null)
1592 __pPopUp = new(std::nothrow) SharePopup();
1593 __pPopUp->Initialize();
1594 if (__pHitElementResult != null)
1596 const Bitmap* pSaveBitmap = null;
1597 String imageName = GetImagePath();
1598 AppLog("Content manager image name %ls",imageName.GetPointer());
1601 imagePath.Append(imageName);
1602 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1603 AppLog("Content manager image path %ls",imagePath.GetPointer());
1604 if (__pHitElementResult != null)
1606 pSaveBitmap = __pHitElementResult->GetImage();
1608 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1610 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1611 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1613 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1614 pShareInfo->SetPageTitle(L"");
1615 pShareInfo->SetPageUrl(srcUrl);
1616 pShareInfo->SetImageAttached(true);
1617 pShareInfo->SetImagePath(imagePath);
1618 __pPopUp->RemoveAllShareInfo();
1619 __pPopUp->AddShareInfo(pShareInfo);
1620 __pPopUp->SetShowState(true);
1625 case IDA_FIND_TEXT__CLICKED:
1627 AppLogDebug("MainForm::OnActionPerformed find word clicked");
1628 __currentSearchStr.Clear();
1629 __currentSearchStr.Append(__currentSelectedStr);
1630 InitFindWordPanel();
1633 __pMenu->SetShowState(false);
1634 __pMenu->Invalidate(false);
1637 __adressPanelPosition.y = 0;
1639 if (__pAddressbar != null && __pWebViewer != NULL)
1641 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
1642 __pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
1643 __pAddressbar->Invalidate(true);
1644 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
1645 __pWebViewer->Invalidate(true);
1648 ShowFindWordPanel(true);
1649 if (__currentSearchStr.GetLength() > 0)
1655 AppLogDebug("Enter something");
1658 if (__pWebViewer != null)
1660 // releasing the set block
1661 __pWebViewer->ReleaseBlock();
1666 case IDA_SHARE_TEXT_CLICKED:
1668 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
1669 if(__pPopUp != null)
1674 __pPopUp = new(std::nothrow) SharePopup();
1675 __pPopUp->Initialize();
1676 if (__pHitElementResult != null)
1678 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1679 pShareInfo->SetPageTitle(L"");
1680 pShareInfo->SetPageUrl(__currentSelectedStr);
1681 pShareInfo->SetImageAttached(false);
1682 __pPopUp->RemoveAllShareInfo();
1683 __pPopUp->AddShareInfo(pShareInfo);
1684 __pPopUp->SetShowState(true);
1689 case IDA_COPY_TEXT_CLICKED:
1691 // need to implement
1692 //__currentSelectedStr
1693 // Sets data to a clip board item
1695 String resourcePath = App::GetInstance()->GetAppResourcePath();
1696 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
1698 // copying the item to clipboard
1699 Clipboard* pClipboard = Clipboard::GetInstance();
1700 if (pClipboard != null)
1702 pClipboard->CopyItem(item);
1706 case IDA_PASTE_TEXT_CLICKED:
1708 Clipboard* pClipboard = Clipboard::GetInstance();
1710 if(pClipboard == null)
1714 // Retrieves a latest item
1715 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
1721 //Gets data from the clipboard item
1722 String* pString = dynamic_cast<String*>(pItem->GetData());
1724 if (pString != null)
1726 String idElement = __pHitElementResult->GetAttributeValue(L"id");
1727 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
1728 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(";
1729 script.Append(idElement);
1731 script.Append("\"");
1732 script.Append(*pString);
1733 script.Append("\");");
1734 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
1735 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
1747 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
1750 UiApp* pApp = UiApp::GetInstance();
1759 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
1760 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
1762 String* pSelectedScene = NULL;
1763 Object* pValue = NULL;
1764 String* pUrl = null;
1765 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
1766 pSelectedScene = (String*) pValue;
1768 if (pSelectedScene != null)
1770 delete pSelectedScene;
1772 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
1773 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
1774 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
1775 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
1777 // setting the current scene ID
1778 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
1780 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
1782 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
1784 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1785 if(__pWindowInfo == null)
1787 // if(__pWindowInfo == null)
1789 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
1792 else if ( pArgs != null && pArgs->GetCount() == 1)
1794 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
1800 if(__pWebViewer != null)
1802 __pWebViewer->Resume();
1805 if(pUrl != null && pUrl->GetLength() > 0)
1809 else if(__pWindowInfo != null)
1811 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)
1813 LoadUrl(__pWindowInfo->pageUrl);
1815 else if (__pWindowInfo->isJavascriptInitiated == true)
1819 __pWindowInfo->pCurrentWeb = __pWebViewer;
1823 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
1824 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
1825 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
1827 InitMostVisitedSitesView(GetOrientationStatus());
1830 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
1832 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
1834 if (pBookmarkUrl == null)
1836 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
1837 __pAddressbar->SetUrl(*pBookmarkUrl);
1839 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
1840 __pWebViewer->LoadUrl(*pBookmarkUrl);
1841 delete pBookmarkUrl;
1844 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1845 Bitmap* pBitmap = null;
1846 if (isPrivateBrowsing == true)
1848 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1850 if (__pWebViewer != null)
1852 __pWebViewer->SetPrivateBrowsingEnabled(true);
1855 if (__pAddressbar != null)
1857 __pAddressbar->UpdateFaviconBitmap(true);
1863 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1865 if (__pWebViewer != null)
1867 __pWebViewer->SetPrivateBrowsingEnabled(false);
1870 if (__pAddressbar != null)
1872 __pAddressbar->UpdateFaviconBitmap(false);
1876 if (__pMenu != null && __pMenu->GetItemCount() == 3)
1878 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1880 else if (__pMenu != null )
1882 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1885 if (pBitmap != null)
1890 AppLog("ABC: OnSceneActivatedN started exit");
1895 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
1896 const Tizen::Ui::Scenes::SceneId& nextSceneId)
1898 Canvas* pWebCanvas = null;
1899 if (__pWebViewer != null)
1901 pWebCanvas = __pWebViewer->GetCanvasN();
1902 __pWebViewer->Pause();
1905 if (pWebCanvas == null)
1909 if (__pWindowInfo != null)
1911 if (__pWindowInfo->pWebCanvasBitmap != null)
1913 delete __pWindowInfo->pWebCanvasBitmap;
1915 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
1916 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
1917 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
1919 Bitmap* pBitmap = GetCapturedBitmapN();
1920 AppLog("Coming here");
1921 Canvas* pCanvas = new(std::nothrow) Canvas();
1922 pCanvas->Construct(GetClientAreaBounds());
1925 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
1928 if(__pWebViewer != null && __pWindowInfo != null)
1929 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
1931 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
1932 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
1934 AppLog("Coming here");
1938 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
1939 const Tizen::Base::String& realm,
1940 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
1946 MainForm::OnHttpAuthenticationCanceled(void)
1951 MainForm::OnLoadingStarted(void)
1953 AppLogDebug("MainForm::OnLoadingStarted entered");
1955 if(__pAddressbar == NULL)
1959 String url = __pWebViewer->GetUrl();
1960 if(url.Contains(IDS_TIZEN_SERVICE))
1963 String delim(L":;");
1965 // Creates a StringTokenizer instance
1966 StringTokenizer strTok(url, delim);
1968 int count = strTok.GetTokenCount(); // count == 4
1970 HashMap *pMap = new HashMap();
1975 while (strTok.HasMoreTokens())
1977 AppLog("Token: %ls", token.GetPointer());
1978 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
1979 if(token.Contains(IDS_APPID))
1981 token.SubString(6, appId);
1982 AppLog("AppID:%ls", appId.GetPointer());
1984 else if(token.Contains("="))
1986 String *pKey = new String();
1987 String *pValue = new String();
1989 token.IndexOf("=", 0, index);
1992 token.SubString(0, index, *pKey);
1993 token.SubString(index + 1, *pValue);
1994 pMap->Add(pKey, pValue);
2000 AppControl *pAppControl = null;
2001 String operationId = L"http://tizen.org/appcontrol/operation/main";
2002 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2005 AppLog("Starting AppControl");
2006 result r = pAppControl->Start(null, null, pMap, null);
2007 AppLog("Result of Start %s", GetErrorMessage(r));
2011 AppLogException("AppControl not found");
2016 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2017 __pAddressbar->SetFaviconBitmap(*pBitmap);
2019 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2021 // updating the address bar position with respect to web control
2022 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2023 __distanceMoved = 0;
2027 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2030 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2031 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2032 if (__pWindowInfo != NULL)
2034 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2036 __pAddressbar->Invalidate(true);
2042 MainForm::OnLoadingCanceled(void)
2049 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2051 if(__pAddressbar != null)
2053 OnAddressBarKeypadOpened(*__pAddressbar);
2058 MainForm::OnKeypadClosed(Tizen::Ui::Control& source){
2059 if(__pAddressbar != null)
2061 OnAddressBarKeypadClosed(*__pAddressbar);
2066 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2067 const Tizen::Base::String& reason)
2069 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2073 MainForm::OnLoadingCompleted(void)
2076 result r = E_SUCCESS;
2078 if (__pWebViewer == null)
2083 if (__pAddressbar == null)
2087 if (__pWebViewer->CanGoForward())
2089 __pAddressbar->SetForwardButtonEnabled(true);
2093 __pAddressbar->SetForwardButtonEnabled(false);
2096 if (__pWebViewer->CanGoBack())
2098 __pAddressbar->SetBackButtonEnabled(true);
2102 __pAddressbar->SetBackButtonEnabled(false);
2104 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2106 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2108 __pAddressbar->UpdateProgress(0);
2111 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2112 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2113 if (isPrivateBrowsing == false)
2115 History* pHistory = new(std::nothrow) History;
2117 HistoryPresentationModel::GetCurrentDateTime(date);
2120 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2121 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2123 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2124 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2126 pHistory->SetVisitedTime(date);
2129 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2130 pHistory->SetFaviconId(id);
2131 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2132 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2133 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2135 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2136 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2137 pHistory->SetThumbnail(pBitmap);
2139 HistoryPresentationModel::GetInstance()->SaveHistory(*pHistory);
2146 if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2148 // temperary fixed (webpage can be not loaded)
2154 MainForm::OnEstimatedProgress(int progress)
2156 AppLogDebug("MainForm::OnEstimatedProgress entered");
2157 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2158 progress = DEFAULT_PROGRESS_PERCENTAGE;
2160 __pAddressbar->UpdateProgress(progress);
2164 MainForm::OnUrlSubmitted(Addressbar& addBar)
2166 String url = addBar.GetUrl();
2168 __pFooterPanel->SetShowState(true);
2169 __pFooterPanel->Invalidate(true);
2170 RequestRedraw(true);
2174 MainForm::LoadUrl(String& url)
2176 AppLogDebug("MainForm::LoadUrl enter");
2178 if (url.CompareTo(L"") == 0)
2182 if(__pFooterPanel != null)
2184 __pFooterPanel->SetShowState(true);
2185 __pFooterPanel->Invalidate(true);
2192 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2193 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)
2195 RegularExpression firstRegex;
2196 RegularExpression secondRegex;
2198 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2199 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2202 ret = firstRegex.Match(url, false); // This returns true value
2203 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2205 if (ret == true && __pWebViewer != null)
2207 __pWebViewer->LoadUrl(url);
2209 else if(__pWebViewer != null)
2211 String tempUrl = L"http://";
2212 tempUrl.Append(url);
2216 __pWebViewer->LoadUrl(tempUrl);
2220 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(url));
2223 if (__pAddressbar != null)
2225 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2228 AppLogDebug("MainForm::LoadUrl exit");
2235 MainForm::OnStopClicked(Addressbar& addBar)
2237 AppLogDebug("MainForm::OnStopClicked called");
2240 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2241 __pWebViewer->StopLoading();
2242 RequestRedraw(true);
2247 MainForm::OnReaderClicked(const Addressbar& addBar)
2249 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2251 CreateReaderPanel();
2252 AppLogDebug("MainScene::OnReaderClicked entered");
2255 /*if (__pArticleReaderPanel)
2257 AppLogDebug("showstate true for reader panel");
2258 __pArticleReaderPanel->SetShowState(true);
2259 __pArticleReaderPanel->Show();
2261 int xPos = __pArticleReaderPanel->GetX();
2262 int yPos = __pArticleReaderPanel->GetY();
2263 AppLog("OnReaderClicked() xPos = %d",xPos);
2264 AppLog("OnReaderClicked() yPos = %d",yPos);
2266 if (__pReaderData == null)
2271 String loadData = L"<html>\
2273 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2278 background-color: transparent;\
2297 <body style='width:'";
2298 loadData.Append(bodyWidth);
2299 loadData.Append(L"px'>");
2300 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2301 loadData.Append(*__pReaderData);
2302 loadData.Append(L"</body></html>");
2305 buf.Construct(loadData.GetLength());
2306 AppLogDebug("data->GetLength %d",loadData.GetLength());
2307 for (int z=0;z<loadData.GetLength();z++)
2310 loadData.GetCharAt(z,b);
2311 buf.SetByte((byte)b);
2315 if (__pWebReader != null)
2317 __pWebReader->LoadData(L"",buf,L"text/html");
2318 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2322 AppLogDebug("cannot LoadData __pWebReader is null");
2328 MainForm::OnBackClicked(const Addressbar& addBar)
2330 if (__pWebViewer == null)
2333 if (__pWebViewer->CanGoBack())
2335 __pWebViewer->GoBack();
2341 MainForm::OnForwardClicked(const Addressbar& addBar)
2343 if (__pWebViewer == null)
2346 if (__pWebViewer->CanGoForward())
2348 __pWebViewer->GoForward();
2353 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
2355 __pFooterPanel->SetShowState(true);
2356 __pFooterPanel->Invalidate(false);
2360 MainForm::OnAddressBarModeChanged(const Addressbar& addBar)
2362 __prevAddressBarMode = __curAddressBarMode;
2364 if (__pAddressbar != null)
2366 __curAddressBarMode = __pAddressbar->GetAddressbarMode();
2369 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
2371 __adressPanelPosition.y = 0;
2372 if (__pAddressbar != null)
2374 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2375 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
2376 __pAddressbar->Invalidate(true);
2378 if (__pWebViewer != null)
2380 __pWebViewer->StopLoading();
2385 if (__pWebViewer != null)
2387 if(__pFooterPanel->GetShowState() == false)
2388 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2390 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2391 __pWebViewer->Invalidate(true);
2396 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar)
2399 if(__pFooterPanel != null)
2401 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2402 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2404 InitMostVisitedSitesView(GetOrientationStatus());
2406 __pFooterPanel->SetShowState(true);
2407 __pFooterPanel->Invalidate(false);
2412 //AppLogDebug("MainForm::OnAddressBarKeypadClosed enterd");
2414 if (__pWebViewer != null && __pFooterPanel != null)
2416 AppLog("MainForm::OnAddressBarKeypadClosed GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2417 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - (__pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
2419 if(__pFooterPanel->GetShowState() == false)
2420 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2422 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2423 __pWebViewer->Invalidate(false);
2424 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2426 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
2427 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
2432 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
2434 __pFooterPanel->SetShowState(false);
2435 __pFooterPanel->Invalidate(false);
2439 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
2441 __pFooterPanel->SetShowState(false);
2442 __pFooterPanel->Invalidate(false);
2446 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
2450 __pWindowInfo->pageTitle = title;
2451 if (__pWebViewer != null)
2453 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2456 if (__pAddressbar != null && __pWebViewer != null)
2458 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2459 __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
2460 __pAddressbar->Invalidate(true);
2466 MainForm::UpdateFavicon(void)
2468 bool urlImageType = false;
2469 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();");
2470 Bitmap* pBitmap = null;
2472 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
2474 if (__pWindowInfo != null)
2477 url.SetUri(*tempPath);
2478 if (url.GetHost().GetLength() == 0)
2481 webUrl.SetUri(__pWebViewer->GetUrl());
2482 result r = url.SetHost(webUrl.GetHost());
2489 if (url.GetScheme().GetLength() == 0)
2492 webUrl.SetUri(__pWebViewer->GetUrl());
2493 url.SetScheme(webUrl.GetScheme());
2495 __pWindowInfo->faviconUrl = url.ToString();
2497 pBitmap = __pWebViewer->GetFaviconN();
2499 if (pBitmap != null)
2501 if (__pWindowInfo->pFavicon != NULL)
2503 // delete __pWindowInfo->pFavicon;
2504 __pWindowInfo->pFavicon = null;
2506 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
2507 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
2508 //bool isPrivateBrowsing = __pWebViewer->IsPrivateBrowsingEnabled();
2510 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2512 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2514 else if(__pWindowInfo->pFavicon != null)
2516 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
2520 __pAddressbar->SetFaviconBitmap(*FaviconManager::GetInstance()->GetDefaultFaviconN());
2523 AppLogDebug("Favicon download requested: url: %ls", url.ToString().GetPointer());
2530 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
2537 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
2538 Tizen::Web::Controls::WebNavigationType type)
2540 // when load new page if find word panel is open its show state is false
2541 ShowFindWordPanel(false);
2544 uriInfo.SetUri(url);
2546 if(url.Contains(IDS_TIZEN_SERVICE))
2549 String delim(L":;");
2551 // Creates a StringTokenizer instance
2552 StringTokenizer strTok(url, delim);
2554 int count = strTok.GetTokenCount(); // count == 4
2556 HashMap *pMap = new HashMap();
2562 while (strTok.HasMoreTokens())
2564 AppLog("Token: %ls", token.GetPointer());
2565 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2566 if(token.Contains(IDS_APPID))
2568 token.SubString(6, appId);
2569 AppLog("AppID:%ls", appId.GetPointer());
2571 else if(token.Contains("="))
2573 String *pKey = new String();
2574 String *pValue = new String();
2576 token.IndexOf("=", 0, index);
2579 token.SubString(0, index, *pKey);
2580 token.SubString(index + 1, *pValue);
2581 pMap->Add(pKey, pValue);
2587 AppControl *pAppControl = null;
2588 String operationId = L"http://tizen.org/appcontrol/operation/main";
2589 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2592 AppLog("Starting AppControl");
2593 result r = pAppControl->Start(null, null, pMap, null);
2594 AppLog("Result of Start %s", GetErrorMessage(r));
2598 AppLogException("AppControl not found");
2604 if (__pWebViewer && __pAddressbar)
2606 AppLog("__pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2607 __pAddressbar->SetUrl(__pWebViewer->GetUrl());
2608 __pAddressbar->UpdateProgress(DEFAULT_PROGRESS_PERCENTAGE);
2612 __pWindowInfo->pageTitle = CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK");
2613 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2614 __pWindowInfo->faviconUrl = "";
2615 __pWindowInfo->faviconFilePath = "";
2617 if (__pWindowInfo->pFavicon != NULL)
2619 // delete __pWindowInfo->pFavicon;
2620 __pWindowInfo->pFavicon = null ;
2622 __pWindowInfo->pFavicon = FaviconManager::GetInstance()->GetDefaultFaviconN();
2626 __pAddressbar->Invalidate(true);
2632 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
2633 const Tizen::Net::Http::HttpHeader& httpHeader)
2635 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
2640 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
2642 AppLog("MainForm::OnWebPageBlockSelected");
2644 if (__pHitElementResult != null)
2646 delete __pHitElementResult;
2647 __pHitElementResult = null;
2650 if (__pWebViewer != null)
2652 AppLog("MainForm::OnWebPageBlockSelected web not null");
2653 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
2656 if (__pHitElementResult == null)
2661 if (__pHitElementResult->HasImage() != true)
2663 String tagName = __pHitElementResult->GetTagName();
2664 String type = __pHitElementResult->GetAttributeValue("type");
2666 __currentSelectedStr.Clear();
2667 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
2669 if ((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0)
2671 AppLog("MainForm::OnWebPageBlockSelected show paste option");
2673 InitSelectTextContextMenu(startPoint,true);
2674 __pImageMenu->SetShowState(true);
2675 __pImageMenu->Show();
2676 __pImageMenu->Invalidate(true);
2678 else if (__pHitElementResult->HasUrl() == true || __currentSelectedStr.GetLength() > 0)
2680 AppLog("MainForm::OnWebPageBlockSelected no paste option");
2682 if(__pHitElementResult->GetUrl().GetLength() > 0)
2684 __currentSelectedStr.Clear();
2685 __currentSelectedStr = __pHitElementResult->GetUrl();
2687 InitSelectTextContextMenu(startPoint,false);
2688 __pImageMenu->SetShowState(true);
2689 __pImageMenu->Show();
2690 __pImageMenu->Invalidate(true);
2693 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
2694 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
2695 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
2700 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
2706 MainForm::OnWebWindowCreateRequested(void)
2708 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
2710 if (pNewWindowInfo == null)
2714 result r = E_SUCCESS;
2715 SceneManager* pSceneManager = SceneManager::GetInstance();
2716 if (pSceneManager == NULL)
2720 ArrayList* pArgList = new(std::nothrow) ArrayList();
2721 if (pArgList == NULL)
2725 r = pArgList->Construct();
2728 pNewWindowInfo->isJavascriptInitiated = true;
2729 pArgList->Add(*pNewWindowInfo);
2730 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2734 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
2741 return pNewWindowInfo->pCurrentWeb;
2745 MainForm::RelayoutControls(bool showAddressbar)
2747 if (showAddressbar == false)
2749 __pAddressbar->SetShowState(false);
2750 __pWebViewer->SetBounds(__pWebViewer->GetX(), 0, __pWebViewer->GetWidth(), __webControlHeight);
2751 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
2755 __pAddressbar->SetShowState(true);
2756 __pWebViewer->SetBounds(__pWebViewer->GetX(), __pWebViewer->GetY(), __pWebViewer->GetWidth(), __webControlHeight);
2757 __pFooterPanel->SetBounds(__pFooterPanel->GetX(), GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
2759 RequestRedraw(true);
2762 void MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
2764 if (__pFindWordPanel == null)
2770 InitFindWordPanel();
2771 __pFindWordEditField->SetText(__currentSearchStr);
2772 //__pFindWordCountLabel->SetText(L"");
2773 __pFindWordCountLabel->SetText(L"0/0");
2777 AppLog("MainForm::ShowFindWordPanel %d",show);
2778 if (show && !isTouchPressed)
2780 if (__pFindWordEditField)
2781 __pFindWordEditField->ShowKeypad();
2785 if (__pFindWordEditField)
2786 __pFindWordEditField->HideKeypad();
2789 if (__pAddressbar != null)
2791 __pAddressbar->SetShowState(!show);
2792 __pAddressbar->Invalidate(true);
2794 if (__pFindWordPanel != null)
2796 __pFindWordPanel->SetShowState(show);
2797 __pFindWordPanel->Invalidate(true);
2803 MainForm::StartWordSearch()
2805 //Get the count of occurances of the word in the current page
2806 __maxOccurrances = 0;
2807 __currentWordIndex = 0;
2809 __pFindWordPrev->SetEnabled(false);
2810 String *pCountStr = null;
2811 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
2812 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
2813 if (pCountStr != null)
2815 Integer::Parse(*pCountStr, 10, __maxOccurrances);
2819 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
2824 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
2826 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
2827 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
2829 /* if(totalCount == -1 || totalCount == 0)
2831 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),4,__pFindWordCountLabel->GetHeight());
2832 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
2835 else if(totalCount > 100)
2837 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
2838 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
2841 __maxOccurrances = totalCount;
2842 __currentWordIndex = currentOrdinal;
2844 //Reset the UI controls as per the maxOccurrance value
2845 if (totalCount <= 0)
2847 AppLog("Word not found");
2848 //Show error notification to user
2849 __pFindWordNext->SetEnabled(false);
2850 __pFindWordCountLabel->SetText(L"0/0");
2851 __pFindWordNext->Invalidate(false);
2852 __pFindWordPrev->Invalidate(false);
2853 __pFindWordCountLabel->Invalidate(false);
2857 if (totalCount == 1)
2859 __pFindWordNext->SetEnabled(false);
2863 __pFindWordNext->SetEnabled(true);
2866 String countStr = L"";
2867 countStr.Append(__currentWordIndex);
2868 countStr.Append(L"/");
2869 countStr.Append(__maxOccurrances);
2870 __pFindWordCountLabel->SetText(countStr);
2871 // __pFindWordCountLabel->SetShowState(true);
2872 __pFindWordCountLabel->Invalidate(false);
2874 //FindNextWord(true);
2875 //Update the controls
2876 __pFindWordNext->Invalidate(false);
2877 __pFindWordPrev->Invalidate(false);
2878 __pFindWordCountLabel->Invalidate(false);
2882 MainForm::FindNextWord(bool next)
2886 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
2888 if(__currentWordIndex < __maxOccurrances)
2890 __currentWordIndex++;
2896 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
2898 if(__currentWordIndex > 1)
2900 __currentWordIndex--;
2905 String countStr = L"";
2906 countStr.Append(__currentWordIndex);
2907 countStr.Append(L"/");
2908 countStr.Append(__maxOccurrances);
2909 __pFindWordCountLabel->SetText(countStr);
2910 // __pFindWordCountLabel->SetShowState(true);
2911 __pFindWordCountLabel->Invalidate(false);
2912 if (__currentWordIndex >= __maxOccurrances)
2914 __pFindWordNext->SetEnabled(false);
2918 __pFindWordNext->SetEnabled(true);
2920 if (__currentWordIndex <= 1)
2922 __pFindWordPrev->SetEnabled(false);
2926 __pFindWordPrev->SetEnabled(true);
2928 __pFindWordPrev->Invalidate(false);
2929 __pFindWordNext->Invalidate(false);
2930 __pFindWordCountLabel->Invalidate(false);
2931 __pFindWordPanel->Invalidate(true);
2934 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
2936 OnAddressBarKeypadOpened(*__pAddressbar);
2940 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
2943 if (__pWebViewer != null && __pFooterPanel != null)
2945 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
2946 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
2948 if(__pFooterPanel->GetShowState() == false)
2949 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
2951 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2953 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
2958 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
2960 OnAddressBarKeypadClosed(*__pAddressbar);
2964 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
2966 Control* temp = const_cast< Control* >(&source);
2967 Header* pHeader = dynamic_cast< Header* >(temp);
2968 if (pHeader != null)
2970 //Header double - clicked
2971 AppLog("Header double clicked");
2973 if(__pFindWordPanel)
2975 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
2976 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
2980 AppLog("MainScene::OnTouchDoublePressed");
2981 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2982 if (isReaderEnabled == true)
2986 delete __pReaderData;
2987 __pReaderData = null;
2989 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2990 filePath.Append(L"data/reader.js");
2996 result r = E_SUCCESS;
2997 FileAttributes attr;
2999 File::GetAttributes(filePath,attr);
3001 r = file.Construct(filePath, L"r+");
3004 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3007 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3010 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3013 file.Read(pScript,attr.GetFileSize());
3015 AppLogDebug("scipt length %d",strlen(pScript));
3016 String strScript = L"";
3017 strScript.Append(pScript);
3018 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3021 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3024 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3025 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3027 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3033 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3035 AppLog("MainForm::OnTouchLongPressed");
3037 if (__pHitElementResult != null)
3039 delete __pHitElementResult;
3040 __pHitElementResult = null;
3043 if (__pWebViewer != null)
3045 AppLog("MainForm::OnTouchLongPressed web not null");
3046 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3049 if (__pHitElementResult == null)
3054 if (__pHitElementResult->HasImage() == true)
3056 InitImageContextMenu(currentPosition);
3057 __pImageMenu->SetShowState(true);
3058 __pImageMenu->Show();
3059 __pImageMenu->Invalidate(true);
3063 String tagName = __pHitElementResult->GetTagName();
3064 String type = __pHitElementResult->GetAttributeValue("type");
3065 String value = __pHitElementResult->GetAttributeValue(L"value");
3066 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3068 __currentSelectedStr.Clear();
3069 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3071 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0)
3073 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3075 InitSelectTextContextMenu(currentPosition,true, true);
3076 __pImageMenu->SetShowState(true);
3077 __pImageMenu->Show();
3078 __pImageMenu->Invalidate(true);
3080 __pWebViewer->SetBlockSelectionPosition(currentPosition);
3083 __inputEventToBeSupressed = true;
3087 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3089 AppLog("MainForm::OnTouchReleased");
3091 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3092 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3094 __pWebViewer->ConsumeInputEvent();
3096 if(pHitElement != null)
3100 __inputEventToBeSupressed = false;
3104 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3106 int widthContextItem = 0;
3108 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3111 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3115 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3118 if( __pItemContext != NULL)
3120 delete __pItemContext;
3121 __pItemContext = null;
3125 __pItemContext= new(std::nothrow) ListContextItem();
3126 __pItemContext->Construct();
3127 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", widthContextItem,HEIGHT_CONTEXT_MENU_BUTTON);
3128 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", widthContextItem, HEIGHT_CONTEXT_MENU_BUTTON);
3130 if (pBitmapNormal != null && pBitmapPressed != null)
3132 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
3135 if (pBitmapNormal != null)
3137 delete pBitmapNormal;
3140 if (pBitmapPressed != null)
3142 delete pBitmapPressed;
3146 if (__pFindWordPanel != null && __pFindWordPanel->GetShowState() == true)
3148 __pFindWordPanel->SetBounds(0,0,GetClientAreaBounds().width,__pFindWordPanel->GetHeight());
3149 __pFindWordControl->SetBounds(0,0, __pFindWordPanel->GetWidth(), __pFindWordPanel->GetHeight());
3150 __pFindWordControl->SetShowState(true);
3151 __pFindWordControl->Invalidate(true);
3152 __pFindWordPanel->SetShowState(true);
3153 __pFindWordPanel->Invalidate(true);
3156 if (__pWebViewer != null && __pFooterPanel != null)
3158 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3159 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
3161 if(__pFooterPanel->GetShowState() == false)
3162 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12)));
3164 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3165 __pWebViewer->Invalidate(true);
3167 //__pWebViewer->SetBounds(Rectangle(0, 82, GetClientAreaBounds().width,webControlHeight));
3169 if (__pAddressbar != null)
3171 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3172 __pAddressbar->SetAddressbarMode(__pAddressbar->GetAddressbarMode());
3173 __pAddressbar->UpdateFaviconBitmap(SettingPresentationModel::GetInstance()->GetPrivateOn());
3175 if (__pFindWordBgLabel != null)
3177 // __pFindWordBgLabel->SetSize(GetClientAreaBounds().width,GetClientAreaBounds().height);
3178 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3179 if (pBitmap != null)
3181 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3185 if (__pFooterPanel /*&& __pFooterPanel->GetShowState() == true*/)
3187 AppLog("__pFooterPanel->GetShowState() is true");
3192 if(__pMoreButton && __pMenu)
3194 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3195 __pMenu->SetAnchorPosition(p);
3196 __pMenu->Invalidate(true);
3201 __pFooterPanel->Invalidate(true);
3203 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3204 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3206 InitMostVisitedSitesView(orientationStatus);
3209 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3211 __pMostVisitedListView->SetBounds(__pAddressbar->GetX(),__pAddressbar->GetY()+__pAddressbar->GetHeight(),GetClientAreaBounds().width,GetClientAreaBounds().height - __pAddressbar->GetHeight()- __pFooterPanel->GetHeight());
3214 AppLog("OnOrientationChanged 0");
3215 if (__pArticleReaderPanel != null)
3217 if (__pArticleReaderPanel->GetShowState() == true)
3219 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
3221 if (__pBlankPanel != null)
3222 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
3224 if (__pWebReader != null)
3226 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
3228 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3229 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
3231 if ( pBitmap != null && pSrcBitmap != null)
3233 AppLog("CreateReaderPanel ninepatchbitmap found");
3234 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
3237 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
3238 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
3239 if (pBitmap != null)
3244 if (pSrcBitmap != null)
3252 if(__pAddressbar != null)
3254 __pAddressbar->OrientationChanged();
3259 MainForm::OnSettingsChange(int settingvalue)
3261 AppLogDebug("MainForm::OnSettingsChange entered");
3262 if (__pWebViewer == null)
3264 AppLogDebug("Webviewer is not initialized yet.");
3267 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
3269 WebSetting settings = __pWebViewer->GetSetting();
3270 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
3272 settings.SetAutoFittingEnabled(true);
3274 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
3276 settings.SetAutoFittingEnabled(false);
3278 __pWebViewer->SetSetting(settings);
3280 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
3282 WebSetting settings = __pWebViewer->GetSetting();
3283 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
3284 __pWebViewer->SetSetting(settings);
3286 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
3288 WebSetting settings = __pWebViewer->GetSetting();
3289 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
3290 __pWebViewer->SetSetting(settings);
3292 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
3294 WebSetting settings = __pWebViewer->GetSetting();
3295 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
3296 __pWebViewer->SetSetting(settings);
3298 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
3302 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3306 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
3308 WebSetting settings = __pWebViewer->GetSetting();
3309 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
3311 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
3315 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
3317 __pWebViewer->SetSetting(settings);
3319 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
3323 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
3324 WebSetting settings = __pWebReader->GetSetting();
3325 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
3326 __pWebReader->SetSetting(settings);
3332 MainForm::OnSettingsReset()
3336 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
3337 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
3342 MainForm::OnClearCache()
3344 result r = E_SUCCESS;
3346 if (__pWebViewer != NULL)
3348 r = __pWebViewer->ClearCache();
3351 AppLogDebug("Cache cleared success");
3355 AppLogDebug("Cache cleared fail");
3361 MainForm::OnClearCookie()
3363 result r = E_SUCCESS;
3365 if (__pWebViewer != NULL)
3367 __pWebViewer->ClearCookie();
3371 AppLogDebug("Cookie cleared success");
3375 AppLogDebug("Cache cleared fail");
3380 MainForm::findDistance(int x1,int y1,int x2, int y2)
3382 int deltaX = Math::Abs(x2 - x1);
3383 int deltaY = Math::Abs(y2 - y1);
3384 double num = deltaX*deltaX + deltaY*deltaY;
3390 for (i = 0; i < 20; i++)
3392 x = (((x*x)+ num)/(2*x));
3403 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3405 if(__pFindWordPanel)
3407 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3408 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3412 IList* pList = null;
3413 pList = touch.GetTouchInfoListN(source);
3417 int count = pList->GetCount();
3420 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3421 __touchPoint1 = pTouchInfo->position;
3423 if (__pAddressbar != null)
3425 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
3427 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3429 __pAddressbar->SaveAddressbarEditText();
3431 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3434 __pAddressbar->Invalidate(true);
3437 else if (count == 2)
3439 AppLogDebug("MainForm::OnTouchPressed count is two");
3440 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3441 __touchPoint1 = pTouchInfo->position;
3443 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3444 __touchPoint2 = pTouchInfo->position;
3450 pList->RemoveAll(true);
3457 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3459 AppLog("Start MainForm::OnTouchMoved MoveUiControls");
3460 if(__pFindWordPanel)
3462 AppLog("MainForm::OnTouchPressed %d",__pFindWordPanel->GetShowState());
3463 ShowFindWordPanel(__pFindWordPanel->GetShowState(), true);
3466 if (__pFindWordEditField != null)
3468 __pFindWordEditField->HideKeypad();
3471 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
3477 IList* pList = null;
3478 pList = touch.GetTouchInfoListN(source);
3482 int count = pList->GetCount();
3485 AppLogDebug("MainForm::OnTouchMoved count 1");
3486 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3488 if( pTouchInfo == NULL )
3492 pTouchInfo->position.y += __pWebViewer->GetY();
3493 AppLog("MainForm::OnTouchMoved MoveUiControls %d,%d",pTouchInfo->position.x,pTouchInfo->position.y);
3495 if (__isLoaded == false)
3498 __distanceMoved = pTouchInfo->position.y - __touchPoint1.y;
3499 __touchPoint1 = pTouchInfo->position;
3501 // move the address bar and web control according to distance moved
3504 else if (count == 2)
3506 AppLogDebug("MainForm::OnTouchMoved count 2");
3510 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
3512 if( pTouchInfo == NULL )
3516 Point firstPoint = pTouchInfo->position;
3518 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
3519 if( pTouchInfo == NULL )
3523 Point secondPoint = pTouchInfo->position;
3525 if (__touchPoint1 == Point(-1,-1) || __touchPoint2 == Point(-1,-1))
3527 __touchPoint1 = firstPoint;
3528 __touchPoint2 = secondPoint;
3533 int currX1 = firstPoint.x;
3534 int currY1 = firstPoint.y;
3535 int currX2 = secondPoint.x;
3536 int currY2 = secondPoint.y;
3538 double prevDist = findDistance(__touchPoint1.x,__touchPoint1.y,__touchPoint2.x,__touchPoint2.y);
3539 double dist = findDistance(currX1, currY1, currX2, currY2);
3540 __distanceMoved = prevDist - dist;
3542 __touchPoint1 = firstPoint;
3543 __touchPoint2 = secondPoint;
3555 MainForm::MoveUiControls()
3557 __adressPanelPosition.y = __adressPanelPosition.y + __distanceMoved;
3558 if(__pAddressbar == NULL)
3563 if (__adressPanelPosition.y > 0)
3565 __adressPanelPosition.y = 0;
3566 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3568 else if (__adressPanelPosition.y < (0-(__pAddressbar->GetHeight() - 12))) // -12 is for the progress label
3570 __adressPanelPosition.y = 0-(__pAddressbar->GetHeight() - 12);
3571 __webControlPosition.y = 0;
3575 __webControlPosition.y = __adressPanelPosition.y + (__pAddressbar->GetHeight() - 12);
3578 AppLogDebug("__adressPanelPosition.y = %d, __webControlPosition.y = %d", __adressPanelPosition.y, __webControlPosition.y);
3580 __pAddressbar->SetBounds(0,__adressPanelPosition.y,__pAddressbar->GetWidth(),__pAddressbar->GetHeight());
3581 __pAddressbar->Invalidate(false);
3583 if (__pWebViewer != NULL)
3585 if(__pFooterPanel->GetShowState() == true)
3586 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
3588 __webControlHeight = GetClientAreaBounds().height - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
3589 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
3590 __pWebViewer->Invalidate(false);
3595 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
3597 if (__pFindWordEditField != null)
3599 __currentSearchStr = __pFindWordEditField->GetText();
3600 __pFindWordNext->SetEnabled(false);
3601 __pFindWordPrev->SetEnabled(false);
3602 __pFindWordNext->Invalidate(true);
3603 __pFindWordPrev->Invalidate(true);
3604 __pFindWordCountLabel->SetText(L"0/0");
3605 __pFindWordCountLabel->Invalidate(true);
3607 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
3608 if (__currentSearchStr.GetLength() > 0)
3614 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
3616 AppLogDebug("Enter something");
3621 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
3628 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
3630 if(__pWebViewer != null)
3633 AppLog("MainForm::InitMostVisitedSitesView");
3634 result r = E_SUCCESS;
3637 if (__pWebViewer != null && __pMostVisitedListView != null)
3642 if (__pMostVisitedListView != null)
3644 RemoveControl(*__pMostVisitedListView);
3646 if(__pMostVisitedSites != null)
3648 __pMostVisitedSites->RemoveAll(true);
3651 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
3653 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( __pAddressbar->GetY() + __pAddressbar->GetHeight() - 12);
3654 __pMostVisitedListView = new(std::nothrow) ListView();
3655 if(__pFooterPanel->GetShowState() == false)
3657 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, GetClientAreaBounds().height),true,false);
3661 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight() , GetClientAreaBounds().width, __webControlHeight),true,false);
3666 delete __pMostVisitedListView;
3667 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
3670 __pMostVisitedListView->SetItemProvider(*this);
3671 __pMostVisitedListView->AddListViewItemEventListener(*this);
3672 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
3673 AddControl(*__pMostVisitedListView);
3674 AppLog("__pMostVisitedSitesPanel addcontrol %s",GetErrorMessage(r));
3675 if(__pFooterPanel->GetShowState() == false)
3676 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() + 14));
3678 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__pAddressbar->GetBounds().y + __pAddressbar->GetHeight()-12 , GetClientAreaBounds().width, GetClientAreaBounds().height - __pAddressbar->GetHeight() - __pFooterPanel->GetHeight() + 14));
3680 __pMostVisitedListView->UpdateList();
3687 MainForm::GetImagePath(void)
3691 String formattedTime;
3692 DateTime currentTime;
3693 LocaleManager localManager;
3694 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
3696 localManager.Construct();
3697 Locale locale = localManager.GetSystemLocale();
3698 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
3700 // Get date formatter
3701 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
3705 pTimeFormatter->Format(currentTime, formattedTime);
3708 AppLog("current time stamp is %ls", formattedTime.GetPointer());
3709 String delim(L" :");
3710 StringTokenizer strTok(formattedTime, delim);
3713 String str1("GMT+00");
3714 while (strTok.HasMoreTokens())
3716 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
3717 if(token.Equals(str1))
3719 AppLog("token is %ls", token.GetPointer());
3720 imageName.Append(token);
3726 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
3728 result r = E_FAILURE;
3729 AppLog("Content manager 1");
3730 ContentId contentId;
3731 ContentManager contentManager;
3732 r = contentManager.Construct();
3735 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
3738 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
3739 contentPath.Append(imageName);
3740 contentPath.Append(".jpg");
3741 contentId = contentManager.CreateContent(*aBuffer, contentPath);
3742 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));