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";
75 const int IDA_BACKBTN_CLICKED = 101;
76 const int IDA_BOOKMARKBTN_CLICKED = 102;
77 const int IDA_MOREBTN_CLICKED = 103;
78 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
79 const int IDA_NEWWINDOWBTN_CLICKED = 105;
80 const int IDA_FORWARD_CLICKED = 106;
81 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
82 const int IDA_SHARE_CLICKED = 108;
83 const int IDA_FINDONPAGE_CLICKED = 109;
84 const int IDA_PRIVATEON_CLICKED = 110;
85 const int IDA_SETTINGS_CLICKED = 111;
86 const int IDA_READER_CLOSE_CLICKED = 112;
87 const int IDA_SMALLFONT_BTN_CLICKED = 113;
88 const int IDA_LARGEFONT_BTN_CLICKED = 114;
89 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
90 const int IDA_HISTORY_CLICKED = 116;
91 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
92 const int IDA_ADD_TO_HOME_CLICKED = 118;
93 const int IDA_SAVED_PAGES_CLICKED = 119;
94 const int IDA_DESKTOP_VIEW_CLICKED = 120;
95 const int IDA_SAVE_CLICKED = 121;
96 const int IDA_PRINT_CLICKED = 122;
98 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
99 const int IDA_FINDWORD_NEXT_CLICKED = 202;
100 const int IDA_FINDWORD_PREV_CLICKED = 203;
101 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
102 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
104 const int IDA_COPY_IMAGE_CLICKED = 206;
105 const int IDA_VIEW_IMAGE_CLICKED = 207;
106 const int IDA_SAVE_IMAGE_CLICKED = 208;
107 const int IDA_SHARE_IMAGE_CLICKED = 209;
109 const int IDA_COPY_TEXT_CLICKED = 210;
110 const int IDA_PASTE_TEXT_CLICKED = 211;
111 const int IDA_FIND_TEXT__CLICKED = 212;
112 const int IDA_SHARE_TEXT_CLICKED = 213;
114 const int IDA_GO_BACK = 214;
115 const int IDA_GO_FORWARD = 215;
116 const int IDA_REFRESH_BTN_CLICKED = 216;
117 const int IDA_STOP_BTN_CLICKED = 217;
118 const int IDA_CLEAR_URL = 218;
120 const int IDA_HYPERLINK_OPEN_CLICKED = 219;
121 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 220;
122 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
123 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
125 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
127 const int MainForm::IDA_FORMAT_BITMAP = 500;
128 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
129 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
130 const int MainForm::IDA_FORMAT_URL_STRING = 503;
131 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
133 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
134 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
135 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
137 MainForm::MainForm(void)
139 __isLongPressedDone = false;
140 __pAddressbar = null;
141 // __pMostVisitedSitesPanel = null;
142 __pMostVisitedListView = null;
143 __pFooterPanel = null;
144 __pHitElementResult = null;
145 __pWindowInfo = null;
149 __pFindWordControl = null;
151 __pFindWordBgLabel = null;
152 __pFindWordEditField = null;
153 __pFindWordClear = null;
154 __pFindWordCountLabel = null;
155 __pFindWordNext = null;
156 __pFindWordPrev = null;
157 __previousZoomLevel = 1.0;
159 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
162 __currentSearchStr = L"";
163 __currentSelectedStr = L"";
164 __maxOccurrances = 0;
165 __currentWordIndex = 0;
168 __inputEventToBeSupressed = false;
169 __isLoadingData = false;
170 __isLoadingCompleted = false;
171 __progressPercentage = 0;
172 __touchPoint1 = Point(-1,-1);
173 __touchPoint2 = Point(-1,-1);
175 // __pReaderPopup = null;
176 __pReaderData = null;
178 __pReaderCloseBtn = null;
179 //__pNewWindowButton = null;
180 __pMoreButton = null;
181 __pMultiWindowButton = null;
182 __pArticleReaderPanel = null;
183 __pBlankPanel = null;
184 __pArticleReaderLabel = null;
185 __webControlHeight = 0;
186 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
187 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
188 __pMostVisitedSites = null;
189 __pFooterUrlField = null;
191 __pGoForwardBtn = null;
192 __pRefreshBtn = null;
193 __pProgressbarLabel = null;
194 __pFooterLabel = null;
197 __isWebKeypadOpened = false;
200 MainForm::~MainForm(void)
202 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
206 __pAddressbar->SetAddressbarEventListener(null);
208 if (__pReaderData != null)
210 delete __pReaderData;
211 __pReaderData = null;
214 if (__pPopUp != null)
220 if (__pHitElementResult != null)
222 delete __pHitElementResult;
223 __pHitElementResult = null;
226 String* pSelectedScene = NULL;
227 Object* pValue = NULL;
228 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
229 pSelectedScene = (String*) pValue;
231 /*if (pSelectedScene != null)
233 delete pSelectedScene;
235 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
239 MainForm::Initialize(void)
241 Construct(L"IDL_FORM");
246 MainForm::OnInitializing(void)
248 AppLog("get client area width = %d",GetClientAreaBounds().width);
249 AppLog("get client area height = %d",GetClientAreaBounds().height);
250 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
251 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
253 Panel* pFooterPanel = null;
255 __pSaveImage = new Image();
256 __pSaveImage->Construct();
258 // Setup back event listener
259 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
260 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
261 AddOrientationEventListener(*this);
262 AppLogDebug(" MainForm::OnInitializing ended");
263 if (__pMostVisitedSites == null)
265 __pMostVisitedSites = new(std::nothrow) ArrayList();
266 __pMostVisitedSites->Construct();
268 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
270 __pItemContext= new(std::nothrow) ListContextItem();
271 __pItemContext->Construct();
272 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
273 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
275 if (pBitmapNormal != null && pBitmapPressed != null)
277 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
280 if (pBitmapNormal != null)
282 delete pBitmapNormal;
285 if (pBitmapPressed != null)
287 delete pBitmapPressed;
290 __pItemContextLandscape= new(std::nothrow) ListContextItem();
291 __pItemContextLandscape->Construct();
292 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
293 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
295 if (pBitmapNormal != null && pBitmapPressed != null)
297 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
300 if (pBitmapNormal != null)
302 delete pBitmapNormal;
305 if (pBitmapPressed != null)
307 delete pBitmapPressed;
314 MainForm::InitAddressbar(void)
316 AppLogDebug("MainForm::InitAddressbar entered");
318 result r = E_SUCCESS;
320 if (__pAddressbar != null)
324 __pAddressbar = new(std::nothrow) Addressbar();
325 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
326 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
329 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
332 __pAddressbar->SetAddressbarEventListener(this);
333 AddControl(*__pAddressbar);
334 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
335 SetControlAlwaysOnTop(*__pAddressbar, true);
336 __adressPanelPosition = __pAddressbar->GetPosition();
338 AppLogDebug("MainForm::InitAddressbar exit");
344 MainForm::CreateReaderPanel(void)
346 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
347 result r = E_FAILURE;
349 Button *pSmallFontBtn = null;
350 Button *pLargeFontBtn = null;
352 __pBlankPanel = new (std::nothrow) Panel();
353 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
355 __pArticleReaderPanel = new (std::nothrow) Panel();
356 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
358 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
359 if (__pReaderCloseBtn)
361 AppLogDebug("CreateReaderPanel() 6");
362 __pReaderCloseBtn->AddActionEventListener(*this);
363 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
366 __pWebReader = new (std::nothrow) Web();
367 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
369 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
370 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
372 r = __pWebReader->SetSetting(settings);
374 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
377 __pArticleReaderLabel = new Label();
378 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
380 __pBlankPanel->AddControl(*__pArticleReaderLabel);
381 __pBlankPanel->AddControl(*__pArticleReaderPanel);
382 AddControl(*__pBlankPanel);
384 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
385 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
386 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
388 __pArticleReaderPanel->AddControl(*__pWebReader);
389 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
390 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
391 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
393 if (pBitmap != null && pSrcBitmap != null)
395 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
397 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
399 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
402 pSmallFontBtn->AddActionEventListener(*this);
403 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
406 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
409 pLargeFontBtn->AddActionEventListener(*this);
410 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
419 if (pSrcBitmap != null)
425 SetControlAlwaysOnTop(*__pBlankPanel, true);
426 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
433 MainForm::InitWebControl()
435 AppLogDebug("MainForm::InitWebControl enter");
436 result r = E_SUCCESS;
437 AppLogDebug("InitWebControl");
439 if (__pAddressbar == null || __pFooterPanel == null)
442 const int Y_WEBCONTROL_POSITION = 0;
443 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
444 if (__pMostVisitedListView)
446 __pMostVisitedListView->SetShowState(false);
448 if (__pWebViewer != null)
450 AppLogDebug("Already initialized");
453 __pWebViewer = new(std::nothrow) Web();
454 if(__pWebViewer == NULL)
456 AppLogDebug("Initialization failed");
459 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
463 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
470 r = AddControl(*__pWebViewer);
476 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
479 __webControlPosition = __pWebViewer->GetPosition();
480 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
483 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
487 __pWebViewer->SetLoadingListener(this);
488 __pWebViewer->SetWebUiEventListener(this);
489 __pWebViewer->SetWebKeypadEventListener(this);
490 __pWebViewer->SetFocus();
491 __pWebViewer->AddTouchEventListener(*this);
493 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
494 __pWebViewer->SetTextSearchListener(this);
497 AppLogDebug("MainForm :before return");
499 AppLogDebug("MainForm::InitWebControl Exit");
505 MainForm::OnFocusGained(const Control& source)
507 AppLog("MainForm::OnFocusGained");
511 MainForm::OnFocusLost(const Control& source)
513 AppLog("MainForm::OnFocusLost");
517 MainForm::SetJavascriptEnabled()
519 WebSetting settings = __pWebViewer->GetSetting();
520 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
521 __pWebViewer->SetSetting(settings);
525 MainForm::SetImageLoadEnabled()
527 WebSetting settings = __pWebViewer->GetSetting();
528 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
529 __pWebViewer->SetSetting(settings);
533 MainForm::InitFooter(void)
535 AppLogDebug("MainForm::InitFooter entered");
536 Button* pBackButton = null;
537 Button* pBookmarkButton = null;
538 Button* pMultiWindowButton = null;
539 Bitmap *pIconBitmap = null;
540 Bitmap *pBGBitmap = null;
541 Label *pBGLabel = null;
543 if (__pFooterPanel == null)
545 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
548 if (__pFooterPanel == null)
553 SetControlAlwaysOnTop(*__pFooterPanel, true);
555 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
556 if ( __pFooterLabel == NULL )
560 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
561 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
564 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
568 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
570 if ( __pMultiWindowButton == NULL )
575 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
577 if ( __pMoreButton == NULL )
582 if (__pMultiWindowButton != null)
584 Bitmap* pBitmap = null;
585 Bitmap* pPressedBitmap = null;
586 String imagePath = "I01_toolbar_icon_windows_manager_0";
587 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
588 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
589 imagePath.Append(totalCount);
590 imagePath.Append(".png");
592 pressedImagePath.Append(totalCount);
593 pressedImagePath.Append("_press.png");
595 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
596 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
597 if ( pBitmap == null )
602 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
605 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
606 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
611 __pMultiWindowButton->AddActionEventListener(*this);
612 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
617 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
618 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
621 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
622 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
623 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
627 __pMoreButton->AddActionEventListener(*this);
628 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
631 //Add the editfield for url
632 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
633 if (__pFooterUrlField == NULL)
635 return E_INVALID_KEY;
638 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
639 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
640 //__pFooterUrlField->AddFocusEventListener(*this);
641 __pFooterUrlField->AddKeypadEventListener(*this);
642 //__pFooterUrlField->AddFocusEventListener(*this);
643 __pFooterUrlField->SetPropagatedTouchEventListener(this);
645 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
647 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
649 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
651 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
655 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
656 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
660 //Add the go Back Button
661 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
662 if (__pGoBackBtn == NULL)
664 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
665 return E_INVALID_KEY;
667 __pGoBackBtn->SetActionId(IDA_GO_BACK);
668 __pGoBackBtn->AddActionEventListener(*this);
670 //Add the go forward Button
671 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
672 if (__pGoForwardBtn == NULL)
674 AppLogDebug("Control not found returning E_INVALID_KEY");
675 return E_INVALID_KEY;
677 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
678 __pGoForwardBtn->AddActionEventListener(*this);
679 // __pGoForwardBtn->SetEnabled(false);
680 if (__pWebViewer && __pWebViewer->CanGoForward())
682 //__pAddressbar->SetForwardButtonEnabled(true);
683 SetForwardButtonEnabled(true);
687 //__pAddressbar->SetForwardButtonEnabled(false);
688 SetForwardButtonEnabled(false);
691 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
692 if (__pRefreshBtn == NULL)
694 AppLogDebug("Control not found returning E_INVALID_KEY");
695 return E_INVALID_KEY;
698 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
699 __pRefreshBtn->AddActionEventListener(*this);
700 __pRefreshBtn->SetShowState(true);
702 //Add the backround label for displaying progressbar
703 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
704 if (__pProgressbarLabel == NULL)
706 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
707 return E_INVALID_KEY;
709 __pProgressbarLabel->SetShowState(false);
711 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
712 if (__pStopBtn == NULL)
714 AppLogDebug("Control not found returning E_INVALID_KEY");
715 return E_INVALID_KEY;
717 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
718 __pStopBtn->AddActionEventListener(*this);
719 __pStopBtn->SetShowState(false);
721 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
722 if (__pClearBtn == NULL)
724 AppLogDebug("Control not found returning E_INVALID_KEY");
725 return E_INVALID_KEY;
727 __pClearBtn->SetActionId(IDA_CLEAR_URL);
728 __pClearBtn->AddActionEventListener(*this);
729 __pClearBtn->SetShowState(false);
731 // __pFooterPanel->Invalidate(true);
732 AppLogDebug("MainForm::InitFooter exit");
738 MainForm::InitContextMenu(Point& p)
740 result r = E_SUCCESS;
741 bool isPrivateBrowsing = false;
742 Bitmap* pBitmap = null;
746 __pMenu->SetAnchorPosition(p);
747 __pMenu->Invalidate(true);
751 __pMenu = new(std::nothrow) ContextMenu();
752 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
753 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
755 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
758 if (isPrivateBrowsing == true)
760 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
764 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
767 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
769 if ( pBitmap != NULL)
771 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
774 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
775 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
776 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
779 __pMenu->SetMaxVisibleItemsCount(6);
780 __pMenu->SetShowState(false);
781 __pMenu->AddActionEventListener(*this);
782 SetControlAlwaysOnTop(*__pMenu, true);
788 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
790 result r = E_SUCCESS;
791 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
793 AppLog("MainForm::InitImageContextMenu clicked on image");
794 if (__pImageMenu != null)
800 // p.y = p.y + __pAddressbar->GetHeight() + 12;
801 // AppLog("vinaypy %d",p.y);
804 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
808 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
810 __pImageMenu = new (std::nothrow) ContextMenu();
811 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
812 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
814 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
815 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
816 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
817 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
818 __pImageMenu->SetMaxVisibleItemsCount(4);
819 __pImageMenu->AddActionEventListener(*this);
820 SetControlAlwaysOnTop(*__pImageMenu, true);
826 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
828 result r = E_SUCCESS;
829 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
831 AppLog("MainForm::InitImageContextMenu clicked on image");
832 if (__pImageMenu != null)
838 p.y = p.y + __pAddressbar->GetHeight();
841 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
845 // direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
847 __pImageMenu = new (std::nothrow) ContextMenu();
848 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
849 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
851 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
852 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
853 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
854 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
856 __pImageMenu->SetMaxVisibleItemsCount(3);
857 __pImageMenu->AddActionEventListener(*this);
858 SetControlAlwaysOnTop(*__pImageMenu, true);
865 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
867 result r = E_SUCCESS;
868 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
869 if(onlyPasteOption == true)
872 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
873 if (__pImageMenu != null)
878 // p.y = p.y + __pAddressbar->GetHeight() + 12;
883 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
888 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
890 __pImageMenu = new (std::nothrow) ContextMenu();
891 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
892 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
894 if(onlyPasteOption == false)
896 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
898 if (pasteOption || onlyPasteOption)
900 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
902 if(onlyPasteOption == false)
904 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
905 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
908 __pImageMenu->SetMaxVisibleItemsCount(3);
909 __pImageMenu->AddActionEventListener(*this);
910 SetControlAlwaysOnTop(*__pImageMenu, true);
917 MainForm::InitFindWordPanel(void)
919 result r = E_SUCCESS;
920 Bitmap *pIconBitmap = null;
922 if (__pFindWordControl != null)
924 AppLogDebug("Findword panel already initialized");
925 if (__pFindWordBgLabel != null)
927 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
930 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
937 __pFindWordControl = new (std::nothrow) Panel();
938 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
941 AppLogException("There is some problem in the xml file. Please check.");
944 AddControl(*__pFindWordControl);
945 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
946 SetControlAlwaysOnTop(*__pFindWordControl,true);
947 __pFindWordControl->SetShowState(false);
948 __pFindWordControl->Invalidate(false);
950 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
951 if (__pFindWordBgLabel != null)
953 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
954 Rectangle pRect = pPanel1->GetBounds();
955 pRect.x = pRect.y = 0;
956 __pFindWordBgLabel->SetBounds(pRect);
957 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
960 AppLogDebug("InitFindWordPanel: Coming here");
961 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
966 AppLogDebug("InitFindWordPanel: shouldn't Come here");
970 Button* pfindWordCancel = null;
971 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
972 if (pfindWordCancel == null)
974 AppLogException("There is some problem in the xml file. Please check.");
977 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
978 pfindWordCancel->AddActionEventListener(*this);
980 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
981 if (__pFindWordClear == null)
983 AppLogException("There is some problem in the xml file. Please check.");
987 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
988 __pFindWordClear->AddActionEventListener(*this);
990 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
991 if (__pFindWordNext == null)
993 AppLogException("There is some problem in the xml file. Please check.");
997 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
998 __pFindWordNext->AddActionEventListener(*this);
1000 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1001 if (__pFindWordPrev == null)
1003 AppLogException("There is some problem in the xml file. Please check.");
1007 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1008 __pFindWordPrev->AddActionEventListener(*this);
1010 __pFindWordNext->SetEnabled(false);
1011 __pFindWordPrev->SetEnabled(false);
1013 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1014 if (__pFindWordCountLabel == null)
1016 AppLogException("There is some problem in the xml file. Please check.");
1020 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1021 if (__pFindWordEditField == null)
1023 AppLogException("There is some problem in the xml file. Please check.");
1026 __pFindWordEditField->AddTextEventListener(*this);
1027 __pFindWordEditField->AddKeypadEventListener(*this);
1028 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1034 MainForm::CreateItem (int index, int itemWidth)
1036 Rectangle listImageRect;
1037 Rectangle pagetTitleRect;
1038 Rectangle pageURLRect;
1039 Rectangle deleteImageRect;
1040 String pageTitle(L"");
1041 String pageURL(L"");
1042 result r = E_SUCCESS;
1043 Bitmap* pListIconImage = null;
1046 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1047 if(pHistory == null)
1051 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1052 if ( pAppResource == NULL )
1056 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1058 CustomItem* pItem = new(std::nothrow) CustomItem();
1059 pageTitle = pHistory->GetHistoryTitle();
1060 pageURL = pHistory->GetHistoryUrl();
1062 if (pageURL.GetLength() == 0)
1065 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1066 pageURL = L"<"+ nourl +">";
1070 Rectangle screenBounds = GetBounds();
1073 r = pItem->Construct(Dimension(itemWidth, 128), style);
1082 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1084 if ( pBitmap != NULL)
1086 pListIconImage = new Bitmap();
1087 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1091 if(pListIconImage == null)
1093 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1096 if ( pListIconImage != NULL)
1098 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1099 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1100 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1103 if (pItem != null && pListIconImage != NULL)
1105 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1109 if (pageTitle.CompareTo(L"") != 0)
1113 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1117 if (pageURL.CompareTo(L"") != 0)
1121 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1126 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1128 if ( __pItemContext!= NULL)
1132 pItem->SetContextItem(__pItemContext);
1138 if ( __pItemContextLandscape!= NULL)
1142 pItem->SetContextItem(__pItemContextLandscape);
1146 if( pListIconImage != NULL)
1148 delete pListIconImage;
1149 pListIconImage = null;
1156 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1163 MainForm::GetItemCount (void)
1165 if(__pMostVisitedSites != null)
1167 __pMostVisitedSites->RemoveAll(true);
1169 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1170 if(__pMostVisitedSites != null)
1172 return __pMostVisitedSites->GetCount();
1179 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1181 if(__pMostVisitedSites != null)
1183 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1184 if (pHistory != null)
1186 String url = pHistory->GetHistoryUrl();
1188 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1189 __pMostVisitedListView->UpdateList();
1195 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1197 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1198 String url = pHistory->GetHistoryUrl();
1206 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1212 MainForm::OnTerminating(void)
1214 result r = E_SUCCESS;
1217 delete __pItemContext;
1219 if(__pItemContextLandscape)
1221 delete __pItemContextLandscape;
1227 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1229 result r = E_SUCCESS;
1231 AppLogDebug("Clicked : %d", actionId);
1234 // case IDA_BACKBTN_CLICKED:
1236 // if (__pWebViewer && __pWebViewer->CanGoBack())
1238 // __pWebViewer->GoBack();
1242 // UiApp* pApp = null;
1243 // pApp = UiApp::GetInstance();
1244 // if (pApp != null)
1246 // r = pApp->Terminate();
1249 // AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1257 case IDA_BACKBTN_CLICKED:
1259 if (__pWebViewer && __pWebViewer->CanGoBack())
1261 __pWebViewer->GoBack();
1263 else if(__pWindowInfo->isJavascriptInitiated == false)
1266 pApp = UiApp::GetInstance();
1269 r = pApp->Terminate();
1272 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1280 WindowInfo* pWindowInfo = null;
1282 SceneManager* pSceneManager = SceneManager::GetInstance();
1283 if (pSceneManager == null)
1287 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1288 if (pAllWindowList == NULL)
1290 pApp = UiApp::GetInstance();
1293 r = pApp->Terminate();
1296 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1301 if (pAllWindowList != null)
1303 totalCount = pAllWindowList->GetCount();
1305 for (int count = 0; count < totalCount; count++)
1307 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1308 if (pWindowInfo == null)
1310 pApp = UiApp::GetInstance();
1313 r = pApp->Terminate();
1316 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1321 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1323 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1326 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1329 r = pAllWindowList->RemoveAt(count, true);
1330 __pWindowInfo = null;
1333 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1338 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1342 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1344 if (pWindowInfo == null)
1346 pApp = UiApp::GetInstance();
1349 r = pApp->Terminate();
1355 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1358 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1371 case IDA_FORWARD_CLICKED:
1372 if (__pWebViewer == null)
1375 if (__pWebViewer->CanGoForward())
1377 __pWebViewer->GoForward();
1379 __pMenu->SetShowState(false);
1380 __pMenu->Invalidate(false);
1383 case IDA_FINDONPAGE_CLICKED:
1385 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1386 __currentSearchStr.Clear();
1388 InitFindWordPanel();
1389 __pMenu->SetShowState(false);
1390 __pMenu->Invalidate(false);
1392 __pFindWordEditField->SetFocus();
1394 if (__pWebViewer != null)
1396 // releasing the set block
1397 __pWebViewer->ReleaseBlock();
1400 ShowFindWordPanel(true);
1403 case IDA_PRIVATEON_CLICKED:
1405 result r = E_SUCCESS;
1407 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1408 Bitmap* pBitmap = null;
1409 if (isPrivateBrowsing == true)
1411 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1414 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1418 if (__pWebViewer != NULL)
1420 __pWebViewer->SetPrivateBrowsingEnabled(false);
1423 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1425 if (__pAddressbar != null)
1427 __pAddressbar->UpdateFaviconBitmap(false);
1433 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1436 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1440 if (__pWebViewer != NULL)
1442 __pWebViewer->SetPrivateBrowsingEnabled(true);
1445 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1447 if (__pAddressbar != null)
1449 __pAddressbar->UpdateFaviconBitmap(true);
1454 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1455 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1456 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1457 __pMenu->Invalidate(true);
1459 if ( pBitmap != NULL )
1466 case IDA_SETTINGS_CLICKED:
1469 ArrayList* pArgList = new(std::nothrow) ArrayList();
1472 pArgList->Construct();
1473 pArgList->Add(*__pWindowInfo);
1474 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1476 __pMenu->SetShowState(false);
1477 __pMenu->Invalidate(false);
1478 if (pArgList != null)
1487 case IDA_ADDTOBOOKMARK_CLICKED:
1490 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1492 int bookmarkCount=0;
1495 url=__pWindowInfo->pageUrl;
1496 result r = E_SUCCESS;
1497 Bitmap* pBitmap = null;
1498 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1506 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1507 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1508 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1510 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1511 if (pNotification != null)
1513 pNotification->SetText(message);
1514 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1515 pNotification->ShowNotification();
1520 String title=__pWindowInfo->pageTitle;
1521 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1522 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1524 pBookmark->SetBookmarkTitle(title);
1525 pBookmark->SetUrl(url);
1526 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1528 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1530 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1531 pBookmark->SetFaviconId(id);
1532 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1533 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1536 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1537 if (pNotification != null)
1539 pNotification->SetText(message);
1540 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1541 pNotification->ShowNotification();
1542 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1545 if (pBitmap != null)
1547 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1551 __pMenu->Invalidate(true);
1555 case IDA_PRINT_CLICKED:
1557 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1558 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1560 AppLog("RequestPrint called!");
1561 Tizen::App::AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1562 result nResult = E_FAILURE;
1565 AppLog("TestPrint if (pAc) == true");
1570 String fileType = L"service_print_files_type";
1571 String typeVal = L"DOC";
1573 String fileCount = L"service_print_files_count";
1574 String countVal = L"1";
1575 String fileFolder= L"service_print_files_folder_name";
1576 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1578 map.Add(&fileCount, &countVal);
1579 // map.Add(&fileIndex, &indexVal);
1580 map.Add(&fileFolder, &folderVal);
1581 map.Add(&fileType, &typeVal);
1583 String fileName = L"service_print_files_files_name";
1585 ArrayList fileNameList;
1586 fileNameList.Construct();
1587 String file1 = L"test.pdf";
1589 fileNameList.Add(&file1);
1590 map.Add(&fileName, &fileNameList);
1592 nResult = pAc->Start(NULL, NULL, &map, NULL);
1594 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1595 else if (nResult == E_MAX_EXCEEDED)
1596 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1597 else if (nResult == E_OBJ_NOT_FOUND)
1598 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1599 else if (nResult == E_IN_PROGRESS)
1600 AppLog("TestPrint ret == E_IN_PROGRESS");
1601 else if (nResult == E_PRIVILEGE_DENIED)
1602 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1603 else if(nResult == E_SYSTEM)
1604 AppLog("TestPrint ret == E_SYSTEM");
1610 int __modalMsgBoxResult;
1611 MessageBox* pMsgBox = new MessageBox();
1612 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1613 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1616 __modalMsgBoxResult = 0;
1620 case IDA_SHARE_CLICKED:
1622 if(__pPopUp != null)
1627 __pPopUp = new(std::nothrow) SharePopup();
1628 __pPopUp->Initialize();
1629 if (__pWindowInfo != null)
1631 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1632 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1633 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1634 pShareInfo->SetImageAttached(false);
1635 __pPopUp->RemoveAllShareInfo();
1636 __pPopUp->AddShareInfo(pShareInfo);
1638 __pPopUp->SetShowState(true);
1642 case IDA_BOOKMARKBTN_CLICKED:
1644 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1645 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1648 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1653 case IDA_MOREBTN_CLICKED:
1655 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1656 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1657 AppLog("Anchot pos: %d %d", p.x, p.y);
1659 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1661 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1662 int bookmarkCount=0;
1665 url=__pWindowInfo->pageUrl;
1666 result r = E_SUCCESS;
1667 Bitmap* pBitmap = null;
1669 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1672 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1677 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1681 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1683 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1685 if (__pMenu->GetItemCount() == 9)
1687 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1691 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1696 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1700 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1701 if (__pMenu->GetItemCount() != 9)
1703 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1704 __pMenu->InsertItemAt(2,"Print", IDA_PRINT_CLICKED);
1705 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1706 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1707 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1708 __pMenu->SetMaxVisibleItemsCount(6);
1710 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1712 AppLog(" Orientation landscape");
1713 __pMenu->SetMaxVisibleItemsCount(5);
1717 AppLog(" Orientation potrait");
1718 __pMenu->SetMaxVisibleItemsCount(6);
1721 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1724 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1725 __pMenu->SetShowState(true);
1726 __pMenu->Invalidate(true);
1730 case IDA_HISTORY_CLICKED:
1732 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1733 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1736 case IDA_SAVED_PAGES_CLICKED:
1741 case IDA_DESKTOP_VIEW_CLICKED:
1746 case IDA_SAVE_CLICKED:
1751 case IDA_MULTIWINDOWBTN_CLICKED:
1753 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1754 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1758 case IDA_NEWWINDOWBTN_CLICKED:
1760 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1762 if (pNewWindowInfo == null)
1766 result r = E_SUCCESS;
1767 SceneManager* pSceneManager = SceneManager::GetInstance();
1769 if (pSceneManager == NULL)
1773 ArrayList* pArgList = new(std::nothrow) ArrayList();
1774 if (pArgList == NULL)
1778 r = pArgList->Construct();
1781 pArgList->Add(*pNewWindowInfo);
1782 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1788 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1793 case IDA_SMALLFONT_BTN_CLICKED:
1795 WebSetting setting = __pWebReader->GetSetting();
1796 setting.SetFontSize(15);
1797 __pWebReader->SetSetting(setting);
1800 case IDA_LARGEFONT_BTN_CLICKED:
1802 WebSetting setting = __pWebReader->GetSetting();
1803 setting.SetFontSize(25);
1804 __pWebReader->SetSetting(setting);
1807 case IDA_READER_CLOSE_CLICKED:
1809 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1811 //__pArticleReaderPanel->SetShowState(false);
1812 //__pArticleReaderPanel->Show();
1813 RemoveControl(*__pBlankPanel);
1814 //RemoveControl(*__pArticleReaderPanel);
1815 __pArticleReaderPanel = null;
1816 __pBlankPanel = null;
1817 __pArticleReaderLabel = null;
1819 //if (__pAddressbar)
1820 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1821 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1824 case IDA_FINDWORD_CANCEL_CLICKED:
1826 __currentSearchStr = L"";
1827 __currentWordIndex = 0;
1828 __maxOccurrances = 0;
1829 __pFindWordEditField->SetText(L"");
1830 __pFindWordNext->SetEnabled(false);
1831 __pFindWordPrev->SetEnabled(false);
1832 __pFindWordCountLabel->SetText(L"0/0");
1833 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1834 ShowFindWordPanel(false);
1837 case IDA_FINDWORD_SEARCH_CLICKED:
1839 __currentSearchStr = __pFindWordEditField->GetText();
1840 if (__currentSearchStr.GetLength() > 0)
1846 AppLogDebug("Enter something");
1850 case IDA_FINDWORD_CLEAR_CLICKED:
1852 __pFindWordCountLabel->SetText(L"0/0");
1853 __pFindWordEditField->SetText(L"");
1854 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1856 __currentSearchStr = L"";
1857 __pFindWordNext->SetEnabled(false);
1858 __pFindWordPrev->SetEnabled(false);
1859 __pFindWordControl->Invalidate(true);
1862 case IDA_FINDWORD_NEXT_CLICKED:
1867 case IDA_FINDWORD_PREV_CLICKED:
1869 FindNextWord(false);
1872 case IDA_BRIGHTNESS_BTN_CLICKED:
1874 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1875 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1878 case IDA_COPY_IMAGE_CLICKED:
1880 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1881 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1883 const Bitmap* pBitmap = null;
1884 if (__pHitElementResult != null)
1886 pBitmap = __pHitElementResult->GetImage();
1889 String resourcePath = App::GetInstance()->GetAppResourcePath();
1890 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1892 // copying the item to clipboard
1893 Clipboard* pClipboard = Clipboard::GetInstance();
1894 if (pClipboard != null)
1896 pClipboard->CopyItem(item);
1900 case IDA_VIEW_IMAGE_CLICKED:
1902 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1903 WindowInfo* pNewWindowInfo = null;
1904 if (__pHitElementResult != null)
1906 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1907 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1913 case IDA_SAVE_IMAGE_CLICKED:
1915 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1916 const Bitmap* pSaveBitmap = null;
1917 String imageName = GetImagePath();
1918 AppLog("Content manager image name %ls",imageName.GetPointer());
1921 imagePath.Append(imageName);
1922 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1923 AppLog("Content manager image path %ls",imagePath.GetPointer());
1924 if (__pHitElementResult != null)
1926 pSaveBitmap = __pHitElementResult->GetImage();
1928 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1932 UpdateImageContent(pBuffer, imageName);
1934 NotificationPanel *pNotification = new NotificationPanel(*this);
1936 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1937 msg.Append(imagePath);
1938 if (pNotification != null)
1940 pNotification->SetText(msg);
1941 if (__pFooterPanel->GetShowState() == true)
1943 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1947 pNotification->SetPositionDiff(0);
1950 pNotification->ShowNotification();
1955 int __modalMsgBoxResult;
1956 MessageBox* pMsgBox = new MessageBox();
1957 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1958 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1961 __modalMsgBoxResult = 0;
1965 case IDA_SHARE_IMAGE_CLICKED:
1967 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1968 if (__pPopUp != null)
1973 __pPopUp = new(std::nothrow) SharePopup();
1974 __pPopUp->Initialize();
1975 if (__pHitElementResult != null)
1977 const Bitmap* pSaveBitmap = null;
1978 String imageName = GetImagePath();
1979 AppLog("Content manager image name %ls",imageName.GetPointer());
1982 imagePath.Append(imageName);
1983 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1984 AppLog("Content manager image path %ls",imagePath.GetPointer());
1985 if (__pHitElementResult != null)
1987 pSaveBitmap = __pHitElementResult->GetImage();
1989 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1991 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1992 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1994 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1995 pShareInfo->SetPageTitle(L"");
1996 pShareInfo->SetPageUrl(srcUrl);
1997 pShareInfo->SetImageAttached(true);
1998 pShareInfo->SetImagePath(imagePath);
1999 __pPopUp->RemoveAllShareInfo();
2000 __pPopUp->AddShareInfo(pShareInfo);
2001 __pPopUp->SetShowState(true);
2006 case IDA_HYPERLINK_OPEN_CLICKED:
2008 if (__pHitElementResult != null)
2010 String srcUrl = __pHitElementResult->GetUrl();
2012 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
2014 if (pNewWindowInfo == null)
2018 result r = E_SUCCESS;
2019 SceneManager* pSceneManager = SceneManager::GetInstance();
2020 if (pSceneManager == NULL)
2024 ArrayList* pArgList = new(std::nothrow) ArrayList();
2025 if (pArgList == NULL)
2029 pArgList->Construct();
2031 pArgList->Add(*pNewWindowInfo);
2032 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2033 if (pArgList != null)
2040 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2046 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2048 if (__pHitElementResult == null)
2053 if(__pPopUp != null)
2058 __pPopUp = new(std::nothrow) SharePopup();
2059 __pPopUp->Initialize();
2061 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2062 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2063 pShareInfo->SetImageAttached(false);
2064 __pPopUp->RemoveAllShareInfo();
2065 __pPopUp->AddShareInfo(pShareInfo);
2067 __pPopUp->SetShowState(true);
2071 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2075 if (__pHitElementResult != null)
2077 url = __pHitElementResult->GetUrl();
2080 String resourcePath = App::GetInstance()->GetAppResourcePath();
2081 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2083 // copying the item to clipboard
2084 Clipboard* pClipboard = Clipboard::GetInstance();
2085 if (pClipboard != null)
2087 pClipboard->CopyItem(item);
2091 case IDA_FIND_TEXT__CLICKED:
2093 OnAddressCancelledClicked(*__pAddressbar);
2094 __pFooterPanel->SetShowState(false);
2095 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2096 __currentSearchStr.Clear();
2097 __currentSearchStr.Append(__currentSelectedStr);
2098 InitFindWordPanel();
2099 __pFindWordEditField->SetText(__currentSearchStr);
2102 __pMenu->SetShowState(false);
2103 __pMenu->Invalidate(false);
2106 __adressPanelPosition.y = 0;
2108 if (__pAddressbar != null && __pWebViewer != NULL)
2110 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2111 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2112 //__pAddressbar->Invalidate(true);
2113 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2115 if (__pFooterPanel->GetShowState() == false)
2116 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2118 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2119 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2120 __pWebViewer->Invalidate(true);
2123 ShowFindWordPanel(true);
2124 __pFindWordEditField->SetFocus();
2125 if (__currentSearchStr.GetLength() > 0)
2131 AppLogDebug("Enter something");
2134 if (__pWebViewer != null)
2136 // releasing the set block
2137 __pWebViewer->ReleaseBlock();
2142 case IDA_SHARE_TEXT_CLICKED:
2144 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2145 if(__pPopUp != null)
2150 __pPopUp = new(std::nothrow) SharePopup();
2151 __pPopUp->Initialize();
2152 if (__pHitElementResult != null)
2154 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2155 pShareInfo->SetPageTitle(L"");
2156 pShareInfo->SetPageUrl(__currentSelectedStr);
2157 pShareInfo->SetImageAttached(false);
2158 __pPopUp->RemoveAllShareInfo();
2159 __pPopUp->AddShareInfo(pShareInfo);
2160 __pPopUp->SetShowState(true);
2165 case IDA_COPY_TEXT_CLICKED:
2167 __pWebViewer->ReleaseBlock();
2168 // need to implement
2169 //__currentSelectedStr
2170 // Sets data to a clip board item
2172 String resourcePath = App::GetInstance()->GetAppResourcePath();
2173 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2175 // copying the item to clipboard
2176 Clipboard* pClipboard = Clipboard::GetInstance();
2177 if (pClipboard != null)
2179 pClipboard->CopyItem(item);
2183 case IDA_PASTE_TEXT_CLICKED:
2185 Clipboard* pClipboard = Clipboard::GetInstance();
2187 if(pClipboard == null)
2191 // Retrieves a latest item
2192 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2198 //Gets data from the clipboard item
2199 String* pString = dynamic_cast<String*>(pItem->GetData());
2201 if (pString != null)
2203 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2204 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2205 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2206 // String script = L"function insertAtCursor(myField, myValue) { if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } } ";
2207 String 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; } } ";
2208 if(idElement.GetLength() != 0)
2210 script.Append("insertAtCursor('");
2211 script.Append(idElement);
2212 script.Append("',");
2213 script.Append("\"");
2214 script.Append(*pString);
2215 script.Append("\");");
2217 else if (nameElement.GetLength() != 0)
2219 script.Append("insertAtCursor(document.getElementsByName('");
2220 script.Append(nameElement);
2221 script.Append("')[0],");
2222 script.Append("\"");
2223 script.Append(*pString);
2224 script.Append("\");");
2226 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2227 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2238 case IDA_GO_FORWARD:
2243 case IDA_REFRESH_BTN_CLICKED:
2245 __isLoadingCompleted = false;
2246 __isLoadingData = true;
2247 __progressPercentage = 0;
2248 __displayUrl = __pFooterUrlField->GetText();
2250 String url = __pFooterUrlField->GetText();
2251 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2255 UpdateProgressBitmap();
2258 case IDA_STOP_BTN_CLICKED:
2260 __isLoadingCompleted = false;
2261 __isLoadingData = false;
2262 __progressPercentage = 0;
2263 __pFooterUrlField->HideKeypad();
2264 __displayUrl = __pFooterUrlField->GetText();
2268 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2269 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2270 __pWebViewer->StopLoading();
2271 RequestRedraw(true);
2274 UpdateProgressBitmap();
2279 if (__pFooterUrlField->GetText().IsEmpty() == false)
2281 //__displayUrl = __pUrlField->GetText();
2282 __pFooterUrlField->Clear();
2293 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2296 UiApp* pApp = UiApp::GetInstance();
2305 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2306 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2308 AppLog("MainForm::OnSceneActivatedN called");
2309 String* pSelectedScene = NULL;
2310 Object* pValue = NULL;
2311 String* pUrl = null;
2312 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2313 pSelectedScene = (String*) pValue;
2315 if (pSelectedScene != null)
2317 delete pSelectedScene;
2319 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2320 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2321 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2322 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2324 // setting the current scene ID
2325 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2327 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2329 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2331 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2332 if(__pWindowInfo == null)
2334 // if(__pWindowInfo == null)
2336 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2339 else if ( pArgs != null && pArgs->GetCount() == 1)
2341 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2347 // hiding the address bar
2348 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2349 __pAddressbar->SetShowState(false);
2350 if(__pWebViewer != null)
2352 __pWebViewer->Resume();
2355 if(pUrl != null && pUrl->GetLength() > 0)
2359 else if(__pWindowInfo != null)
2361 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)
2363 LoadUrl(__pWindowInfo->pageUrl);
2365 else if (__pWindowInfo->isJavascriptInitiated == true)
2369 __pWindowInfo->pCurrentWeb = __pWebViewer;
2373 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2374 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2375 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2377 InitMostVisitedSitesView(GetOrientationStatus());
2380 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2382 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2384 if (pBookmarkUrl == null)
2386 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2387 //__pAddressbar->SetUrl(*pBookmarkUrl);
2388 SetUrl(*pBookmarkUrl);
2390 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2391 __pWebViewer->LoadUrl(*pBookmarkUrl);
2392 delete pBookmarkUrl;
2395 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2396 Bitmap* pBitmap = null;
2397 if (isPrivateBrowsing == true)
2399 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2401 if (__pWebViewer != null)
2403 __pWebViewer->SetPrivateBrowsingEnabled(true);
2406 if (__pAddressbar != null)
2408 // __pAddressbar->UpdateFaviconBitmap(true);
2414 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2416 if (__pWebViewer != null)
2418 __pWebViewer->SetPrivateBrowsingEnabled(false);
2421 if (__pAddressbar != null)
2423 // __pAddressbar->UpdateFaviconBitmap(false);
2427 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2429 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2431 else if (__pMenu != null )
2433 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2436 if (pBitmap != null)
2441 AppLog("ABC: OnSceneActivatedN started exit");
2446 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2447 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2449 Canvas* pWebCanvas = null;
2450 if (__pWebViewer != null)
2452 pWebCanvas = __pWebViewer->GetCanvasN();
2453 __pWebViewer->Pause();
2456 if (pWebCanvas == null)
2460 if (__pWindowInfo != null)
2462 if (__pWindowInfo->pWebCanvasBitmap != null)
2464 delete __pWindowInfo->pWebCanvasBitmap;
2466 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2467 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2468 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2470 Bitmap* pBitmap = GetCapturedBitmapN();
2471 AppLog("Coming here");
2472 Canvas* pCanvas = new(std::nothrow) Canvas();
2473 pCanvas->Construct(GetClientAreaBounds());
2476 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2479 if(__pWebViewer != null && __pWindowInfo != null)
2480 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2482 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2483 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2485 AppLog("Coming here");
2489 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2490 const Tizen::Base::String& realm,
2491 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2497 MainForm::OnHttpAuthenticationCanceled(void)
2502 MainForm::OnLoadingStarted(void)
2504 AppLogDebug("MainForm::OnLoadingStarted entered");
2506 if(__pAddressbar == NULL || __pWebViewer == null)
2510 String url = __pWebViewer->GetUrl();
2511 if(url.Contains(IDS_TIZEN_SERVICE))
2514 String delim(L":;");
2516 // Creates a StringTokenizer instance
2517 StringTokenizer strTok(url, delim);
2519 int count = strTok.GetTokenCount(); // count == 4
2521 HashMap *pMap = new HashMap();
2526 while (strTok.HasMoreTokens())
2528 AppLog("Token: %ls", token.GetPointer());
2529 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2530 if(token.Contains(IDS_APPID))
2532 token.SubString(6, appId);
2533 AppLog("AppID:%ls", appId.GetPointer());
2535 else if(token.Contains("="))
2537 String *pKey = new String();
2538 String *pValue = new String();
2540 token.IndexOf("=", 0, index);
2543 token.SubString(0, index, *pKey);
2544 token.SubString(index + 1, *pValue);
2545 pMap->Add(pKey, pValue);
2551 AppControl *pAppControl = null;
2552 String operationId = L"http://tizen.org/appcontrol/operation/main";
2553 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2556 AppLog("Starting AppControl");
2557 result r = pAppControl->Start(null, null, pMap, null);
2558 AppLog("Result of Start %s", GetErrorMessage(r));
2562 AppLogException("AppControl not found");
2567 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2570 __pAddressbar->SetFaviconBitmap(*pBitmap);
2573 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2575 // updating the address bar position with respect to web control
2576 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2577 __distanceMoved = 0;
2581 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2582 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2583 if (__pWebViewer != null)
2585 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2586 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2587 SetUrl(__pWebViewer->GetUrl());
2588 if (__pWindowInfo != NULL)
2590 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2592 __pAddressbar->Invalidate(true);
2598 MainForm::OnLoadingCanceled(void)
2605 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2607 AppLog("MainForm::OnKeypadWillOpen");
2608 if (__pAddressbar != null)
2610 OnAddressBarKeypadWillOpen(*__pAddressbar);
2616 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2618 if(__pAddressbar != null)
2620 OnAddressBarKeypadOpened(*__pAddressbar);
2626 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2630 if (__pAddressbar != null)
2632 OnAddressBarKeypadClosed(*__pAddressbar);
2637 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2639 AppLog("KeypadBoundsChanged");
2640 RelayoutControls(false);
2644 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2645 const Tizen::Base::String& reason)
2647 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2651 MainForm::OnLoadingCompleted(void)
2653 AppLog("MainForm::OnLoadingCompleted start");
2655 result r = E_SUCCESS;
2657 if (__pWebViewer == null)
2662 if (__pAddressbar == null)
2666 if (__pWebViewer->CanGoForward())
2668 //__pAddressbar->SetForwardButtonEnabled(true);
2669 SetForwardButtonEnabled(true);
2673 //__pAddressbar->SetForwardButtonEnabled(false);
2674 SetForwardButtonEnabled(false);
2677 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2679 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2681 //__pAddressbar->UpdateProgress(0);
2685 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2687 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2691 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2692 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2693 if (isPrivateBrowsing == false)
2695 History* pHistory = new(std::nothrow) History;
2697 HistoryPresentationModel::GetCurrentDateTime(date);
2700 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2701 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2703 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2704 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2706 pHistory->SetVisitedTime(date);
2709 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2710 pHistory->SetFaviconId(id);*/
2712 if (__pWebViewer != null)
2714 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2716 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2717 if (pTempBitmap != null)
2719 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2720 pHistory->SetFavIconBitmap(*pTempBitmap);
2723 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2726 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2727 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2728 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2730 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2731 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2732 pHistory->SetThumbnail(pBitmap);
2734 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2737 pHistory->SetFavIconBitmap(*pFavIcon);
2741 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2748 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2750 // temperary fixed (webpage can be not loaded)
2753 AppLog("MainForm::OnLoadingCompleted done");
2757 MainForm::OnEstimatedProgress(int progress)
2759 AppLogDebug("MainForm::OnEstimatedProgress entered");
2760 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2761 progress = DEFAULT_PROGRESS_PERCENTAGE;
2763 // __pAddressbar->UpdateProgress(progress);
2764 UpdateProgress(progress);
2767 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2769 AppLog("MainForm::OnFaviconReceived");
2770 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2772 if (pFavIconBitmap != null)
2774 pFavIconBitmap->GetWidth();
2775 pFavIconBitmap->GetHeight();
2780 MainForm::OnUrlValueChanged(Addressbar&)
2786 MainForm::OnUrlSubmitted(Addressbar& addBar)
2788 AppLog("MainForm::OnUrlSubmitted");
2789 String url = addBar.GetUrl();
2790 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2792 // __pFooterPanel->SetShowState(true);
2793 if(__pFooterUrlField)
2794 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2795 OnAddressCancelledClicked(*__pAddressbar);
2796 // __pAddressbar->SetShowState(false);
2797 // RelayoutControls(false);
2802 MainForm::LoadUrl(String& url)
2806 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2807 AppLogDebug("MainForm::LoadUrl enter");
2809 if (__pWebViewer != null)
2811 __pWebViewer->SetShowState(true);
2812 __pWebViewer->Invalidate(true);
2815 if (url.CompareTo(L"") == 0)
2819 if(__pFooterPanel != null)
2821 __pFooterPanel->SetShowState(true);
2822 __pFooterPanel->Invalidate(true);
2829 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2830 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)
2832 RegularExpression firstRegex;
2833 RegularExpression secondRegex;
2835 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2836 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2839 ret = firstRegex.Match(url, false); // This returns true value
2840 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2842 if (ret == true && __pWebViewer != null)
2845 __pWebViewer->LoadUrl(url);
2847 else if(__pWebViewer != null)
2849 String tempUrl = L"http://";
2850 tempUrl.Append(url);
2854 __pWebViewer->LoadUrl(tempUrl);
2858 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2859 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2862 if (__pAddressbar != null)
2864 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2865 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2868 AppLogDebug("MainForm::LoadUrl exit");
2875 MainForm::OnStopClicked(Addressbar& addBar)
2877 AppLogDebug("MainForm::OnStopClicked called");
2880 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2881 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2882 __pWebViewer->StopLoading();
2883 RequestRedraw(true);
2888 MainForm::OnReaderClicked(const Addressbar& addBar)
2890 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2892 CreateReaderPanel();
2893 AppLogDebug("MainScene::OnReaderClicked entered");
2896 /*if (__pArticleReaderPanel)
2898 AppLogDebug("showstate true for reader panel");
2899 __pArticleReaderPanel->SetShowState(true);
2900 __pArticleReaderPanel->Show();
2902 int xPos = __pArticleReaderPanel->GetX();
2903 int yPos = __pArticleReaderPanel->GetY();
2904 AppLog("OnReaderClicked() xPos = %d",xPos);
2905 AppLog("OnReaderClicked() yPos = %d",yPos);
2907 if (__pReaderData == null)
2912 String loadData = L"<html>\
2914 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2919 background-color: transparent;\
2938 <body style='width:'";
2939 loadData.Append(bodyWidth);
2940 loadData.Append(L"px'>");
2941 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2942 loadData.Append(*__pReaderData);
2943 loadData.Append(L"</body></html>");
2946 buf.Construct(loadData.GetLength());
2947 AppLogDebug("data->GetLength %d",loadData.GetLength());
2948 for (int z=0;z<loadData.GetLength();z++)
2951 loadData.GetCharAt(z,b);
2952 buf.SetByte((byte)b);
2956 if (__pWebReader != null)
2958 __pWebReader->LoadData(L"",buf,L"text/html");
2959 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2963 AppLogDebug("cannot LoadData __pWebReader is null");
2969 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2971 // AppLog("MainForm::OnBackClicked");
2972 result r = E_FAILURE;
2974 if (__pWebViewer && __pWebViewer->CanGoBack())
2976 __pWebViewer->GoBack();
2978 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2981 pApp = UiApp::GetInstance();
2984 r = pApp->Terminate();
2987 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2995 WindowInfo* pWindowInfo = null;
2997 SceneManager* pSceneManager = SceneManager::GetInstance();
2998 if (pSceneManager == null)
3002 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3003 if (pAllWindowList == NULL)
3005 pApp = UiApp::GetInstance();
3008 r = pApp->Terminate();
3011 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3016 if (pAllWindowList != null)
3018 totalCount = pAllWindowList->GetCount();
3020 for (int count = 0; count < totalCount; count++)
3022 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3023 if (pWindowInfo == null)
3025 pApp = UiApp::GetInstance();
3028 r = pApp->Terminate();
3031 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3036 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3038 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3041 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3044 r = pAllWindowList->RemoveAt(count, true);
3045 __pWindowInfo = null;
3048 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3053 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3057 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3059 if (pWindowInfo == null)
3061 pApp = UiApp::GetInstance();
3064 r = pApp->Terminate();
3070 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3073 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3087 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3089 AppLog("MainForm::OnForwardClicked");
3090 if (__pWebViewer == null)
3093 if (__pWebViewer->CanGoForward())
3095 __pWebViewer->GoForward();
3100 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3102 result r = E_SUCCESS;
3104 __pFooterPanel->SetShowState(true);
3105 __pFooterUrlField->SetFocusable(true);
3108 __pWebViewer->SetFocus();
3109 else if(__pMostVisitedListView)
3110 __pMostVisitedListView->SetFocus();
3111 else if(__pMultiWindowButton)
3112 __pMultiWindowButton->SetFocus();
3113 __pMoreButton->SetFocus();
3115 __pAddressbar->SetShowState(false);
3117 RelayoutControls(false);
3122 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3124 __prevAddressBarMode = __curAddressBarMode;
3126 if (__pAddressbar != null)
3128 __curAddressBarMode = GetAddressbarMode();
3131 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3133 __adressPanelPosition.y = 0;
3134 if (__pAddressbar != null)
3136 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3137 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3138 __pAddressbar->Invalidate(true);
3140 if (__pWebViewer != null)
3142 __pWebViewer->StopLoading();
3145 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3147 __adressPanelPosition.y = 0;
3148 if (__pAddressbar != null)
3150 __webControlPosition.y = 0;
3151 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3152 __pAddressbar->Invalidate(true);
3158 MainForm::OnClipboardClosed(const Addressbar& addBar)
3160 RelayoutControls(false);
3164 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3167 __pAddressbar->SetShowState(false);
3169 __pFooterPanel->SetShowState(true);
3171 // __pWebViewer->SetFocus();
3172 if(__pFooterUrlField)
3174 __pFooterUrlField->SetFocusable(true);
3176 RelayoutControls(false);
3180 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3182 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3184 __pAddressbar->SetShowState(false);
3188 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3190 __pAddressbar->SetShowState(true);
3191 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3192 __pAddressbar->SetAddressbarURLFocus();
3196 RelayoutControls(false);
3200 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3202 __pFooterPanel->SetShowState(false);
3206 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3208 AppLog("KeypadBoundsChanged");
3209 RelayoutControls(false);
3213 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3217 __pWindowInfo->pageTitle = title;
3218 if (__pWebViewer != null)
3220 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3223 if (__pAddressbar != null && __pWebViewer != null)
3225 SetUrl(__pWebViewer->GetUrl());
3226 __pAddressbar->Invalidate(true);
3231 MainForm::UpdateFavicon(void)
3233 bool urlImageType = false;
3234 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();");
3235 Bitmap* pBitmap = null;
3237 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3239 if (__pWindowInfo != null)
3242 url.SetUri(*tempPath);
3243 if (url.GetHost().GetLength() == 0)
3246 webUrl.SetUri(__pWebViewer->GetUrl());
3247 result r = url.SetHost(webUrl.GetHost());
3254 if (url.GetScheme().GetLength() == 0)
3257 webUrl.SetUri(__pWebViewer->GetUrl());
3258 url.SetScheme(webUrl.GetScheme());
3260 __pWindowInfo->faviconUrl = url.ToString();
3262 pBitmap = __pWebViewer->GetFaviconN();
3264 if (pBitmap != null)
3266 if (__pWindowInfo->pFavicon != NULL)
3268 __pWindowInfo->pFavicon = null;
3270 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3271 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3273 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3275 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3277 else if(__pWindowInfo->pFavicon != null)
3279 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3283 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3284 if(pDefaultBmp != null)
3286 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3295 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3302 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3303 Tizen::Web::Controls::WebNavigationType type)
3305 // when load new page if find word panel is open its show state is false
3306 ShowFindWordPanel(false);
3308 __pFooterPanel->Invalidate(true);
3311 uriInfo.SetUri(url);
3313 if(url.Contains(IDS_TIZEN_SERVICE))
3316 String delim(L":;,");
3318 // Creates a StringTokenizer instance
3319 StringTokenizer strTok(url, delim);
3321 int count = strTok.GetTokenCount(); // count == 4
3323 HashMap *pMap = new HashMap();
3329 while (strTok.HasMoreTokens())
3331 AppLog("Token: %ls", token.GetPointer());
3332 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3333 if(token.Contains(IDS_APPID))
3335 token.SubString(6, appId);
3336 AppLog("AppID:%ls", appId.GetPointer());
3338 else if(token.Contains("="))
3340 String *pKey = new String();
3341 String *pValue = new String();
3343 token.IndexOf("=", 0, index);
3346 token.SubString(0, index, *pKey);
3347 token.SubString(index + 1, *pValue);
3348 pMap->Add(pKey, pValue);
3354 AppControl *pAppControl = null;
3355 String operationId = L"http://tizen.org/appcontrol/operation/main";
3356 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3359 result r = pAppControl->Start(null, null, pMap, null);
3363 AppLogException("AppControl not found");
3369 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3371 __pAddressbar->SetShowState(false);
3372 OnAddressCancelledClicked(*__pAddressbar);
3373 __pAddressbar->Invalidate(true);
3379 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3380 const Tizen::Net::Http::HttpHeader& httpHeader)
3382 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3387 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3389 AppLog("MainForm::OnWebPageBlockSelected");
3390 if (__pHitElementResult != null)
3392 delete __pHitElementResult;
3393 __pHitElementResult = null;
3396 if (__pWebViewer != null)
3398 AppLog("MainForm::OnWebPageBlockSelected web not null");
3399 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3402 if (__pHitElementResult == null)
3407 if (__pHitElementResult->HasImage() != true)
3409 String tagName = __pHitElementResult->GetTagName();
3410 String type = __pHitElementResult->GetAttributeValue("type");
3412 __currentSelectedStr.Clear();
3413 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3414 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3415 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3417 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3419 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3421 InitSelectTextContextMenu(endPoint,true);
3422 __pImageMenu->SetShowState(true);
3423 __pImageMenu->Show();
3424 __pImageMenu->Invalidate(true);
3426 else if(__isLongPressedDone == true)
3428 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3430 if(__pHitElementResult->GetUrl().GetLength() > 0)
3432 __currentSelectedStr.Clear();
3433 __currentSelectedStr = __pHitElementResult->GetUrl();
3435 InitSelectTextContextMenu(endPoint,false);
3436 __pImageMenu->SetShowState(true);
3437 __pImageMenu->Show();
3438 __pImageMenu->Invalidate(true);
3441 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3442 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3443 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3449 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3455 MainForm::OnWebWindowCreateRequested(void)
3457 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3459 if (pNewWindowInfo == null)
3463 result r = E_SUCCESS;
3464 SceneManager* pSceneManager = SceneManager::GetInstance();
3465 if (pSceneManager == NULL)
3469 ArrayList* pArgList = new(std::nothrow) ArrayList();
3470 if (pArgList == NULL)
3474 r = pArgList->Construct();
3477 pNewWindowInfo->isJavascriptInitiated = true;
3478 pArgList->Add(*pNewWindowInfo);
3479 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3483 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3490 return pNewWindowInfo->pCurrentWeb;
3494 MainForm::RelayoutControls(bool showAddressbar)
3496 __webControlPosition.y = 0;
3497 __webControlHeight = GetClientAreaBounds().height;
3498 AppLog("Client area height: %d", __webControlHeight);
3500 AppLog("Client area height: %d", __webControlHeight);
3501 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3503 __webControlPosition.y += __pAddressbar->GetHeight();
3504 __webControlHeight -= __pAddressbar->GetHeight();
3505 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3507 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3509 __webControlPosition.y += __pFindWordControl->GetHeight();
3510 __webControlHeight -= __pFindWordControl->GetHeight();
3511 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3514 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3516 __webControlHeight -= __pFooterPanel->GetHeight();
3517 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3519 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3521 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3522 __pWebViewer->Invalidate(false);
3524 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3526 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3533 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3535 if (__pFindWordControl == null)
3541 InitFindWordPanel();
3542 // __pFindWordEditField->SetText(__currentSearchStr);
3543 //__pFindWordCountLabel->SetText(L"");
3544 // __pFindWordCountLabel->SetText(L"0/0");
3545 __pFindWordControl->SetShowState(true);
3549 if(__pFindWordControl != null)
3551 __pFindWordControl->SetShowState(false);
3555 AppLog("MainForm::ShowFindWordPanel %d",show);
3556 if (show && !isTouchPressed)
3558 if (__pFindWordEditField)
3560 __pFindWordEditField->SetFocus();
3561 __pFindWordEditField->ShowKeypad();
3566 if (__pFindWordEditField)
3567 __pFindWordEditField->HideKeypad();
3570 RelayoutControls(false);
3574 MainForm::StartWordSearch()
3576 //Get the count of occurances of the word in the current page
3577 __maxOccurrances = 0;
3578 __currentWordIndex = 0;
3580 __pFindWordPrev->SetEnabled(false);
3581 String *pCountStr = null;
3582 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3583 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3584 if (pCountStr != null)
3586 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3590 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3595 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3597 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3598 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3600 if(totalCount == -1 || totalCount == 0)
3602 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3603 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3606 else if(totalCount > 100)
3608 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3609 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3613 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3614 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3617 __maxOccurrances = totalCount;
3618 __currentWordIndex = currentOrdinal;
3620 //Reset the UI controls as per the maxOccurrance value
3621 if (totalCount <= 0)
3623 AppLog("Word not found");
3624 //Show error notification to user
3625 __pFindWordNext->SetEnabled(false);
3626 __pFindWordCountLabel->SetText(L"0/0");
3627 __pFindWordNext->Invalidate(false);
3628 __pFindWordPrev->Invalidate(false);
3629 __pFindWordCountLabel->Invalidate(false);
3633 if (totalCount == 1)
3635 __pFindWordNext->SetEnabled(false);
3639 __pFindWordNext->SetEnabled(true);
3642 String countStr = L"";
3643 countStr.Append(__currentWordIndex);
3644 countStr.Append(L"/");
3645 countStr.Append(__maxOccurrances);
3646 __pFindWordCountLabel->SetText(countStr);
3647 // __pFindWordCountLabel->SetShowState(true);
3648 __pFindWordCountLabel->Invalidate(false);
3650 //FindNextWord(true);
3651 //Update the controls
3652 __pFindWordNext->Invalidate(false);
3653 __pFindWordPrev->Invalidate(false);
3654 __pFindWordCountLabel->Invalidate(false);
3658 MainForm::FindNextWord(bool next)
3662 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3664 if(__currentWordIndex < __maxOccurrances)
3666 __currentWordIndex++;
3672 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3674 if(__currentWordIndex > 1)
3676 __currentWordIndex--;
3681 String countStr = L"";
3682 countStr.Append(__currentWordIndex);
3683 countStr.Append(L"/");
3684 countStr.Append(__maxOccurrances);
3685 __pFindWordCountLabel->SetText(countStr);
3686 // __pFindWordCountLabel->SetShowState(true);
3687 __pFindWordCountLabel->Invalidate(false);
3688 if (__currentWordIndex >= __maxOccurrances)
3690 __pFindWordNext->SetEnabled(false);
3694 __pFindWordNext->SetEnabled(true);
3696 if (__currentWordIndex <= 1)
3698 __pFindWordPrev->SetEnabled(false);
3702 __pFindWordPrev->SetEnabled(true);
3704 __pFindWordPrev->Invalidate(false);
3705 __pFindWordNext->Invalidate(false);
3706 __pFindWordCountLabel->Invalidate(false);
3707 __pFindWordControl->Invalidate(true);
3710 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3712 AppLog("MainForm::OnWebKeypadWillOpen");
3713 __isWebKeypadOpened = true;
3714 // OnAddressBarKeypadOpened(*__pAddressbar);
3718 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3721 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3723 __currentSearchStr = L"";
3724 __currentWordIndex = 0;
3725 __maxOccurrances = 0;
3726 __pFindWordEditField->SetText(L"");
3727 __pFindWordNext->SetEnabled(false);
3728 __pFindWordPrev->SetEnabled(false);
3729 __pFindWordCountLabel->SetText(L"0/0");
3730 __pWebViewer->SearchTextAllAsync(L"",false);
3731 __pFindWordControl->SetShowState(false);
3732 __pFindWordEditField->HideKeypad();
3736 if (__pWebViewer != null && __pFooterPanel != null)
3738 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3739 if(__pAddressbar != null)
3741 __pAddressbar->SetShowState(false);
3743 if(__pFindWordControl != null)
3745 __pFindWordControl->SetShowState(false);
3747 __pFooterPanel->SetShowState(false);
3748 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3750 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3752 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3753 // AppLog("omgomgomg");
3759 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3761 __pFooterPanel->SetShowState(true);
3762 OnAddressBarKeypadClosed(*__pAddressbar);
3763 __isWebKeypadOpened = false;
3767 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3769 Control* temp = const_cast< Control* >(&source);
3770 Header* pHeader = dynamic_cast< Header* >(temp);
3771 if (pHeader != null)
3773 //Header double - clicked
3774 AppLog("Header double clicked");
3776 if(__pFindWordControl)
3778 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3779 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3783 AppLog("MainScene::OnTouchDoublePressed");
3784 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3785 if (isReaderEnabled == true)
3789 delete __pReaderData;
3790 __pReaderData = null;
3792 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3793 filePath.Append(L"data/reader.js");
3799 result r = E_SUCCESS;
3800 FileAttributes attr;
3802 File::GetAttributes(filePath,attr);
3804 r = file.Construct(filePath, L"r+");
3807 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3810 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3813 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3816 file.Read(pScript,attr.GetFileSize());
3818 AppLogDebug("scipt length %d",strlen(pScript));
3819 String strScript = L"";
3820 strScript.Append(pScript);
3821 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3824 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3827 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3828 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3830 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3831 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3837 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3839 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3841 if (__pHitElementResult != null)
3843 delete __pHitElementResult;
3844 __pHitElementResult = null;
3847 if (__pWebViewer != null)
3849 AppLog("MainForm::OnTouchLongPressed web not null");
3850 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3853 if (__pHitElementResult == null)
3858 if (__pHitElementResult->HasImage() == true)
3860 InitImageContextMenu(currentPosition);
3861 __pImageMenu->SetShowState(true);
3862 __pImageMenu->Show();
3863 __pImageMenu->Invalidate(true);
3865 else if(__pHitElementResult->HasUrl() == true)
3867 String tempURl = __pHitElementResult->GetUrl();
3868 AppLog("tempURl is %ls", tempURl.GetPointer());
3869 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3870 if (pBitmap != null)
3878 InitImageLinkContextMenu(currentPosition);
3879 __pImageMenu->SetShowState(true);
3880 __pImageMenu->Show();
3881 __pImageMenu->Invalidate(true);
3885 String tagName = __pHitElementResult->GetTagName();
3886 String type = __pHitElementResult->GetAttributeValue("type");
3887 String value = __pHitElementResult->GetAttributeValue(L"value");
3888 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3890 __currentSelectedStr.Clear();
3891 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3893 AppLog("tag name is %ls", tagName.GetPointer());
3894 AppLog("type is %ls", type.GetPointer());
3895 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3897 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3899 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3901 InitSelectTextContextMenu(currentPosition,true, true);
3904 // __pImageMenu->SetShowState(true);
3905 // __pImageMenu->Show();
3906 // __pImageMenu->Invalidate(true);
3909 __isLongPressedDone = true;
3910 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3911 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3914 __inputEventToBeSupressed = true;
3918 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3920 AppLog("MainForm::OnTouchReleased");
3922 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3923 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3925 __pWebViewer->ConsumeInputEvent();
3927 if(pHitElement != null)
3931 __inputEventToBeSupressed = false;
3935 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3942 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3944 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3946 __currentSearchStr = L"";
3947 __currentWordIndex = 0;
3948 __maxOccurrances = 0;
3949 __pFindWordEditField->SetText(L"");
3950 __pFindWordNext->SetEnabled(false);
3951 __pFindWordPrev->SetEnabled(false);
3952 __pFindWordCountLabel->SetText(L"0/0");
3953 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3954 __pFindWordControl->SetShowState(false);
3955 __pFindWordEditField->HideKeypad();
3957 if(__pAddressbar->GetShowState() == false)
3959 __pAddressbar->SetShowState(true);
3960 __pAddressbar->SetAddressbarURLFocus();
3961 __pFooterUrlField->SetFocusable(false);
3962 __pFooterPanel->SetShowState(false);
3969 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3975 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3981 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3987 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3993 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3999 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4001 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4002 int widthContextItem = 0;
4004 // As per the platform engineer comment removed this line
4005 /*if(__pWebViewer != null)
4007 // 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
4008 __pWebViewer->ReleaseBlock();
4011 if(__pFindWordControl != null)
4012 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4013 if ( __pFooterLabel != null)
4015 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4018 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4023 if (__pFindWordBgLabel != null)
4025 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4026 if (pBitmap != null)
4028 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4034 __pMenu->SetShowState(false);
4035 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4037 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4041 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4046 AppLog("__pFooterPanel->GetShowState() is true");
4048 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4049 __pFooterPanel->Invalidate(true);
4053 if(__pMoreButton && __pMenu)
4055 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4056 __pMenu->SetAnchorPosition(p);
4057 __pMenu->Invalidate(true);
4060 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4061 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4063 InitMostVisitedSitesView(orientationStatus);
4066 RelayoutControls(false);
4067 if (__pArticleReaderPanel != null)
4069 if (__pArticleReaderPanel->GetShowState() == true)
4071 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4073 if (__pBlankPanel != null)
4074 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4076 if (__pWebReader != null)
4078 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4080 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4081 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4083 if ( pBitmap != null && pSrcBitmap != null)
4085 AppLog("CreateReaderPanel ninepatchbitmap found");
4086 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4089 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4090 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4091 if (pBitmap != null)
4096 if (pSrcBitmap != null)
4105 if (__pAddressbar != null)
4107 int width = GetClientAreaBounds().width;
4108 __pAddressbar->OrientationChanged(width);
4113 MainForm::OnSettingsChange(int settingvalue)
4115 AppLogDebug("MainForm::OnSettingsChange entered");
4117 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4119 __pAddressbar->ResetGuideText();
4121 if (__pWebViewer == null)
4123 AppLogDebug("Webviewer is not initialized yet.");
4127 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4129 WebSetting settings = __pWebViewer->GetSetting();
4130 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4132 settings.SetAutoFittingEnabled(true);
4134 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4136 settings.SetAutoFittingEnabled(false);
4138 __pWebViewer->SetSetting(settings);
4140 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4142 WebSetting settings = __pWebViewer->GetSetting();
4143 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4144 __pWebViewer->SetSetting(settings);
4146 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4148 WebSetting settings = __pWebViewer->GetSetting();
4149 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4150 __pWebViewer->SetSetting(settings);
4152 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4154 WebSetting settings = __pWebViewer->GetSetting();
4155 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4156 __pWebViewer->SetSetting(settings);
4158 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4162 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4166 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4168 WebSetting settings = __pWebViewer->GetSetting();
4169 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4171 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4175 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4177 __pWebViewer->SetSetting(settings);
4179 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4183 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4184 WebSetting settings = __pWebReader->GetSetting();
4185 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4186 __pWebReader->SetSetting(settings);
4192 MainForm::OnSettingsReset()
4196 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4197 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4202 MainForm::OnClearCache()
4204 result r = E_SUCCESS;
4206 if (__pWebViewer != NULL)
4208 r = __pWebViewer->ClearCache();
4211 AppLogDebug("Cache cleared success");
4215 AppLogDebug("Cache cleared fail");
4221 MainForm::OnClearCookie()
4223 result r = E_SUCCESS;
4225 if (__pWebViewer != NULL)
4227 __pWebViewer->ClearCookie();
4231 AppLogDebug("Cookie cleared success");
4235 AppLogDebug("Cache cleared fail");
4240 MainForm::OnClearFormData()
4242 result r = E_SUCCESS;
4244 if (__pWebViewer != NULL)
4246 __pWebViewer->ClearFormData();
4250 AppLogDebug("Cookie cleared success");
4254 AppLogDebug("Cache cleared fail");
4259 MainForm::OnClearPasswords()
4261 result r = E_SUCCESS;
4263 if (__pWebViewer != NULL)
4265 __pWebViewer->ClearLoginFormData();
4269 AppLogDebug("Cookie cleared success");
4273 AppLogDebug("Cache cleared fail");
4279 MainForm::findDistance(int x1,int y1,int x2, int y2)
4281 int deltaX = Math::Abs(x2 - x1);
4282 int deltaY = Math::Abs(y2 - y1);
4283 double num = deltaX*deltaX + deltaY*deltaY;
4289 for (i = 0; i < 20; i++)
4291 x = (((x*x)+ num)/(2*x));
4302 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4304 if(__pFindWordControl)
4306 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4307 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4309 __isLongPressedDone = false;
4312 IList* pList = null;
4313 pList = touch.GetTouchInfoListN(source);
4317 int count = pList->GetCount();
4320 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4321 __touchPoint1 = pTouchInfo->position;
4323 /*if (__pAddressbar != null)
4325 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4327 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4329 __pAddressbar->SaveAddressbarEditText();
4331 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4334 __pAddressbar->Invalidate(true);
4336 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4338 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4340 //__pAddressbar->SaveAddressbarEditText();
4342 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4345 else if (count == 2)
4347 AppLogDebug("MainForm::OnTouchPressed count is two");
4348 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4349 __touchPoint1 = pTouchInfo->position;
4351 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4352 __touchPoint2 = pTouchInfo->position;
4358 pList->RemoveAll(true);
4365 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4367 // __currentWordIndex = 0;
4368 __isLongPressedDone = false;
4373 MainForm::MoveUiControls()
4378 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4380 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4382 if(__pFooterUrlField->GetTextLength() == 0)
4384 __pFooterUrlField->SetKeypadActionEnabled(false);
4388 __pFooterUrlField->SetKeypadActionEnabled(true);
4391 if (__pFindWordEditField != null)
4393 __currentSearchStr = __pFindWordEditField->GetText();
4394 __pFindWordNext->SetEnabled(false);
4395 __pFindWordPrev->SetEnabled(false);
4396 __pFindWordNext->Invalidate(true);
4397 __pFindWordPrev->Invalidate(true);
4398 __pFindWordCountLabel->SetText(L"0/0");
4399 __pFindWordCountLabel->Invalidate(true);
4401 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4402 if (__currentSearchStr.GetLength() > 0)
4408 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4410 __currentSearchStr = L"";
4411 AppLogDebug("Enter something");
4416 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4423 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4425 if(__pWebViewer != null)
4428 AppLog("MainForm::InitMostVisitedSitesView");
4429 result r = E_SUCCESS;
4432 if (__pWebViewer != null && __pMostVisitedListView != null)
4437 if (__pMostVisitedListView != null)
4439 RemoveControl(*__pMostVisitedListView);
4441 if(__pMostVisitedSites != null)
4443 __pMostVisitedSites->RemoveAll(true);
4446 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4448 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4449 __pMostVisitedListView = new(std::nothrow) ListView();
4451 int height = GetClientAreaBounds().height;
4453 if(__pFooterPanel->GetShowState() == true)
4455 height = height - __pFooterPanel->GetHeight();
4457 if(__pAddressbar->GetShowState() == true)
4459 height -= __pAddressbar->GetHeight();
4462 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4466 delete __pMostVisitedListView;
4467 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4470 __pMostVisitedListView->SetItemProvider(*this);
4471 __pMostVisitedListView->AddListViewItemEventListener(*this);
4472 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4473 AddControl(*__pMostVisitedListView);
4474 __pMostVisitedListView->UpdateList();
4481 MainForm::GetImagePath(void)
4485 String formattedTime;
4486 DateTime currentTime;
4487 LocaleManager localManager;
4488 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4490 localManager.Construct();
4491 Locale locale = localManager.GetSystemLocale();
4492 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4494 // Get date formatter
4495 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4499 pTimeFormatter->Format(currentTime, formattedTime);
4502 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4503 String delim(L" :");
4504 StringTokenizer strTok(formattedTime, delim);
4507 String str1("GMT+00");
4508 while (strTok.HasMoreTokens())
4510 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4511 if(token.Equals(str1))
4513 AppLog("token is %ls", token.GetPointer());
4514 imageName.Append(token);
4520 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4522 result r = E_FAILURE;
4523 AppLog("Content manager 1");
4524 ContentId contentId;
4525 ContentManager contentManager;
4526 r = contentManager.Construct();
4529 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4532 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4533 contentPath.Append(imageName);
4534 contentPath.Append(".jpg");
4535 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4536 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4540 MainForm::SetForwardButtonEnabled(bool isEnabled)
4542 __pGoForwardBtn->SetEnabled(isEnabled);
4543 __pGoForwardBtn->Invalidate(true);
4547 MainForm::SetBackButtonEnabled(bool isEnabled)
4549 __pGoBackBtn->SetEnabled(isEnabled);
4550 __pGoBackBtn->Invalidate(true);
4554 MainForm::UpdateProgress(int percentage)
4556 __progressPercentage = percentage;
4557 if (percentage == 0 || percentage == 100)
4559 __isLoadingData = false;
4560 if (percentage == 100)
4562 __isLoadingCompleted = true;
4563 __progressPercentage = 0;
4567 __isLoadingCompleted = false;
4572 __isLoadingData = true;
4574 UpdateProgressBitmap();
4578 MainForm::GetProgress(void)
4580 return __progressPercentage;
4584 MainForm::UpdateProgressBitmap(void)
4586 result r = E_SUCCESS;
4587 if (__pProgressbarLabel == null)
4589 int w = __pProgressbarLabel->GetWidth();
4590 int h = __pProgressbarLabel->GetHeight();
4592 int progressWidth = 0;
4593 Bitmap* pRetBitmap = null;
4595 if (__progressPercentage == 0 || __progressPercentage == 100)
4597 __pProgressbarLabel->SetShowState(false);
4598 __pProgressbarLabel->Invalidate(false);
4603 __pProgressbarLabel->SetShowState(true);
4604 __pProgressbarLabel->Invalidate(false);
4607 r = canvas.Construct(Rectangle(0, 0, w, h));
4611 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4616 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4620 pBgBmp->Scale(Dimension(w, h));
4621 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4625 progressWidth = (double) (w) * __progressPercentage / 100;
4626 AppLogDebug("progressWidth: %d", progressWidth);
4627 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4629 if (pProgressBmp != null)
4631 pProgressBmp->Scale(Dimension(progressWidth, h));
4632 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4633 delete pProgressBmp;
4636 pRetBitmap = new (std::nothrow) Bitmap();
4638 if (pRetBitmap == null)
4640 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4644 pRetBitmap->Construct(canvas, canvas.GetBounds());
4646 if (__pProgressbarLabel != null && pRetBitmap != null)
4648 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4649 __pProgressbarLabel->Invalidate(false);
4652 if (pRetBitmap != null)
4660 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4662 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4664 __currentAddMode = addMode;
4668 case ADDRESSBAR_MODE_INVALID:
4673 case ADDRESSBAR_MODE_READER:
4675 __pStopBtn->SetShowState(false);
4676 __pClearBtn->SetShowState(false);
4679 case ADDRESSBAR_MODE_LOADING:
4681 __pRefreshBtn->SetShowState(false);
4682 __pStopBtn->SetShowState(true);
4683 __pClearBtn->SetShowState(false);
4686 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4688 // SetUrl(__pAddressbar->GetUrl());
4690 __pRefreshBtn->SetShowState(true);
4691 __pStopBtn->SetShowState(false);
4692 __pClearBtn->SetShowState(false);
4695 case ADDRESSBAR_MODE_EDIT:
4697 __pRefreshBtn->SetShowState(false);
4698 __pStopBtn->SetShowState(false);
4699 __pClearBtn->SetShowState(true);
4706 OnAddressBarModeChanged();
4709 AddressBarMode MainForm::GetAddressbarMode(void)
4711 return __currentAddMode;
4714 void MainForm::SetUrl(const String& url)
4718 if (__pFooterUrlField != NULL)
4720 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4721 if (removedHttpUrl.IsEmpty() == false)
4723 __pFooterUrlField->SetText(removedHttpUrl);
4724 if(__pAddressbar != NULL)
4725 __pAddressbar->SetUrl(__displayUrl);
4729 __pFooterUrlField->SetText(__displayUrl);
4730 if(__pAddressbar != NULL)
4731 __pAddressbar->SetUrl(__displayUrl);
4733 if(__pFooterUrlField)
4734 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4735 __pFooterUrlField->Invalidate(false);
4736 if(__pAddressbar != NULL)
4737 __pAddressbar->Invalidate(true);
4738 // __pFooterUrlField->SetCursorPosition(0);
4743 MainForm::RemoveHttpTextFromDisplayURL(void)
4745 bool isHttpText = __displayUrl.Contains(L"http://");
4746 String updatedDisplayUrl;
4747 updatedDisplayUrl.Clear();
4749 if (isHttpText == true)
4751 __displayUrl.SubString(7,updatedDisplayUrl);
4753 return updatedDisplayUrl;
4756 void MainForm::OnSharePopupControlStarted(void)
4758 __pWebViewer->AddTouchEventListener(*this);
4761 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4763 if (requestId == BACK_GROUND_APP_EVENT)
4765 if(__pWebViewer != null)
4767 __pWebViewer->Pause();