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;
119 const int IDA_READER_BTN_CLICKED = 219;
122 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
123 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
124 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
125 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
127 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
129 const int MainForm::IDA_FORMAT_BITMAP = 500;
130 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
131 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
132 const int MainForm::IDA_FORMAT_URL_STRING = 503;
133 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
135 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
136 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
137 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
139 MainForm::MainForm(void)
141 __isLongPressedDone = false;
143 __pAddressbar = null;
144 // __pMostVisitedSitesPanel = null;
145 __pMostVisitedListView = null;
146 __pFooterPanel = null;
147 __pHitElementResult = null;
148 __pWindowInfo = null;
152 __pFindWordControl = null;
154 __pFindWordBgLabel = null;
155 __pFindWordEditField = null;
156 __pFindWordClear = null;
157 __pFindWordCountLabel = null;
158 __pFindWordNext = null;
159 __pFindWordPrev = null;
160 __previousZoomLevel = 1.0;
162 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
165 __currentSearchStr = L"";
166 __currentSelectedStr = L"";
167 __maxOccurrances = 0;
168 __currentWordIndex = 0;
171 //__inputEventToBeSupressed = false;
172 __isLoadingData = false;
173 __isLoadingCompleted = false;
174 __progressPercentage = 0;
175 __touchPoint1 = Point(-1,-1);
176 __touchPoint2 = Point(-1,-1);
178 // __pReaderPopup = null;
179 __pReaderData = null;
181 __pReaderCloseBtn = null;
182 //__pNewWindowButton = null;
183 __pMoreButton = null;
184 __pMultiWindowButton = null;
185 __pArticleReaderPanel = null;
186 __pBlankPanel = null;
187 __pArticleReaderLabel = null;
188 __webControlHeight = 0;
189 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
190 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
191 __pMostVisitedSites = null;
192 __pFooterUrlField = null;
194 __pGoForwardBtn = null;
195 __pRefreshBtn = null;
196 __pProgressbarLabel = null;
197 __pFooterLabel = null;
201 __isWebKeypadOpened = false;
204 MainForm::~MainForm(void)
206 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
210 __pAddressbar->SetAddressbarEventListener(null);
213 if(__pHistory != null)
219 if (__pReaderData != null)
221 delete __pReaderData;
222 __pReaderData = null;
225 if (__pPopUp != null)
231 if (__pHitElementResult != null)
233 delete __pHitElementResult;
234 __pHitElementResult = null;
237 String* pSelectedScene = NULL;
238 Object* pValue = NULL;
239 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
240 pSelectedScene = (String*) pValue;
242 /*if (pSelectedScene != null)
244 delete pSelectedScene;
246 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
250 MainForm::Initialize(void)
252 Construct(L"IDL_FORM");
257 MainForm::OnInitializing(void)
259 AppLog("get client area width = %d",GetClientAreaBounds().width);
260 AppLog("get client area height = %d",GetClientAreaBounds().height);
261 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
262 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
264 Panel* pFooterPanel = null;
266 __pSaveImage = new Image();
267 __pSaveImage->Construct();
269 // Setup back event listener
270 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
271 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
272 AddOrientationEventListener(*this);
273 AppLogDebug(" MainForm::OnInitializing ended");
274 if (__pMostVisitedSites == null)
276 __pMostVisitedSites = new(std::nothrow) ArrayList();
277 __pMostVisitedSites->Construct();
279 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
281 __pItemContext= new(std::nothrow) ListContextItem();
282 __pItemContext->Construct();
283 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
284 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
286 if (pBitmapNormal != null && pBitmapPressed != null)
288 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
291 if (pBitmapNormal != null)
293 delete pBitmapNormal;
296 if (pBitmapPressed != null)
298 delete pBitmapPressed;
301 __pItemContextLandscape= new(std::nothrow) ListContextItem();
302 __pItemContextLandscape->Construct();
303 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
304 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
306 if (pBitmapNormal != null && pBitmapPressed != null)
308 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
311 if (pBitmapNormal != null)
313 delete pBitmapNormal;
316 if (pBitmapPressed != null)
318 delete pBitmapPressed;
325 MainForm::InitAddressbar(void)
327 AppLogDebug("MainForm::InitAddressbar entered");
329 result r = E_SUCCESS;
331 if (__pAddressbar != null)
335 __pAddressbar = new(std::nothrow) Addressbar();
336 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
337 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
340 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
343 __pAddressbar->SetAddressbarEventListener(this);
344 AddControl(__pAddressbar);
345 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
346 SetControlAlwaysOnTop(*__pAddressbar, true);
347 __adressPanelPosition = __pAddressbar->GetPosition();
349 AppLogDebug("MainForm::InitAddressbar exit");
355 MainForm::CreateReaderPanel(void)
357 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
358 result r = E_FAILURE;
360 Button *pSmallFontBtn = null;
361 Button *pLargeFontBtn = null;
363 __pBlankPanel = new (std::nothrow) Panel();
364 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
366 __pArticleReaderPanel = new (std::nothrow) Panel();
367 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
369 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
370 if (__pReaderCloseBtn)
372 AppLogDebug("CreateReaderPanel() 6");
373 __pReaderCloseBtn->AddActionEventListener(*this);
374 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
377 __pWebReader = new (std::nothrow) Web();
378 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
380 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
381 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
383 r = __pWebReader->SetSetting(settings);
385 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
388 __pArticleReaderLabel = new Label();
389 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
391 __pBlankPanel->AddControl(__pArticleReaderLabel);
392 __pBlankPanel->AddControl(__pArticleReaderPanel);
393 AddControl(__pBlankPanel);
395 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
396 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
397 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
399 __pArticleReaderPanel->AddControl(__pWebReader);
400 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
401 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
402 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
404 if (pBitmap != null && pSrcBitmap != null)
406 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
408 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
410 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
413 pSmallFontBtn->AddActionEventListener(*this);
414 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
417 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
420 pLargeFontBtn->AddActionEventListener(*this);
421 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
430 if (pSrcBitmap != null)
436 SetControlAlwaysOnTop(*__pBlankPanel, true);
437 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
444 MainForm::InitWebControl()
446 AppLogDebug("MainForm::InitWebControl enter");
447 result r = E_SUCCESS;
448 AppLogDebug("InitWebControl");
450 if (__pAddressbar == null || __pFooterPanel == null)
453 const int Y_WEBCONTROL_POSITION = 0;
454 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
455 if (__pMostVisitedListView)
457 __pMostVisitedListView->SetShowState(false);
459 if (__pWebViewer != null)
461 AppLogDebug("Already initialized");
464 __pWebViewer = new(std::nothrow) Web();
465 if(__pWebViewer == NULL)
467 AppLogDebug("Initialization failed");
470 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
474 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
481 r = AddControl(__pWebViewer);
487 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
490 __webControlPosition = __pWebViewer->GetPosition();
491 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
494 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
498 __pWebViewer->SetLoadingListener(this);
499 __pWebViewer->SetWebUiEventListener(this);
500 __pWebViewer->SetWebKeypadEventListener(this);
501 __pWebViewer->SetFocus();
502 __pWebViewer->AddTouchEventListener(*this);
504 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
505 __pWebViewer->SetTextSearchListener(this);
508 AppLogDebug("MainForm :before return");
510 AppLogDebug("MainForm::InitWebControl Exit");
516 MainForm::OnFocusGained(const Control& source)
518 AppLog("MainForm::OnFocusGained");
522 MainForm::OnFocusLost(const Control& source)
524 AppLog("MainForm::OnFocusLost");
528 MainForm::SetJavascriptEnabled()
530 WebSetting settings = __pWebViewer->GetSetting();
531 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
532 __pWebViewer->SetSetting(settings);
536 MainForm::SetImageLoadEnabled()
538 WebSetting settings = __pWebViewer->GetSetting();
539 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
540 __pWebViewer->SetSetting(settings);
544 MainForm::InitFooter(void)
546 AppLogDebug("MainForm::InitFooter entered");
547 Button* pBackButton = null;
548 Button* pBookmarkButton = null;
549 Button* pMultiWindowButton = null;
550 Bitmap *pIconBitmap = null;
551 Bitmap *pBGBitmap = null;
552 Label *pBGLabel = null;
554 if (__pFooterPanel == null)
556 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
559 if (__pFooterPanel == null)
564 SetControlAlwaysOnTop(*__pFooterPanel, true);
566 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
567 if ( __pFooterLabel == NULL )
571 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
572 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
575 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
579 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
581 if ( __pMultiWindowButton == NULL )
586 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
588 if ( __pMoreButton == NULL )
593 if (__pMultiWindowButton != null)
595 Bitmap* pBitmap = null;
596 Bitmap* pPressedBitmap = null;
597 String imagePath = "I01_toolbar_icon_windows_manager_0";
598 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
599 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
600 imagePath.Append(totalCount);
601 imagePath.Append(".png");
603 pressedImagePath.Append(totalCount);
604 pressedImagePath.Append("_press.png");
606 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
607 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
608 if ( pBitmap == null )
613 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
616 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
617 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
622 __pMultiWindowButton->AddActionEventListener(*this);
623 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
628 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
629 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
632 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
633 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
634 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
638 __pMoreButton->AddActionEventListener(*this);
639 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
642 //Add the editfield for url
643 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
644 if (__pFooterUrlField == NULL)
646 return E_INVALID_KEY;
649 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
650 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
651 __pFooterUrlField->AddKeypadEventListener(*this);
652 __pFooterUrlField->SetPropagatedTouchEventListener(this);
654 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
656 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
658 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
660 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
664 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
665 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
669 //Add the go Back Button
670 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
671 if (__pGoBackBtn == NULL)
673 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
674 return E_INVALID_KEY;
676 __pGoBackBtn->SetActionId(IDA_GO_BACK);
677 __pGoBackBtn->AddActionEventListener(*this);
679 //Add the go forward Button
680 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
681 if (__pGoForwardBtn == NULL)
683 AppLogDebug("Control not found returning E_INVALID_KEY");
684 return E_INVALID_KEY;
686 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
687 __pGoForwardBtn->AddActionEventListener(*this);
688 if (__pWebViewer && __pWebViewer->CanGoForward())
690 SetForwardButtonEnabled(true);
694 SetForwardButtonEnabled(false);
697 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
698 if (__pRefreshBtn == NULL)
700 AppLogDebug("Control not found returning E_INVALID_KEY");
701 return E_INVALID_KEY;
704 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
705 __pRefreshBtn->AddActionEventListener(*this);
706 __pRefreshBtn->SetShowState(true);
708 //Add the backround label for displaying progressbar
709 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
710 if (__pProgressbarLabel == NULL)
712 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
713 return E_INVALID_KEY;
715 __pProgressbarLabel->SetShowState(false);
717 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
718 if (__pStopBtn == NULL)
720 AppLogDebug("Control not found returning E_INVALID_KEY");
721 return E_INVALID_KEY;
723 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
724 __pStopBtn->AddActionEventListener(*this);
725 __pStopBtn->SetShowState(false);
727 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
728 if (__pClearBtn == NULL)
730 AppLogDebug("Control not found returning E_INVALID_KEY");
731 return E_INVALID_KEY;
733 __pClearBtn->SetActionId(IDA_CLEAR_URL);
734 __pClearBtn->AddActionEventListener(*this);
735 __pClearBtn->SetShowState(false);
737 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
738 if (__pReaderBtn == NULL)
740 AppLogDebug("Control not found returning E_INVALID_KEY");
741 return E_INVALID_KEY;
743 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
744 __pReaderBtn->AddActionEventListener(*this);
745 __pReaderBtn->SetShowState(false);
747 // __pFooterPanel->Invalidate(true);
748 AppLogDebug("MainForm::InitFooter exit");
754 MainForm::InitContextMenu(Point& p)
756 result r = E_SUCCESS;
757 bool isPrivateBrowsing = false;
758 Bitmap* pBitmap = null;
762 __pMenu->SetAnchorPosition(p);
763 __pMenu->Invalidate(true);
767 __pMenu = new(std::nothrow) ContextMenu();
768 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
769 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
771 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
774 if (isPrivateBrowsing == true)
776 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
780 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
783 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
785 if ( pBitmap != NULL)
787 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"), IDA_PRIVATEON_CLICKED,*pBitmap);
790 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
791 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
792 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
795 __pMenu->SetMaxVisibleItemsCount(6);
796 __pMenu->SetShowState(false);
797 __pMenu->AddActionEventListener(*this);
798 SetControlAlwaysOnTop(*__pMenu, true);
804 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
806 result r = E_SUCCESS;
807 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
809 AppLog("MainForm::InitImageContextMenu clicked on image");
810 if (__pImageMenu != null)
816 __pImageMenu = new (std::nothrow) ContextMenu();
817 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
818 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
820 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
821 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
822 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
823 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB"),IDA_SHARE_IMAGE_CLICKED);
824 __pImageMenu->SetMaxVisibleItemsCount(4);
825 __pImageMenu->AddActionEventListener(*this);
826 SetControlAlwaysOnTop(*__pImageMenu, true);
832 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
834 result r = E_SUCCESS;
835 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
837 AppLog("MainForm::InitImageContextMenu clicked on image");
838 if (__pImageMenu != null)
844 if(__pAddressbar->GetShowState() == true)
845 p.y = p.y + __pAddressbar->GetHeight();
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;
870 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
871 if (__pImageMenu != null)
880 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
884 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
886 __pImageMenu = new (std::nothrow) ContextMenu();
887 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
888 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
890 if(onlyPasteOption == false)
892 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
894 if (pasteOption || onlyPasteOption)
896 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
898 if(onlyPasteOption == false)
900 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
901 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
904 __pImageMenu->SetMaxVisibleItemsCount(3);
905 __pImageMenu->AddActionEventListener(*this);
906 SetControlAlwaysOnTop(*__pImageMenu, true);
913 MainForm::InitFindWordPanel(void)
915 result r = E_SUCCESS;
916 Bitmap *pIconBitmap = null;
918 if (__pFindWordControl != null)
920 AppLogDebug("Findword panel already initialized");
921 if (__pFindWordBgLabel != null)
923 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
926 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
933 __pFindWordControl = new (std::nothrow) Panel();
934 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
937 AppLogException("There is some problem in the xml file. Please check.");
940 AddControl(__pFindWordControl);
941 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
942 SetControlAlwaysOnTop(*__pFindWordControl,true);
943 __pFindWordControl->SetShowState(false);
944 __pFindWordControl->Invalidate(false);
946 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
947 if (__pFindWordBgLabel != null)
949 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
950 Rectangle pRect = pPanel1->GetBounds();
951 pRect.x = pRect.y = 0;
952 __pFindWordBgLabel->SetBounds(pRect);
953 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
956 AppLogDebug("InitFindWordPanel: Coming here");
957 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
962 AppLogDebug("InitFindWordPanel: shouldn't Come here");
966 Button* pfindWordCancel = null;
967 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
968 if (pfindWordCancel == null)
970 AppLogException("There is some problem in the xml file. Please check.");
973 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
974 pfindWordCancel->AddActionEventListener(*this);
976 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
977 if (__pFindWordClear == null)
979 AppLogException("There is some problem in the xml file. Please check.");
983 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
984 __pFindWordClear->AddActionEventListener(*this);
986 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
987 if (__pFindWordNext == null)
989 AppLogException("There is some problem in the xml file. Please check.");
993 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
994 __pFindWordNext->AddActionEventListener(*this);
996 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
997 if (__pFindWordPrev == null)
999 AppLogException("There is some problem in the xml file. Please check.");
1003 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1004 __pFindWordPrev->AddActionEventListener(*this);
1006 __pFindWordNext->SetEnabled(false);
1007 __pFindWordPrev->SetEnabled(false);
1009 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1010 if (__pFindWordCountLabel == null)
1012 AppLogException("There is some problem in the xml file. Please check.");
1016 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1017 if (__pFindWordEditField == null)
1019 AppLogException("There is some problem in the xml file. Please check.");
1022 __pFindWordEditField->AddTextEventListener(*this);
1023 __pFindWordEditField->AddKeypadEventListener(*this);
1024 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1030 MainForm::CreateItem (int index, int itemWidth)
1032 Rectangle listImageRect;
1033 Rectangle pagetTitleRect;
1034 Rectangle pageURLRect;
1035 Rectangle deleteImageRect;
1036 String pageTitle(L"");
1037 String pageURL(L"");
1038 result r = E_SUCCESS;
1039 Bitmap* pListIconImage = null;
1042 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1043 if(pHistory == null)
1047 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1048 if ( pAppResource == NULL )
1052 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1054 CustomItem* pItem = new(std::nothrow) CustomItem();
1055 pageTitle = pHistory->GetHistoryTitle();
1056 pageURL = pHistory->GetHistoryUrl();
1058 if (pageURL.GetLength() == 0)
1061 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1062 pageURL = L"<"+ nourl +">";
1066 Rectangle screenBounds = GetBounds();
1069 r = pItem->Construct(Dimension(itemWidth, 128), style);
1078 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1080 if ( pBitmap != NULL)
1082 pListIconImage = new Bitmap();
1083 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1087 if(pListIconImage == null)
1089 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1092 if ( pListIconImage != NULL)
1094 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28,72, 72);
1095 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60);
1096 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1099 if (pItem != null && pListIconImage != NULL)
1101 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1105 if (pageTitle.CompareTo(L"") != 0)
1109 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, 44, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1113 if (pageURL.CompareTo(L"") != 0)
1117 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1122 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1124 if ( __pItemContext!= NULL)
1128 pItem->SetContextItem(__pItemContext);
1134 if ( __pItemContextLandscape!= NULL)
1138 pItem->SetContextItem(__pItemContextLandscape);
1142 if( pListIconImage != NULL)
1144 delete pListIconImage;
1145 pListIconImage = null;
1152 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1159 MainForm::GetItemCount (void)
1161 if(__pMostVisitedSites != null)
1163 __pMostVisitedSites->RemoveAll(true);
1165 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1166 if(__pMostVisitedSites != null)
1168 return __pMostVisitedSites->GetCount();
1175 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1177 if(__pMostVisitedSites != null)
1179 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1180 if (pHistory != null)
1182 String url = pHistory->GetHistoryUrl();
1184 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1185 __pMostVisitedListView->UpdateList();
1191 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1193 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1194 String url = pHistory->GetHistoryUrl();
1202 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1208 MainForm::OnTerminating(void)
1210 result r = E_SUCCESS;
1213 delete __pItemContext;
1215 if(__pItemContextLandscape)
1217 delete __pItemContextLandscape;
1223 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1225 result r = E_SUCCESS;
1227 AppLogDebug("Clicked : %d", actionId);
1230 case IDA_BACKBTN_CLICKED:
1232 if (__pWebViewer && __pWebViewer->CanGoBack())
1234 __pWebViewer->GoBack();
1236 else if(__pWindowInfo->isJavascriptInitiated == false)
1239 pApp = UiApp::GetInstance();
1242 r = pApp->Terminate();
1245 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1253 WindowInfo* pWindowInfo = null;
1255 SceneManager* pSceneManager = SceneManager::GetInstance();
1256 if (pSceneManager == null)
1260 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1261 if (pAllWindowList == NULL)
1263 pApp = UiApp::GetInstance();
1266 r = pApp->Terminate();
1269 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1274 if (pAllWindowList != null)
1276 totalCount = pAllWindowList->GetCount();
1278 for (int count = 0; count < totalCount; count++)
1280 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1281 if (pWindowInfo == null)
1283 pApp = UiApp::GetInstance();
1286 r = pApp->Terminate();
1289 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1296 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1298 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1301 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1304 r = pAllWindowList->RemoveAt(count, true);
1305 __pWindowInfo = null;
1308 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1313 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1317 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1319 if (pWindowInfo == null)
1321 pApp = UiApp::GetInstance();
1324 r = pApp->Terminate();
1330 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1333 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1345 case IDA_FORWARD_CLICKED:
1346 if (__pWebViewer == null)
1349 if (__pWebViewer->CanGoForward())
1351 __pWebViewer->GoForward();
1353 __pMenu->SetShowState(false);
1354 __pMenu->Invalidate(false);
1357 case IDA_FINDONPAGE_CLICKED:
1359 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1360 __currentSearchStr.Clear();
1362 InitFindWordPanel();
1363 __pMenu->SetShowState(false);
1364 __pMenu->Invalidate(false);
1366 __pFindWordEditField->SetFocus();
1367 ShowFindWordPanel(true);
1370 case IDA_PRIVATEON_CLICKED:
1372 result r = E_SUCCESS;
1374 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1375 Bitmap* pBitmap = null;
1376 if (isPrivateBrowsing == true)
1378 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1381 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1385 if (__pWebViewer != NULL)
1387 __pWebViewer->SetPrivateBrowsingEnabled(false);
1390 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1392 if (__pAddressbar != null)
1394 __pAddressbar->UpdateFaviconBitmap(false);
1400 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1403 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1407 if (__pWebViewer != NULL)
1409 __pWebViewer->SetPrivateBrowsingEnabled(true);
1412 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1414 if (__pAddressbar != null)
1416 __pAddressbar->UpdateFaviconBitmap(true);
1421 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1422 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
1423 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1424 __pMenu->Invalidate(true);
1426 if ( pBitmap != NULL )
1433 case IDA_SETTINGS_CLICKED:
1436 ArrayList* pArgList = new(std::nothrow) ArrayList();
1439 pArgList->Construct();
1440 pArgList->Add(*__pWindowInfo);
1441 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1443 __pMenu->SetShowState(false);
1444 __pMenu->Invalidate(false);
1445 if (pArgList != null)
1454 case IDA_ADDTOBOOKMARK_CLICKED:
1457 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1459 int bookmarkCount=0;
1462 url=__pWindowInfo->pageUrl;
1463 result r = E_SUCCESS;
1464 Bitmap* pBitmap = null;
1465 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1473 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1474 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1475 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1477 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1478 if (pNotification != null)
1480 pNotification->SetText(message);
1481 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1482 pNotification->ShowNotification();
1487 String title=__pWindowInfo->pageTitle;
1488 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1489 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1491 pBookmark->SetBookmarkTitle(title);
1492 pBookmark->SetUrl(url);
1493 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1495 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1497 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1498 pBookmark->SetFaviconId(id);
1499 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1500 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1503 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1504 if (pNotification != null)
1506 pNotification->SetText(message);
1507 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1508 pNotification->ShowNotification();
1509 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1512 if (pBitmap != null)
1514 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1518 __pMenu->Invalidate(true);
1522 case IDA_PRINT_CLICKED:
1524 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1525 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1527 AppLog("RequestPrint called!");
1528 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1529 result nResult = E_FAILURE;
1532 AppLog("TestPrint if (pAc) == true");
1537 String fileType = L"service_print_files_type";
1538 String typeVal = L"DOC";
1540 String fileCount = L"service_print_files_count";
1541 String countVal = L"1";
1542 String fileFolder= L"service_print_files_folder_name";
1543 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1545 map.Add(&fileCount, &countVal);
1546 map.Add(&fileFolder, &folderVal);
1547 map.Add(&fileType, &typeVal);
1549 String fileName = L"service_print_files_files_name";
1551 ArrayList fileNameList;
1552 fileNameList.Construct();
1553 String file1 = L"test.pdf";
1555 fileNameList.Add(&file1);
1556 map.Add(&fileName, &fileNameList);
1558 nResult = pAc->Start(NULL, NULL, &map, NULL);
1560 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1561 else if (nResult == E_MAX_EXCEEDED)
1562 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1563 else if (nResult == E_OBJ_NOT_FOUND)
1564 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1565 else if (nResult == E_IN_PROGRESS)
1566 AppLog("TestPrint ret == E_IN_PROGRESS");
1567 else if (nResult == E_PRIVILEGE_DENIED)
1568 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1569 else if(nResult == E_SYSTEM)
1570 AppLog("TestPrint ret == E_SYSTEM");
1576 int __modalMsgBoxResult;
1577 MessageBox* pMsgBox = new MessageBox();
1578 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1579 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1582 __modalMsgBoxResult = 0;
1586 case IDA_SHARE_CLICKED:
1588 if(__pPopUp != null)
1593 __pPopUp = new(std::nothrow) SharePopup();
1594 __pPopUp->Initialize();
1595 if (__pWindowInfo != null)
1597 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1598 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1599 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1600 pShareInfo->SetImageAttached(false);
1601 __pPopUp->RemoveAllShareInfo();
1602 __pPopUp->AddShareInfo(pShareInfo);
1604 __pPopUp->SetShowState(true);
1608 case IDA_BOOKMARKBTN_CLICKED:
1610 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1611 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1614 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1619 case IDA_MOREBTN_CLICKED:
1621 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1622 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1623 AppLog("Anchot pos: %d %d", p.x, p.y);
1625 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1627 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1628 int bookmarkCount=0;
1631 url=__pWindowInfo->pageUrl;
1632 result r = E_SUCCESS;
1633 Bitmap* pBitmap = null;
1635 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1638 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1643 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1647 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1649 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1651 if (__pMenu->GetItemCount() == 9)
1653 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1657 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1662 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1666 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1667 if (__pMenu->GetItemCount() != 9)
1669 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1670 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_COM_SK_PRINT"), IDA_PRINT_CLICKED);
1671 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1672 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1673 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1674 __pMenu->SetMaxVisibleItemsCount(6);
1676 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1678 AppLog(" Orientation landscape");
1679 __pMenu->SetMaxVisibleItemsCount(5);
1683 AppLog(" Orientation potrait");
1684 __pMenu->SetMaxVisibleItemsCount(6);
1687 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1690 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1691 __pMenu->SetShowState(true);
1692 __pMenu->Invalidate(true);
1696 case IDA_HISTORY_CLICKED:
1698 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1699 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1702 case IDA_SAVED_PAGES_CLICKED:
1707 case IDA_DESKTOP_VIEW_CLICKED:
1712 case IDA_SAVE_CLICKED:
1717 case IDA_MULTIWINDOWBTN_CLICKED:
1719 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1720 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1724 case IDA_NEWWINDOWBTN_CLICKED:
1726 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
1728 if (pNewWindowInfo == null)
1732 result r = E_SUCCESS;
1733 SceneManager* pSceneManager = SceneManager::GetInstance();
1735 if (pSceneManager == NULL)
1739 ArrayList* pArgList = new(std::nothrow) ArrayList();
1740 if (pArgList == NULL)
1744 r = pArgList->Construct();
1747 pArgList->Add(*pNewWindowInfo);
1748 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1754 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1759 case IDA_SMALLFONT_BTN_CLICKED:
1761 WebSetting setting = __pWebReader->GetSetting();
1762 setting.SetFontSize(15);
1763 __pWebReader->SetSetting(setting);
1766 case IDA_LARGEFONT_BTN_CLICKED:
1768 WebSetting setting = __pWebReader->GetSetting();
1769 setting.SetFontSize(25);
1770 __pWebReader->SetSetting(setting);
1773 case IDA_READER_CLOSE_CLICKED:
1775 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1777 RemoveControl(__pBlankPanel);
1778 __pArticleReaderPanel = null;
1779 __pBlankPanel = null;
1780 __pArticleReaderLabel = null;
1782 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1785 case IDA_FINDWORD_CANCEL_CLICKED:
1787 __currentSearchStr = L"";
1788 __currentWordIndex = 0;
1789 __maxOccurrances = 0;
1790 __pFindWordEditField->SetText(L"");
1791 __pFindWordNext->SetEnabled(false);
1792 __pFindWordPrev->SetEnabled(false);
1793 __pFindWordCountLabel->SetText(L"0/0");
1794 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1795 AppLog("akjshdasd 1");
1796 __pFooterPanel->SetShowState(true);
1797 ShowFindWordPanel(false);
1800 case IDA_FINDWORD_SEARCH_CLICKED:
1802 __currentSearchStr = __pFindWordEditField->GetText();
1803 if (__currentSearchStr.GetLength() > 0)
1809 AppLogDebug("Enter something");
1813 case IDA_FINDWORD_CLEAR_CLICKED:
1815 __pFindWordCountLabel->SetText(L"0/0");
1816 __pFindWordEditField->SetText(L"");
1817 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1819 __currentSearchStr = L"";
1820 __pFindWordNext->SetEnabled(false);
1821 __pFindWordPrev->SetEnabled(false);
1822 __pFindWordControl->Invalidate(true);
1825 case IDA_FINDWORD_NEXT_CLICKED:
1830 case IDA_FINDWORD_PREV_CLICKED:
1832 FindNextWord(false);
1835 case IDA_BRIGHTNESS_BTN_CLICKED:
1837 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1838 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1841 case IDA_COPY_IMAGE_CLICKED:
1843 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1844 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1846 const Bitmap* pBitmap = null;
1847 if (__pHitElementResult != null)
1849 pBitmap = __pHitElementResult->GetImage();
1852 String resourcePath = App::GetInstance()->GetAppResourcePath();
1853 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1855 // copying the item to clipboard
1856 Clipboard* pClipboard = Clipboard::GetInstance();
1857 if (pClipboard != null)
1859 pClipboard->CopyItem(item);
1863 case IDA_VIEW_IMAGE_CLICKED:
1865 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1866 WindowInfo* pNewWindowInfo = null;
1867 if (__pHitElementResult != null)
1869 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1870 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1876 case IDA_SAVE_IMAGE_CLICKED:
1878 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1879 const Bitmap* pSaveBitmap = null;
1880 String imageName = GetImagePath();
1881 AppLog("Content manager image name %ls",imageName.GetPointer());
1884 imagePath.Append(imageName);
1885 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1886 AppLog("Content manager image path %ls",imagePath.GetPointer());
1887 if (__pHitElementResult != null)
1889 pSaveBitmap = __pHitElementResult->GetImage();
1891 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
1895 UpdateImageContent(pBuffer, imageName);
1897 NotificationPanel *pNotification = new NotificationPanel(*this);
1899 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
1900 msg.Append(imagePath);
1901 if (pNotification != null)
1903 pNotification->SetText(msg);
1904 if (__pFooterPanel->GetShowState() == true)
1906 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1910 pNotification->SetPositionDiff(0);
1913 pNotification->ShowNotification();
1918 int __modalMsgBoxResult;
1919 MessageBox* pMsgBox = new MessageBox();
1920 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
1921 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1924 __modalMsgBoxResult = 0;
1928 case IDA_SHARE_IMAGE_CLICKED:
1930 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
1931 if (__pPopUp != null)
1936 __pPopUp = new(std::nothrow) SharePopup();
1937 __pPopUp->Initialize();
1938 if (__pHitElementResult != null)
1940 const Bitmap* pSaveBitmap = null;
1941 String imageName = GetImagePath();
1942 AppLog("Content manager image name %ls",imageName.GetPointer());
1945 imagePath.Append(imageName);
1946 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1947 AppLog("Content manager image path %ls",imagePath.GetPointer());
1948 if (__pHitElementResult != null)
1950 pSaveBitmap = __pHitElementResult->GetImage();
1952 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
1954 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1955 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1957 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1958 pShareInfo->SetPageTitle(L"");
1959 pShareInfo->SetPageUrl(srcUrl);
1960 pShareInfo->SetImageAttached(true);
1961 pShareInfo->SetImagePath(imagePath);
1962 __pPopUp->RemoveAllShareInfo();
1963 __pPopUp->AddShareInfo(pShareInfo);
1964 __pPopUp->SetShowState(true);
1969 case IDA_HYPERLINK_OPEN_CLICKED:
1971 if (__pHitElementResult != null)
1973 String srcUrl = __pHitElementResult->GetUrl();
1975 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene(srcUrl);
1977 if (pNewWindowInfo == null)
1981 result r = E_SUCCESS;
1982 SceneManager* pSceneManager = SceneManager::GetInstance();
1983 if (pSceneManager == NULL)
1987 ArrayList* pArgList = new(std::nothrow) ArrayList();
1988 if (pArgList == NULL)
1992 pArgList->Construct();
1994 pArgList->Add(*pNewWindowInfo);
1995 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1996 if (pArgList != null)
2003 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2009 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2011 if (__pHitElementResult == null)
2016 if(__pPopUp != null)
2021 __pPopUp = new(std::nothrow) SharePopup();
2022 __pPopUp->Initialize();
2024 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2025 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2026 pShareInfo->SetImageAttached(false);
2027 __pPopUp->RemoveAllShareInfo();
2028 __pPopUp->AddShareInfo(pShareInfo);
2030 __pPopUp->SetShowState(true);
2034 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2038 if (__pHitElementResult != null)
2040 url = __pHitElementResult->GetUrl();
2043 String resourcePath = App::GetInstance()->GetAppResourcePath();
2044 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2046 // copying the item to clipboard
2047 Clipboard* pClipboard = Clipboard::GetInstance();
2048 if (pClipboard != null)
2050 pClipboard->CopyItem(item);
2054 case IDA_FIND_TEXT__CLICKED:
2056 // AddressBarCancelledClicked(*__pAddressbar);
2057 RelayoutControls(false);
2058 // __pFooterPanel->SetShowState(false);
2059 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2060 __currentSearchStr.Clear();
2061 __currentSearchStr.Append(__currentSelectedStr);
2062 InitFindWordPanel();
2063 __pFindWordEditField->SetText(__currentSearchStr);
2066 __pMenu->SetShowState(false);
2067 __pMenu->Invalidate(false);
2070 __adressPanelPosition.y = 0;
2072 if (__pAddressbar != null && __pWebViewer != NULL)
2074 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2075 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2077 if (__pFooterPanel->GetShowState() == false)
2078 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2080 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2081 __pWebViewer->Invalidate(true);
2084 ShowFindWordPanel(true);
2085 __pFindWordEditField->SetFocus();
2086 if (__currentSearchStr.GetLength() > 0)
2092 AppLogDebug("Enter something");
2095 if (__pWebViewer != null)
2097 // releasing the set block
2098 __pWebViewer->ReleaseBlock();
2103 case IDA_SHARE_TEXT_CLICKED:
2105 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2106 if(__pPopUp != null)
2111 __pPopUp = new(std::nothrow) SharePopup();
2112 __pPopUp->Initialize();
2113 if (__pHitElementResult != null)
2115 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2116 pShareInfo->SetPageTitle(L"");
2117 pShareInfo->SetPageUrl(__currentSelectedStr);
2118 pShareInfo->SetImageAttached(false);
2119 __pPopUp->RemoveAllShareInfo();
2120 __pPopUp->AddShareInfo(pShareInfo);
2121 __pPopUp->SetShowState(true);
2126 case IDA_COPY_TEXT_CLICKED:
2128 __pWebViewer->ReleaseBlock();
2129 // need to implement
2130 //__currentSelectedStr
2131 // Sets data to a clip board item
2133 String resourcePath = App::GetInstance()->GetAppResourcePath();
2134 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2136 // copying the item to clipboard
2137 Clipboard* pClipboard = Clipboard::GetInstance();
2138 if (pClipboard != null)
2140 pClipboard->CopyItem(item);
2144 case IDA_PASTE_TEXT_CLICKED:
2146 Clipboard* pClipboard = Clipboard::GetInstance();
2148 if(pClipboard == null)
2152 // Retrieves a latest item
2153 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2159 //Gets data from the clipboard item
2160 String* pString = dynamic_cast<String*>(pItem->GetData());
2162 if (pString != null)
2164 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2165 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2166 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2169 if(idElement.GetLength() != 0)
2171 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; } } ";
2172 script.Append("insertAtCursor('");
2173 script.Append(idElement);
2174 script.Append("',");
2175 script.Append("\"");
2176 script.Append(*pString);
2177 script.Append("\");");
2179 else if (nameElement.GetLength() != 0)
2181 script = L"function insertAtCursor(myField, myValue) { if (document.selection) { document.getElementByName(myField)[0].focus(); sel = document.selection.createRange(); sel.text = myValue; } else if (myField.selectionStart || myField.selectionStart == '0'){ var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length); } else { document.getElementByName(myField)[0].value += myValue; } } ";
2182 script.Append("insertAtCursor(document.getElementsByName('");
2183 script.Append(nameElement);
2184 script.Append("')[0],");
2185 script.Append("\"");
2186 script.Append(*pString);
2187 script.Append("\");");
2189 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2190 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2201 case IDA_GO_FORWARD:
2206 case IDA_REFRESH_BTN_CLICKED:
2208 __isLoadingCompleted = false;
2209 __isLoadingData = true;
2210 __progressPercentage = 0;
2211 __displayUrl = __pFooterUrlField->GetText();
2213 String url = __pFooterUrlField->GetText();
2214 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2218 UpdateProgressBitmap();
2221 case IDA_STOP_BTN_CLICKED:
2223 __isLoadingCompleted = false;
2224 __isLoadingData = false;
2225 __progressPercentage = 0;
2226 __pFooterUrlField->HideKeypad();
2227 __displayUrl = __pFooterUrlField->GetText();
2231 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2232 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2233 __pWebViewer->StopLoading();
2234 RequestRedraw(true);
2237 UpdateProgressBitmap();
2242 if (__pFooterUrlField->GetText().IsEmpty() == false)
2244 //__displayUrl = __pUrlField->GetText();
2245 __pFooterUrlField->Clear();
2250 case IDA_READER_BTN_CLICKED:
2261 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2264 UiApp* pApp = UiApp::GetInstance();
2273 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2274 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2276 AppLog("MainForm::OnSceneActivatedN called");
2277 String* pSelectedScene = NULL;
2278 Object* pValue = NULL;
2279 String* pUrl = null;
2280 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2281 pSelectedScene = (String*) pValue;
2283 if (pSelectedScene != null)
2285 delete pSelectedScene;
2287 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2288 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2289 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2290 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2292 // setting the current scene ID
2293 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2295 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2297 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2299 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2300 if(__pWindowInfo == null)
2302 // if(__pWindowInfo == null)
2304 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2307 else if ( pArgs != null && pArgs->GetCount() == 1)
2309 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2315 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2317 // hiding the address bar
2318 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2319 __pAddressbar->SetShowState(false);
2320 if(__pWebViewer != null)
2322 __pWebViewer->Resume();
2325 if(pUrl != null && pUrl->GetLength() > 0)
2329 else if(__pWindowInfo != null)
2331 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)
2333 LoadUrl(__pWindowInfo->pageUrl);
2335 else if (__pWindowInfo->isJavascriptInitiated == true)
2339 __pWindowInfo->pCurrentWeb = __pWebViewer;
2343 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2344 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2345 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2347 InitMostVisitedSitesView(GetOrientationStatus());
2349 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2351 if(__pMostVisitedListView != null)
2353 __pMostVisitedListView->SetShowState(false);
2357 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2359 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2361 if (pBookmarkUrl == null)
2363 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2364 //__pAddressbar->SetUrl(*pBookmarkUrl);
2365 SetUrl(*pBookmarkUrl);
2367 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2368 __pWebViewer->LoadUrl(*pBookmarkUrl);
2369 delete pBookmarkUrl;
2372 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2373 Bitmap* pBitmap = null;
2374 if (isPrivateBrowsing == true)
2376 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2378 if (__pWebViewer != null)
2380 __pWebViewer->SetPrivateBrowsingEnabled(true);
2383 if (__pAddressbar != null)
2385 // __pAddressbar->UpdateFaviconBitmap(true);
2391 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2393 if (__pWebViewer != null)
2395 __pWebViewer->SetPrivateBrowsingEnabled(false);
2398 if (__pAddressbar != null)
2400 // __pAddressbar->UpdateFaviconBitmap(false);
2404 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2406 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2408 else if (__pMenu != null )
2410 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY"),IDA_PRIVATEON_CLICKED,*pBitmap);
2413 if (pBitmap != null)
2418 AppLog("ABC: OnSceneActivatedN started exit");
2423 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2424 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2426 Canvas* pWebCanvas = null;
2427 if (__pWebViewer != null)
2429 pWebCanvas = __pWebViewer->GetCanvasN();
2430 __pWebViewer->Pause();
2433 if (pWebCanvas == null)
2437 if (__pWindowInfo != null)
2439 if (__pWindowInfo->pWebCanvasBitmap != null)
2441 delete __pWindowInfo->pWebCanvasBitmap;
2443 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2444 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2445 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2447 Bitmap* pBitmap = GetCapturedBitmapN();
2448 AppLog("Coming here");
2449 Canvas* pCanvas = new(std::nothrow) Canvas();
2450 pCanvas->Construct(GetClientAreaBounds());
2453 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2456 if(__pWebViewer != null && __pWindowInfo != null)
2457 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2459 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2460 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2462 AppLog("Coming here");
2466 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2467 const Tizen::Base::String& realm,
2468 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2474 MainForm::OnHttpAuthenticationCanceled(void)
2479 MainForm::OnLoadingStarted(void)
2481 AppLogDebug("MainForm::OnLoadingStarted entered");
2483 if(__pAddressbar == NULL || __pWebViewer == null)
2487 // this is added in case if menu is opened and user load the page
2488 if(__pMenu != null && __pMenu->GetShowState() == true)
2490 __pMenu->SetShowState(false);
2491 __pMenu->Invalidate(true);
2493 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2495 __pImageMenu->SetShowState(false);
2496 __pImageMenu->Invalidate(true);
2498 String url = __pWebViewer->GetUrl();
2499 if(url.Contains(IDS_TIZEN_SERVICE))
2502 String delim(L":;");
2504 // Creates a StringTokenizer instance
2505 StringTokenizer strTok(url, delim);
2507 int count = strTok.GetTokenCount(); // count == 4
2509 HashMap *pMap = new HashMap();
2514 while (strTok.HasMoreTokens())
2516 AppLog("Token: %ls", token.GetPointer());
2517 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2518 if(token.Contains(IDS_APPID))
2520 token.SubString(6, appId);
2521 AppLog("AppID:%ls", appId.GetPointer());
2523 else if(token.Contains("="))
2525 String *pKey = new String();
2526 String *pValue = new String();
2528 token.IndexOf("=", 0, index);
2531 token.SubString(0, index, *pKey);
2532 token.SubString(index + 1, *pValue);
2533 pMap->Add(pKey, pValue);
2539 AppControl *pAppControl = null;
2540 String operationId = L"http://tizen.org/appcontrol/operation/main";
2541 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2544 AppLog("Starting AppControl");
2545 result r = pAppControl->Start(null, null, pMap, null);
2546 AppLog("Result of Start %s", GetErrorMessage(r));
2550 AppLogException("AppControl not found");
2555 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2557 __pAddressbar->SetShowState(false);
2558 AddressBarCancelledClicked(*__pAddressbar);
2559 __pAddressbar->Invalidate(true);
2561 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2564 __pAddressbar->SetFaviconBitmap(*pBitmap);
2567 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2569 // updating the address bar position with respect to web control
2570 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2571 __distanceMoved = 0;
2575 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2576 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2577 if (__pWebViewer != null)
2579 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2580 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2581 SetUrl(__pWebViewer->GetUrl());
2582 if (__pWindowInfo != NULL)
2584 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2585 __pWindowInfo->pageTitle = L"";
2586 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2588 __pAddressbar->Invalidate(true);
2594 MainForm::OnLoadingCanceled(void)
2601 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2603 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2608 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2610 AppLog("XYZ::MainForm::OnKeypadOpened");
2615 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2617 AppLog("XYZ::MainForm::OnKeypadClosed");
2618 RelayoutControls(true);
2622 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2624 AppLog("KeypadBoundsChanged");
2625 RelayoutControls(false);
2629 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2630 const Tizen::Base::String& reason)
2632 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2636 MainForm::OnLoadingCompleted(void)
2638 AppLog("MainForm::OnLoadingCompleted start");
2640 result r = E_SUCCESS;
2642 if (__pWebViewer == null)
2647 if (__pAddressbar == null)
2651 if (__pWebViewer->CanGoForward())
2653 //__pAddressbar->SetForwardButtonEnabled(true);
2654 SetForwardButtonEnabled(true);
2658 //__pAddressbar->SetForwardButtonEnabled(false);
2659 SetForwardButtonEnabled(false);
2662 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2664 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2666 //__pAddressbar->UpdateProgress(0);
2670 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2672 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2676 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2677 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2678 if (isPrivateBrowsing == false)
2680 if(__pHistory != null)
2686 __pHistory = new(std::nothrow) History;
2687 HistoryPresentationModel::GetCurrentDateTime(date);
2690 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2691 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2693 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2694 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2696 __pHistory->SetVisitedTime(date);
2698 if (__pWebViewer != null)
2700 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2702 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2703 if (pTempBitmap != null)
2705 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2706 __pHistory->SetFavIconBitmap(*pTempBitmap);
2709 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2712 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2713 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2714 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2716 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2717 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2718 __pHistory->SetThumbnail(pBitmap);
2720 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2723 __pHistory->SetFavIconBitmap(*pFavIcon);
2727 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2734 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2736 // temperary fixed (webpage can be not loaded)
2740 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2741 if (isReaderEnabled == true)
2745 delete __pReaderData;
2746 __pReaderData = null;
2748 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2749 filePath.Append(L"data/reader.js");
2755 result r = E_SUCCESS;
2756 FileAttributes attr;
2758 File::GetAttributes(filePath,attr);
2760 r = file.Construct(filePath, L"r+");
2763 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2766 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2769 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2772 // file.Read(pScript,attr.GetFileSize());
2774 // AppLogDebug("scipt length %d",strlen(pScript));
2775 String strScript = L"";
2776 // strScript.Append(pScript);
2777 // for(int i=0; i<25; i++)
2779 file.Read(pScript,attr.GetFileSize());
2780 // AppLog("xyzz tell %d",file.Tell());
2781 // r = strScript.Append(pScript);
2782 // AppLog("xyzz append result %s",GetErrorMessage(r));
2783 // AppLog("xyzz strScript length %d",strScript.GetLength());
2785 // AppLog("xyzz final strScript length %d",strScript.GetLength());
2787 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
2788 if (__pReaderData == null)
2790 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2793 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2794 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2796 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2797 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2803 AppLog("MainForm::OnLoadingCompleted done");
2807 MainForm::OnEstimatedProgress(int progress)
2809 AppLogDebug("MainForm::OnEstimatedProgress entered");
2810 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2811 progress = DEFAULT_PROGRESS_PERCENTAGE;
2813 // __pAddressbar->UpdateProgress(progress);
2814 UpdateProgress(progress);
2817 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2819 AppLog("MainForm::OnFaviconReceived");
2820 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2822 Bitmap* favIcon = __pWebViewer->GetFaviconN();
2825 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
2832 MainForm::OnUrlValueChanged(Addressbar&)
2838 MainForm::OnUrlSubmitted(Addressbar& addBar)
2840 AppLog("MainForm::OnUrlSubmitted");
2841 String url = addBar.GetUrl();
2842 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2844 if(__pFooterUrlField)
2845 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2846 AddressBarCancelledClicked(*__pAddressbar);
2851 MainForm::LoadUrl(String& url)
2855 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2856 AppLogDebug("MainForm::LoadUrl enter");
2858 if (__pWebViewer != null)
2860 __pWebViewer->SetShowState(true);
2861 __pWebViewer->Invalidate(true);
2864 if (url.CompareTo(L"") == 0)
2868 if(__pFooterPanel != null)
2870 __pFooterPanel->SetShowState(true);
2871 __pFooterPanel->Invalidate(true);
2878 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2879 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)
2881 RegularExpression firstRegex;
2882 RegularExpression secondRegex;
2884 firstRegex.Construct(firstPattern, REGEX_CASELESS);
2885 secondRegex.Construct(secondPattern, REGEX_CASELESS);
2888 ret = firstRegex.Match(url, false); // This returns true value
2889 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
2891 if (ret == true && __pWebViewer != null)
2894 __pWebViewer->LoadUrl(url);
2896 else if(__pWebViewer != null)
2898 String tempUrl = L"http://";
2899 tempUrl.Append(url);
2903 __pWebViewer->LoadUrl(tempUrl);
2907 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2908 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
2911 if (__pAddressbar != null)
2913 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2914 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2917 AppLogDebug("MainForm::LoadUrl exit");
2924 MainForm::OnStopClicked(Addressbar& addBar)
2926 AppLogDebug("MainForm::OnStopClicked called");
2929 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2930 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2931 __pWebViewer->StopLoading();
2932 RequestRedraw(true);
2937 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
2939 // AppLog("MainForm::OnBackClicked");
2940 result r = E_FAILURE;
2942 if (__pWebViewer && __pWebViewer->CanGoBack())
2944 __pWebViewer->GoBack();
2946 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
2949 pApp = UiApp::GetInstance();
2952 r = pApp->Terminate();
2955 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2963 WindowInfo* pWindowInfo = null;
2965 SceneManager* pSceneManager = SceneManager::GetInstance();
2966 if (pSceneManager == null)
2970 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2971 if (pAllWindowList == NULL)
2973 pApp = UiApp::GetInstance();
2976 r = pApp->Terminate();
2979 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
2984 if (pAllWindowList != null)
2986 totalCount = pAllWindowList->GetCount();
2988 for (int count = 0; count < totalCount; count++)
2990 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2991 if (pWindowInfo == null)
2993 pApp = UiApp::GetInstance();
2996 r = pApp->Terminate();
2999 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3004 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3006 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3009 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3012 r = pAllWindowList->RemoveAt(count, true);
3013 __pWindowInfo = null;
3016 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3021 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3025 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3027 if (pWindowInfo == null)
3029 pApp = UiApp::GetInstance();
3032 r = pApp->Terminate();
3038 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3041 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3055 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3057 AppLog("MainForm::OnForwardClicked");
3058 if (__pWebViewer == null)
3061 if (__pWebViewer->CanGoForward())
3063 __pWebViewer->GoForward();
3068 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3070 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3071 if(__pFooterPanel != null)
3073 __pFooterPanel->SetShowState(false);
3076 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3078 __pAddressbar->SetShowState(true);
3079 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3082 RelayoutControls(false);
3086 MainForm::OnAddressBarFocusLost(const Addressbar& addBar)
3088 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3091 __pAddressbar->SetShowState(false);
3094 AppLog("akjshdasd 3");
3095 __pFooterPanel->SetShowState(true);
3098 RelayoutControls(false);
3102 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3104 AddressBarCancelledClicked(addBar);
3108 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3110 __prevAddressBarMode = __curAddressBarMode;
3112 if (__pAddressbar != null)
3114 __curAddressBarMode = GetAddressbarMode();
3117 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3119 __adressPanelPosition.y = 0;
3120 if (__pAddressbar != null)
3122 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3123 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3124 __pAddressbar->Invalidate(true);
3126 if (__pWebViewer != null)
3128 __pWebViewer->StopLoading();
3131 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3133 __adressPanelPosition.y = 0;
3134 if (__pAddressbar != null)
3136 __webControlPosition.y = 0;
3137 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3138 __pAddressbar->Invalidate(true);
3144 MainForm::OnClipboardClosed(const Addressbar& addBar)
3146 RelayoutControls(false);
3150 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3152 RelayoutControls(false,footerState);
3156 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3158 RelayoutControls(false);
3162 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3164 __pFooterPanel->SetShowState(false);
3168 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3170 AppLog("KeypadBoundsChanged");
3171 RelayoutControls(false);
3175 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3179 __pWindowInfo->pageTitle = title;
3180 if (__pWebViewer != null)
3182 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3185 if (__pAddressbar != null && __pWebViewer != null)
3187 SetUrl(__pWebViewer->GetUrl());
3188 __pAddressbar->Invalidate(true);
3193 MainForm::UpdateFavicon(void)
3195 bool urlImageType = false;
3196 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();");
3197 Bitmap* pBitmap = null;
3199 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3201 if (__pWindowInfo != null)
3204 url.SetUri(*tempPath);
3205 if (url.GetHost().GetLength() == 0)
3208 webUrl.SetUri(__pWebViewer->GetUrl());
3209 result r = url.SetHost(webUrl.GetHost());
3216 if (url.GetScheme().GetLength() == 0)
3219 webUrl.SetUri(__pWebViewer->GetUrl());
3220 url.SetScheme(webUrl.GetScheme());
3222 __pWindowInfo->faviconUrl = url.ToString();
3224 pBitmap = __pWebViewer->GetFaviconN();
3226 if (pBitmap != null)
3228 if (__pWindowInfo->pFavicon != NULL)
3230 __pWindowInfo->pFavicon = null;
3232 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3233 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3235 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3237 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3239 else if(__pWindowInfo->pFavicon != null)
3241 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3245 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3246 if(pDefaultBmp != null)
3248 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3257 if(tempPath != null)
3261 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3268 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3269 Tizen::Web::Controls::WebNavigationType type)
3271 // when load new page if find word panel is open its show state is false
3272 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3274 __currentSearchStr = L"";
3275 __currentWordIndex = 0;
3276 __maxOccurrances = 0;
3277 __pFindWordEditField->SetText(L"");
3278 __pFindWordNext->SetEnabled(false);
3279 __pFindWordPrev->SetEnabled(false);
3280 __pFindWordCountLabel->SetText(L"0/0");
3281 __pFindWordControl->SetShowState(false);
3282 __pFindWordEditField->HideKeypad();
3283 RelayoutControls(false);
3288 __pFooterPanel->Invalidate(true);
3291 uriInfo.SetUri(url);
3293 if(url.Contains(IDS_TIZEN_SERVICE))
3296 String delim(L":;,");
3298 // Creates a StringTokenizer instance
3299 StringTokenizer strTok(url, delim);
3301 int count = strTok.GetTokenCount(); // count == 4
3303 HashMap *pMap = new HashMap();
3309 while (strTok.HasMoreTokens())
3311 AppLog("Token: %ls", token.GetPointer());
3312 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3313 if(token.Contains(IDS_APPID))
3315 token.SubString(6, appId);
3316 AppLog("AppID:%ls", appId.GetPointer());
3318 else if(token.Contains("="))
3320 String *pKey = new String();
3321 String *pValue = new String();
3323 token.IndexOf("=", 0, index);
3326 token.SubString(0, index, *pKey);
3327 token.SubString(index + 1, *pValue);
3328 pMap->Add(pKey, pValue);
3334 AppControl *pAppControl = null;
3335 String operationId = L"http://tizen.org/appcontrol/operation/main";
3336 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3339 result r = pAppControl->Start(null, null, pMap, null);
3343 AppLogException("AppControl not found");
3353 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3354 const Tizen::Net::Http::HttpHeader& httpHeader)
3356 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3361 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3363 AppLog("MainForm::OnWebPageBlockSelected");
3364 if (__pHitElementResult != null)
3366 delete __pHitElementResult;
3367 __pHitElementResult = null;
3370 if (__pWebViewer != null)
3372 AppLog("MainForm::OnWebPageBlockSelected web not null");
3373 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3374 if(GetLastResult() == E_INVALID_ARG)
3376 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3380 if (__pHitElementResult == null)
3385 if (__pHitElementResult->HasImage() != true)
3387 String tagName = __pHitElementResult->GetTagName();
3388 String type = __pHitElementResult->GetAttributeValue("type");
3390 __currentSelectedStr.Clear();
3391 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3392 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3393 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3395 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && __isLongPressedDone == true)
3397 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3399 InitSelectTextContextMenu(endPoint,true);
3400 __pImageMenu->SetShowState(true);
3401 __pImageMenu->Show();
3402 __pImageMenu->Invalidate(true);
3404 else if(__isLongPressedDone == true)
3406 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3408 if(__pHitElementResult->GetUrl().GetLength() > 0)
3410 __currentSelectedStr.Clear();
3411 __currentSelectedStr = __pHitElementResult->GetUrl();
3413 InitSelectTextContextMenu(endPoint,false);
3414 __pImageMenu->SetShowState(true);
3415 __pImageMenu->Show();
3416 __pImageMenu->Invalidate(true);
3419 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3420 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3421 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3427 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3433 MainForm::OnWebWindowCreateRequested(void)
3435 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewScene();
3437 if (pNewWindowInfo == null)
3441 result r = E_SUCCESS;
3442 SceneManager* pSceneManager = SceneManager::GetInstance();
3443 if (pSceneManager == NULL)
3447 ArrayList* pArgList = new(std::nothrow) ArrayList();
3448 if (pArgList == NULL)
3452 r = pArgList->Construct();
3455 pNewWindowInfo->isJavascriptInitiated = true;
3456 pArgList->Add(*pNewWindowInfo);
3457 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3461 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3468 return pNewWindowInfo->pCurrentWeb;
3472 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3474 __webControlPosition.y = 0;
3475 __webControlHeight = GetClientAreaBounds().height;
3476 AppLog("Client area height: %d", __webControlHeight);
3478 AppLog("Client area height: %d", __webControlHeight);
3479 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3481 __webControlPosition.y += __pAddressbar->GetHeight();
3482 __webControlHeight -= __pAddressbar->GetHeight();
3483 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3485 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3487 __webControlPosition.y += __pFindWordControl->GetHeight();
3488 __webControlHeight -= __pFindWordControl->GetHeight();
3489 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3492 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3494 __webControlHeight -= __pFooterPanel->GetHeight();
3496 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3498 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3500 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight);
3501 __pWebViewer->Invalidate(false);
3503 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3505 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3512 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3514 if (__pFindWordControl == null)
3520 InitFindWordPanel();
3521 // __pFindWordEditField->SetText(__currentSearchStr);
3522 //__pFindWordCountLabel->SetText(L"");
3523 // __pFindWordCountLabel->SetText(L"0/0");
3524 __pFindWordControl->SetShowState(true);
3528 if(__pFindWordControl != null)
3530 __pFindWordControl->SetShowState(false);
3534 AppLog("MainForm::ShowFindWordPanel %d",show);
3535 if (show && !isTouchPressed)
3537 if (__pFindWordEditField)
3539 __pFindWordEditField->SetFocus();
3540 __pFindWordEditField->ShowKeypad();
3545 if (__pFindWordEditField)
3546 __pFindWordEditField->HideKeypad();
3549 RelayoutControls(false);
3553 MainForm::StartWordSearch()
3555 //Get the count of occurances of the word in the current page
3556 __maxOccurrances = 0;
3557 __currentWordIndex = 0;
3559 __pFindWordPrev->SetEnabled(false);
3560 String *pCountStr = null;
3561 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3562 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3563 if (pCountStr != null)
3565 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3569 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3574 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3576 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3577 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3579 if(totalCount == -1 || totalCount == 0)
3581 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3582 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3585 else if(totalCount > 100)
3587 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3588 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3592 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3593 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3596 __maxOccurrances = totalCount;
3597 __currentWordIndex = currentOrdinal;
3599 //Reset the UI controls as per the maxOccurrance value
3600 if (totalCount <= 0)
3602 AppLog("Word not found");
3603 //Show error notification to user
3604 __pFindWordNext->SetEnabled(false);
3605 __pFindWordCountLabel->SetText(L"0/0");
3606 __pFindWordNext->Invalidate(false);
3607 __pFindWordPrev->Invalidate(false);
3608 __pFindWordCountLabel->Invalidate(false);
3612 if (totalCount == 1)
3614 __pFindWordNext->SetEnabled(false);
3618 __pFindWordNext->SetEnabled(true);
3621 String countStr = L"";
3622 countStr.Append(__currentWordIndex);
3623 countStr.Append(L"/");
3624 countStr.Append(__maxOccurrances);
3625 __pFindWordCountLabel->SetText(countStr);
3626 // __pFindWordCountLabel->SetShowState(true);
3627 __pFindWordCountLabel->Invalidate(false);
3629 //FindNextWord(true);
3630 //Update the controls
3631 __pFindWordNext->Invalidate(false);
3632 __pFindWordPrev->Invalidate(false);
3633 __pFindWordCountLabel->Invalidate(false);
3637 MainForm::FindNextWord(bool next)
3641 if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3643 if(__currentWordIndex < __maxOccurrances)
3645 __currentWordIndex++;
3651 if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3653 if(__currentWordIndex > 1)
3655 __currentWordIndex--;
3660 String countStr = L"";
3661 countStr.Append(__currentWordIndex);
3662 countStr.Append(L"/");
3663 countStr.Append(__maxOccurrances);
3664 __pFindWordCountLabel->SetText(countStr);
3665 // __pFindWordCountLabel->SetShowState(true);
3666 __pFindWordCountLabel->Invalidate(false);
3667 if (__currentWordIndex >= __maxOccurrances)
3669 __pFindWordNext->SetEnabled(false);
3673 __pFindWordNext->SetEnabled(true);
3675 if (__currentWordIndex <= 1)
3677 __pFindWordPrev->SetEnabled(false);
3681 __pFindWordPrev->SetEnabled(true);
3683 __pFindWordPrev->Invalidate(false);
3684 __pFindWordNext->Invalidate(false);
3685 __pFindWordCountLabel->Invalidate(false);
3686 __pFindWordControl->Invalidate(true);
3689 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3691 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
3692 __isWebKeypadOpened = true;
3693 __pFooterPanel->SetShowState(false);
3694 // OnAddressBarKeypadOpened(*__pAddressbar);
3698 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3700 AppLog("xyz::MainForm::OnWebKeypadOpened");
3702 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3704 __currentSearchStr = L"";
3705 __currentWordIndex = 0;
3706 __maxOccurrances = 0;
3707 __pFindWordEditField->SetText(L"");
3708 __pFindWordNext->SetEnabled(false);
3709 __pFindWordPrev->SetEnabled(false);
3710 __pFindWordCountLabel->SetText(L"0/0");
3711 __pWebViewer->SearchTextAllAsync(L"",false);
3712 __pFindWordControl->SetShowState(false);
3713 __pFindWordEditField->HideKeypad();
3717 if (__pWebViewer != null && __pFooterPanel != null)
3719 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3720 if(__pAddressbar != null)
3722 __pAddressbar->SetShowState(false);
3724 if(__pFindWordControl != null)
3726 __pFindWordControl->SetShowState(false);
3728 __pFooterPanel->SetShowState(false);
3729 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3731 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3733 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3734 // AppLog("omgomgomg");
3740 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3742 AppLog("xyz::MainForm::OnWebKeypadClosed");
3743 AppLog("akjshdasd 4");
3744 __pFooterPanel->SetShowState(true);
3745 // OnAddressBarKeypadClosed(*__pAddressbar);
3746 RelayoutControls(false);
3747 __isWebKeypadOpened = false;
3751 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3753 Control* temp = const_cast< Control* >(&source);
3754 Header* pHeader = dynamic_cast< Header* >(temp);
3755 if (pHeader != null)
3757 //Header double - clicked
3758 AppLog("Header double clicked");
3760 if(__pFindWordControl)
3762 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3763 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3767 AppLog("MainScene::OnTouchDoublePressed");
3771 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3773 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
3775 if (__pHitElementResult != null)
3777 delete __pHitElementResult;
3778 __pHitElementResult = null;
3781 if (__pWebViewer != null)
3783 AppLog("MainForm::OnTouchLongPressed web not null");
3784 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
3787 if (__pHitElementResult == null)
3792 if (__pHitElementResult->HasImage() == true)
3794 InitImageContextMenu(currentPosition);
3795 __pImageMenu->SetShowState(true);
3796 __pImageMenu->Show();
3797 __pImageMenu->Invalidate(true);
3799 else if(__pHitElementResult->HasUrl() == true)
3801 String tempURl = __pHitElementResult->GetUrl();
3802 AppLog("tempURl is %ls", tempURl.GetPointer());
3803 const Bitmap* pBitmap = __pHitElementResult->GetImage();
3804 if (pBitmap != null)
3812 InitImageLinkContextMenu(currentPosition);
3813 __pImageMenu->SetShowState(true);
3814 __pImageMenu->Show();
3815 __pImageMenu->Invalidate(true);
3819 String tagName = __pHitElementResult->GetTagName();
3820 String type = __pHitElementResult->GetAttributeValue("type");
3821 String value = __pHitElementResult->GetAttributeValue(L"value");
3822 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
3824 __currentSelectedStr.Clear();
3825 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3827 AppLog("tag name is %ls", tagName.GetPointer());
3828 AppLog("type is %ls", type.GetPointer());
3829 AppLog("innerHtml is %ls", innerHtml.GetPointer());
3831 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && value.GetLength() == 0 && innerHtml.GetLength() == 0 && __isWebKeypadOpened == true)
3833 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3835 InitSelectTextContextMenu(currentPosition,true, true);
3838 __pImageMenu->SetShowState(true);
3839 __pImageMenu->Show();
3840 __pImageMenu->Invalidate(true);
3843 __isLongPressedDone = true;
3844 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
3845 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
3848 // __inputEventToBeSupressed = true;
3852 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
3854 AppLog("MainForm::OnTouchReleased");
3857 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
3858 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
3860 __pWebViewer->ConsumeInputEvent();
3862 if(pHitElement != null)
3866 __inputEventToBeSupressed = false;*/
3870 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3877 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3879 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3881 __currentSearchStr = L"";
3882 __currentWordIndex = 0;
3883 __maxOccurrances = 0;
3884 __pFindWordEditField->SetText(L"");
3885 __pFindWordNext->SetEnabled(false);
3886 __pFindWordPrev->SetEnabled(false);
3887 __pFindWordCountLabel->SetText(L"0/0");
3888 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
3889 __pFindWordControl->SetShowState(false);
3890 __pFindWordEditField->HideKeypad();
3892 if(__pAddressbar->GetShowState() == false)
3894 __pAddressbar->SetAddressbarURLFocus();
3895 __pFooterPanel->SetShowState(false);
3902 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3908 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3914 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3920 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3926 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
3932 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
3934 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
3935 int widthContextItem = 0;
3937 // As per the platform engineer comment removed this line
3938 /*if(__pWebViewer != null)
3940 // 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
3941 __pWebViewer->ReleaseBlock();
3944 if(__pFindWordControl != null)
3945 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
3946 if ( __pFooterLabel != null)
3948 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
3951 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
3956 if (__pFindWordBgLabel != null)
3958 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
3959 if (pBitmap != null)
3961 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
3967 __pMenu->SetShowState(false);
3968 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
3970 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
3974 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
3979 AppLog("__pFooterPanel->GetShowState() is true");
3981 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
3982 __pFooterPanel->Invalidate(true);
3986 if(__pMoreButton && __pMenu)
3988 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
3989 __pMenu->SetAnchorPosition(p);
3990 __pMenu->Invalidate(true);
3993 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
3994 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
3996 InitMostVisitedSitesView(orientationStatus);
3999 RelayoutControls(false);
4000 if (__pArticleReaderPanel != null)
4002 if (__pArticleReaderPanel->GetShowState() == true)
4004 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4006 if (__pBlankPanel != null)
4007 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4009 if (__pWebReader != null)
4011 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4013 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4014 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4016 if ( pBitmap != null && pSrcBitmap != null)
4018 AppLog("CreateReaderPanel ninepatchbitmap found");
4019 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4022 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4023 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4024 if (pBitmap != null)
4029 if (pSrcBitmap != null)
4038 if (__pAddressbar != null)
4040 int width = GetClientAreaBounds().width;
4041 __pAddressbar->OrientationChanged(width);
4046 MainForm::OnSettingsChange(int settingvalue)
4048 AppLogDebug("MainForm::OnSettingsChange entered");
4050 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4052 __pAddressbar->ResetGuideText();
4054 if (__pWebViewer == null)
4056 AppLogDebug("Webviewer is not initialized yet.");
4060 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4062 WebSetting settings = __pWebViewer->GetSetting();
4063 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4065 settings.SetAutoFittingEnabled(true);
4067 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo(CommonUtil::GetString(L"IDS_BR_BODY_READABLE")) == 0)
4069 settings.SetAutoFittingEnabled(false);
4071 __pWebViewer->SetSetting(settings);
4073 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4075 WebSetting settings = __pWebViewer->GetSetting();
4076 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4077 __pWebViewer->SetSetting(settings);
4079 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4081 WebSetting settings = __pWebViewer->GetSetting();
4082 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4083 __pWebViewer->SetSetting(settings);
4085 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4087 WebSetting settings = __pWebViewer->GetSetting();
4088 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4089 __pWebViewer->SetSetting(settings);
4091 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4095 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4098 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4102 WebSetting settings = __pWebViewer->GetSetting();
4103 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4106 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4110 WebSetting settings = __pWebViewer->GetSetting();
4111 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4114 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4116 WebSetting settings = __pWebViewer->GetSetting();
4117 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4119 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4123 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4125 __pWebViewer->SetSetting(settings);
4127 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4131 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4132 WebSetting settings = __pWebReader->GetSetting();
4133 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4134 __pWebReader->SetSetting(settings);
4140 MainForm::OnSettingsReset()
4144 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4145 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4150 MainForm::OnClearCache()
4152 result r = E_SUCCESS;
4154 if (__pWebViewer != NULL)
4156 r = __pWebViewer->ClearCache();
4159 AppLogDebug("Cache cleared success");
4163 AppLogDebug("Cache cleared fail");
4169 MainForm::OnClearCookie()
4171 result r = E_SUCCESS;
4173 if (__pWebViewer != NULL)
4175 __pWebViewer->ClearCookie();
4179 AppLogDebug("Cookie cleared success");
4183 AppLogDebug("Cache cleared fail");
4188 MainForm::OnClearFormData()
4190 result r = E_SUCCESS;
4192 if (__pWebViewer != NULL)
4194 __pWebViewer->ClearFormData();
4198 AppLogDebug("Cookie cleared success");
4202 AppLogDebug("Cache cleared fail");
4207 MainForm::OnClearPasswords()
4209 result r = E_SUCCESS;
4211 if (__pWebViewer != NULL)
4213 __pWebViewer->ClearLoginFormData();
4217 AppLogDebug("Cookie cleared success");
4221 AppLogDebug("Cache cleared fail");
4227 MainForm::findDistance(int x1,int y1,int x2, int y2)
4229 int deltaX = Math::Abs(x2 - x1);
4230 int deltaY = Math::Abs(y2 - y1);
4231 double num = deltaX*deltaX + deltaY*deltaY;
4237 for (i = 0; i < 20; i++)
4239 x = (((x*x)+ num)/(2*x));
4250 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4252 if(__pFindWordControl)
4254 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4255 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4257 __isLongPressedDone = false;
4260 IList* pList = null;
4261 pList = touch.GetTouchInfoListN(source);
4265 int count = pList->GetCount();
4268 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4269 __touchPoint1 = pTouchInfo->position;
4271 /*if (__pAddressbar != null)
4273 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4275 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4277 __pAddressbar->SaveAddressbarEditText();
4279 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4282 __pAddressbar->Invalidate(true);
4284 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4286 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4288 //__pAddressbar->SaveAddressbarEditText();
4290 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4293 else if (count == 2)
4295 AppLogDebug("MainForm::OnTouchPressed count is two");
4296 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4297 __touchPoint1 = pTouchInfo->position;
4299 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4300 __touchPoint2 = pTouchInfo->position;
4306 pList->RemoveAll(true);
4313 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4315 // __currentWordIndex = 0;
4316 __isLongPressedDone = false;
4321 MainForm::MoveUiControls()
4326 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4328 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4330 if(__pFooterUrlField->GetTextLength() == 0)
4332 __pFooterUrlField->SetKeypadActionEnabled(false);
4336 __pFooterUrlField->SetKeypadActionEnabled(true);
4339 if (__pFindWordEditField != null)
4341 __currentSearchStr = __pFindWordEditField->GetText();
4342 __pFindWordNext->SetEnabled(false);
4343 __pFindWordPrev->SetEnabled(false);
4344 __pFindWordNext->Invalidate(true);
4345 __pFindWordPrev->Invalidate(true);
4346 __pFindWordCountLabel->SetText(L"0/0");
4347 __pFindWordCountLabel->Invalidate(true);
4349 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4350 if (__currentSearchStr.GetLength() > 0)
4356 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4358 __currentSearchStr = L"";
4359 AppLogDebug("Enter something");
4364 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4371 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4373 if(__pWebViewer != null)
4376 AppLog("MainForm::InitMostVisitedSitesView");
4377 result r = E_SUCCESS;
4380 if (__pWebViewer != null && __pMostVisitedListView != null)
4385 if (__pMostVisitedListView != null)
4387 RemoveControl(__pMostVisitedListView);
4389 if(__pMostVisitedSites != null)
4391 __pMostVisitedSites->RemoveAll(true);
4394 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4396 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4397 __pMostVisitedListView = new(std::nothrow) ListView();
4399 int height = GetClientAreaBounds().height;
4401 if(__pFooterPanel->GetShowState() == true)
4403 height = height - __pFooterPanel->GetHeight();
4405 if(__pAddressbar->GetShowState() == true)
4407 height -= __pAddressbar->GetHeight();
4410 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4414 delete __pMostVisitedListView;
4415 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4418 __pMostVisitedListView->SetItemProvider(*this);
4419 __pMostVisitedListView->AddListViewItemEventListener(*this);
4420 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4421 AddControl(__pMostVisitedListView);
4422 __pMostVisitedListView->UpdateList();
4429 MainForm::GetImagePath(void)
4433 String formattedTime;
4434 DateTime currentTime;
4435 LocaleManager localManager;
4436 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4438 localManager.Construct();
4439 Locale locale = localManager.GetSystemLocale();
4440 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4442 // Get date formatter
4443 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4447 pTimeFormatter->Format(currentTime, formattedTime);
4450 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4451 String delim(L" :");
4452 StringTokenizer strTok(formattedTime, delim);
4455 String str1("GMT+00");
4456 while (strTok.HasMoreTokens())
4458 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4459 if(token.Equals(str1))
4461 AppLog("token is %ls", token.GetPointer());
4462 imageName.Append(token);
4468 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4470 result r = E_FAILURE;
4471 AppLog("Content manager 1");
4472 ContentId contentId;
4473 ContentManager contentManager;
4474 r = contentManager.Construct();
4477 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4480 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4481 contentPath.Append(imageName);
4482 contentPath.Append(".jpg");
4483 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4484 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4488 MainForm::SetForwardButtonEnabled(bool isEnabled)
4490 __pGoForwardBtn->SetEnabled(isEnabled);
4491 __pGoForwardBtn->Invalidate(true);
4495 MainForm::SetBackButtonEnabled(bool isEnabled)
4497 __pGoBackBtn->SetEnabled(isEnabled);
4498 __pGoBackBtn->Invalidate(true);
4502 MainForm::UpdateProgress(int percentage)
4504 __progressPercentage = percentage;
4505 if (percentage == 0 || percentage == 100)
4507 __isLoadingData = false;
4508 if (percentage == 100)
4510 __isLoadingCompleted = true;
4511 __progressPercentage = 0;
4515 __isLoadingCompleted = false;
4520 __isLoadingData = true;
4522 UpdateProgressBitmap();
4526 MainForm::GetProgress(void)
4528 return __progressPercentage;
4532 MainForm::UpdateProgressBitmap(void)
4534 result r = E_SUCCESS;
4535 if (__pProgressbarLabel == null)
4537 int w = __pProgressbarLabel->GetWidth();
4538 int h = __pProgressbarLabel->GetHeight();
4540 int progressWidth = 0;
4541 Bitmap* pRetBitmap = null;
4543 if (__progressPercentage == 0 || __progressPercentage == 100)
4545 __pProgressbarLabel->SetShowState(false);
4546 __pProgressbarLabel->Invalidate(false);
4551 __pProgressbarLabel->SetShowState(true);
4552 __pProgressbarLabel->Invalidate(false);
4555 r = canvas.Construct(Rectangle(0, 0, w, h));
4559 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4564 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4568 pBgBmp->Scale(Dimension(w, h));
4569 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4573 progressWidth = (double) (w) * __progressPercentage / 100;
4574 AppLogDebug("progressWidth: %d", progressWidth);
4575 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4577 if (pProgressBmp != null)
4579 pProgressBmp->Scale(Dimension(progressWidth, h));
4580 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4581 delete pProgressBmp;
4584 pRetBitmap = new (std::nothrow) Bitmap();
4586 if (pRetBitmap == null)
4588 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4592 pRetBitmap->Construct(canvas, canvas.GetBounds());
4594 if (__pProgressbarLabel != null && pRetBitmap != null)
4596 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4597 __pProgressbarLabel->Invalidate(false);
4600 if (pRetBitmap != null)
4609 MainForm::ReaderClicked()
4611 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
4615 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
4617 CreateReaderPanel();
4618 AppLogDebug("MainScene::ReaderClicked entered");
4621 /*if (__pArticleReaderPanel)
4623 AppLogDebug("showstate true for reader panel");
4624 __pArticleReaderPanel->SetShowState(true);
4625 __pArticleReaderPanel->Show();
4627 int xPos = __pArticleReaderPanel->GetX();
4628 int yPos = __pArticleReaderPanel->GetY();
4629 AppLog("ReaderClicked() xPos = %d",xPos);
4630 AppLog("ReaderClicked() yPos = %d",yPos);
4632 if (__pReaderData == null)
4637 String loadData = L"<html>\
4639 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
4644 background-color: transparent;\
4663 <body style='width:'";
4664 loadData.Append(bodyWidth);
4665 loadData.Append(L"px'>");
4666 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
4667 loadData.Append(*__pReaderData);
4668 loadData.Append(L"</body></html>");
4671 buf.Construct(loadData.GetLength());
4672 AppLogDebug("data->GetLength %d",loadData.GetLength());
4673 for (int z=0;z<loadData.GetLength();z++)
4676 loadData.GetCharAt(z,b);
4677 buf.SetByte((byte)b);
4681 if (__pWebReader != null)
4683 __pWebReader->LoadData(L"",buf,L"text/html");
4684 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
4688 AppLogDebug("cannot LoadData __pWebReader is null");
4693 void MainForm::SetAddressbarMode(AddressBarMode addMode)
4695 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
4697 __currentAddMode = addMode;
4701 case ADDRESSBAR_MODE_INVALID:
4706 case ADDRESSBAR_MODE_READER:
4708 __pStopBtn->SetShowState(false);
4709 __pRefreshBtn->SetShowState(false);
4710 __pClearBtn->SetShowState(false);
4711 __pReaderBtn->SetShowState(false);
4714 case ADDRESSBAR_MODE_LOADING:
4716 __pRefreshBtn->SetShowState(false);
4717 __pStopBtn->SetShowState(true);
4718 __pClearBtn->SetShowState(false);
4719 __pReaderBtn->SetShowState(false);
4722 case ADDRESSBAR_MODE_LOADING_COMPLETE:
4724 // SetUrl(__pAddressbar->GetUrl());
4726 __pRefreshBtn->SetShowState(true);
4727 __pStopBtn->SetShowState(false);
4728 __pClearBtn->SetShowState(false);
4729 __pReaderBtn->SetShowState(false);
4732 case ADDRESSBAR_MODE_EDIT:
4734 __pRefreshBtn->SetShowState(false);
4735 __pStopBtn->SetShowState(false);
4736 __pReaderBtn->SetShowState(false);
4737 __pClearBtn->SetShowState(true);
4744 OnAddressBarModeChanged();
4747 AddressBarMode MainForm::GetAddressbarMode(void)
4749 return __currentAddMode;
4752 void MainForm::SetUrl(const String& url)
4756 if (__pFooterUrlField != NULL)
4758 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
4759 if (removedHttpUrl.IsEmpty() == false)
4761 __pFooterUrlField->SetText(removedHttpUrl);
4762 if(__pAddressbar != NULL)
4763 __pAddressbar->SetUrl(__displayUrl);
4767 __pFooterUrlField->SetText(__displayUrl);
4768 if(__pAddressbar != NULL)
4769 __pAddressbar->SetUrl(__displayUrl);
4771 if(__pFooterUrlField)
4772 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
4773 __pFooterUrlField->Invalidate(false);
4774 if(__pAddressbar != NULL)
4775 __pAddressbar->Invalidate(true);
4776 // __pFooterUrlField->SetCursorPosition(0);
4781 MainForm::RemoveHttpTextFromDisplayURL(void)
4783 bool isHttpText = __displayUrl.Contains(L"http://");
4784 String updatedDisplayUrl;
4785 updatedDisplayUrl.Clear();
4787 if (isHttpText == true)
4789 __displayUrl.SubString(7,updatedDisplayUrl);
4791 return updatedDisplayUrl;
4794 void MainForm::OnSharePopupControlStarted(void)
4796 __pWebViewer->AddTouchEventListener(*this);
4799 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
4801 if (requestId == BACK_GROUND_APP_EVENT)
4803 if(__pWebViewer != null)
4805 __pWebViewer->Pause();
4808 else if(requestId == FORE_GROUND_APP_EVENT)
4810 if(__pWebViewer != null)
4812 __pWebViewer->Resume();
4818 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
4820 result r = E_SUCCESS;
4821 AppLog("akjshdasd 5");
4822 __pFooterPanel->SetShowState(true);
4825 __pWebViewer->SetFocus();
4826 else if(__pMostVisitedListView)
4827 __pMostVisitedListView->SetFocus();
4828 else if(__pMultiWindowButton)
4829 __pMultiWindowButton->SetFocus();
4830 __pMoreButton->SetFocus();
4832 __pAddressbar->SetShowState(false);
4834 RelayoutControls(false);