2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
73 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
74 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
76 const int IDA_BACKBTN_CLICKED = 101;
77 const int IDA_BOOKMARKBTN_CLICKED = 102;
78 const int IDA_MOREBTN_CLICKED = 103;
79 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
80 const int IDA_NEWWINDOWBTN_CLICKED = 105;
81 const int IDA_FORWARD_CLICKED = 106;
82 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
83 const int IDA_SHARE_CLICKED = 108;
84 const int IDA_FINDONPAGE_CLICKED = 109;
85 const int IDA_PRIVATEON_CLICKED = 110;
86 const int IDA_SETTINGS_CLICKED = 111;
87 const int IDA_READER_CLOSE_CLICKED = 112;
88 const int IDA_SMALLFONT_BTN_CLICKED = 113;
89 const int IDA_LARGEFONT_BTN_CLICKED = 114;
90 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
91 const int IDA_HISTORY_CLICKED = 116;
92 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
93 const int IDA_ADD_TO_HOME_CLICKED = 118;
94 const int IDA_SAVED_PAGES_CLICKED = 119;
95 const int IDA_DESKTOP_VIEW_CLICKED = 120;
96 const int IDA_SAVE_CLICKED = 121;
97 const int IDA_PRINT_CLICKED = 122;
99 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
100 const int IDA_FINDWORD_NEXT_CLICKED = 202;
101 const int IDA_FINDWORD_PREV_CLICKED = 203;
102 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
103 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
105 const int IDA_COPY_IMAGE_CLICKED = 206;
106 const int IDA_VIEW_IMAGE_CLICKED = 207;
107 const int IDA_SAVE_IMAGE_CLICKED = 208;
108 const int IDA_SHARE_IMAGE_CLICKED = 209;
110 const int IDA_COPY_TEXT_CLICKED = 210;
111 const int IDA_PASTE_TEXT_CLICKED = 211;
112 const int IDA_FIND_TEXT__CLICKED = 212;
113 const int IDA_SHARE_TEXT_CLICKED = 213;
115 const int IDA_GO_BACK = 214;
116 const int IDA_GO_FORWARD = 215;
117 const int IDA_REFRESH_BTN_CLICKED = 216;
118 const int IDA_STOP_BTN_CLICKED = 217;
119 const int IDA_CLEAR_URL = 218;
120 const int IDA_READER_BTN_CLICKED = 219;
123 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
124 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
125 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
126 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
128 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
130 const int MainForm::IDA_FORMAT_BITMAP = 500;
131 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
132 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
133 const int MainForm::IDA_FORMAT_URL_STRING = 503;
134 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
136 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
137 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
138 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
140 MainForm::MainForm(void)
142 __isLongPressedDone = false;
144 __pAddressbar = null;
145 // __pMostVisitedSitesPanel = null;
146 __pMostVisitedListView = null;
147 __pFooterPanel = null;
148 __pHitElementResult = null;
149 __pWindowInfo = null;
153 __pFindWordControl = null;
155 __pFindWordBgLabel = null;
156 __pFindWordEditField = null;
157 __pFindWordClear = null;
158 __pFindWordCountLabel = null;
159 __pFindWordNext = null;
160 __pFindWordPrev = null;
161 __previousZoomLevel = 1.0;
163 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
166 __currentSearchStr = L"";
167 __currentSelectedStr = L"";
168 __maxOccurrances = 0;
169 __currentWordIndex = 0;
172 //__inputEventToBeSupressed = false;
173 __isLoadingData = false;
174 __isLoadingCompleted = false;
175 __progressPercentage = 0;
176 __touchPoint1 = Point(-1,-1);
177 __touchPoint2 = Point(-1,-1);
179 // __pReaderPopup = null;
180 __pReaderData = null;
182 __pReaderCloseBtn = null;
183 //__pNewWindowButton = null;
184 __pMoreButton = null;
185 __pMultiWindowButton = null;
186 __pArticleReaderPanel = null;
187 __pBlankPanel = null;
188 __pArticleReaderLabel = null;
189 __webControlHeight = 0;
190 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
191 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
192 __pMostVisitedSites = null;
193 __pFooterUrlField = null;
195 __pGoForwardBtn = null;
196 __pRefreshBtn = null;
197 __pProgressbarLabel = null;
198 __pFooterLabel = null;
202 __isWebKeypadOpened = false;
205 MainForm::~MainForm(void)
207 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
211 __pAddressbar->SetAddressbarEventListener(null);
214 if(__pHistory != null)
220 if (__pReaderData != null)
222 delete __pReaderData;
223 __pReaderData = null;
226 if (__pPopUp != null)
232 if (__pHitElementResult != null)
234 delete __pHitElementResult;
235 __pHitElementResult = null;
238 String* pSelectedScene = NULL;
239 Object* pValue = NULL;
240 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
241 pSelectedScene = (String*) pValue;
243 /*if (pSelectedScene != null)
245 delete pSelectedScene;
247 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
251 MainForm::Initialize(void)
253 Construct(L"IDL_FORM");
258 MainForm::OnInitializing(void)
260 AppLog("get client area width = %d",GetClientAreaBounds().width);
261 AppLog("get client area height = %d",GetClientAreaBounds().height);
262 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
263 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
265 Panel* pFooterPanel = null;
267 __pSaveImage = new Image();
268 __pSaveImage->Construct();
270 // Setup back event listener
271 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
272 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
273 AddOrientationEventListener(*this);
274 AppLogDebug(" MainForm::OnInitializing ended");
275 if (__pMostVisitedSites == null)
277 __pMostVisitedSites = new(std::nothrow) ArrayList();
278 __pMostVisitedSites->Construct();
280 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
282 __pItemContext= new(std::nothrow) ListContextItem();
283 __pItemContext->Construct();
284 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
285 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
287 if (pBitmapNormal != null && pBitmapPressed != null)
289 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
292 if (pBitmapNormal != null)
294 delete pBitmapNormal;
297 if (pBitmapPressed != null)
299 delete pBitmapPressed;
302 __pItemContextLandscape= new(std::nothrow) ListContextItem();
303 __pItemContextLandscape->Construct();
304 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
305 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
307 if (pBitmapNormal != null && pBitmapPressed != null)
309 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
312 if (pBitmapNormal != null)
314 delete pBitmapNormal;
317 if (pBitmapPressed != null)
319 delete pBitmapPressed;
326 MainForm::InitAddressbar(void)
328 AppLogDebug("MainForm::InitAddressbar entered");
330 result r = E_SUCCESS;
332 if (__pAddressbar != null)
336 __pAddressbar = new(std::nothrow) Addressbar();
337 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
338 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
341 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
344 __pAddressbar->SetAddressbarEventListener(this);
345 AddControl(__pAddressbar);
346 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
347 SetControlAlwaysOnTop(*__pAddressbar, true);
348 __adressPanelPosition = __pAddressbar->GetPosition();
350 AppLogDebug("MainForm::InitAddressbar exit");
356 MainForm::CreateReaderPanel(void)
358 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
359 result r = E_FAILURE;
361 Button *pSmallFontBtn = null;
362 Button *pLargeFontBtn = null;
364 __pBlankPanel = new (std::nothrow) Panel();
365 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
367 __pArticleReaderPanel = new (std::nothrow) Panel();
368 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
370 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
371 if (__pReaderCloseBtn)
373 AppLogDebug("CreateReaderPanel() 6");
374 __pReaderCloseBtn->AddActionEventListener(*this);
375 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
378 __pWebReader = new (std::nothrow) Web();
379 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
381 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
382 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
384 r = __pWebReader->SetSetting(settings);
386 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
389 __pArticleReaderLabel = new Label();
390 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
392 __pBlankPanel->AddControl(__pArticleReaderLabel);
393 __pBlankPanel->AddControl(__pArticleReaderPanel);
394 AddControl(__pBlankPanel);
396 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
397 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
398 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
400 __pArticleReaderPanel->AddControl(__pWebReader);
401 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
402 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
405 if (pBitmap != null && pSrcBitmap != null)
407 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
409 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
411 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
414 pSmallFontBtn->AddActionEventListener(*this);
415 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
418 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
421 pLargeFontBtn->AddActionEventListener(*this);
422 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
431 if (pSrcBitmap != null)
437 SetControlAlwaysOnTop(*__pBlankPanel, true);
438 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
445 MainForm::InitWebControl()
447 AppLogDebug("MainForm::InitWebControl enter");
448 result r = E_SUCCESS;
449 AppLogDebug("InitWebControl");
451 if (__pAddressbar == null || __pFooterPanel == null)
454 const int Y_WEBCONTROL_POSITION = 0;
455 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
456 if (__pMostVisitedListView)
458 __pMostVisitedListView->SetShowState(false);
460 if (__pWebViewer != null)
462 AppLogDebug("Already initialized");
465 __pWebViewer = new(std::nothrow) Web();
466 if(__pWebViewer == NULL)
468 AppLogDebug("Initialization failed");
471 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
475 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
482 r = AddControl(__pWebViewer);
488 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
491 __webControlPosition = __pWebViewer->GetPosition();
492 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
495 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
499 __pWebViewer->SetLoadingListener(this);
500 __pWebViewer->SetWebUiEventListener(this);
501 __pWebViewer->SetWebKeypadEventListener(this);
502 __pWebViewer->SetFocus();
503 __pWebViewer->AddTouchEventListener(*this);
505 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
506 __pWebViewer->SetTextSearchListener(this);
509 AppLogDebug("MainForm :before return");
511 AppLogDebug("MainForm::InitWebControl Exit");
517 MainForm::OnFocusGained(const Control& source)
519 AppLog("MainForm::OnFocusGained");
523 MainForm::OnFocusLost(const Control& source)
525 AppLog("MainForm::OnFocusLost");
529 MainForm::SetJavascriptEnabled()
531 WebSetting settings = __pWebViewer->GetSetting();
532 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
533 __pWebViewer->SetSetting(settings);
537 MainForm::SetImageLoadEnabled()
539 WebSetting settings = __pWebViewer->GetSetting();
540 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
541 __pWebViewer->SetSetting(settings);
545 MainForm::InitFooter(void)
547 AppLogDebug("MainForm::InitFooter entered");
548 Button* pBackButton = null;
549 Button* pBookmarkButton = null;
550 Button* pMultiWindowButton = null;
551 Bitmap *pIconBitmap = null;
552 Bitmap *pBGBitmap = null;
553 Label *pBGLabel = null;
555 if (__pFooterPanel == null)
557 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
560 if (__pFooterPanel == null)
565 SetControlAlwaysOnTop(*__pFooterPanel, true);
567 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
568 if ( __pFooterLabel == NULL )
572 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
573 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
576 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
580 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
582 if ( __pMultiWindowButton == NULL )
587 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
589 if ( __pMoreButton == NULL )
594 if (__pMultiWindowButton != null)
596 Bitmap* pBitmap = null;
597 Bitmap* pPressedBitmap = null;
598 String imagePath = "I01_toolbar_icon_windows_manager_0";
599 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
600 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
601 imagePath.Append(totalCount);
602 imagePath.Append(".png");
604 pressedImagePath.Append(totalCount);
605 pressedImagePath.Append("_press.png");
607 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
608 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
609 if ( pBitmap == null )
614 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
617 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
618 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
623 __pMultiWindowButton->AddActionEventListener(*this);
624 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
629 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
630 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
633 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
634 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
635 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
639 __pMoreButton->AddActionEventListener(*this);
640 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
643 //Add the editfield for url
644 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
645 if (__pFooterUrlField == NULL)
647 return E_INVALID_KEY;
650 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
651 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
652 __pFooterUrlField->AddKeypadEventListener(*this);
653 __pFooterUrlField->SetPropagatedTouchEventListener(this);
655 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
657 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
659 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
661 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
665 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
666 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
670 //Add the go Back Button
671 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
672 if (__pGoBackBtn == NULL)
674 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
675 return E_INVALID_KEY;
677 __pGoBackBtn->SetActionId(IDA_GO_BACK);
678 __pGoBackBtn->AddActionEventListener(*this);
680 //Add the go forward Button
681 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
682 if (__pGoForwardBtn == NULL)
684 AppLogDebug("Control not found returning E_INVALID_KEY");
685 return E_INVALID_KEY;
687 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
688 __pGoForwardBtn->AddActionEventListener(*this);
689 if (__pWebViewer && __pWebViewer->CanGoForward())
691 SetForwardButtonEnabled(true);
695 SetForwardButtonEnabled(false);
698 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
699 if (__pRefreshBtn == NULL)
701 AppLogDebug("Control not found returning E_INVALID_KEY");
702 return E_INVALID_KEY;
705 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
706 __pRefreshBtn->AddActionEventListener(*this);
707 __pRefreshBtn->SetShowState(true);
709 //Add the backround label for displaying progressbar
710 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
711 if (__pProgressbarLabel == NULL)
713 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
716 __pProgressbarLabel->SetShowState(false);
718 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
719 if (__pStopBtn == NULL)
721 AppLogDebug("Control not found returning E_INVALID_KEY");
722 return E_INVALID_KEY;
724 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
725 __pStopBtn->AddActionEventListener(*this);
726 __pStopBtn->SetShowState(false);
728 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
729 if (__pClearBtn == NULL)
731 AppLogDebug("Control not found returning E_INVALID_KEY");
732 return E_INVALID_KEY;
734 __pClearBtn->SetActionId(IDA_CLEAR_URL);
735 __pClearBtn->AddActionEventListener(*this);
736 __pClearBtn->SetShowState(false);
738 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
739 if (__pReaderBtn == NULL)
741 AppLogDebug("Control not found returning E_INVALID_KEY");
742 return E_INVALID_KEY;
744 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
745 __pReaderBtn->AddActionEventListener(*this);
746 __pReaderBtn->SetShowState(false);
748 // __pFooterPanel->Invalidate(true);
749 AppLogDebug("MainForm::InitFooter exit");
755 MainForm::InitContextMenu(Point& p)
757 result r = E_SUCCESS;
758 bool isPrivateBrowsing = false;
759 Bitmap* pBitmap = null;
763 __pMenu->SetAnchorPosition(p);
764 __pMenu->Invalidate(true);
768 __pMenu = new(std::nothrow) ContextMenu();
769 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
770 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
772 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
775 if (isPrivateBrowsing == true)
777 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
781 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
784 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
786 if ( pBitmap != NULL)
788 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
791 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
792 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
793 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
796 __pMenu->SetMaxVisibleItemsCount(6);
797 __pMenu->SetShowState(false);
798 __pMenu->AddActionEventListener(*this);
799 SetControlAlwaysOnTop(*__pMenu, true);
805 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
807 result r = E_SUCCESS;
808 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
810 AppLog("MainForm::InitImageContextMenu clicked on image");
811 if (__pImageMenu != null)
817 __pImageMenu = new (std::nothrow) ContextMenu();
818 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
819 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
823 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
824 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
825 __pImageMenu->SetMaxVisibleItemsCount(4);
826 __pImageMenu->AddActionEventListener(*this);
827 SetControlAlwaysOnTop(*__pImageMenu, true);
833 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
835 result r = E_SUCCESS;
836 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
838 AppLog("MainForm::InitImageContextMenu clicked on image");
839 if (__pImageMenu != null)
845 if(__pAddressbar->GetShowState() == true)
846 p.y = p.y + __pAddressbar->GetHeight();
848 __pImageMenu = new (std::nothrow) ContextMenu();
849 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
850 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
852 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
853 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
854 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
855 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
857 __pImageMenu->SetMaxVisibleItemsCount(3);
858 __pImageMenu->AddActionEventListener(*this);
859 SetControlAlwaysOnTop(*__pImageMenu, true);
866 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
868 result r = E_SUCCESS;
869 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
871 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
872 if (__pImageMenu != null)
881 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
885 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
887 __pImageMenu = new (std::nothrow) ContextMenu();
888 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
889 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
891 if(onlyPasteOption == false)
893 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
895 if (pasteOption || onlyPasteOption)
897 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
899 if(onlyPasteOption == false)
901 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
902 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
905 __pImageMenu->SetMaxVisibleItemsCount(3);
906 __pImageMenu->AddActionEventListener(*this);
907 SetControlAlwaysOnTop(*__pImageMenu, true);
914 MainForm::InitFindWordPanel(void)
916 result r = E_SUCCESS;
917 Bitmap *pIconBitmap = null;
919 if (__pFindWordControl != null)
921 AppLogDebug("Findword panel already initialized");
922 if (__pFindWordBgLabel != null)
924 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
927 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
934 __pFindWordControl = new (std::nothrow) Panel();
935 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
938 AppLogException("There is some problem in the xml file. Please check.");
941 AddControl(__pFindWordControl);
942 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
943 SetControlAlwaysOnTop(*__pFindWordControl,true);
944 __pFindWordControl->SetShowState(false);
945 __pFindWordControl->Invalidate(false);
947 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
948 if (__pFindWordBgLabel != null)
950 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
951 Rectangle pRect = pPanel1->GetBounds();
952 pRect.x = pRect.y = 0;
953 __pFindWordBgLabel->SetBounds(pRect);
954 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
957 AppLogDebug("InitFindWordPanel: Coming here");
958 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
963 AppLogDebug("InitFindWordPanel: shouldn't Come here");
967 Button* pfindWordCancel = null;
968 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
969 if (pfindWordCancel == null)
971 AppLogException("There is some problem in the xml file. Please check.");
974 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
975 pfindWordCancel->AddActionEventListener(*this);
977 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
978 if (__pFindWordClear == null)
980 AppLogException("There is some problem in the xml file. Please check.");
984 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
985 __pFindWordClear->AddActionEventListener(*this);
987 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
988 if (__pFindWordNext == null)
990 AppLogException("There is some problem in the xml file. Please check.");
994 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
995 __pFindWordNext->AddActionEventListener(*this);
997 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
998 if (__pFindWordPrev == null)
1000 AppLogException("There is some problem in the xml file. Please check.");
1004 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1005 __pFindWordPrev->AddActionEventListener(*this);
1007 __pFindWordNext->SetEnabled(false);
1008 __pFindWordPrev->SetEnabled(false);
1010 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1011 if (__pFindWordCountLabel == null)
1013 AppLogException("There is some problem in the xml file. Please check.");
1017 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1018 if (__pFindWordEditField == null)
1020 AppLogException("There is some problem in the xml file. Please check.");
1023 __pFindWordEditField->AddTextEventListener(*this);
1024 __pFindWordEditField->AddKeypadEventListener(*this);
1025 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1031 MainForm::CreateItem (int index, int itemWidth)
1033 Rectangle listImageRect;
1034 Rectangle pagetTitleRect;
1035 Rectangle pageURLRect;
1036 Rectangle deleteImageRect;
1037 String pageTitle(L"");
1038 String pageURL(L"");
1039 result r = E_SUCCESS;
1040 Bitmap* pListIconImage = null;
1043 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1044 if(pHistory == null)
1048 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1049 if ( pAppResource == NULL )
1053 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1055 CustomItem* pItem = new(std::nothrow) CustomItem();
1056 pageTitle = pHistory->GetHistoryTitle();
1057 pageURL = pHistory->GetHistoryUrl();
1059 if (pageURL.GetLength() == 0)
1062 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1063 pageURL = L"<"+ nourl +">";
1067 Rectangle screenBounds = GetBounds();
1070 r = pItem->Construct(Dimension(itemWidth, 128), style);
1079 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1081 if ( pBitmap != NULL)
1083 pListIconImage = new Bitmap();
1084 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1088 if(pListIconImage == null)
1090 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1093 if ( pListIconImage != NULL)
1095 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1096 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1097 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1100 if (pItem != null && pListIconImage != NULL)
1102 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1106 if (pageTitle.CompareTo(L"") != 0)
1110 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1114 if (pageURL.CompareTo(L"") != 0)
1118 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1123 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1125 if ( __pItemContext!= NULL)
1129 pItem->SetContextItem(__pItemContext);
1135 if ( __pItemContextLandscape!= NULL)
1139 pItem->SetContextItem(__pItemContextLandscape);
1143 if( pListIconImage != NULL)
1145 delete pListIconImage;
1146 pListIconImage = null;
1153 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1160 MainForm::GetItemCount (void)
1162 if(__pMostVisitedSites != null)
1164 __pMostVisitedSites->RemoveAll(true);
1166 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1167 if(__pMostVisitedSites != null)
1169 return __pMostVisitedSites->GetCount();
1176 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1178 if(__pMostVisitedSites != null)
1180 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1181 if (pHistory != null)
1183 String url = pHistory->GetHistoryUrl();
1185 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1186 __pMostVisitedListView->UpdateList();
1192 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1194 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1195 String url = pHistory->GetHistoryUrl();
1203 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1209 MainForm::OnTerminating(void)
1211 result r = E_SUCCESS;
1214 delete __pItemContext;
1216 if(__pItemContextLandscape)
1218 delete __pItemContextLandscape;
1224 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1226 result r = E_SUCCESS;
1228 AppLogDebug("Clicked : %d", actionId);
1231 case IDA_BACKBTN_CLICKED:
1233 if (__pWebViewer && __pWebViewer->CanGoBack())
1235 __pWebViewer->GoBack();
1237 else if(__pWindowInfo->isJavascriptInitiated == false)
1240 pApp = UiApp::GetInstance();
1243 r = pApp->Terminate();
1246 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1254 WindowInfo* pWindowInfo = null;
1256 SceneManager* pSceneManager = SceneManager::GetInstance();
1257 if (pSceneManager == null)
1261 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1262 if (pAllWindowList == NULL)
1264 pApp = UiApp::GetInstance();
1267 r = pApp->Terminate();
1270 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1275 if (pAllWindowList != null)
1277 totalCount = pAllWindowList->GetCount();
1279 for (int count = 0; count < totalCount; count++)
1281 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1282 if (pWindowInfo == null)
1284 pApp = UiApp::GetInstance();
1287 r = pApp->Terminate();
1290 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1297 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1299 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1302 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1305 r = pAllWindowList->RemoveAt(count, true);
1306 __pWindowInfo = null;
1309 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1314 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1318 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1320 if (pWindowInfo == null)
1322 pApp = UiApp::GetInstance();
1325 r = pApp->Terminate();
1331 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1334 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1346 case IDA_FORWARD_CLICKED:
1347 if (__pWebViewer == null)
1350 if (__pWebViewer->CanGoForward())
1352 __pWebViewer->GoForward();
1354 __pMenu->SetShowState(false);
1355 __pMenu->Invalidate(false);
1358 case IDA_FINDONPAGE_CLICKED:
1360 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1361 __currentSearchStr.Clear();
1363 InitFindWordPanel();
1364 __pMenu->SetShowState(false);
1365 __pMenu->Invalidate(false);
1367 __pFindWordEditField->SetFocus();
1368 ShowFindWordPanel(true);
1371 case IDA_PRIVATEON_CLICKED:
1373 result r = E_SUCCESS;
1375 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1376 Bitmap* pBitmap = null;
1377 if (isPrivateBrowsing == true)
1379 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1382 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1386 if (__pWebViewer != NULL)
1388 __pWebViewer->SetPrivateBrowsingEnabled(false);
1391 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1393 if (__pAddressbar != null)
1395 __pAddressbar->UpdateFaviconBitmap(false);
1401 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1404 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1408 if (__pWebViewer != NULL)
1410 __pWebViewer->SetPrivateBrowsingEnabled(true);
1413 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1415 if (__pAddressbar != null)
1417 __pAddressbar->UpdateFaviconBitmap(true);
1422 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1423 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1424 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1425 __pMenu->Invalidate(true);
1427 if ( pBitmap != NULL )
1434 case IDA_SETTINGS_CLICKED:
1437 ArrayList* pArgList = new(std::nothrow) ArrayList();
1440 pArgList->Construct();
1441 pArgList->Add(*__pWindowInfo);
1442 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1444 __pMenu->SetShowState(false);
1445 __pMenu->Invalidate(false);
1446 if (pArgList != null)
1455 case IDA_ADDTOBOOKMARK_CLICKED:
1458 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1460 int bookmarkCount=0;
1463 url=__pWindowInfo->pageUrl;
1464 result r = E_SUCCESS;
1465 Bitmap* pBitmap = null;
1466 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1474 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1475 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1476 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1478 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1479 if (pNotification != null)
1481 pNotification->SetText(message);
1482 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1483 pNotification->ShowNotification();
1488 String title=__pWindowInfo->pageTitle;
1489 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1490 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1492 pBookmark->SetBookmarkTitle(title);
1493 pBookmark->SetUrl(url);
1494 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1496 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1498 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1499 pBookmark->SetFaviconId(id);
1500 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1501 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1504 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1505 if (pNotification != null)
1507 pNotification->SetText(message);
1508 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1509 pNotification->ShowNotification();
1510 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1513 if (pBitmap != null)
1515 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1519 __pMenu->Invalidate(true);
1523 case IDA_PRINT_CLICKED:
1525 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1526 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1528 AppLog("RequestPrint called!");
1529 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1530 result nResult = E_FAILURE;
1533 AppLog("TestPrint if (pAc) == true");
1538 String fileType = L"service_print_files_type";
1539 String typeVal = L"DOC";
1541 String fileCount = L"service_print_files_count";
1542 String countVal = L"1";
1543 String fileFolder= L"service_print_files_folder_name";
1544 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1546 map.Add(&fileCount, &countVal);
1547 map.Add(&fileFolder, &folderVal);
1548 map.Add(&fileType, &typeVal);
1550 String fileName = L"service_print_files_files_name";
1552 ArrayList fileNameList;
1553 fileNameList.Construct();
1554 String file1 = L"test.pdf";
1556 fileNameList.Add(&file1);
1557 map.Add(&fileName, &fileNameList);
1559 nResult = pAc->Start(NULL, NULL, &map, NULL);
1561 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1562 else if (nResult == E_MAX_EXCEEDED)
1563 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1564 else if (nResult == E_OBJ_NOT_FOUND)
1565 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1566 else if (nResult == E_IN_PROGRESS)
1567 AppLog("TestPrint ret == E_IN_PROGRESS");
1568 else if (nResult == E_PRIVILEGE_DENIED)
1569 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1570 else if(nResult == E_SYSTEM)
1571 AppLog("TestPrint ret == E_SYSTEM");
1577 int __modalMsgBoxResult;
1578 MessageBox* pMsgBox = new MessageBox();
1579 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1580 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1583 __modalMsgBoxResult = 0;
1587 case IDA_SHARE_CLICKED:
1589 if(__pPopUp != null)
1594 __pPopUp = new(std::nothrow) SharePopup();
1595 __pPopUp->Initialize();
1596 if (__pWindowInfo != null)
1598 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1599 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1600 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1601 pShareInfo->SetImageAttached(false);
1602 __pPopUp->RemoveAllShareInfo();
1603 __pPopUp->AddShareInfo(pShareInfo);
1605 __pPopUp->SetShowState(true);
1609 case IDA_BOOKMARKBTN_CLICKED:
1611 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1612 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1615 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1620 case IDA_MOREBTN_CLICKED:
1622 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1623 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1624 AppLog("Anchot pos: %d %d", p.x, p.y);
1626 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1628 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1629 int bookmarkCount=0;
1632 url=__pWindowInfo->pageUrl;
1633 result r = E_SUCCESS;
1634 Bitmap* pBitmap = null;
1636 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1639 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1644 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1648 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1650 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1652 if (__pMenu->GetItemCount() == 9)
1654 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1658 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1663 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1667 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1668 if (__pMenu->GetItemCount() != 9)
1670 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1671 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_COM_SK_PRINT"), IDA_PRINT_CLICKED);
1672 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1673 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1674 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1675 __pMenu->SetMaxVisibleItemsCount(6);
1677 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1679 AppLog(" Orientation landscape");
1680 __pMenu->SetMaxVisibleItemsCount(5);
1684 AppLog(" Orientation potrait");
1685 __pMenu->SetMaxVisibleItemsCount(6);
1688 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1691 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1692 __pMenu->SetShowState(true);
1693 __pMenu->Invalidate(true);
1697 case IDA_HISTORY_CLICKED:
1699 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1700 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1703 case IDA_SAVED_PAGES_CLICKED:
1708 case IDA_DESKTOP_VIEW_CLICKED:
1713 case IDA_SAVE_CLICKED:
1718 case IDA_MULTIWINDOWBTN_CLICKED:
1720 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1721 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1725 case IDA_NEWWINDOWBTN_CLICKED:
1727 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1729 if (pNewWindowInfo == null)
1733 result r = E_SUCCESS;
1734 SceneManager* pSceneManager = SceneManager::GetInstance();
1736 if (pSceneManager == NULL)
1740 ArrayList* pArgList = new(std::nothrow) ArrayList();
1741 if (pArgList == NULL)
1745 r = pArgList->Construct();
1748 pArgList->Add(*pNewWindowInfo);
1749 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1755 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1760 case IDA_SMALLFONT_BTN_CLICKED:
1762 WebSetting setting = __pWebReader->GetSetting();
1763 setting.SetFontSize(15);
1764 __pWebReader->SetSetting(setting);
1767 case IDA_LARGEFONT_BTN_CLICKED:
1769 WebSetting setting = __pWebReader->GetSetting();
1770 setting.SetFontSize(25);
1771 __pWebReader->SetSetting(setting);
1774 case IDA_READER_CLOSE_CLICKED:
1776 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1778 RemoveControl(__pBlankPanel);
1779 __pArticleReaderPanel = null;
1780 __pBlankPanel = null;
1781 __pArticleReaderLabel = null;
1783 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1786 case IDA_FINDWORD_CANCEL_CLICKED:
1788 __currentSearchStr = L"";
1789 __currentWordIndex = 0;
1790 __maxOccurrances = 0;
1791 __pFindWordEditField->SetText(L"");
1792 __pFindWordNext->SetEnabled(false);
1793 __pFindWordPrev->SetEnabled(false);
1794 __pFindWordCountLabel->SetText(L"0/0");
1795 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1796 AppLog("akjshdasd 1");
1797 __pFooterPanel->SetShowState(true);
1798 ShowFindWordPanel(false);
1801 case IDA_FINDWORD_SEARCH_CLICKED:
1803 __currentSearchStr = __pFindWordEditField->GetText();
1804 if (__currentSearchStr.GetLength() > 0)
1810 AppLogDebug("Enter something");
1814 case IDA_FINDWORD_CLEAR_CLICKED:
1816 __pFindWordCountLabel->SetText(L"0/0");
1817 __pFindWordEditField->SetText(L"");
1818 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1820 __currentSearchStr = L"";
1821 __pFindWordNext->SetEnabled(false);
1822 __pFindWordPrev->SetEnabled(false);
1823 __pFindWordControl->Invalidate(true);
1826 case IDA_FINDWORD_NEXT_CLICKED:
1831 case IDA_FINDWORD_PREV_CLICKED:
1833 FindNextWord(false);
1836 case IDA_BRIGHTNESS_BTN_CLICKED:
1838 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1839 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1842 case IDA_COPY_IMAGE_CLICKED:
1844 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1845 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1847 const Bitmap* pBitmap = null;
1848 if (__pHitElementResult != null)
1850 pBitmap = __pHitElementResult->GetImage();
1853 String resourcePath = App::GetInstance()->GetAppResourcePath();
1854 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1856 // copying the item to clipboard
1857 Clipboard* pClipboard = Clipboard::GetInstance();
1858 if (pClipboard != null)
1860 pClipboard->CopyItem(item);
1864 case IDA_VIEW_IMAGE_CLICKED:
1866 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1867 WindowInfo* pNewWindowInfo = null;
1868 if (__pHitElementResult != null)
1870 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1871 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1877 case IDA_SAVE_IMAGE_CLICKED:
1879 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1880 const Bitmap* pSaveBitmap = null;
1881 String imageName = GetImagePath();
1882 AppLog("Content manager image name %ls",imageName.GetPointer());
1885 imagePath.Append(imageName);
1886 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1887 AppLog("Content manager image path %ls",imagePath.GetPointer());
1888 if (__pHitElementResult != null)
1890 pSaveBitmap = __pHitElementResult->GetImage();
1892 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1896 UpdateImageContent(pBuffer, imageName);
1898 NotificationPanel *pNotification = new NotificationPanel(*this);
1900 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1901 msg.Append(imagePath);
1902 if (pNotification != null)
1904 pNotification->SetText(msg);
1905 if (__pFooterPanel->GetShowState() == true)
1907 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1911 pNotification->SetPositionDiff(0);
1914 pNotification->ShowNotification();
1919 int __modalMsgBoxResult;
1920 MessageBox* pMsgBox = new MessageBox();
1921 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1922 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1925 __modalMsgBoxResult = 0;
1929 case IDA_SHARE_IMAGE_CLICKED:
1931 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1932 if (__pPopUp != null)
1937 __pPopUp = new(std::nothrow) SharePopup();
1938 __pPopUp->Initialize();
1939 if (__pHitElementResult != null)
1941 const Bitmap* pSaveBitmap = null;
1942 String imageName = GetImagePath();
1943 AppLog("Content manager image name %ls",imageName.GetPointer());
1946 imagePath.Append(imageName);
1947 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1948 AppLog("Content manager image path %ls",imagePath.GetPointer());
1949 if (__pHitElementResult != null)
1951 pSaveBitmap = __pHitElementResult->GetImage();
1953 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1955 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1956 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1958 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1959 pShareInfo->SetPageTitle(L"");
1960 pShareInfo->SetPageUrl(srcUrl);
1961 pShareInfo->SetImageAttached(true);
1962 pShareInfo->SetImagePath(imagePath);
1963 __pPopUp->RemoveAllShareInfo();
1964 __pPopUp->AddShareInfo(pShareInfo);
1965 __pPopUp->SetShowState(true);
1970 case IDA_HYPERLINK_OPEN_CLICKED:
1972 if (__pHitElementResult != null)
1974 String srcUrl = __pHitElementResult->GetUrl();
1976 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
1978 if (pNewWindowInfo == null)
1982 result r = E_SUCCESS;
1983 SceneManager* pSceneManager = SceneManager::GetInstance();
1984 if (pSceneManager == NULL)
1988 ArrayList* pArgList = new(std::nothrow) ArrayList();
1989 if (pArgList == NULL)
1993 pArgList->Construct();
1995 pArgList->Add(*pNewWindowInfo);
1996 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1997 if (pArgList != null)
2004 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2010 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2012 if (__pHitElementResult == null)
2017 if(__pPopUp != null)
2022 __pPopUp = new(std::nothrow) SharePopup();
2023 __pPopUp->Initialize();
2025 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2026 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2027 pShareInfo->SetImageAttached(false);
2028 __pPopUp->RemoveAllShareInfo();
2029 __pPopUp->AddShareInfo(pShareInfo);
2031 __pPopUp->SetShowState(true);
2035 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2039 if (__pHitElementResult != null)
2041 url = __pHitElementResult->GetUrl();
2044 String resourcePath = App::GetInstance()->GetAppResourcePath();
2045 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2047 // copying the item to clipboard
2048 Clipboard* pClipboard = Clipboard::GetInstance();
2049 if (pClipboard != null)
2051 pClipboard->CopyItem(item);
2055 case IDA_FIND_TEXT__CLICKED:
2057 // AddressBarCancelledClicked(*__pAddressbar);
2058 RelayoutControls(false);
2059 // __pFooterPanel->SetShowState(false);
2060 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2061 __currentSearchStr.Clear();
2062 __currentSearchStr.Append(__currentSelectedStr);
2063 InitFindWordPanel();
2064 __pFindWordEditField->SetText(__currentSearchStr);
2067 __pMenu->SetShowState(false);
2068 __pMenu->Invalidate(false);
2071 __adressPanelPosition.y = 0;
2073 if (__pAddressbar != null && __pWebViewer != NULL)
2075 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2076 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2078 if (__pFooterPanel->GetShowState() == false)
2079 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2081 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2082 __pWebViewer->Invalidate(true);
2085 ShowFindWordPanel(true);
2086 __pFindWordEditField->SetFocus();
2087 if (__currentSearchStr.GetLength() > 0)
2093 AppLogDebug("Enter something");
2096 if (__pWebViewer != null)
2098 // releasing the set block
2099 __pWebViewer->ReleaseBlock();
2104 case IDA_SHARE_TEXT_CLICKED:
2106 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2107 if(__pPopUp != null)
2112 __pPopUp = new(std::nothrow) SharePopup();
2113 __pPopUp->Initialize();
2114 if (__pHitElementResult != null)
2116 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2117 pShareInfo->SetPageTitle(L"");
2118 pShareInfo->SetPageUrl(__currentSelectedStr);
2119 pShareInfo->SetImageAttached(false);
2120 __pPopUp->RemoveAllShareInfo();
2121 __pPopUp->AddShareInfo(pShareInfo);
2122 __pPopUp->SetShowState(true);
2127 case IDA_COPY_TEXT_CLICKED:
2129 __pWebViewer->ReleaseBlock();
2130 // need to implement
2131 //__currentSelectedStr
2132 // Sets data to a clip board item
2134 String resourcePath = App::GetInstance()->GetAppResourcePath();
2135 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2137 // copying the item to clipboard
2138 Clipboard* pClipboard = Clipboard::GetInstance();
2139 if (pClipboard != null)
2141 pClipboard->CopyItem(item);
2145 case IDA_PASTE_TEXT_CLICKED:
2147 Clipboard* pClipboard = Clipboard::GetInstance();
2149 if(pClipboard == null)
2153 // Retrieves a latest item
2154 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2160 //Gets data from the clipboard item
2161 String* pString = dynamic_cast<String*>(pItem->GetData());
2163 if (pString != null)
2165 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2166 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2167 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2170 if(idElement.GetLength() != 0)
2172 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementById(myField).focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (document.getElementById(myField).selectionStart || document.getElementById(myField).selectionStart == '0'){ var startPos = document.getElementById(myField).selectionStart; var endPos = document.getElementById(myField).selectionEnd; document.getElementById(myField).value = document.getElementById(myField).value.substring(0, startPos)+ myValue + document.getElementById(myField).value.substring(endPos, document.getElementById(myField).value.length); } else { document.getElementById(myField).value += myValue; } } ";
2173 script.Append("insertAtCursor('");
2174 script.Append(idElement);
2175 script.Append("',");
2176 script.Append("\"");
2177 script.Append(*pString);
2178 script.Append("\");");
2180 else if (nameElement.GetLength() != 0)
2182 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].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 { document.getElementByName(myField)[0].value += myValue; } } ";
2183 script.Append("insertAtCursor(document.getElementsByName('");
2184 script.Append(nameElement);
2185 script.Append("')[0],");
2186 script.Append("\"");
2187 script.Append(*pString);
2188 script.Append("\");");
2190 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2191 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2202 case IDA_GO_FORWARD:
2207 case IDA_REFRESH_BTN_CLICKED:
2209 __isLoadingCompleted = false;
2210 __isLoadingData = true;
2211 __progressPercentage = 0;
2212 __displayUrl = __pFooterUrlField->GetText();
2214 String url = __pFooterUrlField->GetText();
2215 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2219 UpdateProgressBitmap();
2222 case IDA_STOP_BTN_CLICKED:
2224 __isLoadingCompleted = false;
2225 __isLoadingData = false;
2226 __progressPercentage = 0;
2227 __pFooterUrlField->HideKeypad();
2228 __displayUrl = __pFooterUrlField->GetText();
2232 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2233 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2234 __pWebViewer->StopLoading();
2235 RequestRedraw(true);
2238 UpdateProgressBitmap();
2243 if (__pFooterUrlField->GetText().IsEmpty() == false)
2245 //__displayUrl = __pUrlField->GetText();
2246 __pFooterUrlField->Clear();
2251 case IDA_READER_BTN_CLICKED:
2262 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2265 UiApp* pApp = UiApp::GetInstance();
2274 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2275 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2277 AppLog("MainForm::OnSceneActivatedN called");
2278 String* pSelectedScene = NULL;
2279 Object* pValue = NULL;
2280 String* pUrl = null;
2281 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2282 pSelectedScene = (String*) pValue;
2284 if (pSelectedScene != null)
2286 delete pSelectedScene;
2288 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2289 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2290 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2291 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2293 // setting the current scene ID
2294 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2296 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2298 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2300 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2301 if(__pWindowInfo == null)
2303 // if(__pWindowInfo == null)
2305 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2308 else if ( pArgs != null && pArgs->GetCount() == 1)
2310 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2316 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2318 // hiding the address bar
2319 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2320 __pAddressbar->SetShowState(false);
2321 if(__pWebViewer != null)
2323 __pWebViewer->Resume();
2326 if(pUrl != null && pUrl->GetLength() > 0)
2330 else if(__pWindowInfo != null)
2332 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)
2334 LoadUrl(__pWindowInfo->pageUrl);
2336 else if (__pWindowInfo->isJavascriptInitiated == true)
2340 __pWindowInfo->pCurrentWeb = __pWebViewer;
2344 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2345 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2346 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2348 InitMostVisitedSitesView(GetOrientationStatus());
2350 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2352 if(__pMostVisitedListView != null)
2354 __pMostVisitedListView->SetShowState(false);
2358 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2360 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2362 if (pBookmarkUrl == null)
2364 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2365 //__pAddressbar->SetUrl(*pBookmarkUrl);
2366 SetUrl(*pBookmarkUrl);
2368 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2369 __pWebViewer->LoadUrl(*pBookmarkUrl);
2370 delete pBookmarkUrl;
2373 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2374 Bitmap* pBitmap = null;
2375 if (isPrivateBrowsing == true)
2377 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2379 if (__pWebViewer != null)
2381 __pWebViewer->SetPrivateBrowsingEnabled(true);
2384 if (__pAddressbar != null)
2386 // __pAddressbar->UpdateFaviconBitmap(true);
2392 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2394 if (__pWebViewer != null)
2396 __pWebViewer->SetPrivateBrowsingEnabled(false);
2399 if (__pAddressbar != null)
2401 // __pAddressbar->UpdateFaviconBitmap(false);
2405 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2407 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2409 else if (__pMenu != null )
2411 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2414 if (pBitmap != null)
2419 AppLog("ABC: OnSceneActivatedN started exit");
2424 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2425 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2427 Canvas* pWebCanvas = null;
2428 if (__pWebViewer != null)
2430 pWebCanvas = __pWebViewer->GetCanvasN();
2431 __pWebViewer->Pause();
2434 if (pWebCanvas == null)
2438 if (__pWindowInfo != null)
2440 if (__pWindowInfo->pWebCanvasBitmap != null)
2442 delete __pWindowInfo->pWebCanvasBitmap;
2444 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2445 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2446 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2448 Bitmap* pBitmap = GetCapturedBitmapN();
2449 AppLog("Coming here");
2450 Canvas* pCanvas = new(std::nothrow) Canvas();
2451 pCanvas->Construct(GetClientAreaBounds());
2454 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2457 if(__pWebViewer != null && __pWindowInfo != null)
2458 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2460 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2461 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2463 AppLog("Coming here");
2467 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2468 const Tizen::Base::String& realm,
2469 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2475 MainForm::OnHttpAuthenticationCanceled(void)
2480 MainForm::OnLoadingStarted(void)
2482 AppLogDebug("MainForm::OnLoadingStarted entered");
2484 if(__pAddressbar == NULL || __pWebViewer == null)
2488 // this is added in case if menu is opened and user load the page
2489 if(__pMenu != null && __pMenu->GetShowState() == true)
2491 __pMenu->SetShowState(false);
2492 __pMenu->Invalidate(true);
2494 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2496 __pImageMenu->SetShowState(false);
2497 __pImageMenu->Invalidate(true);
2499 String url = __pWebViewer->GetUrl();
2500 if(url.Contains(IDS_TIZEN_SERVICE))
2503 String delim(L":;");
2505 // Creates a StringTokenizer instance
2506 StringTokenizer strTok(url, delim);
2508 int count = strTok.GetTokenCount(); // count == 4
2510 HashMap *pMap = new HashMap();
2515 while (strTok.HasMoreTokens())
2517 AppLog("Token: %ls", token.GetPointer());
2518 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2519 if(token.Contains(IDS_APPID))
2521 token.SubString(6, appId);
2522 AppLog("AppID:%ls", appId.GetPointer());
2524 else if(token.Contains("="))
2526 String *pKey = new String();
2527 String *pValue = new String();
2529 token.IndexOf("=", 0, index);
2532 token.SubString(0, index, *pKey);
2533 token.SubString(index + 1, *pValue);
2534 pMap->Add(pKey, pValue);
2540 AppControl *pAppControl = null;
2541 String operationId = L"http://tizen.org/appcontrol/operation/main";
2542 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2545 AppLog("Starting AppControl");
2546 result r = pAppControl->Start(null, null, pMap, null);
2547 AppLog("Result of Start %s", GetErrorMessage(r));
2551 AppLogException("AppControl not found");
2556 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2558 __pAddressbar->SetShowState(false);
2559 AddressBarCancelledClicked(*__pAddressbar);
2560 __pAddressbar->Invalidate(true);
2562 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2565 __pAddressbar->SetFaviconBitmap(*pBitmap);
2568 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2570 // updating the address bar position with respect to web control
2571 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2572 __distanceMoved = 0;
2576 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2577 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2578 if (__pWebViewer != null)
2580 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2581 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2582 SetUrl(__pWebViewer->GetUrl());
2583 if (__pWindowInfo != NULL)
2585 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2586 __pWindowInfo->pageTitle = L"";
2587 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2589 __pAddressbar->Invalidate(true);
2595 MainForm::OnLoadingCanceled(void)
2602 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2604 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2609 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2611 AppLog("XYZ::MainForm::OnKeypadOpened");
2616 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2618 AppLog("XYZ::MainForm::OnKeypadClosed");
2619 RelayoutControls(true);
2623 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2625 AppLog("KeypadBoundsChanged");
2626 RelayoutControls(false);
2630 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2631 const Tizen::Base::String& reason)
2633 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2637 MainForm::OnLoadingCompleted(void)
2639 AppLog("MainForm::OnLoadingCompleted start");
2641 result r = E_SUCCESS;
2643 if (__pWebViewer == null)
2648 if (__pAddressbar == null)
2652 if (__pWebViewer->CanGoForward())
2654 //__pAddressbar->SetForwardButtonEnabled(true);
2655 SetForwardButtonEnabled(true);
2659 //__pAddressbar->SetForwardButtonEnabled(false);
2660 SetForwardButtonEnabled(false);
2663 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2665 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2667 //__pAddressbar->UpdateProgress(0);
2671 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2673 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2677 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2678 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2679 if (isPrivateBrowsing == false)
2681 if(__pHistory != null)
2687 __pHistory = new(std::nothrow) History;
2688 HistoryPresentationModel::GetCurrentDateTime(date);
2691 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2692 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2694 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2695 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2697 __pHistory->SetVisitedTime(date);
2699 if (__pWebViewer != null)
2701 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2703 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2704 if (pTempBitmap != null)
2706 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2707 __pHistory->SetFavIconBitmap(*pTempBitmap);
2710 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2713 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2714 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2715 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2717 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2718 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2719 __pHistory->SetThumbnail(pBitmap);
2721 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2724 __pHistory->SetFavIconBitmap(*pFavIcon);
2728 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2735 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2737 // temperary fixed (webpage can be not loaded)
2741 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2742 if (isReaderEnabled == true)
2746 delete __pReaderData;
2747 __pReaderData = null;
2749 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2750 filePath.Append(L"data/reader.js");
2756 result r = E_SUCCESS;
2757 FileAttributes attr;
2759 File::GetAttributes(filePath,attr);
2761 r = file.Construct(filePath, L"r+");
2764 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2767 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2770 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2773 // file.Read(pScript,attr.GetFileSize());
2775 // AppLogDebug("scipt length %d",strlen(pScript));
2776 String strScript = L"";
2777 // strScript.Append(pScript);
2778 // for(int i=0; i<25; i++)
2780 file.Read(pScript,attr.GetFileSize());
2781 // AppLog("xyzz tell %d",file.Tell());
2782 // r = strScript.Append(pScript);
2783 // AppLog("xyzz append result %s",GetErrorMessage(r));
2784 // AppLog("xyzz strScript length %d",strScript.GetLength());
2786 // AppLog("xyzz final strScript length %d",strScript.GetLength());
2788 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
2789 if (__pReaderData == null)
2791 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2792 __pReaderData = new String(L"<meta name=\"viewport\" content=\"width=0, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\"> <h1>Chinese PM Li Keqiang vows to open up markets to India</h1><div><span class=\"arttle\"><h1>Chinese PM Li Keqiang vows to open up markets to India</h1></span></div>");
2795 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2796 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2798 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2799 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2805 AppLog("MainForm::OnLoadingCompleted done");
2809 MainForm::OnEstimatedProgress(int progress)
2811 AppLogDebug("MainForm::OnEstimatedProgress entered");
2812 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2813 progress = DEFAULT_PROGRESS_PERCENTAGE;
2815 // __pAddressbar->UpdateProgress(progress);
2816 UpdateProgress(progress);
2819 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2821 AppLog("MainForm::OnFaviconReceived");
2822 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2824 Bitmap* favIcon = __pWebViewer->GetFaviconN();
2827 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
2834 MainForm::OnUrlValueChanged(Addressbar&)
2840 MainForm::OnUrlSubmitted(Addressbar& addBar)
2842 AppLog("MainForm::OnUrlSubmitted");
2843 String url = addBar.GetUrl();
2844 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2846 if(__pFooterUrlField)
2847 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2848 AddressBarCancelledClicked(*__pAddressbar);
2853 MainForm::LoadUrl(String& url)
2857 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2858 AppLogDebug("MainForm::LoadUrl enter");
2860 if (__pWebViewer != null)
2862 __pWebViewer->SetShowState(true);
2863 __pWebViewer->Invalidate(true);
2866 if (url.CompareTo(L"") == 0)
2870 if(__pFooterPanel != null)
2872 __pFooterPanel->SetShowState(true);
2873 __pFooterPanel->Invalidate(true);
2880 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2881 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)
2883 RegularExpression firstRegex;
2884 RegularExpression secondRegex;
2886 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2887 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2890 ret = firstRegex.Match(url, false); // This returns true value
2891 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2893 if (ret == true && __pWebViewer != null)
2896 __pWebViewer->LoadUrl(url);
2898 else if(__pWebViewer != null)
2900 String tempUrl = L"http://";
2901 tempUrl.Append(url);
2905 __pWebViewer->LoadUrl(tempUrl);
2909 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2910 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2913 if (__pAddressbar != null)
2915 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2916 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2919 AppLogDebug("MainForm::LoadUrl exit");
2926 MainForm::OnStopClicked(Addressbar& addBar)
2928 AppLogDebug("MainForm::OnStopClicked called");
2931 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2932 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2933 __pWebViewer->StopLoading();
2934 RequestRedraw(true);
2939 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2941 // AppLog("MainForm::OnBackClicked");
2942 result r = E_FAILURE;
2944 if (__pWebViewer && __pWebViewer->CanGoBack())
2946 __pWebViewer->GoBack();
2948 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2951 pApp = UiApp::GetInstance();
2954 r = pApp->Terminate();
2957 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2965 WindowInfo* pWindowInfo = null;
2967 SceneManager* pSceneManager = SceneManager::GetInstance();
2968 if (pSceneManager == null)
2972 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2973 if (pAllWindowList == NULL)
2975 pApp = UiApp::GetInstance();
2978 r = pApp->Terminate();
2981 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2986 if (pAllWindowList != null)
2988 totalCount = pAllWindowList->GetCount();
2990 for (int count = 0; count < totalCount; count++)
2992 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2993 if (pWindowInfo == null)
2995 pApp = UiApp::GetInstance();
2998 r = pApp->Terminate();
3001 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3006 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3008 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3011 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3014 r = pAllWindowList->RemoveAt(count, true);
3015 __pWindowInfo = null;
3018 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3023 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3027 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3029 if (pWindowInfo == null)
3031 pApp = UiApp::GetInstance();
3034 r = pApp->Terminate();
3040 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3043 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3057 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3059 AppLog("MainForm::OnForwardClicked");
3060 if (__pWebViewer == null)
3063 if (__pWebViewer->CanGoForward())
3065 __pWebViewer->GoForward();
3070 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3072 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3073 if(__pFooterPanel != null)
3075 __pFooterPanel->SetShowState(false);
3078 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3080 __pAddressbar->SetShowState(true);
3081 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3084 RelayoutControls(false);
3088 MainForm::OnAddressBarFocusLost(const Addressbar& addBar)
3090 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3093 __pAddressbar->SetShowState(false);
3096 AppLog("akjshdasd 3");
3097 __pFooterPanel->SetShowState(true);
3100 RelayoutControls(false);
3104 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3106 AddressBarCancelledClicked(addBar);
3110 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3112 __prevAddressBarMode = __curAddressBarMode;
3114 if (__pAddressbar != null)
3116 __curAddressBarMode = GetAddressbarMode();
3119 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3121 __adressPanelPosition.y = 0;
3122 if (__pAddressbar != null)
3124 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3125 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3126 __pAddressbar->Invalidate(true);
3128 if (__pWebViewer != null)
3130 __pWebViewer->StopLoading();
3133 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3135 __adressPanelPosition.y = 0;
3136 if (__pAddressbar != null)
3138 __webControlPosition.y = 0;
3139 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3140 __pAddressbar->Invalidate(true);
3146 MainForm::OnClipboardClosed(const Addressbar& addBar)
3148 RelayoutControls(false);
3152 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3154 RelayoutControls(false,footerState);
3158 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3160 RelayoutControls(false);
3164 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3166 __pFooterPanel->SetShowState(false);
3170 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3172 AppLog("KeypadBoundsChanged");
3173 RelayoutControls(false);
3177 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3181 __pWindowInfo->pageTitle = title;
3182 if (__pWebViewer != null)
3184 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3187 if (__pAddressbar != null && __pWebViewer != null)
3189 SetUrl(__pWebViewer->GetUrl());
3190 __pAddressbar->Invalidate(true);
3195 MainForm::UpdateFavicon(void)
3197 bool urlImageType = false;
3198 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();");
3199 Bitmap* pBitmap = null;
3201 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3203 if (__pWindowInfo != null)
3206 url.SetUri(*tempPath);
3207 if (url.GetHost().GetLength() == 0)
3210 webUrl.SetUri(__pWebViewer->GetUrl());
3211 result r = url.SetHost(webUrl.GetHost());
3218 if (url.GetScheme().GetLength() == 0)
3221 webUrl.SetUri(__pWebViewer->GetUrl());
3222 url.SetScheme(webUrl.GetScheme());
3224 __pWindowInfo->faviconUrl = url.ToString();
3226 pBitmap = __pWebViewer->GetFaviconN();
3228 if (pBitmap != null)
3230 if (__pWindowInfo->pFavicon != NULL)
3232 __pWindowInfo->pFavicon = null;
3234 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3235 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3237 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3239 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3241 else if(__pWindowInfo->pFavicon != null)
3243 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3247 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3248 if(pDefaultBmp != null)
3250 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3259 if(tempPath != null)
3263 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3270 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3271 Tizen::Web::Controls::WebNavigationType type)
3273 // when load new page if find word panel is open its show state is false
3274 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3276 __currentSearchStr = L"";
3277 __currentWordIndex = 0;
3278 __maxOccurrances = 0;
3279 __pFindWordEditField->SetText(L"");
3280 __pFindWordNext->SetEnabled(false);
3281 __pFindWordPrev->SetEnabled(false);
3282 __pFindWordCountLabel->SetText(L"0/0");
3283 __pFindWordControl->SetShowState(false);
3284 __pFindWordEditField->HideKeypad();
3285 RelayoutControls(false);
3290 __pFooterPanel->Invalidate(true);
3293 uriInfo.SetUri(url);
3295 if(url.Contains(IDS_TIZEN_SERVICE))
3298 String delim(L":;,");
3300 // Creates a StringTokenizer instance
3301 StringTokenizer strTok(url, delim);
3303 int count = strTok.GetTokenCount(); // count == 4
3305 HashMap *pMap = new HashMap();
3311 while (strTok.HasMoreTokens())
3313 AppLog("Token: %ls", token.GetPointer());
3314 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3315 if(token.Contains(IDS_APPID))
3317 token.SubString(6, appId);
3318 AppLog("AppID:%ls", appId.GetPointer());
3320 else if(token.Contains("="))
3322 String *pKey = new String();
3323 String *pValue = new String();
3325 token.IndexOf("=", 0, index);
3328 token.SubString(0, index, *pKey);
3329 token.SubString(index + 1, *pValue);
3330 pMap->Add(pKey, pValue);
3336 AppControl *pAppControl = null;
3337 String operationId = L"http://tizen.org/appcontrol/operation/main";
3338 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3341 result r = pAppControl->Start(null, null, pMap, null);
3345 AppLogException("AppControl not found");
3355 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3356 const Tizen::Net::Http::HttpHeader& httpHeader)
3358 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3363 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3365 AppLog("MainForm::OnWebPageBlockSelected");
3366 if (__pHitElementResult != null)
3368 delete __pHitElementResult;
3369 __pHitElementResult = null;
3372 if (__pWebViewer != null)
3374 AppLog("MainForm::OnWebPageBlockSelected web not null");
3375 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3376 if(GetLastResult() == E_INVALID_ARG)
3378 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3382 if (__pHitElementResult == null)
3387 if (__pHitElementResult->HasImage() != true)
3389 String tagName = __pHitElementResult->GetTagName();
3390 String type = __pHitElementResult->GetAttributeValue("type");
3392 __currentSelectedStr.Clear();
3393 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3394 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3395 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3397 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3399 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3401 InitSelectTextContextMenu(endPoint,true);
3402 __pImageMenu->SetShowState(true);
3403 __pImageMenu->Show();
3404 __pImageMenu->Invalidate(true);
3406 else if(__isLongPressedDone == true)
3408 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3410 if(__pHitElementResult->GetUrl().GetLength() > 0)
3412 __currentSelectedStr.Clear();
3413 __currentSelectedStr = __pHitElementResult->GetUrl();
3415 InitSelectTextContextMenu(endPoint,false);
3416 __pImageMenu->SetShowState(true);
3417 __pImageMenu->Show();
3418 __pImageMenu->Invalidate(true);
3421 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3422 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3423 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3429 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3435 MainForm::OnWebWindowCreateRequested(void)
3437 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3439 if (pNewWindowInfo == null)
3443 result r = E_SUCCESS;
3444 SceneManager* pSceneManager = SceneManager::GetInstance();
3445 if (pSceneManager == NULL)
3449 ArrayList* pArgList = new(std::nothrow) ArrayList();
3450 if (pArgList == NULL)
3454 r = pArgList->Construct();
3457 pNewWindowInfo->isJavascriptInitiated = true;
3458 pArgList->Add(*pNewWindowInfo);
3459 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3463 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3470 return pNewWindowInfo->pCurrentWeb;
3474 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3476 __webControlPosition.y = 0;
3477 __webControlHeight = GetClientAreaBounds().height;
3478 AppLog("Client area height: %d", __webControlHeight);
3480 AppLog("Client area height: %d", __webControlHeight);
3481 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3483 __webControlPosition.y += __pAddressbar->GetHeight();
3484 __webControlHeight -= __pAddressbar->GetHeight();
3485 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3487 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3489 __webControlPosition.y += __pFindWordControl->GetHeight();
3490 __webControlHeight -= __pFindWordControl->GetHeight();
3491 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3494 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3496 __webControlHeight -= __pFooterPanel->GetHeight();
3498 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3500 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3502 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3503 __pWebViewer->Invalidate(false);
3505 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3507 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3514 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3516 if (__pFindWordControl == null)
3522 InitFindWordPanel();
3523 // __pFindWordEditField->SetText(__currentSearchStr);
3524 //__pFindWordCountLabel->SetText(L"");
3525 // __pFindWordCountLabel->SetText(L"0/0");
3526 __pFindWordControl->SetShowState(true);
3530 if(__pFindWordControl != null)
3532 __pFindWordControl->SetShowState(false);
3536 AppLog("MainForm::ShowFindWordPanel %d",show);
3537 if (show && !isTouchPressed)
3539 if (__pFindWordEditField)
3541 __pFindWordEditField->SetFocus();
3542 __pFindWordEditField->ShowKeypad();
3547 if (__pFindWordEditField)
3548 __pFindWordEditField->HideKeypad();
3551 RelayoutControls(false);
3555 MainForm::StartWordSearch()
3557 //Get the count of occurances of the word in the current page
3558 __maxOccurrances = 0;
3559 __currentWordIndex = 0;
3561 __pFindWordPrev->SetEnabled(false);
3562 String *pCountStr = null;
3563 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3564 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3565 if (pCountStr != null)
3567 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3571 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3576 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3578 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3579 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3581 if(totalCount == -1 || totalCount == 0)
3583 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3584 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3587 else if(totalCount > 100)
3589 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3590 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3594 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3595 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3598 __maxOccurrances = totalCount;
3599 __currentWordIndex = currentOrdinal;
3601 //Reset the UI controls as per the maxOccurrance value
3602 if (totalCount <= 0)
3604 AppLog("Word not found");
3605 //Show error notification to user
3606 __pFindWordNext->SetEnabled(false);
3607 __pFindWordCountLabel->SetText(L"0/0");
3608 __pFindWordNext->Invalidate(false);
3609 __pFindWordPrev->Invalidate(false);
3610 __pFindWordCountLabel->Invalidate(false);
3614 if (totalCount == 1)
3616 __pFindWordNext->SetEnabled(false);
3620 __pFindWordNext->SetEnabled(true);
3623 String countStr = L"";
3624 countStr.Append(__currentWordIndex);
3625 countStr.Append(L"/");
3626 countStr.Append(__maxOccurrances);
3627 __pFindWordCountLabel->SetText(countStr);
3628 // __pFindWordCountLabel->SetShowState(true);
3629 __pFindWordCountLabel->Invalidate(false);
3631 //FindNextWord(true);
3632 //Update the controls
3633 __pFindWordNext->Invalidate(false);
3634 __pFindWordPrev->Invalidate(false);
3635 __pFindWordCountLabel->Invalidate(false);
3639 MainForm::FindNextWord(bool next)
3643 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3645 if(__currentWordIndex < __maxOccurrances)
3647 __currentWordIndex++;
3653 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3655 if(__currentWordIndex > 1)
3657 __currentWordIndex--;
3662 String countStr = L"";
3663 countStr.Append(__currentWordIndex);
3664 countStr.Append(L"/");
3665 countStr.Append(__maxOccurrances);
3666 __pFindWordCountLabel->SetText(countStr);
3667 // __pFindWordCountLabel->SetShowState(true);
3668 __pFindWordCountLabel->Invalidate(false);
3669 if (__currentWordIndex >= __maxOccurrances)
3671 __pFindWordNext->SetEnabled(false);
3675 __pFindWordNext->SetEnabled(true);
3677 if (__currentWordIndex <= 1)
3679 __pFindWordPrev->SetEnabled(false);
3683 __pFindWordPrev->SetEnabled(true);
3685 __pFindWordPrev->Invalidate(false);
3686 __pFindWordNext->Invalidate(false);
3687 __pFindWordCountLabel->Invalidate(false);
3688 __pFindWordControl->Invalidate(true);
3692 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3694 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
3695 __isWebKeypadOpened = true;
3696 __pFooterPanel->SetShowState(false);
3697 // OnAddressBarKeypadOpened(*__pAddressbar);
3701 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3703 AppLog("xyz::MainForm::OnWebKeypadOpened");
3705 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3707 __currentSearchStr = L"";
3708 __currentWordIndex = 0;
3709 __maxOccurrances = 0;
3710 __pFindWordEditField->SetText(L"");
3711 __pFindWordNext->SetEnabled(false);
3712 __pFindWordPrev->SetEnabled(false);
3713 __pFindWordCountLabel->SetText(L"0/0");
3714 __pWebViewer->SearchTextAllAsync(L"",false);
3715 __pFindWordControl->SetShowState(false);
3716 __pFindWordEditField->HideKeypad();
3720 if (__pWebViewer != null && __pFooterPanel != null)
3722 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3723 if(__pAddressbar != null)
3725 __pAddressbar->SetShowState(false);
3727 if(__pFindWordControl != null)
3729 __pFindWordControl->SetShowState(false);
3731 __pFooterPanel->SetShowState(false);
3732 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3734 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3736 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3737 // AppLog("omgomgomg");
3743 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3745 AppLog("xyz::MainForm::OnWebKeypadClosed");
3746 AppLog("akjshdasd 4");
3747 __pFooterPanel->SetShowState(true);
3748 // OnAddressBarKeypadClosed(*__pAddressbar);
3749 RelayoutControls(false);
3750 __isWebKeypadOpened = false;
3754 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3756 Control* temp = const_cast< Control* >(&source);
3757 Header* pHeader = dynamic_cast< Header* >(temp);
3758 if (pHeader != null)
3760 //Header double - clicked
3761 AppLog("Header double clicked");
3763 if(__pFindWordControl)
3765 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3766 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3770 AppLog("MainScene::OnTouchDoublePressed");
3774 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3776 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3778 if (__pHitElementResult != null)
3780 delete __pHitElementResult;
3781 __pHitElementResult = null;
3784 if (__pWebViewer != null)
3786 AppLog("MainForm::OnTouchLongPressed web not null");
3787 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3790 if (__pHitElementResult == null)
3795 if (__pHitElementResult->HasImage() == true)
3797 InitImageContextMenu(currentPosition);
3798 __pImageMenu->SetShowState(true);
3799 __pImageMenu->Show();
3800 __pImageMenu->Invalidate(true);
3802 else if(__pHitElementResult->HasUrl() == true)
3804 String tempURl = __pHitElementResult->GetUrl();
3805 AppLog("tempURl is %ls", tempURl.GetPointer());
3806 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3807 if (pBitmap != null)
3815 InitImageLinkContextMenu(currentPosition);
3816 __pImageMenu->SetShowState(true);
3817 __pImageMenu->Show();
3818 __pImageMenu->Invalidate(true);
3822 String tagName = __pHitElementResult->GetTagName();
3823 String type = __pHitElementResult->GetAttributeValue("type");
3824 String value = __pHitElementResult->GetAttributeValue(L"value");
3825 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3827 __currentSelectedStr.Clear();
3828 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3830 AppLog("tag name is %ls", tagName.GetPointer());
3831 AppLog("type is %ls", type.GetPointer());
3832 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3834 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3836 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3838 InitSelectTextContextMenu(currentPosition,true, true);
3841 __pImageMenu->SetShowState(true);
3842 __pImageMenu->Show();
3843 __pImageMenu->Invalidate(true);
3846 __isLongPressedDone = true;
3847 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3848 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3851 // __inputEventToBeSupressed = true;
3855 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3857 AppLog("MainForm::OnTouchReleased");
3860 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3861 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3863 __pWebViewer->ConsumeInputEvent();
3865 if(pHitElement != null)
3869 __inputEventToBeSupressed = false;*/
3873 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3880 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3882 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3884 __currentSearchStr = L"";
3885 __currentWordIndex = 0;
3886 __maxOccurrances = 0;
3887 __pFindWordEditField->SetText(L"");
3888 __pFindWordNext->SetEnabled(false);
3889 __pFindWordPrev->SetEnabled(false);
3890 __pFindWordCountLabel->SetText(L"0/0");
3891 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3892 __pFindWordControl->SetShowState(false);
3893 __pFindWordEditField->HideKeypad();
3895 if(__pAddressbar->GetShowState() == false)
3897 __pAddressbar->SetAddressbarURLFocus();
3898 __pFooterPanel->SetShowState(false);
3905 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3911 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3917 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3923 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3929 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3935 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3937 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3938 int widthContextItem = 0;
3940 // As per the platform engineer comment removed this line
3941 /*if(__pWebViewer != null)
3943 // this is added because if any text is selected on long press followed by on rotation we are hiding the context menu therefore we should release the text block also
3944 __pWebViewer->ReleaseBlock();
3947 if(__pFindWordControl != null)
3948 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3949 if ( __pFooterLabel != null)
3951 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3954 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3960 if (__pFindWordBgLabel != null)
3962 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3963 if (pBitmap != null)
3965 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3971 __pMenu->SetShowState(false);
3972 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3974 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3978 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3983 AppLog("__pFooterPanel->GetShowState() is true");
3985 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3986 __pFooterPanel->Invalidate(true);
3990 if(__pMoreButton && __pMenu)
3992 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3993 __pMenu->SetAnchorPosition(p);
3994 __pMenu->Invalidate(true);
3997 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3998 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4000 InitMostVisitedSitesView(orientationStatus);
4003 RelayoutControls(false);
4004 if (__pArticleReaderPanel != null)
4006 if (__pArticleReaderPanel->GetShowState() == true)
4008 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4010 if (__pBlankPanel != null)
4011 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4013 if (__pWebReader != null)
4015 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4017 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4018 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4020 if ( pBitmap != null && pSrcBitmap != null)
4022 AppLog("CreateReaderPanel ninepatchbitmap found");
4023 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4026 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4027 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4028 if (pBitmap != null)
4033 if (pSrcBitmap != null)
4042 if (__pAddressbar != null)
4044 int width = GetClientAreaBounds().width;
4045 __pAddressbar->OrientationChanged(width);
4050 MainForm::OnSettingsChange(int settingvalue)
4052 AppLogDebug("MainForm::OnSettingsChange entered");
4054 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4056 __pAddressbar->ResetGuideText();
4058 if (__pWebViewer == null)
4060 AppLogDebug("Webviewer is not initialized yet.");
4064 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4066 WebSetting settings = __pWebViewer->GetSetting();
4067 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4069 settings.SetAutoFittingEnabled(true);
4071 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4073 settings.SetAutoFittingEnabled(false);
4075 __pWebViewer->SetSetting(settings);
4077 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4079 WebSetting settings = __pWebViewer->GetSetting();
4080 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4081 __pWebViewer->SetSetting(settings);
4083 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4085 WebSetting settings = __pWebViewer->GetSetting();
4086 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4087 __pWebViewer->SetSetting(settings);
4089 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4091 WebSetting settings = __pWebViewer->GetSetting();
4092 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4093 __pWebViewer->SetSetting(settings);
4095 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4099 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4102 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4106 WebSetting settings = __pWebViewer->GetSetting();
4107 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4110 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4114 WebSetting settings = __pWebViewer->GetSetting();
4115 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4118 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4120 WebSetting settings = __pWebViewer->GetSetting();
4121 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4123 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4127 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4129 __pWebViewer->SetSetting(settings);
4131 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4135 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4136 WebSetting settings = __pWebReader->GetSetting();
4137 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4138 __pWebReader->SetSetting(settings);
4144 MainForm::OnSettingsReset()
4148 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4149 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4154 MainForm::OnClearCache()
4156 result r = E_SUCCESS;
4158 if (__pWebViewer != NULL)
4160 r = __pWebViewer->ClearCache();
4163 AppLogDebug("Cache cleared success");
4167 AppLogDebug("Cache cleared fail");
4173 MainForm::OnClearCookie()
4175 result r = E_SUCCESS;
4177 if (__pWebViewer != NULL)
4179 __pWebViewer->ClearCookie();
4183 AppLogDebug("Cookie cleared success");
4187 AppLogDebug("Cache cleared fail");
4192 MainForm::OnClearFormData()
4194 result r = E_SUCCESS;
4196 if (__pWebViewer != NULL)
4198 __pWebViewer->ClearFormData();
4202 AppLogDebug("Cookie cleared success");
4206 AppLogDebug("Cache cleared fail");
4211 MainForm::OnClearPasswords()
4213 result r = E_SUCCESS;
4215 if (__pWebViewer != NULL)
4217 __pWebViewer->ClearLoginFormData();
4221 AppLogDebug("Cookie cleared success");
4225 AppLogDebug("Cache cleared fail");
4231 MainForm::findDistance(int x1,int y1,int x2, int y2)
4233 int deltaX = Math::Abs(x2 - x1);
4234 int deltaY = Math::Abs(y2 - y1);
4235 double num = deltaX*deltaX + deltaY*deltaY;
4241 for (i = 0; i < 20; i++)
4243 x = (((x*x)+ num)/(2*x));
4254 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4256 if(__pFindWordControl)
4258 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4259 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4261 __isLongPressedDone = false;
4264 IList* pList = null;
4265 pList = touch.GetTouchInfoListN(source);
4269 int count = pList->GetCount();
4272 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4273 __touchPoint1 = pTouchInfo->position;
4275 /*if (__pAddressbar != null)
4277 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4279 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4281 __pAddressbar->SaveAddressbarEditText();
4283 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4286 __pAddressbar->Invalidate(true);
4288 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4290 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4292 //__pAddressbar->SaveAddressbarEditText();
4294 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4297 else if (count == 2)
4299 AppLogDebug("MainForm::OnTouchPressed count is two");
4300 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4301 __touchPoint1 = pTouchInfo->position;
4303 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4304 __touchPoint2 = pTouchInfo->position;
4310 pList->RemoveAll(true);
4317 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4319 // __currentWordIndex = 0;
4320 __isLongPressedDone = false;
4325 MainForm::MoveUiControls()
4330 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4332 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4334 if(__pFooterUrlField->GetTextLength() == 0)
4336 __pFooterUrlField->SetKeypadActionEnabled(false);
4340 __pFooterUrlField->SetKeypadActionEnabled(true);
4343 if (__pFindWordEditField != null)
4345 __currentSearchStr = __pFindWordEditField->GetText();
4346 __pFindWordNext->SetEnabled(false);
4347 __pFindWordPrev->SetEnabled(false);
4348 __pFindWordNext->Invalidate(true);
4349 __pFindWordPrev->Invalidate(true);
4350 __pFindWordCountLabel->SetText(L"0/0");
4351 __pFindWordCountLabel->Invalidate(true);
4353 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4354 if (__currentSearchStr.GetLength() > 0)
4360 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4362 __currentSearchStr = L"";
4363 AppLogDebug("Enter something");
4368 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4375 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4377 if(__pWebViewer != null)
4380 AppLog("MainForm::InitMostVisitedSitesView");
4381 result r = E_SUCCESS;
4384 if (__pWebViewer != null && __pMostVisitedListView != null)
4389 if (__pMostVisitedListView != null)
4391 RemoveControl(__pMostVisitedListView);
4393 if(__pMostVisitedSites != null)
4395 __pMostVisitedSites->RemoveAll(true);
4398 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4400 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4401 __pMostVisitedListView = new(std::nothrow) ListView();
4403 int height = GetClientAreaBounds().height;
4405 if(__pFooterPanel->GetShowState() == true)
4407 height = height - __pFooterPanel->GetHeight();
4409 if(__pAddressbar->GetShowState() == true)
4411 height -= __pAddressbar->GetHeight();
4414 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4418 delete __pMostVisitedListView;
4419 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4422 __pMostVisitedListView->SetItemProvider(*this);
4423 __pMostVisitedListView->AddListViewItemEventListener(*this);
4424 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4425 AddControl(__pMostVisitedListView);
4426 __pMostVisitedListView->UpdateList();
4433 MainForm::GetImagePath(void)
4437 String formattedTime;
4438 DateTime currentTime;
4439 LocaleManager localManager;
4440 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4442 localManager.Construct();
4443 Locale locale = localManager.GetSystemLocale();
4444 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4446 // Get date formatter
4447 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4451 pTimeFormatter->Format(currentTime, formattedTime);
4454 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4455 String delim(L" :");
4456 StringTokenizer strTok(formattedTime, delim);
4459 String str1("GMT+00");
4460 while (strTok.HasMoreTokens())
4462 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4463 if(token.Equals(str1))
4465 AppLog("token is %ls", token.GetPointer());
4466 imageName.Append(token);
4472 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4474 result r = E_FAILURE;
4475 AppLog("Content manager 1");
4476 ContentId contentId;
4477 ContentManager contentManager;
4478 r = contentManager.Construct();
4481 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4484 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4485 contentPath.Append(imageName);
4486 contentPath.Append(".jpg");
4487 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4488 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4492 MainForm::SetForwardButtonEnabled(bool isEnabled)
4494 __pGoForwardBtn->SetEnabled(isEnabled);
4495 __pGoForwardBtn->Invalidate(true);
4499 MainForm::SetBackButtonEnabled(bool isEnabled)
4501 __pGoBackBtn->SetEnabled(isEnabled);
4502 __pGoBackBtn->Invalidate(true);
4506 MainForm::UpdateProgress(int percentage)
4508 __progressPercentage = percentage;
4509 if (percentage == 0 || percentage == 100)
4511 __isLoadingData = false;
4512 if (percentage == 100)
4514 __isLoadingCompleted = true;
4515 __progressPercentage = 0;
4519 __isLoadingCompleted = false;
4524 __isLoadingData = true;
4526 UpdateProgressBitmap();
4530 MainForm::GetProgress(void)
4532 return __progressPercentage;
4536 MainForm::UpdateProgressBitmap(void)
4538 result r = E_SUCCESS;
4539 if (__pProgressbarLabel == null)
4541 int w = __pProgressbarLabel->GetWidth();
4542 int h = __pProgressbarLabel->GetHeight();
4544 int progressWidth = 0;
4545 Bitmap* pRetBitmap = null;
4547 if (__progressPercentage == 0 || __progressPercentage == 100)
4549 __pProgressbarLabel->SetShowState(false);
4550 __pProgressbarLabel->Invalidate(false);
4555 __pProgressbarLabel->SetShowState(true);
4556 __pProgressbarLabel->Invalidate(false);
4559 r = canvas.Construct(Rectangle(0, 0, w, h));
4563 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4568 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4572 pBgBmp->Scale(Dimension(w, h));
4573 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4577 progressWidth = (double) (w) * __progressPercentage / 100;
4578 AppLogDebug("progressWidth: %d", progressWidth);
4579 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4581 if (pProgressBmp != null)
4583 pProgressBmp->Scale(Dimension(progressWidth, h));
4584 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4585 delete pProgressBmp;
4588 pRetBitmap = new (std::nothrow) Bitmap();
4590 if (pRetBitmap == null)
4592 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4596 pRetBitmap->Construct(canvas, canvas.GetBounds());
4598 if (__pProgressbarLabel != null && pRetBitmap != null)
4600 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4601 __pProgressbarLabel->Invalidate(false);
4604 if (pRetBitmap != null)
4613 MainForm::ReaderClicked()
4615 result r = E_SUCCESS;
4616 ArrayList* pArgList = new(std::nothrow) ArrayList();
4617 if (pArgList != null)
4619 r = pArgList->Construct();
4626 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
4633 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
4640 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
4648 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4652 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
4654 CreateReaderPanel();
4655 AppLogDebug("MainScene::ReaderClicked entered");
4658 /*if (__pArticleReaderPanel)
4660 AppLogDebug("showstate true for reader panel");
4661 __pArticleReaderPanel->SetShowState(true);
4662 __pArticleReaderPanel->Show();
4664 int xPos = __pArticleReaderPanel->GetX();
4665 int yPos = __pArticleReaderPanel->GetY();
4666 AppLog("ReaderClicked() xPos = %d",xPos);
4667 AppLog("ReaderClicked() yPos = %d",yPos);
4669 if (__pReaderData == null)
4674 String loadData = L"<html>\
4676 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
4681 background-color: transparent;\
4700 <body style='width:'";
4701 loadData.Append(bodyWidth);
4702 loadData.Append(L"px'>");
4703 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
4704 loadData.Append(*__pReaderData);
4705 loadData.Append(L"</body></html>");
4708 buf.Construct(loadData.GetLength());
4709 AppLogDebug("data->GetLength %d",loadData.GetLength());
4710 for (int z=0;z<loadData.GetLength();z++)
4713 loadData.GetCharAt(z,b);
4714 buf.SetByte((byte)b);
4718 if (__pWebReader != null)
4720 __pWebReader->LoadData(L"",buf,L"text/html");
4721 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
4725 AppLogDebug("cannot LoadData __pWebReader is null");
4730 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4732 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4734 __currentAddMode = addMode;
4738 case ADDRESSBAR_MODE_INVALID:
4743 case ADDRESSBAR_MODE_READER:
4745 __pStopBtn->SetShowState(false);
4746 __pRefreshBtn->SetShowState(false);
4747 __pClearBtn->SetShowState(false);
4748 __pReaderBtn->SetShowState(false);
4751 case ADDRESSBAR_MODE_LOADING:
4753 __pRefreshBtn->SetShowState(false);
4754 __pStopBtn->SetShowState(true);
4755 __pClearBtn->SetShowState(false);
4756 __pReaderBtn->SetShowState(false);
4759 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4761 // SetUrl(__pAddressbar->GetUrl());
4763 __pRefreshBtn->SetShowState(true);
4764 __pStopBtn->SetShowState(false);
4765 __pClearBtn->SetShowState(false);
4766 __pReaderBtn->SetShowState(false);
4769 case ADDRESSBAR_MODE_EDIT:
4771 __pRefreshBtn->SetShowState(false);
4772 __pStopBtn->SetShowState(false);
4773 __pReaderBtn->SetShowState(false);
4774 __pClearBtn->SetShowState(true);
4781 OnAddressBarModeChanged();
4784 AddressBarMode MainForm::GetAddressbarMode(void)
4786 return __currentAddMode;
4789 void MainForm::SetUrl(const String& url)
4793 if (__pFooterUrlField != NULL)
4795 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4796 if (removedHttpUrl.IsEmpty() == false)
4798 __pFooterUrlField->SetText(removedHttpUrl);
4799 if(__pAddressbar != NULL)
4800 __pAddressbar->SetUrl(__displayUrl);
4804 __pFooterUrlField->SetText(__displayUrl);
4805 if(__pAddressbar != NULL)
4806 __pAddressbar->SetUrl(__displayUrl);
4808 if(__pFooterUrlField)
4809 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4810 __pFooterUrlField->Invalidate(false);
4811 if(__pAddressbar != NULL)
4812 __pAddressbar->Invalidate(true);
4813 // __pFooterUrlField->SetCursorPosition(0);
4818 MainForm::RemoveHttpTextFromDisplayURL(void)
4820 bool isHttpText = __displayUrl.Contains(L"http://");
4821 String updatedDisplayUrl;
4822 updatedDisplayUrl.Clear();
4824 if (isHttpText == true)
4826 __displayUrl.SubString(7,updatedDisplayUrl);
4828 return updatedDisplayUrl;
4831 void MainForm::OnSharePopupControlStarted(void)
4833 __pWebViewer->AddTouchEventListener(*this);
4836 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4838 if (requestId == BACK_GROUND_APP_EVENT)
4840 if(__pWebViewer != null)
4842 __pWebViewer->Pause();
4845 else if(requestId == FORE_GROUND_APP_EVENT)
4847 if(__pWebViewer != null)
4849 __pWebViewer->Resume();
4855 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
4857 result r = E_SUCCESS;
4858 AppLog("akjshdasd 5");
4859 __pFooterPanel->SetShowState(true);
4862 __pWebViewer->SetFocus();
4863 else if(__pMostVisitedListView)
4864 __pMostVisitedListView->SetFocus();
4865 else if(__pMultiWindowButton)
4866 __pMultiWindowButton->SetFocus();
4867 __pMoreButton->SetFocus();
4869 __pAddressbar->SetShowState(false);
4871 RelayoutControls(false);