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));
1323 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1325 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1328 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1331 r = pAllWindowList->RemoveAt(count, true);
1332 __pWindowInfo = null;
1335 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1340 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1344 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1346 if (pWindowInfo == null)
1348 pApp = UiApp::GetInstance();
1351 r = pApp->Terminate();
1357 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1360 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1372 case IDA_FORWARD_CLICKED:
1373 if (__pWebViewer == null)
1376 if (__pWebViewer->CanGoForward())
1378 __pWebViewer->GoForward();
1380 __pMenu->SetShowState(false);
1381 __pMenu->Invalidate(false);
1384 case IDA_FINDONPAGE_CLICKED:
1386 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1387 __currentSearchStr.Clear();
1389 InitFindWordPanel();
1390 __pMenu->SetShowState(false);
1391 __pMenu->Invalidate(false);
1393 __pFindWordEditField->SetFocus();
1395 if (__pWebViewer != null)
1397 // releasing the set block
1398 __pWebViewer->ReleaseBlock();
1401 ShowFindWordPanel(true);
1404 case IDA_PRIVATEON_CLICKED:
1406 result r = E_SUCCESS;
1408 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1409 Bitmap* pBitmap = null;
1410 if (isPrivateBrowsing == true)
1412 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1415 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1419 if (__pWebViewer != NULL)
1421 __pWebViewer->SetPrivateBrowsingEnabled(false);
1424 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1426 if (__pAddressbar != null)
1428 __pAddressbar->UpdateFaviconBitmap(false);
1434 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1437 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1441 if (__pWebViewer != NULL)
1443 __pWebViewer->SetPrivateBrowsingEnabled(true);
1446 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1448 if (__pAddressbar != null)
1450 __pAddressbar->UpdateFaviconBitmap(true);
1455 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1456 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1457 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1458 __pMenu->Invalidate(true);
1460 if ( pBitmap != NULL )
1467 case IDA_SETTINGS_CLICKED:
1470 ArrayList* pArgList = new(std::nothrow) ArrayList();
1473 pArgList->Construct();
1474 pArgList->Add(*__pWindowInfo);
1475 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1477 __pMenu->SetShowState(false);
1478 __pMenu->Invalidate(false);
1479 if (pArgList != null)
1488 case IDA_ADDTOBOOKMARK_CLICKED:
1491 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1493 int bookmarkCount=0;
1496 url=__pWindowInfo->pageUrl;
1497 result r = E_SUCCESS;
1498 Bitmap* pBitmap = null;
1499 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1507 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1508 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1509 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1511 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1512 if (pNotification != null)
1514 pNotification->SetText(message);
1515 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1516 pNotification->ShowNotification();
1521 String title=__pWindowInfo->pageTitle;
1522 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1523 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1525 pBookmark->SetBookmarkTitle(title);
1526 pBookmark->SetUrl(url);
1527 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1529 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1531 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1532 pBookmark->SetFaviconId(id);
1533 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1534 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1537 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1538 if (pNotification != null)
1540 pNotification->SetText(message);
1541 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1542 pNotification->ShowNotification();
1543 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1546 if (pBitmap != null)
1548 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1552 __pMenu->Invalidate(true);
1556 case IDA_PRINT_CLICKED:
1558 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1559 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1561 AppLog("RequestPrint called!");
1562 Tizen::App::AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1563 result nResult = E_FAILURE;
1566 AppLog("TestPrint if (pAc) == true");
1571 String fileType = L"service_print_files_type";
1572 String typeVal = L"DOC";
1574 String fileCount = L"service_print_files_count";
1575 String countVal = L"1";
1576 String fileFolder= L"service_print_files_folder_name";
1577 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1579 map.Add(&fileCount, &countVal);
1580 // map.Add(&fileIndex, &indexVal);
1581 map.Add(&fileFolder, &folderVal);
1582 map.Add(&fileType, &typeVal);
1584 String fileName = L"service_print_files_files_name";
1586 ArrayList fileNameList;
1587 fileNameList.Construct();
1588 String file1 = L"test.pdf";
1590 fileNameList.Add(&file1);
1591 map.Add(&fileName, &fileNameList);
1593 nResult = pAc->Start(NULL, NULL, &map, NULL);
1595 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1596 else if (nResult == E_MAX_EXCEEDED)
1597 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1598 else if (nResult == E_OBJ_NOT_FOUND)
1599 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1600 else if (nResult == E_IN_PROGRESS)
1601 AppLog("TestPrint ret == E_IN_PROGRESS");
1602 else if (nResult == E_PRIVILEGE_DENIED)
1603 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1604 else if(nResult == E_SYSTEM)
1605 AppLog("TestPrint ret == E_SYSTEM");
1611 int __modalMsgBoxResult;
1612 MessageBox* pMsgBox = new MessageBox();
1613 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1614 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1617 __modalMsgBoxResult = 0;
1621 case IDA_SHARE_CLICKED:
1623 if(__pPopUp != null)
1628 __pPopUp = new(std::nothrow) SharePopup();
1629 __pPopUp->Initialize();
1630 if (__pWindowInfo != null)
1632 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1633 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1634 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1635 pShareInfo->SetImageAttached(false);
1636 __pPopUp->RemoveAllShareInfo();
1637 __pPopUp->AddShareInfo(pShareInfo);
1639 __pPopUp->SetShowState(true);
1643 case IDA_BOOKMARKBTN_CLICKED:
1645 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1646 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1649 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1654 case IDA_MOREBTN_CLICKED:
1656 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1657 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1658 AppLog("Anchot pos: %d %d", p.x, p.y);
1660 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1662 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1663 int bookmarkCount=0;
1666 url=__pWindowInfo->pageUrl;
1667 result r = E_SUCCESS;
1668 Bitmap* pBitmap = null;
1670 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1673 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1678 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1682 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1684 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1686 if (__pMenu->GetItemCount() == 9)
1688 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1692 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1697 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1701 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1702 if (__pMenu->GetItemCount() != 9)
1704 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1705 __pMenu->InsertItemAt(2,"Print", IDA_PRINT_CLICKED);
1706 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1707 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1708 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1709 __pMenu->SetMaxVisibleItemsCount(6);
1711 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1713 AppLog(" Orientation landscape");
1714 __pMenu->SetMaxVisibleItemsCount(5);
1718 AppLog(" Orientation potrait");
1719 __pMenu->SetMaxVisibleItemsCount(6);
1722 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1725 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1726 __pMenu->SetShowState(true);
1727 __pMenu->Invalidate(true);
1731 case IDA_HISTORY_CLICKED:
1733 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1734 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1737 case IDA_SAVED_PAGES_CLICKED:
1742 case IDA_DESKTOP_VIEW_CLICKED:
1747 case IDA_SAVE_CLICKED:
1752 case IDA_MULTIWINDOWBTN_CLICKED:
1754 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1755 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1759 case IDA_NEWWINDOWBTN_CLICKED:
1761 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1763 if (pNewWindowInfo == null)
1767 result r = E_SUCCESS;
1768 SceneManager* pSceneManager = SceneManager::GetInstance();
1770 if (pSceneManager == NULL)
1774 ArrayList* pArgList = new(std::nothrow) ArrayList();
1775 if (pArgList == NULL)
1779 r = pArgList->Construct();
1782 pArgList->Add(*pNewWindowInfo);
1783 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1789 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1794 case IDA_SMALLFONT_BTN_CLICKED:
1796 WebSetting setting = __pWebReader->GetSetting();
1797 setting.SetFontSize(15);
1798 __pWebReader->SetSetting(setting);
1801 case IDA_LARGEFONT_BTN_CLICKED:
1803 WebSetting setting = __pWebReader->GetSetting();
1804 setting.SetFontSize(25);
1805 __pWebReader->SetSetting(setting);
1808 case IDA_READER_CLOSE_CLICKED:
1810 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1812 //__pArticleReaderPanel->SetShowState(false);
1813 //__pArticleReaderPanel->Show();
1814 RemoveControl(*__pBlankPanel);
1815 //RemoveControl(*__pArticleReaderPanel);
1816 __pArticleReaderPanel = null;
1817 __pBlankPanel = null;
1818 __pArticleReaderLabel = null;
1820 //if (__pAddressbar)
1821 // __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1822 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1825 case IDA_FINDWORD_CANCEL_CLICKED:
1827 __currentSearchStr = L"";
1828 __currentWordIndex = 0;
1829 __maxOccurrances = 0;
1830 __pFindWordEditField->SetText(L"");
1831 __pFindWordNext->SetEnabled(false);
1832 __pFindWordPrev->SetEnabled(false);
1833 __pFindWordCountLabel->SetText(L"0/0");
1834 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1835 ShowFindWordPanel(false);
1838 case IDA_FINDWORD_SEARCH_CLICKED:
1840 __currentSearchStr = __pFindWordEditField->GetText();
1841 if (__currentSearchStr.GetLength() > 0)
1847 AppLogDebug("Enter something");
1851 case IDA_FINDWORD_CLEAR_CLICKED:
1853 __pFindWordCountLabel->SetText(L"0/0");
1854 __pFindWordEditField->SetText(L"");
1855 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1857 __currentSearchStr = L"";
1858 __pFindWordNext->SetEnabled(false);
1859 __pFindWordPrev->SetEnabled(false);
1860 __pFindWordControl->Invalidate(true);
1863 case IDA_FINDWORD_NEXT_CLICKED:
1868 case IDA_FINDWORD_PREV_CLICKED:
1870 FindNextWord(false);
1873 case IDA_BRIGHTNESS_BTN_CLICKED:
1875 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1876 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1879 case IDA_COPY_IMAGE_CLICKED:
1881 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1882 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1884 const Bitmap* pBitmap = null;
1885 if (__pHitElementResult != null)
1887 pBitmap = __pHitElementResult->GetImage();
1890 String resourcePath = App::GetInstance()->GetAppResourcePath();
1891 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1893 // copying the item to clipboard
1894 Clipboard* pClipboard = Clipboard::GetInstance();
1895 if (pClipboard != null)
1897 pClipboard->CopyItem(item);
1901 case IDA_VIEW_IMAGE_CLICKED:
1903 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1904 WindowInfo* pNewWindowInfo = null;
1905 if (__pHitElementResult != null)
1907 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1908 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1914 case IDA_SAVE_IMAGE_CLICKED:
1916 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1917 const Bitmap* pSaveBitmap = null;
1918 String imageName = GetImagePath();
1919 AppLog("Content manager image name %ls",imageName.GetPointer());
1922 imagePath.Append(imageName);
1923 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1924 AppLog("Content manager image path %ls",imagePath.GetPointer());
1925 if (__pHitElementResult != null)
1927 pSaveBitmap = __pHitElementResult->GetImage();
1929 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1933 UpdateImageContent(pBuffer, imageName);
1935 NotificationPanel *pNotification = new NotificationPanel(*this);
1937 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1938 msg.Append(imagePath);
1939 if (pNotification != null)
1941 pNotification->SetText(msg);
1942 if (__pFooterPanel->GetShowState() == true)
1944 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1948 pNotification->SetPositionDiff(0);
1951 pNotification->ShowNotification();
1956 int __modalMsgBoxResult;
1957 MessageBox* pMsgBox = new MessageBox();
1958 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1959 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1962 __modalMsgBoxResult = 0;
1966 case IDA_SHARE_IMAGE_CLICKED:
1968 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1969 if (__pPopUp != null)
1974 __pPopUp = new(std::nothrow) SharePopup();
1975 __pPopUp->Initialize();
1976 if (__pHitElementResult != null)
1978 const Bitmap* pSaveBitmap = null;
1979 String imageName = GetImagePath();
1980 AppLog("Content manager image name %ls",imageName.GetPointer());
1983 imagePath.Append(imageName);
1984 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1985 AppLog("Content manager image path %ls",imagePath.GetPointer());
1986 if (__pHitElementResult != null)
1988 pSaveBitmap = __pHitElementResult->GetImage();
1990 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1992 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1993 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1995 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1996 pShareInfo->SetPageTitle(L"");
1997 pShareInfo->SetPageUrl(srcUrl);
1998 pShareInfo->SetImageAttached(true);
1999 pShareInfo->SetImagePath(imagePath);
2000 __pPopUp->RemoveAllShareInfo();
2001 __pPopUp->AddShareInfo(pShareInfo);
2002 __pPopUp->SetShowState(true);
2007 case IDA_HYPERLINK_OPEN_CLICKED:
2009 if (__pHitElementResult != null)
2011 String srcUrl = __pHitElementResult->GetUrl();
2013 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
2015 if (pNewWindowInfo == null)
2019 result r = E_SUCCESS;
2020 SceneManager* pSceneManager = SceneManager::GetInstance();
2021 if (pSceneManager == NULL)
2025 ArrayList* pArgList = new(std::nothrow) ArrayList();
2026 if (pArgList == NULL)
2030 pArgList->Construct();
2032 pArgList->Add(*pNewWindowInfo);
2033 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2034 if (pArgList != null)
2041 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2047 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2049 if (__pHitElementResult == null)
2054 if(__pPopUp != null)
2059 __pPopUp = new(std::nothrow) SharePopup();
2060 __pPopUp->Initialize();
2062 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2063 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2064 pShareInfo->SetImageAttached(false);
2065 __pPopUp->RemoveAllShareInfo();
2066 __pPopUp->AddShareInfo(pShareInfo);
2068 __pPopUp->SetShowState(true);
2072 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2076 if (__pHitElementResult != null)
2078 url = __pHitElementResult->GetUrl();
2081 String resourcePath = App::GetInstance()->GetAppResourcePath();
2082 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2084 // copying the item to clipboard
2085 Clipboard* pClipboard = Clipboard::GetInstance();
2086 if (pClipboard != null)
2088 pClipboard->CopyItem(item);
2092 case IDA_FIND_TEXT__CLICKED:
2094 OnAddressCancelledClicked(*__pAddressbar);
2095 __pFooterPanel->SetShowState(false);
2096 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2097 __currentSearchStr.Clear();
2098 __currentSearchStr.Append(__currentSelectedStr);
2099 InitFindWordPanel();
2100 __pFindWordEditField->SetText(__currentSearchStr);
2103 __pMenu->SetShowState(false);
2104 __pMenu->Invalidate(false);
2107 __adressPanelPosition.y = 0;
2109 if (__pAddressbar != null && __pWebViewer != NULL)
2111 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2112 //__pAddressbar->SetBounds(0,__adressPanelPosition.y,GetClientAreaBounds().width,__pAddressbar->GetHeight());
2113 //__pAddressbar->Invalidate(true);
2114 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2116 if (__pFooterPanel->GetShowState() == false)
2117 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2119 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2120 // __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,__webControlHeight));
2121 __pWebViewer->Invalidate(true);
2124 ShowFindWordPanel(true);
2125 __pFindWordEditField->SetFocus();
2126 if (__currentSearchStr.GetLength() > 0)
2132 AppLogDebug("Enter something");
2135 if (__pWebViewer != null)
2137 // releasing the set block
2138 __pWebViewer->ReleaseBlock();
2143 case IDA_SHARE_TEXT_CLICKED:
2145 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2146 if(__pPopUp != null)
2151 __pPopUp = new(std::nothrow) SharePopup();
2152 __pPopUp->Initialize();
2153 if (__pHitElementResult != null)
2155 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2156 pShareInfo->SetPageTitle(L"");
2157 pShareInfo->SetPageUrl(__currentSelectedStr);
2158 pShareInfo->SetImageAttached(false);
2159 __pPopUp->RemoveAllShareInfo();
2160 __pPopUp->AddShareInfo(pShareInfo);
2161 __pPopUp->SetShowState(true);
2166 case IDA_COPY_TEXT_CLICKED:
2168 __pWebViewer->ReleaseBlock();
2169 // need to implement
2170 //__currentSelectedStr
2171 // Sets data to a clip board item
2173 String resourcePath = App::GetInstance()->GetAppResourcePath();
2174 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2176 // copying the item to clipboard
2177 Clipboard* pClipboard = Clipboard::GetInstance();
2178 if (pClipboard != null)
2180 pClipboard->CopyItem(item);
2184 case IDA_PASTE_TEXT_CLICKED:
2186 Clipboard* pClipboard = Clipboard::GetInstance();
2188 if(pClipboard == null)
2192 // Retrieves a latest item
2193 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2199 //Gets data from the clipboard item
2200 String* pString = dynamic_cast<String*>(pItem->GetData());
2202 if (pString != null)
2204 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2205 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2206 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2207 // 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; } } ";
2208 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; } } ";
2209 if(idElement.GetLength() != 0)
2211 script.Append("insertAtCursor('");
2212 script.Append(idElement);
2213 script.Append("',");
2214 script.Append("\"");
2215 script.Append(*pString);
2216 script.Append("\");");
2218 else if (nameElement.GetLength() != 0)
2220 script.Append("insertAtCursor(document.getElementsByName('");
2221 script.Append(nameElement);
2222 script.Append("')[0],");
2223 script.Append("\"");
2224 script.Append(*pString);
2225 script.Append("\");");
2227 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2228 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2239 case IDA_GO_FORWARD:
2244 case IDA_REFRESH_BTN_CLICKED:
2246 __isLoadingCompleted = false;
2247 __isLoadingData = true;
2248 __progressPercentage = 0;
2249 __displayUrl = __pFooterUrlField->GetText();
2251 String url = __pFooterUrlField->GetText();
2252 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2256 UpdateProgressBitmap();
2259 case IDA_STOP_BTN_CLICKED:
2261 __isLoadingCompleted = false;
2262 __isLoadingData = false;
2263 __progressPercentage = 0;
2264 __pFooterUrlField->HideKeypad();
2265 __displayUrl = __pFooterUrlField->GetText();
2269 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2270 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2271 __pWebViewer->StopLoading();
2272 RequestRedraw(true);
2275 UpdateProgressBitmap();
2280 if (__pFooterUrlField->GetText().IsEmpty() == false)
2282 //__displayUrl = __pUrlField->GetText();
2283 __pFooterUrlField->Clear();
2294 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2297 UiApp* pApp = UiApp::GetInstance();
2306 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2307 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2309 AppLog("MainForm::OnSceneActivatedN called");
2310 String* pSelectedScene = NULL;
2311 Object* pValue = NULL;
2312 String* pUrl = null;
2313 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2314 pSelectedScene = (String*) pValue;
2316 if (pSelectedScene != null)
2318 delete pSelectedScene;
2320 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2321 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2322 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2323 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2325 // setting the current scene ID
2326 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2328 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2330 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2332 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2333 if(__pWindowInfo == null)
2335 // if(__pWindowInfo == null)
2337 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2340 else if ( pArgs != null && pArgs->GetCount() == 1)
2342 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2348 // hiding the address bar
2349 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2350 __pAddressbar->SetShowState(false);
2351 if(__pWebViewer != null)
2353 __pWebViewer->Resume();
2356 if(pUrl != null && pUrl->GetLength() > 0)
2360 else if(__pWindowInfo != null)
2362 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)
2364 LoadUrl(__pWindowInfo->pageUrl);
2366 else if (__pWindowInfo->isJavascriptInitiated == true)
2370 __pWindowInfo->pCurrentWeb = __pWebViewer;
2374 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2375 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2376 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2378 InitMostVisitedSitesView(GetOrientationStatus());
2381 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2383 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2385 if (pBookmarkUrl == null)
2387 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2388 //__pAddressbar->SetUrl(*pBookmarkUrl);
2389 SetUrl(*pBookmarkUrl);
2391 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2392 __pWebViewer->LoadUrl(*pBookmarkUrl);
2393 delete pBookmarkUrl;
2396 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2397 Bitmap* pBitmap = null;
2398 if (isPrivateBrowsing == true)
2400 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2402 if (__pWebViewer != null)
2404 __pWebViewer->SetPrivateBrowsingEnabled(true);
2407 if (__pAddressbar != null)
2409 // __pAddressbar->UpdateFaviconBitmap(true);
2415 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2417 if (__pWebViewer != null)
2419 __pWebViewer->SetPrivateBrowsingEnabled(false);
2422 if (__pAddressbar != null)
2424 // __pAddressbar->UpdateFaviconBitmap(false);
2428 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2430 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2432 else if (__pMenu != null )
2434 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2437 if (pBitmap != null)
2442 AppLog("ABC: OnSceneActivatedN started exit");
2447 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2448 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2450 Canvas* pWebCanvas = null;
2451 if (__pWebViewer != null)
2453 pWebCanvas = __pWebViewer->GetCanvasN();
2454 __pWebViewer->Pause();
2457 if (pWebCanvas == null)
2461 if (__pWindowInfo != null)
2463 if (__pWindowInfo->pWebCanvasBitmap != null)
2465 delete __pWindowInfo->pWebCanvasBitmap;
2467 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2468 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2469 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2471 Bitmap* pBitmap = GetCapturedBitmapN();
2472 AppLog("Coming here");
2473 Canvas* pCanvas = new(std::nothrow) Canvas();
2474 pCanvas->Construct(GetClientAreaBounds());
2477 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2480 if(__pWebViewer != null && __pWindowInfo != null)
2481 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2483 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2484 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2486 AppLog("Coming here");
2490 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2491 const Tizen::Base::String& realm,
2492 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2498 MainForm::OnHttpAuthenticationCanceled(void)
2503 MainForm::OnLoadingStarted(void)
2505 AppLogDebug("MainForm::OnLoadingStarted entered");
2507 if(__pAddressbar == NULL || __pWebViewer == null)
2511 String url = __pWebViewer->GetUrl();
2512 if(url.Contains(IDS_TIZEN_SERVICE))
2515 String delim(L":;");
2517 // Creates a StringTokenizer instance
2518 StringTokenizer strTok(url, delim);
2520 int count = strTok.GetTokenCount(); // count == 4
2522 HashMap *pMap = new HashMap();
2527 while (strTok.HasMoreTokens())
2529 AppLog("Token: %ls", token.GetPointer());
2530 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2531 if(token.Contains(IDS_APPID))
2533 token.SubString(6, appId);
2534 AppLog("AppID:%ls", appId.GetPointer());
2536 else if(token.Contains("="))
2538 String *pKey = new String();
2539 String *pValue = new String();
2541 token.IndexOf("=", 0, index);
2544 token.SubString(0, index, *pKey);
2545 token.SubString(index + 1, *pValue);
2546 pMap->Add(pKey, pValue);
2552 AppControl *pAppControl = null;
2553 String operationId = L"http://tizen.org/appcontrol/operation/main";
2554 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2557 AppLog("Starting AppControl");
2558 result r = pAppControl->Start(null, null, pMap, null);
2559 AppLog("Result of Start %s", GetErrorMessage(r));
2563 AppLogException("AppControl not found");
2568 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2571 __pAddressbar->SetFaviconBitmap(*pBitmap);
2574 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2576 // updating the address bar position with respect to web control
2577 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2578 __distanceMoved = 0;
2582 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2583 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2584 if (__pWebViewer != null)
2586 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2587 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2588 SetUrl(__pWebViewer->GetUrl());
2589 if (__pWindowInfo != NULL)
2591 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2593 __pAddressbar->Invalidate(true);
2599 MainForm::OnLoadingCanceled(void)
2606 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2608 AppLog("MainForm::OnKeypadWillOpen");
2609 if (__pAddressbar != null)
2611 OnAddressBarKeypadWillOpen(*__pAddressbar);
2617 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2619 if(__pAddressbar != null)
2621 OnAddressBarKeypadOpened(*__pAddressbar);
2627 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2631 if (__pAddressbar != null)
2633 OnAddressBarKeypadClosed(*__pAddressbar);
2638 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2640 AppLog("KeypadBoundsChanged");
2641 RelayoutControls(false);
2645 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2646 const Tizen::Base::String& reason)
2648 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2652 MainForm::OnLoadingCompleted(void)
2654 AppLog("MainForm::OnLoadingCompleted start");
2656 result r = E_SUCCESS;
2658 if (__pWebViewer == null)
2663 if (__pAddressbar == null)
2667 if (__pWebViewer->CanGoForward())
2669 //__pAddressbar->SetForwardButtonEnabled(true);
2670 SetForwardButtonEnabled(true);
2674 //__pAddressbar->SetForwardButtonEnabled(false);
2675 SetForwardButtonEnabled(false);
2678 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2680 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2682 //__pAddressbar->UpdateProgress(0);
2686 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2688 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2692 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2693 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2694 if (isPrivateBrowsing == false)
2696 History* pHistory = new(std::nothrow) History;
2698 HistoryPresentationModel::GetCurrentDateTime(date);
2701 pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2702 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2704 pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2705 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2707 pHistory->SetVisitedTime(date);
2710 id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
2711 pHistory->SetFaviconId(id);*/
2713 if (__pWebViewer != null)
2715 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2717 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2718 if (pTempBitmap != null)
2720 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2721 pHistory->SetFavIconBitmap(*pTempBitmap);
2724 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2727 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2728 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2729 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2731 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2732 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2733 pHistory->SetThumbnail(pBitmap);
2735 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2738 pHistory->SetFavIconBitmap(*pFavIcon);
2742 HistoryPresentationModel::GetInstance()->SaveTempHistory(*pHistory);
2749 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2751 // temperary fixed (webpage can be not loaded)
2754 AppLog("MainForm::OnLoadingCompleted done");
2758 MainForm::OnEstimatedProgress(int progress)
2760 AppLogDebug("MainForm::OnEstimatedProgress entered");
2761 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2762 progress = DEFAULT_PROGRESS_PERCENTAGE;
2764 // __pAddressbar->UpdateProgress(progress);
2765 UpdateProgress(progress);
2768 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2770 AppLog("MainForm::OnFaviconReceived");
2771 Bitmap* pFavIconBitmap = __pWebViewer->GetFaviconN();
2773 if (pFavIconBitmap != null)
2775 pFavIconBitmap->GetWidth();
2776 pFavIconBitmap->GetHeight();
2781 MainForm::OnUrlValueChanged(Addressbar&)
2787 MainForm::OnUrlSubmitted(Addressbar& addBar)
2789 AppLog("MainForm::OnUrlSubmitted");
2790 String url = addBar.GetUrl();
2791 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2793 // __pFooterPanel->SetShowState(true);
2794 if(__pFooterUrlField)
2795 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2796 OnAddressCancelledClicked(*__pAddressbar);
2797 // __pAddressbar->SetShowState(false);
2798 // RelayoutControls(false);
2803 MainForm::LoadUrl(String& url)
2807 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2808 AppLogDebug("MainForm::LoadUrl enter");
2810 if (__pWebViewer != null)
2812 __pWebViewer->SetShowState(true);
2813 __pWebViewer->Invalidate(true);
2816 if (url.CompareTo(L"") == 0)
2820 if(__pFooterPanel != null)
2822 __pFooterPanel->SetShowState(true);
2823 __pFooterPanel->Invalidate(true);
2830 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2831 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)
2833 RegularExpression firstRegex;
2834 RegularExpression secondRegex;
2836 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2837 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2840 ret = firstRegex.Match(url, false); // This returns true value
2841 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2843 if (ret == true && __pWebViewer != null)
2846 __pWebViewer->LoadUrl(url);
2848 else if(__pWebViewer != null)
2850 String tempUrl = L"http://";
2851 tempUrl.Append(url);
2855 __pWebViewer->LoadUrl(tempUrl);
2859 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2860 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2863 if (__pAddressbar != null)
2865 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2866 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2869 AppLogDebug("MainForm::LoadUrl exit");
2876 MainForm::OnStopClicked(Addressbar& addBar)
2878 AppLogDebug("MainForm::OnStopClicked called");
2881 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2882 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2883 __pWebViewer->StopLoading();
2884 RequestRedraw(true);
2889 MainForm::OnReaderClicked(const Addressbar& addBar)
2891 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
2893 CreateReaderPanel();
2894 AppLogDebug("MainScene::OnReaderClicked entered");
2897 /*if (__pArticleReaderPanel)
2899 AppLogDebug("showstate true for reader panel");
2900 __pArticleReaderPanel->SetShowState(true);
2901 __pArticleReaderPanel->Show();
2903 int xPos = __pArticleReaderPanel->GetX();
2904 int yPos = __pArticleReaderPanel->GetY();
2905 AppLog("OnReaderClicked() xPos = %d",xPos);
2906 AppLog("OnReaderClicked() yPos = %d",yPos);
2908 if (__pReaderData == null)
2913 String loadData = L"<html>\
2915 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
2920 background-color: transparent;\
2939 <body style='width:'";
2940 loadData.Append(bodyWidth);
2941 loadData.Append(L"px'>");
2942 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
2943 loadData.Append(*__pReaderData);
2944 loadData.Append(L"</body></html>");
2947 buf.Construct(loadData.GetLength());
2948 AppLogDebug("data->GetLength %d",loadData.GetLength());
2949 for (int z=0;z<loadData.GetLength();z++)
2952 loadData.GetCharAt(z,b);
2953 buf.SetByte((byte)b);
2957 if (__pWebReader != null)
2959 __pWebReader->LoadData(L"",buf,L"text/html");
2960 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
2964 AppLogDebug("cannot LoadData __pWebReader is null");
2970 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2972 // AppLog("MainForm::OnBackClicked");
2973 result r = E_FAILURE;
2975 if (__pWebViewer && __pWebViewer->CanGoBack())
2977 __pWebViewer->GoBack();
2979 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2982 pApp = UiApp::GetInstance();
2985 r = pApp->Terminate();
2988 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2996 WindowInfo* pWindowInfo = null;
2998 SceneManager* pSceneManager = SceneManager::GetInstance();
2999 if (pSceneManager == null)
3003 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3004 if (pAllWindowList == NULL)
3006 pApp = UiApp::GetInstance();
3009 r = pApp->Terminate();
3012 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3017 if (pAllWindowList != null)
3019 totalCount = pAllWindowList->GetCount();
3021 for (int count = 0; count < totalCount; count++)
3023 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3024 if (pWindowInfo == null)
3026 pApp = UiApp::GetInstance();
3029 r = pApp->Terminate();
3032 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3037 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3039 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3042 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3045 r = pAllWindowList->RemoveAt(count, true);
3046 __pWindowInfo = null;
3049 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3054 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3058 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3060 if (pWindowInfo == null)
3062 pApp = UiApp::GetInstance();
3065 r = pApp->Terminate();
3071 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3074 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3088 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3090 AppLog("MainForm::OnForwardClicked");
3091 if (__pWebViewer == null)
3094 if (__pWebViewer->CanGoForward())
3096 __pWebViewer->GoForward();
3101 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3103 result r = E_SUCCESS;
3105 __pFooterPanel->SetShowState(true);
3106 __pFooterUrlField->SetFocusable(true);
3109 __pWebViewer->SetFocus();
3110 else if(__pMostVisitedListView)
3111 __pMostVisitedListView->SetFocus();
3112 else if(__pMultiWindowButton)
3113 __pMultiWindowButton->SetFocus();
3114 __pMoreButton->SetFocus();
3116 __pAddressbar->SetShowState(false);
3118 RelayoutControls(false);
3123 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3125 __prevAddressBarMode = __curAddressBarMode;
3127 if (__pAddressbar != null)
3129 __curAddressBarMode = GetAddressbarMode();
3132 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3134 __adressPanelPosition.y = 0;
3135 if (__pAddressbar != null)
3137 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3138 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3139 __pAddressbar->Invalidate(true);
3141 if (__pWebViewer != null)
3143 __pWebViewer->StopLoading();
3146 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3148 __adressPanelPosition.y = 0;
3149 if (__pAddressbar != null)
3151 __webControlPosition.y = 0;
3152 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3153 __pAddressbar->Invalidate(true);
3159 MainForm::OnClipboardClosed(const Addressbar& addBar)
3161 RelayoutControls(false);
3165 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3168 __pAddressbar->SetShowState(false);
3170 __pFooterPanel->SetShowState(true);
3172 // __pWebViewer->SetFocus();
3173 if(__pFooterUrlField)
3175 __pFooterUrlField->SetFocusable(true);
3177 RelayoutControls(false);
3181 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3183 if (__pFindWordControl && __pFindWordControl->GetShowState() == true)
3185 __pAddressbar->SetShowState(false);
3189 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3191 __pAddressbar->SetShowState(true);
3192 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3193 __pAddressbar->SetAddressbarURLFocus();
3197 RelayoutControls(false);
3201 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3203 __pFooterPanel->SetShowState(false);
3207 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3209 AppLog("KeypadBoundsChanged");
3210 RelayoutControls(false);
3214 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3218 __pWindowInfo->pageTitle = title;
3219 if (__pWebViewer != null)
3221 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3224 if (__pAddressbar != null && __pWebViewer != null)
3226 SetUrl(__pWebViewer->GetUrl());
3227 __pAddressbar->Invalidate(true);
3232 MainForm::UpdateFavicon(void)
3234 bool urlImageType = false;
3235 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();");
3236 Bitmap* pBitmap = null;
3238 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3240 if (__pWindowInfo != null)
3243 url.SetUri(*tempPath);
3244 if (url.GetHost().GetLength() == 0)
3247 webUrl.SetUri(__pWebViewer->GetUrl());
3248 result r = url.SetHost(webUrl.GetHost());
3255 if (url.GetScheme().GetLength() == 0)
3258 webUrl.SetUri(__pWebViewer->GetUrl());
3259 url.SetScheme(webUrl.GetScheme());
3261 __pWindowInfo->faviconUrl = url.ToString();
3263 pBitmap = __pWebViewer->GetFaviconN();
3265 if (pBitmap != null)
3267 if (__pWindowInfo->pFavicon != NULL)
3269 __pWindowInfo->pFavicon = null;
3271 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3272 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3274 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3276 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3278 else if(__pWindowInfo->pFavicon != null)
3280 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3284 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3285 if(pDefaultBmp != null)
3287 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3296 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3303 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3304 Tizen::Web::Controls::WebNavigationType type)
3306 // when load new page if find word panel is open its show state is false
3307 ShowFindWordPanel(false);
3309 __pFooterPanel->Invalidate(true);
3312 uriInfo.SetUri(url);
3314 if(url.Contains(IDS_TIZEN_SERVICE))
3317 String delim(L":;,");
3319 // Creates a StringTokenizer instance
3320 StringTokenizer strTok(url, delim);
3322 int count = strTok.GetTokenCount(); // count == 4
3324 HashMap *pMap = new HashMap();
3330 while (strTok.HasMoreTokens())
3332 AppLog("Token: %ls", token.GetPointer());
3333 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3334 if(token.Contains(IDS_APPID))
3336 token.SubString(6, appId);
3337 AppLog("AppID:%ls", appId.GetPointer());
3339 else if(token.Contains("="))
3341 String *pKey = new String();
3342 String *pValue = new String();
3344 token.IndexOf("=", 0, index);
3347 token.SubString(0, index, *pKey);
3348 token.SubString(index + 1, *pValue);
3349 pMap->Add(pKey, pValue);
3355 AppControl *pAppControl = null;
3356 String operationId = L"http://tizen.org/appcontrol/operation/main";
3357 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3360 result r = pAppControl->Start(null, null, pMap, null);
3364 AppLogException("AppControl not found");
3370 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
3372 __pAddressbar->SetShowState(false);
3373 OnAddressCancelledClicked(*__pAddressbar);
3374 __pAddressbar->Invalidate(true);
3380 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3381 const Tizen::Net::Http::HttpHeader& httpHeader)
3383 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3388 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3390 AppLog("MainForm::OnWebPageBlockSelected");
3391 if (__pHitElementResult != null)
3393 delete __pHitElementResult;
3394 __pHitElementResult = null;
3397 if (__pWebViewer != null)
3399 AppLog("MainForm::OnWebPageBlockSelected web not null");
3400 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3403 if (__pHitElementResult == null)
3408 if (__pHitElementResult->HasImage() != true)
3410 String tagName = __pHitElementResult->GetTagName();
3411 String type = __pHitElementResult->GetAttributeValue("type");
3413 __currentSelectedStr.Clear();
3414 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3415 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3416 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3418 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3420 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3422 InitSelectTextContextMenu(endPoint,true);
3423 __pImageMenu->SetShowState(true);
3424 __pImageMenu->Show();
3425 __pImageMenu->Invalidate(true);
3427 else if(__isLongPressedDone == true)
3429 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3431 if(__pHitElementResult->GetUrl().GetLength() > 0)
3433 __currentSelectedStr.Clear();
3434 __currentSelectedStr = __pHitElementResult->GetUrl();
3436 InitSelectTextContextMenu(endPoint,false);
3437 __pImageMenu->SetShowState(true);
3438 __pImageMenu->Show();
3439 __pImageMenu->Invalidate(true);
3442 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3443 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3444 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3450 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3456 MainForm::OnWebWindowCreateRequested(void)
3458 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3460 if (pNewWindowInfo == null)
3464 result r = E_SUCCESS;
3465 SceneManager* pSceneManager = SceneManager::GetInstance();
3466 if (pSceneManager == NULL)
3470 ArrayList* pArgList = new(std::nothrow) ArrayList();
3471 if (pArgList == NULL)
3475 r = pArgList->Construct();
3478 pNewWindowInfo->isJavascriptInitiated = true;
3479 pArgList->Add(*pNewWindowInfo);
3480 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3484 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3491 return pNewWindowInfo->pCurrentWeb;
3495 MainForm::RelayoutControls(bool showAddressbar)
3497 __webControlPosition.y = 0;
3498 __webControlHeight = GetClientAreaBounds().height;
3499 AppLog("Client area height: %d", __webControlHeight);
3501 AppLog("Client area height: %d", __webControlHeight);
3502 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3504 __webControlPosition.y += __pAddressbar->GetHeight();
3505 __webControlHeight -= __pAddressbar->GetHeight();
3506 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3508 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3510 __webControlPosition.y += __pFindWordControl->GetHeight();
3511 __webControlHeight -= __pFindWordControl->GetHeight();
3512 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3515 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true)
3517 __webControlHeight -= __pFooterPanel->GetHeight();
3518 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3520 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3522 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3523 __pWebViewer->Invalidate(false);
3525 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3527 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3534 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3536 if (__pFindWordControl == null)
3542 InitFindWordPanel();
3543 // __pFindWordEditField->SetText(__currentSearchStr);
3544 //__pFindWordCountLabel->SetText(L"");
3545 // __pFindWordCountLabel->SetText(L"0/0");
3546 __pFindWordControl->SetShowState(true);
3550 if(__pFindWordControl != null)
3552 __pFindWordControl->SetShowState(false);
3556 AppLog("MainForm::ShowFindWordPanel %d",show);
3557 if (show && !isTouchPressed)
3559 if (__pFindWordEditField)
3561 __pFindWordEditField->SetFocus();
3562 __pFindWordEditField->ShowKeypad();
3567 if (__pFindWordEditField)
3568 __pFindWordEditField->HideKeypad();
3571 RelayoutControls(false);
3575 MainForm::StartWordSearch()
3577 //Get the count of occurances of the word in the current page
3578 __maxOccurrances = 0;
3579 __currentWordIndex = 0;
3581 __pFindWordPrev->SetEnabled(false);
3582 String *pCountStr = null;
3583 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3584 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3585 if (pCountStr != null)
3587 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3591 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3596 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3598 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3599 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3601 if(totalCount == -1 || totalCount == 0)
3603 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3604 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3607 else if(totalCount > 100)
3609 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3610 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3614 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3615 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3618 __maxOccurrances = totalCount;
3619 __currentWordIndex = currentOrdinal;
3621 //Reset the UI controls as per the maxOccurrance value
3622 if (totalCount <= 0)
3624 AppLog("Word not found");
3625 //Show error notification to user
3626 __pFindWordNext->SetEnabled(false);
3627 __pFindWordCountLabel->SetText(L"0/0");
3628 __pFindWordNext->Invalidate(false);
3629 __pFindWordPrev->Invalidate(false);
3630 __pFindWordCountLabel->Invalidate(false);
3634 if (totalCount == 1)
3636 __pFindWordNext->SetEnabled(false);
3640 __pFindWordNext->SetEnabled(true);
3643 String countStr = L"";
3644 countStr.Append(__currentWordIndex);
3645 countStr.Append(L"/");
3646 countStr.Append(__maxOccurrances);
3647 __pFindWordCountLabel->SetText(countStr);
3648 // __pFindWordCountLabel->SetShowState(true);
3649 __pFindWordCountLabel->Invalidate(false);
3651 //FindNextWord(true);
3652 //Update the controls
3653 __pFindWordNext->Invalidate(false);
3654 __pFindWordPrev->Invalidate(false);
3655 __pFindWordCountLabel->Invalidate(false);
3659 MainForm::FindNextWord(bool next)
3663 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3665 if(__currentWordIndex < __maxOccurrances)
3667 __currentWordIndex++;
3673 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3675 if(__currentWordIndex > 1)
3677 __currentWordIndex--;
3682 String countStr = L"";
3683 countStr.Append(__currentWordIndex);
3684 countStr.Append(L"/");
3685 countStr.Append(__maxOccurrances);
3686 __pFindWordCountLabel->SetText(countStr);
3687 // __pFindWordCountLabel->SetShowState(true);
3688 __pFindWordCountLabel->Invalidate(false);
3689 if (__currentWordIndex >= __maxOccurrances)
3691 __pFindWordNext->SetEnabled(false);
3695 __pFindWordNext->SetEnabled(true);
3697 if (__currentWordIndex <= 1)
3699 __pFindWordPrev->SetEnabled(false);
3703 __pFindWordPrev->SetEnabled(true);
3705 __pFindWordPrev->Invalidate(false);
3706 __pFindWordNext->Invalidate(false);
3707 __pFindWordCountLabel->Invalidate(false);
3708 __pFindWordControl->Invalidate(true);
3711 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3713 AppLog("MainForm::OnWebKeypadWillOpen");
3714 __isWebKeypadOpened = true;
3715 // OnAddressBarKeypadOpened(*__pAddressbar);
3719 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3722 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3724 __currentSearchStr = L"";
3725 __currentWordIndex = 0;
3726 __maxOccurrances = 0;
3727 __pFindWordEditField->SetText(L"");
3728 __pFindWordNext->SetEnabled(false);
3729 __pFindWordPrev->SetEnabled(false);
3730 __pFindWordCountLabel->SetText(L"0/0");
3731 __pWebViewer->SearchTextAllAsync(L"",false);
3732 __pFindWordControl->SetShowState(false);
3733 __pFindWordEditField->HideKeypad();
3737 if (__pWebViewer != null && __pFooterPanel != null)
3739 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3740 if(__pAddressbar != null)
3742 __pAddressbar->SetShowState(false);
3744 if(__pFindWordControl != null)
3746 __pFindWordControl->SetShowState(false);
3748 __pFooterPanel->SetShowState(false);
3749 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3751 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3753 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3754 // AppLog("omgomgomg");
3760 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3762 __pFooterPanel->SetShowState(true);
3763 OnAddressBarKeypadClosed(*__pAddressbar);
3764 __isWebKeypadOpened = false;
3768 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3770 Control* temp = const_cast< Control* >(&source);
3771 Header* pHeader = dynamic_cast< Header* >(temp);
3772 if (pHeader != null)
3774 //Header double - clicked
3775 AppLog("Header double clicked");
3777 if(__pFindWordControl)
3779 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3780 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3784 AppLog("MainScene::OnTouchDoublePressed");
3785 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3786 if (isReaderEnabled == true)
3790 delete __pReaderData;
3791 __pReaderData = null;
3793 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3794 filePath.Append(L"data/reader.js");
3800 result r = E_SUCCESS;
3801 FileAttributes attr;
3803 File::GetAttributes(filePath,attr);
3805 r = file.Construct(filePath, L"r+");
3808 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3811 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3814 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3817 file.Read(pScript,attr.GetFileSize());
3819 AppLogDebug("scipt length %d",strlen(pScript));
3820 String strScript = L"";
3821 strScript.Append(pScript);
3822 __pReaderData = __pWebViewer->EvaluateJavascriptN(strScript);
3825 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3828 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3829 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3831 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3832 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3838 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3840 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3842 if (__pHitElementResult != null)
3844 delete __pHitElementResult;
3845 __pHitElementResult = null;
3848 if (__pWebViewer != null)
3850 AppLog("MainForm::OnTouchLongPressed web not null");
3851 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3854 if (__pHitElementResult == null)
3859 if (__pHitElementResult->HasImage() == true)
3861 InitImageContextMenu(currentPosition);
3862 __pImageMenu->SetShowState(true);
3863 __pImageMenu->Show();
3864 __pImageMenu->Invalidate(true);
3866 else if(__pHitElementResult->HasUrl() == true)
3868 String tempURl = __pHitElementResult->GetUrl();
3869 AppLog("tempURl is %ls", tempURl.GetPointer());
3870 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3871 if (pBitmap != null)
3879 InitImageLinkContextMenu(currentPosition);
3880 __pImageMenu->SetShowState(true);
3881 __pImageMenu->Show();
3882 __pImageMenu->Invalidate(true);
3886 String tagName = __pHitElementResult->GetTagName();
3887 String type = __pHitElementResult->GetAttributeValue("type");
3888 String value = __pHitElementResult->GetAttributeValue(L"value");
3889 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3891 __currentSelectedStr.Clear();
3892 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3894 AppLog("tag name is %ls", tagName.GetPointer());
3895 AppLog("type is %ls", type.GetPointer());
3896 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3898 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3900 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3902 InitSelectTextContextMenu(currentPosition,true, true);
3905 // __pImageMenu->SetShowState(true);
3906 // __pImageMenu->Show();
3907 // __pImageMenu->Invalidate(true);
3910 __isLongPressedDone = true;
3911 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3912 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3915 __inputEventToBeSupressed = true;
3919 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3921 AppLog("MainForm::OnTouchReleased");
3923 HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3924 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3926 __pWebViewer->ConsumeInputEvent();
3928 if(pHitElement != null)
3932 __inputEventToBeSupressed = false;
3936 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3943 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3945 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3947 __currentSearchStr = L"";
3948 __currentWordIndex = 0;
3949 __maxOccurrances = 0;
3950 __pFindWordEditField->SetText(L"");
3951 __pFindWordNext->SetEnabled(false);
3952 __pFindWordPrev->SetEnabled(false);
3953 __pFindWordCountLabel->SetText(L"0/0");
3954 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3955 __pFindWordControl->SetShowState(false);
3956 __pFindWordEditField->HideKeypad();
3958 if(__pAddressbar->GetShowState() == false)
3960 __pAddressbar->SetShowState(true);
3961 __pAddressbar->SetAddressbarURLFocus();
3962 __pFooterUrlField->SetFocusable(false);
3963 __pFooterPanel->SetShowState(false);
3970 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3976 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3982 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3988 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3994 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4000 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4002 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4003 int widthContextItem = 0;
4005 // As per the platform engineer comment removed this line
4006 /*if(__pWebViewer != null)
4008 // 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
4009 __pWebViewer->ReleaseBlock();
4012 if(__pFindWordControl != null)
4013 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4014 if ( __pFooterLabel != null)
4016 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4019 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4024 if (__pFindWordBgLabel != null)
4026 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4027 if (pBitmap != null)
4029 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4035 __pMenu->SetShowState(false);
4036 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4038 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4042 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4047 AppLog("__pFooterPanel->GetShowState() is true");
4049 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4050 __pFooterPanel->Invalidate(true);
4054 if(__pMoreButton && __pMenu)
4056 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4057 __pMenu->SetAnchorPosition(p);
4058 __pMenu->Invalidate(true);
4061 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4062 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4064 InitMostVisitedSitesView(orientationStatus);
4067 RelayoutControls(false);
4068 if (__pArticleReaderPanel != null)
4070 if (__pArticleReaderPanel->GetShowState() == true)
4072 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4074 if (__pBlankPanel != null)
4075 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4077 if (__pWebReader != null)
4079 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4081 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4082 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4084 if ( pBitmap != null && pSrcBitmap != null)
4086 AppLog("CreateReaderPanel ninepatchbitmap found");
4087 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4090 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4091 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4092 if (pBitmap != null)
4097 if (pSrcBitmap != null)
4106 if (__pAddressbar != null)
4108 int width = GetClientAreaBounds().width;
4109 __pAddressbar->OrientationChanged(width);
4114 MainForm::OnSettingsChange(int settingvalue)
4116 AppLogDebug("MainForm::OnSettingsChange entered");
4118 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4120 __pAddressbar->ResetGuideText();
4122 if (__pWebViewer == null)
4124 AppLogDebug("Webviewer is not initialized yet.");
4128 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4130 WebSetting settings = __pWebViewer->GetSetting();
4131 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4133 settings.SetAutoFittingEnabled(true);
4135 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4137 settings.SetAutoFittingEnabled(false);
4139 __pWebViewer->SetSetting(settings);
4141 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4143 WebSetting settings = __pWebViewer->GetSetting();
4144 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4145 __pWebViewer->SetSetting(settings);
4147 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4149 WebSetting settings = __pWebViewer->GetSetting();
4150 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4151 __pWebViewer->SetSetting(settings);
4153 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4155 WebSetting settings = __pWebViewer->GetSetting();
4156 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4157 __pWebViewer->SetSetting(settings);
4159 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4163 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4167 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4169 WebSetting settings = __pWebViewer->GetSetting();
4170 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4172 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4176 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4178 __pWebViewer->SetSetting(settings);
4180 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4184 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4185 WebSetting settings = __pWebReader->GetSetting();
4186 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4187 __pWebReader->SetSetting(settings);
4193 MainForm::OnSettingsReset()
4197 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4198 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4203 MainForm::OnClearCache()
4205 result r = E_SUCCESS;
4207 if (__pWebViewer != NULL)
4209 r = __pWebViewer->ClearCache();
4212 AppLogDebug("Cache cleared success");
4216 AppLogDebug("Cache cleared fail");
4222 MainForm::OnClearCookie()
4224 result r = E_SUCCESS;
4226 if (__pWebViewer != NULL)
4228 __pWebViewer->ClearCookie();
4232 AppLogDebug("Cookie cleared success");
4236 AppLogDebug("Cache cleared fail");
4241 MainForm::OnClearFormData()
4243 result r = E_SUCCESS;
4245 if (__pWebViewer != NULL)
4247 __pWebViewer->ClearFormData();
4251 AppLogDebug("Cookie cleared success");
4255 AppLogDebug("Cache cleared fail");
4260 MainForm::OnClearPasswords()
4262 result r = E_SUCCESS;
4264 if (__pWebViewer != NULL)
4266 __pWebViewer->ClearLoginFormData();
4270 AppLogDebug("Cookie cleared success");
4274 AppLogDebug("Cache cleared fail");
4280 MainForm::findDistance(int x1,int y1,int x2, int y2)
4282 int deltaX = Math::Abs(x2 - x1);
4283 int deltaY = Math::Abs(y2 - y1);
4284 double num = deltaX*deltaX + deltaY*deltaY;
4290 for (i = 0; i < 20; i++)
4292 x = (((x*x)+ num)/(2*x));
4303 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4305 if(__pFindWordControl)
4307 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4308 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4310 __isLongPressedDone = false;
4313 IList* pList = null;
4314 pList = touch.GetTouchInfoListN(source);
4318 int count = pList->GetCount();
4321 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4322 __touchPoint1 = pTouchInfo->position;
4324 /*if (__pAddressbar != null)
4326 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4328 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4330 __pAddressbar->SaveAddressbarEditText();
4332 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4335 __pAddressbar->Invalidate(true);
4337 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4339 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4341 //__pAddressbar->SaveAddressbarEditText();
4343 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4346 else if (count == 2)
4348 AppLogDebug("MainForm::OnTouchPressed count is two");
4349 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4350 __touchPoint1 = pTouchInfo->position;
4352 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4353 __touchPoint2 = pTouchInfo->position;
4359 pList->RemoveAll(true);
4366 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4368 // __currentWordIndex = 0;
4369 __isLongPressedDone = false;
4374 MainForm::MoveUiControls()
4379 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4381 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4383 if(__pFooterUrlField->GetTextLength() == 0)
4385 __pFooterUrlField->SetKeypadActionEnabled(false);
4389 __pFooterUrlField->SetKeypadActionEnabled(true);
4392 if (__pFindWordEditField != null)
4394 __currentSearchStr = __pFindWordEditField->GetText();
4395 __pFindWordNext->SetEnabled(false);
4396 __pFindWordPrev->SetEnabled(false);
4397 __pFindWordNext->Invalidate(true);
4398 __pFindWordPrev->Invalidate(true);
4399 __pFindWordCountLabel->SetText(L"0/0");
4400 __pFindWordCountLabel->Invalidate(true);
4402 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4403 if (__currentSearchStr.GetLength() > 0)
4409 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4411 __currentSearchStr = L"";
4412 AppLogDebug("Enter something");
4417 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4424 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4426 if(__pWebViewer != null)
4429 AppLog("MainForm::InitMostVisitedSitesView");
4430 result r = E_SUCCESS;
4433 if (__pWebViewer != null && __pMostVisitedListView != null)
4438 if (__pMostVisitedListView != null)
4440 RemoveControl(*__pMostVisitedListView);
4442 if(__pMostVisitedSites != null)
4444 __pMostVisitedSites->RemoveAll(true);
4447 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4449 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4450 __pMostVisitedListView = new(std::nothrow) ListView();
4452 int height = GetClientAreaBounds().height;
4454 if(__pFooterPanel->GetShowState() == true)
4456 height = height - __pFooterPanel->GetHeight();
4458 if(__pAddressbar->GetShowState() == true)
4460 height -= __pAddressbar->GetHeight();
4463 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4467 delete __pMostVisitedListView;
4468 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4471 __pMostVisitedListView->SetItemProvider(*this);
4472 __pMostVisitedListView->AddListViewItemEventListener(*this);
4473 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4474 AddControl(*__pMostVisitedListView);
4475 __pMostVisitedListView->UpdateList();
4482 MainForm::GetImagePath(void)
4486 String formattedTime;
4487 DateTime currentTime;
4488 LocaleManager localManager;
4489 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4491 localManager.Construct();
4492 Locale locale = localManager.GetSystemLocale();
4493 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4495 // Get date formatter
4496 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4500 pTimeFormatter->Format(currentTime, formattedTime);
4503 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4504 String delim(L" :");
4505 StringTokenizer strTok(formattedTime, delim);
4508 String str1("GMT+00");
4509 while (strTok.HasMoreTokens())
4511 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4512 if(token.Equals(str1))
4514 AppLog("token is %ls", token.GetPointer());
4515 imageName.Append(token);
4521 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4523 result r = E_FAILURE;
4524 AppLog("Content manager 1");
4525 ContentId contentId;
4526 ContentManager contentManager;
4527 r = contentManager.Construct();
4530 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4533 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4534 contentPath.Append(imageName);
4535 contentPath.Append(".jpg");
4536 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4537 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4541 MainForm::SetForwardButtonEnabled(bool isEnabled)
4543 __pGoForwardBtn->SetEnabled(isEnabled);
4544 __pGoForwardBtn->Invalidate(true);
4548 MainForm::SetBackButtonEnabled(bool isEnabled)
4550 __pGoBackBtn->SetEnabled(isEnabled);
4551 __pGoBackBtn->Invalidate(true);
4555 MainForm::UpdateProgress(int percentage)
4557 __progressPercentage = percentage;
4558 if (percentage == 0 || percentage == 100)
4560 __isLoadingData = false;
4561 if (percentage == 100)
4563 __isLoadingCompleted = true;
4564 __progressPercentage = 0;
4568 __isLoadingCompleted = false;
4573 __isLoadingData = true;
4575 UpdateProgressBitmap();
4579 MainForm::GetProgress(void)
4581 return __progressPercentage;
4585 MainForm::UpdateProgressBitmap(void)
4587 result r = E_SUCCESS;
4588 if (__pProgressbarLabel == null)
4590 int w = __pProgressbarLabel->GetWidth();
4591 int h = __pProgressbarLabel->GetHeight();
4593 int progressWidth = 0;
4594 Bitmap* pRetBitmap = null;
4596 if (__progressPercentage == 0 || __progressPercentage == 100)
4598 __pProgressbarLabel->SetShowState(false);
4599 __pProgressbarLabel->Invalidate(false);
4604 __pProgressbarLabel->SetShowState(true);
4605 __pProgressbarLabel->Invalidate(false);
4608 r = canvas.Construct(Rectangle(0, 0, w, h));
4612 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4617 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4621 pBgBmp->Scale(Dimension(w, h));
4622 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4626 progressWidth = (double) (w) * __progressPercentage / 100;
4627 AppLogDebug("progressWidth: %d", progressWidth);
4628 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4630 if (pProgressBmp != null)
4632 pProgressBmp->Scale(Dimension(progressWidth, h));
4633 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4634 delete pProgressBmp;
4637 pRetBitmap = new (std::nothrow) Bitmap();
4639 if (pRetBitmap == null)
4641 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4645 pRetBitmap->Construct(canvas, canvas.GetBounds());
4647 if (__pProgressbarLabel != null && pRetBitmap != null)
4649 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4650 __pProgressbarLabel->Invalidate(false);
4653 if (pRetBitmap != null)
4661 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4663 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4665 __currentAddMode = addMode;
4669 case ADDRESSBAR_MODE_INVALID:
4674 case ADDRESSBAR_MODE_READER:
4676 __pStopBtn->SetShowState(false);
4677 __pClearBtn->SetShowState(false);
4680 case ADDRESSBAR_MODE_LOADING:
4682 __pRefreshBtn->SetShowState(false);
4683 __pStopBtn->SetShowState(true);
4684 __pClearBtn->SetShowState(false);
4687 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4689 // SetUrl(__pAddressbar->GetUrl());
4691 __pRefreshBtn->SetShowState(true);
4692 __pStopBtn->SetShowState(false);
4693 __pClearBtn->SetShowState(false);
4696 case ADDRESSBAR_MODE_EDIT:
4698 __pRefreshBtn->SetShowState(false);
4699 __pStopBtn->SetShowState(false);
4700 __pClearBtn->SetShowState(true);
4707 OnAddressBarModeChanged();
4710 AddressBarMode MainForm::GetAddressbarMode(void)
4712 return __currentAddMode;
4715 void MainForm::SetUrl(const String& url)
4719 if (__pFooterUrlField != NULL)
4721 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4722 if (removedHttpUrl.IsEmpty() == false)
4724 __pFooterUrlField->SetText(removedHttpUrl);
4725 if(__pAddressbar != NULL)
4726 __pAddressbar->SetUrl(__displayUrl);
4730 __pFooterUrlField->SetText(__displayUrl);
4731 if(__pAddressbar != NULL)
4732 __pAddressbar->SetUrl(__displayUrl);
4734 if(__pFooterUrlField)
4735 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4736 __pFooterUrlField->Invalidate(false);
4737 if(__pAddressbar != NULL)
4738 __pAddressbar->Invalidate(true);
4739 // __pFooterUrlField->SetCursorPosition(0);
4744 MainForm::RemoveHttpTextFromDisplayURL(void)
4746 bool isHttpText = __displayUrl.Contains(L"http://");
4747 String updatedDisplayUrl;
4748 updatedDisplayUrl.Clear();
4750 if (isHttpText == true)
4752 __displayUrl.SubString(7,updatedDisplayUrl);
4754 return updatedDisplayUrl;
4757 void MainForm::OnSharePopupControlStarted(void)
4759 __pWebViewer->AddTouchEventListener(*this);
4762 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4764 if (requestId == BACK_GROUND_APP_EVENT)
4766 if(__pWebViewer != null)
4768 __pWebViewer->Pause();