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 "IntInternetApp.h"
34 #include "IntMainForm.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* IDS_KEY = L"key";
73 static const wchar_t* IDS_VALUE = L"value";
74 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
75 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
76 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
78 const int IDA_BACKBTN_CLICKED = 101;
79 const int IDA_BOOKMARKBTN_CLICKED = 102;
80 const int IDA_MOREBTN_CLICKED = 103;
81 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
82 const int IDA_NEWWINDOWBTN_CLICKED = 105;
83 const int IDA_FORWARD_CLICKED = 106;
84 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
85 const int IDA_SHARE_CLICKED = 108;
86 const int IDA_FINDONPAGE_CLICKED = 109;
87 const int IDA_PRIVATEON_CLICKED = 110;
88 const int IDA_SETTINGS_CLICKED = 111;
89 const int IDA_READER_CLOSE_CLICKED = 112;
90 const int IDA_SMALLFONT_BTN_CLICKED = 113;
91 const int IDA_LARGEFONT_BTN_CLICKED = 114;
92 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
93 const int IDA_HISTORY_CLICKED = 116;
94 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
95 const int IDA_ADD_TO_HOME_CLICKED = 118;
96 const int IDA_SAVED_PAGES_CLICKED = 119;
97 const int IDA_DESKTOP_VIEW_CLICKED = 120;
98 const int IDA_SAVE_CLICKED = 121;
99 const int IDA_PRINT_CLICKED = 122;
101 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
102 const int IDA_FINDWORD_NEXT_CLICKED = 202;
103 const int IDA_FINDWORD_PREV_CLICKED = 203;
104 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
105 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
107 const int IDA_COPY_IMAGE_CLICKED = 206;
108 const int IDA_VIEW_IMAGE_CLICKED = 207;
109 const int IDA_SAVE_IMAGE_CLICKED = 208;
110 const int IDA_SHARE_IMAGE_CLICKED = 209;
112 const int IDA_COPY_TEXT_CLICKED = 210;
113 const int IDA_PASTE_TEXT_CLICKED = 211;
114 const int IDA_FIND_TEXT__CLICKED = 212;
115 const int IDA_SHARE_TEXT_CLICKED = 213;
117 const int IDA_GO_BACK = 214;
118 const int IDA_GO_FORWARD = 215;
119 const int IDA_REFRESH_BTN_CLICKED = 216;
120 const int IDA_STOP_BTN_CLICKED = 217;
121 const int IDA_CLEAR_URL = 218;
122 const int IDA_READER_BTN_CLICKED = 219;
125 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
126 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
127 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
128 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
130 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
132 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
134 const int MainForm::IDA_FORMAT_BITMAP = 500;
135 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
136 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
137 const int MainForm::IDA_FORMAT_URL_STRING = 503;
138 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
140 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
141 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
142 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
144 MainForm::MainForm(void)
146 //__isLongPressedDone = false;
148 __pAddressbar = null;
149 // __pMostVisitedSitesPanel = null;
150 __pMostVisitedListView = null;
151 __pFooterPanel = null;
152 __pHitElementResult = null;
153 __pWindowInfo = null;
156 __pOptionMenu = null;
157 __pFindWordControl = null;
158 __pFindWordPanelLeftToRight = null;
159 __pFindWordPanelRightToLeft = null;
160 __pFindWordBgLabel = null;
161 __pFindWordBgLabelRightToLeft = null;
162 __pFindWordEditField = null;
163 __pFindWordEditFieldRightToLeft = null;
164 __pFindWordClear = null;
165 __pFindWordClearRightToLeft = null;
166 __pFindWordCountLabel = null;
167 __pFindWordClearRightToLeft = null;
168 __pFindWordNext = null;
169 __pFindWordPrev = null;
170 __previousZoomLevel = 1.0;
172 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
175 __currentSearchStr = L"";
176 __currentSelectedStr = L"";
177 __maxOccurrances = 0;
178 __currentWordIndex = 0;
181 //__inputEventToBeSupressed = false;
182 __isLoadingData = false;
183 __isLoadingCompleted = false;
184 __progressPercentage = 0;
185 __touchPoint1 = Point(-1,-1);
186 __touchPoint2 = Point(-1,-1);
187 __longPressPoint = Point(-1,-1);
189 // __pReaderPopup = null;
190 __pReaderData = null;
192 __pReaderCloseBtn = null;
193 //__pNewWindowButton = null;
194 __pMoreButton = null;
195 __pMultiWindowButton = null;
196 __pArticleReaderPanel = null;
197 __pBlankPanel = null;
198 __pArticleReaderLabel = null;
199 __webControlHeight = 0;
200 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
201 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
202 __pMostVisitedSites = null;
203 __pFooterUrlField = null;
205 __pGoForwardBtn = null;
206 __pRefreshBtn = null;
207 __pProgressbarLabel = null;
208 __pFooterLabel = null;
212 __isWebKeypadOpened = false;
214 __pNotification = null;
217 MainForm::~MainForm(void)
219 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
223 __pAddressbar->SetAddressbarEventListener(null);
226 if(__pHistory != null)
232 if (__pReaderData != null)
234 delete __pReaderData;
235 __pReaderData = null;
238 if (__pPopUp != null)
244 if (__pHitElementResult != null)
246 delete __pHitElementResult;
247 __pHitElementResult = null;
250 String* pSelectedScene = NULL;
251 Object* pValue = NULL;
252 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
253 pSelectedScene = (String*) pValue;
255 /*if (pSelectedScene != null)
257 delete pSelectedScene;
259 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
263 MainForm::Initialize(void)
265 InternetApp* pInternet = static_cast<InternetApp*> (Application::GetInstance());
266 Construct(L"IDL_FORM_HW_KEY");
268 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER);
273 MainForm::OnInitializing(void)
275 AppLog("get client area width = %d",GetClientAreaBounds().width);
276 AppLog("get client area height = %d",GetClientAreaBounds().height);
277 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
278 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
280 __fontSize = CommonUtil::GetFontSize();
281 Panel* pFooterPanel = null;
283 __pSaveImage = new Image();
284 __pSaveImage->Construct();
286 // Setup back event listener
287 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
288 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
289 AddOrientationEventListener(*this);
291 AppLogDebug(" MainForm::OnInitializing ended");
292 if (__pMostVisitedSites == null)
294 __pMostVisitedSites = new(std::nothrow) ArrayList();
295 __pMostVisitedSites->Construct();
297 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
299 __pItemContext= new(std::nothrow) ListContextItem();
300 __pItemContext->Construct();
302 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
305 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
306 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
307 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
309 __pItemContextLandscape= new(std::nothrow) ListContextItem();
310 __pItemContextLandscape->Construct();
312 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
313 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316 SetFormMenuEventListener(this);
321 MainForm::InitAddressbar(void)
323 AppLogDebug("MainForm::InitAddressbar entered");
325 result r = E_SUCCESS;
327 if (__pAddressbar != null)
331 __pAddressbar = new(std::nothrow) Addressbar();
332 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
333 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
336 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
339 __pAddressbar->SetAddressbarEventListener(this);
340 AddControl(__pAddressbar);
341 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
342 SetControlAlwaysOnTop(*__pAddressbar, true);
343 __adressPanelPosition = __pAddressbar->GetPosition();
345 AppLogDebug("MainForm::InitAddressbar exit");
351 MainForm::CreateReaderPanel(void)
353 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
354 result r = E_FAILURE;
356 Button *pSmallFontBtn = null;
357 Button *pLargeFontBtn = null;
359 __pBlankPanel = new (std::nothrow) Panel();
360 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
362 __pArticleReaderPanel = new (std::nothrow) Panel();
363 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
365 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
366 if (__pReaderCloseBtn)
368 AppLogDebug("CreateReaderPanel() 6");
369 __pReaderCloseBtn->AddActionEventListener(*this);
370 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
373 __pWebReader = new (std::nothrow) Web();
374 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
376 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
377 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
379 r = __pWebReader->SetSetting(settings);
381 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
384 __pArticleReaderLabel = new Label();
385 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
387 __pBlankPanel->AddControl(__pArticleReaderLabel);
388 __pBlankPanel->AddControl(__pArticleReaderPanel);
389 AddControl(__pBlankPanel);
391 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
392 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
393 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
395 __pArticleReaderPanel->AddControl(__pWebReader);
396 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
397 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
398 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
400 if (pBitmap != null && pSrcBitmap != null)
402 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
404 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
406 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
409 pSmallFontBtn->AddActionEventListener(*this);
410 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
413 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
416 pLargeFontBtn->AddActionEventListener(*this);
417 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
426 if (pSrcBitmap != null)
432 SetControlAlwaysOnTop(*__pBlankPanel, true);
433 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
440 MainForm::InitWebControl()
442 AppLogDebug("MainForm::InitWebControl enter");
443 result r = E_SUCCESS;
444 AppLogDebug("InitWebControl");
446 if (__pAddressbar == null || __pFooterPanel == null)
449 const int Y_WEBCONTROL_POSITION = 0;
451 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
453 if (__pMostVisitedListView)
455 __pMostVisitedListView->SetShowState(false);
457 if (__pWebViewer != null)
459 AppLogDebug("Already initialized");
462 __pWebViewer = new(std::nothrow) Web();
463 if(__pWebViewer == NULL)
465 AppLogDebug("Initialization failed");
468 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
472 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
479 r = AddControl(__pWebViewer);
485 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
488 __webControlPosition = __pWebViewer->GetPosition();
489 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
492 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
496 __pWebViewer->SetLoadingListener(this);
497 __pWebViewer->SetWebUiEventListenerF(this);
498 __pWebViewer->SetWebKeypadEventListener(this);
499 __pWebViewer->SetFocus();
500 __pWebViewer->AddTouchEventListener(*this);
502 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
503 __pWebViewer->SetTextSearchListener(this);
506 AppLogDebug("MainForm :before return");
508 AppLogDebug("MainForm::InitWebControl Exit");
514 MainForm::SetJavascriptEnabled()
516 WebSetting settings = __pWebViewer->GetSetting();
517 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
518 __pWebViewer->SetSetting(settings);
522 MainForm::SetImageLoadEnabled()
524 WebSetting settings = __pWebViewer->GetSetting();
525 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
526 __pWebViewer->SetSetting(settings);
530 MainForm::InitFooter(void)
532 AppLogDebug("MainForm::InitFooter entered");
533 Button* pBackButton = null;
534 Button* pBookmarkButton = null;
535 Button* pMultiWindowButton = null;
536 Bitmap *pIconBitmap = null;
537 Bitmap *pBGBitmap = null;
538 Label *pBGLabel = null;
540 if (__pFooterPanel == null)
542 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
545 if (__pFooterPanel == null)
550 SetControlAlwaysOnTop(*__pFooterPanel, true);
552 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
553 if ( __pFooterLabel == NULL )
557 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
558 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
561 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
565 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
567 if ( __pMultiWindowButton == NULL )
573 SetFormBackEventListener(this);
574 if (__pMultiWindowButton != null)
576 Bitmap* pBitmap = null;
577 Bitmap* pPressedBitmap = null;
578 String imagePath = "I01_toolbar_icon_windows_manager_0";
579 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
580 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
581 imagePath.Append(totalCount);
582 imagePath.Append(".png");
584 pressedImagePath.Append(totalCount);
585 pressedImagePath.Append("_press.png");
587 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
588 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
589 if ( pBitmap == null )
594 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
597 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
598 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
603 __pMultiWindowButton->AddActionEventListener(*this);
604 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
609 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
610 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
613 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
614 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
615 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
619 __pMoreButton->AddActionEventListener(*this);
620 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
623 //Add the editfield for url
624 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
625 if (__pFooterUrlField == NULL)
627 return E_INVALID_KEY;
630 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
631 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
632 __pFooterUrlField->AddKeypadEventListener(*this);
633 __pFooterUrlField->SetPropagatedTouchEventListener(this);
635 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
637 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
639 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
641 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
645 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
646 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
650 //Add the go Back Button
651 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
652 if (__pGoBackBtn == NULL)
654 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
655 return E_INVALID_KEY;
657 __pGoBackBtn->SetActionId(IDA_GO_BACK);
658 __pGoBackBtn->AddActionEventListener(*this);
660 //Add the go forward Button
661 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
662 if (__pGoForwardBtn == NULL)
664 AppLogDebug("Control not found returning E_INVALID_KEY");
665 return E_INVALID_KEY;
667 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
668 __pGoForwardBtn->AddActionEventListener(*this);
669 if (__pWebViewer && __pWebViewer->CanGoForward())
671 SetForwardButtonEnabled(true);
675 SetForwardButtonEnabled(false);
678 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
679 if (__pRefreshBtn == NULL)
681 AppLogDebug("Control not found returning E_INVALID_KEY");
682 return E_INVALID_KEY;
685 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
686 __pRefreshBtn->AddActionEventListener(*this);
687 __pRefreshBtn->SetShowState(true);
689 //Add the backround label for displaying progressbar
690 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
691 if (__pProgressbarLabel == NULL)
693 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
694 return E_INVALID_KEY;
696 __pProgressbarLabel->SetShowState(false);
698 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
699 if (__pStopBtn == NULL)
701 AppLogDebug("Control not found returning E_INVALID_KEY");
702 return E_INVALID_KEY;
704 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
705 __pStopBtn->AddActionEventListener(*this);
706 __pStopBtn->SetShowState(false);
708 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
709 if (__pClearBtn == NULL)
711 AppLogDebug("Control not found returning E_INVALID_KEY");
712 return E_INVALID_KEY;
714 __pClearBtn->SetActionId(IDA_CLEAR_URL);
715 __pClearBtn->AddActionEventListener(*this);
716 __pClearBtn->SetShowState(false);
718 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
719 if (__pReaderBtn == NULL)
721 AppLogDebug("Control not found returning E_INVALID_KEY");
722 return E_INVALID_KEY;
724 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
725 __pReaderBtn->AddActionEventListener(*this);
726 __pReaderBtn->SetShowState(false);
728 // __pFooterPanel->Invalidate(true);
729 AppLogDebug("MainForm::InitFooter exit");
734 MainForm::InitOptionMenu()
736 result r = E_SUCCESS;
737 bool isPrivateBrowsing = false;
738 Bitmap* pBitmap = null;
740 if (__pOptionMenu != null)
742 __pOptionMenu->Invalidate(true);
746 __pOptionMenu = new(std::nothrow) OptionMenu();
747 r = __pOptionMenu->Construct();
748 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
750 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
753 if (isPrivateBrowsing == true)
755 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
759 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
762 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
764 if ( pBitmap != NULL)
766 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
769 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
770 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
771 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
774 __pOptionMenu->SetMaxVisibleItemsCount(6);
775 __pOptionMenu->SetShowState(false);
776 __pOptionMenu->AddActionEventListener(*this);
777 SetControlAlwaysOnTop(*__pOptionMenu, true);
783 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
785 result r = E_SUCCESS;
786 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
788 AppLog("MainForm::InitImageContextMenu clicked on image");
789 if (__pImageMenu != null)
795 __pImageMenu = new (std::nothrow) ContextMenu();
796 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
797 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
799 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
800 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
801 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
802 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
803 __pImageMenu->SetMaxVisibleItemsCount(4);
804 __pImageMenu->AddActionEventListener(*this);
805 SetControlAlwaysOnTop(*__pImageMenu, true);
811 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
813 result r = E_SUCCESS;
814 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
816 AppLog("MainForm::InitImageContextMenu clicked on image");
817 if (__pImageMenu != null)
823 if(__pAddressbar->GetShowState() == true)
824 p.y = p.y + __pAddressbar->GetHeight();
825 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
830 __pImageMenu = new (std::nothrow) ContextMenu();
831 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
832 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
834 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
835 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
836 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
837 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
839 __pImageMenu->SetMaxVisibleItemsCount(3);
840 __pImageMenu->AddActionEventListener(*this);
841 SetControlAlwaysOnTop(*__pImageMenu, true);
848 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
850 result r = E_SUCCESS;
851 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
853 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
854 if (__pImageMenu != null)
863 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
867 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
869 __pImageMenu = new (std::nothrow) ContextMenu();
870 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
871 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
873 if(onlyPasteOption == false)
875 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
877 if (pasteOption || onlyPasteOption)
879 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
881 if(onlyPasteOption == false)
883 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
884 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
887 __pImageMenu->SetMaxVisibleItemsCount(3);
888 __pImageMenu->AddActionEventListener(*this);
889 SetControlAlwaysOnTop(*__pImageMenu, true);
898 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
900 result r = E_SUCCESS;
901 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
903 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
904 if (__pImageMenu != null)
913 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
917 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
919 __pImageMenu = new (std::nothrow) ContextMenu();
920 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
921 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
923 if(onlyPasteOption == false)
925 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
927 if (pasteOption || onlyPasteOption)
929 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
931 if(onlyPasteOption == false)
933 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
934 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
937 __pImageMenu->SetMaxVisibleItemsCount(3);
938 __pImageMenu->AddActionEventListener(*this);
939 SetControlAlwaysOnTop(*__pImageMenu, true);
946 MainForm::InitFindWordPanel(void)
948 result r = E_SUCCESS;
949 Bitmap *pIconBitmap = null;
951 if (__pFindWordControl != null)
953 AppLogDebug("Findword panel already initialized");
954 if (__pFindWordBgLabel != null)
956 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
959 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
963 if (__pFindWordBgLabelRightToLeft != null)
965 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
968 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
975 __pFindWordControl = new (std::nothrow) Panel();
976 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
979 AppLogException("There is some problem in the xml file. Please check.");
982 AddControl(__pFindWordControl);
983 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
984 SetControlAlwaysOnTop(*__pFindWordControl,true);
985 __pFindWordControl->SetShowState(false);
986 __pFindWordControl->Invalidate(false);
988 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
989 __pFindWordPanelLeftToRight->SetShowState(true);
991 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
992 __pFindWordPanelRightToLeft->SetShowState(false);
994 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
995 if (__pFindWordBgLabel != null)
997 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
998 Rectangle pRect = pPanel1->GetBounds();
999 pRect.x = pRect.y = 0;
1000 __pFindWordBgLabel->SetBounds(pRect);
1001 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1002 if (pBitmap != null)
1004 AppLogDebug("InitFindWordPanel: Coming here");
1005 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1010 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1014 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1015 if (__pFindWordBgLabelRightToLeft != null)
1017 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1018 Rectangle pRect = pPanel1->GetBounds();
1019 pRect.x = pRect.y = 0;
1020 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1021 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1022 if (pBitmap != null)
1024 AppLogDebug("InitFindWordPanel: Coming here");
1025 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1030 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1034 Button* pfindWordCancel = null;
1035 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1036 if (pfindWordCancel == null)
1038 AppLogException("There is some problem in the xml file. Please check.");
1041 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1042 pfindWordCancel->AddActionEventListener(*this);
1044 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1045 if (__pFindWordClear == null)
1047 AppLogException("There is some problem in the xml file. Please check.");
1051 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1052 if (__pFindWordClearRightToLeft == null)
1054 AppLogException("There is some problem in the xml file. Please check.");
1058 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1059 __pFindWordClear->AddActionEventListener(*this);
1061 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1062 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1064 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1065 if (__pFindWordNext == null)
1067 AppLogException("There is some problem in the xml file. Please check.");
1071 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1072 __pFindWordNext->AddActionEventListener(*this);
1074 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1075 if (__pFindWordPrev == null)
1077 AppLogException("There is some problem in the xml file. Please check.");
1081 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1082 __pFindWordPrev->AddActionEventListener(*this);
1084 __pFindWordNext->SetEnabled(false);
1085 __pFindWordPrev->SetEnabled(false);
1087 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1088 if (__pFindWordCountLabel == null)
1090 AppLogException("There is some problem in the xml file. Please check.");
1094 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1095 if (__pFindWordCountLabel == null)
1097 AppLogException("There is some problem in the xml file. Please check.");
1101 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1102 if (__pFindWordEditField == null)
1104 AppLogException("There is some problem in the xml file. Please check.");
1107 __pFindWordEditField->AddTextEventListener(*this);
1108 __pFindWordEditField->AddKeypadEventListener(*this);
1109 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1111 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1112 if (__pFindWordEditFieldRightToLeft == null)
1114 AppLogException("There is some problem in the xml file. Please check.");
1117 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1118 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1119 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1125 MainForm::CreateItem (int index, int itemWidth)
1127 Rectangle listImageRect;
1128 Rectangle pagetTitleRect;
1129 Rectangle pageURLRect;
1130 Rectangle deleteImageRect;
1131 String pageTitle(L"");
1132 String pageURL(L"");
1133 result r = E_SUCCESS;
1134 Bitmap* pListIconImage = null;
1137 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1138 if(pHistory == null)
1142 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1143 if ( pAppResource == NULL )
1147 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1149 CustomItem* pItem = new(std::nothrow) CustomItem();
1150 pageTitle = pHistory->GetHistoryTitle();
1151 pageURL = pHistory->GetHistoryUrl();
1153 if (pageURL.GetLength() == 0)
1156 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1157 pageURL = L"<"+ nourl +">";
1161 Rectangle screenBounds = GetBounds();
1164 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1173 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1175 if ( pBitmap != NULL)
1177 pListIconImage = new Bitmap();
1178 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1182 if(pListIconImage == null)
1184 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1187 if ( pListIconImage != NULL)
1189 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1190 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1191 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1194 if (pItem != null && pListIconImage != NULL)
1196 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1200 if (pageTitle.CompareTo(L"") != 0)
1204 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1208 if (pageURL.CompareTo(L"") != 0)
1212 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1217 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1219 if ( __pItemContext!= NULL)
1223 pItem->SetContextItem(__pItemContext);
1229 if ( __pItemContextLandscape!= NULL)
1233 pItem->SetContextItem(__pItemContextLandscape);
1237 if( pListIconImage != NULL)
1239 delete pListIconImage;
1240 pListIconImage = null;
1247 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1254 MainForm::GetItemCount (void)
1256 if(__pMostVisitedSites != null)
1258 __pMostVisitedSites->RemoveAll(true);
1260 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1261 if(__pMostVisitedSites != null)
1263 return __pMostVisitedSites->GetCount();
1270 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1272 if(__pMostVisitedSites != null)
1274 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1275 if (pHistory != null)
1277 String url = pHistory->GetHistoryUrl();
1279 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1280 __pMostVisitedListView->UpdateList();
1286 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1288 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1289 String url = pHistory->GetHistoryUrl();
1297 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1303 MainForm::OnTerminating(void)
1305 result r = E_SUCCESS;
1307 RemoveOrientationEventListener(*this);
1311 __pAddressbar->SetAddressbarEventListener(null);
1316 __pWebViewer->RemoveTouchEventListener(*this);
1321 delete __pItemContext;
1323 if(__pItemContextLandscape)
1325 delete __pItemContextLandscape;
1331 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1333 result r = E_SUCCESS;
1335 AppLogDebug("Clicked : %d", actionId);
1338 case IDA_BACKBTN_CLICKED:
1340 if (__pWebViewer && __pWebViewer->CanGoBack())
1342 __pWebViewer->GoBack();
1344 else if(__pWindowInfo->isJavascriptInitiated == false)
1347 pApp = UiApp::GetInstance();
1350 r = pApp->Terminate();
1353 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1361 WindowInfo* pWindowInfo = null;
1363 SceneManager* pSceneManager = SceneManager::GetInstance();
1364 if (pSceneManager == null)
1368 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1369 if (pAllWindowList == NULL)
1371 pApp = UiApp::GetInstance();
1374 r = pApp->Terminate();
1377 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1382 if (pAllWindowList != null)
1384 totalCount = pAllWindowList->GetCount();
1386 for (int count = 0; count < totalCount; count++)
1388 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1389 if (pWindowInfo == null)
1391 pApp = UiApp::GetInstance();
1394 r = pApp->Terminate();
1397 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1404 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1406 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1409 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1412 r = pAllWindowList->RemoveAt(count, true);
1413 __pWindowInfo = null;
1416 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1421 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1425 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1427 if (pWindowInfo == null)
1429 pApp = UiApp::GetInstance();
1432 r = pApp->Terminate();
1438 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1441 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1453 case IDA_FORWARD_CLICKED:
1454 if (__pWebViewer == null)
1457 if (__pWebViewer->CanGoForward())
1459 __pWebViewer->GoForward();
1461 __pOptionMenu->SetShowState(false);
1462 __pOptionMenu->Invalidate(false);
1465 case IDA_FINDONPAGE_CLICKED:
1467 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1468 __currentSearchStr.Clear();
1470 InitFindWordPanel();
1471 __pOptionMenu->SetShowState(false);
1472 __pOptionMenu->Invalidate(false);
1474 ShowFindWordPanel(true);
1476 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1478 __pFindWordEditField->SetFocus();
1479 __pFindWordCountLabel->SetShowState(false);
1483 __pFindWordEditFieldRightToLeft->SetFocus();
1484 __pFindWordCountLabelRightToLeft->SetShowState(false);
1488 case IDA_PRIVATEON_CLICKED:
1490 result r = E_SUCCESS;
1492 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1493 Bitmap* pBitmap = null;
1494 if (isPrivateBrowsing == true)
1496 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1499 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1503 if (__pWebViewer != NULL)
1505 __pWebViewer->SetPrivateBrowsingEnabled(false);
1508 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1510 if (__pAddressbar != null)
1512 __pAddressbar->UpdateFaviconBitmap(false);
1518 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1521 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1525 if (__pWebViewer != NULL)
1527 __pWebViewer->SetPrivateBrowsingEnabled(true);
1530 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1532 if (__pAddressbar != null)
1534 __pAddressbar->UpdateFaviconBitmap(true);
1538 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1539 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1540 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1541 __pOptionMenu->Invalidate(true);
1542 if ( pBitmap != NULL )
1549 case IDA_SETTINGS_CLICKED:
1552 ArrayList* pArgList = new(std::nothrow) ArrayList();
1555 pArgList->Construct();
1556 pArgList->Add(*__pWindowInfo);
1557 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1559 __pOptionMenu->SetShowState(false);
1560 __pOptionMenu->Invalidate(false);
1562 if (pArgList != null)
1571 case IDA_ADDTOBOOKMARK_CLICKED:
1574 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1576 int bookmarkCount=0;
1579 url=__pWindowInfo->pageUrl;
1580 result r = E_SUCCESS;
1581 Bitmap* pBitmap = null;
1582 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1590 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1591 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1592 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1594 if(__pNotification != null)
1596 delete __pNotification;
1597 __pNotification = null;
1599 __pNotification = new (std::nothrow) NotificationPanel(*this);
1600 if (__pNotification != null)
1602 __pNotification->SetText(message);
1603 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1604 __pNotification->ShowNotification();
1609 String title=__pWindowInfo->pageTitle;
1610 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1611 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1613 pBookmark->SetBookmarkTitle(title);
1614 pBookmark->SetUrl(url);
1615 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1617 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1619 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1620 pBookmark->SetFaviconId(id);
1621 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1622 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1624 if(__pNotification != null)
1626 delete __pNotification;
1627 __pNotification = null;
1629 __pNotification = new (std::nothrow) NotificationPanel(*this);
1630 if (__pNotification != null)
1632 __pNotification->SetText(message);
1633 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1634 __pNotification->ShowNotification();
1635 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1638 if (pBitmap != null)
1640 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1645 __pOptionMenu->Invalidate(true);
1650 case IDA_PRINT_CLICKED:
1652 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1653 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1655 AppLog("RequestPrint called!");
1656 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1657 result nResult = E_FAILURE;
1660 AppLog("TestPrint if (pAc) == true");
1665 String fileType = L"service_print_files_type";
1666 String typeVal = L"DOC";
1668 String fileCount = L"service_print_files_count";
1669 String countVal = L"1";
1670 String fileFolder= L"service_print_files_folder_name";
1671 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1673 map.Add(&fileCount, &countVal);
1674 map.Add(&fileFolder, &folderVal);
1675 map.Add(&fileType, &typeVal);
1677 String fileName = L"service_print_files_files_name";
1679 ArrayList fileNameList;
1680 fileNameList.Construct();
1681 String file1 = L"test.pdf";
1683 fileNameList.Add(&file1);
1684 map.Add(&fileName, &fileNameList);
1686 nResult = pAc->Start(NULL, NULL, &map, NULL);
1688 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1689 else if (nResult == E_MAX_EXCEEDED)
1690 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1691 else if (nResult == E_OBJ_NOT_FOUND)
1692 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1693 else if (nResult == E_IN_PROGRESS)
1694 AppLog("TestPrint ret == E_IN_PROGRESS");
1695 else if (nResult == E_PRIVILEGE_DENIED)
1696 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1697 else if(nResult == E_SYSTEM)
1698 AppLog("TestPrint ret == E_SYSTEM");
1704 int __modalMsgBoxResult;
1705 MessageBox* pMsgBox = new MessageBox();
1706 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1707 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1710 __modalMsgBoxResult = 0;
1714 case IDA_SHARE_CLICKED:
1716 if(__pPopUp != null)
1723 __pAddressbar->HideKeypad();
1725 __pPopUp = new(std::nothrow) SharePopup();
1726 __pPopUp->Initialize();
1727 if (__pWindowInfo != null)
1729 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1730 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1731 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1732 pShareInfo->SetImageAttached(false);
1733 __pPopUp->RemoveAllShareInfo();
1734 __pPopUp->AddShareInfo(pShareInfo);
1736 __pPopUp->SetShowState(true);
1740 case IDA_BOOKMARKBTN_CLICKED:
1742 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1743 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1746 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1751 case IDA_MOREBTN_CLICKED:
1753 AppLog("IDA_MOREBTN_CLICKED");
1755 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1757 int bookmarkCount=0;
1760 url=__pWindowInfo->pageUrl;
1761 result r = E_SUCCESS;
1762 Bitmap* pBitmap = null;
1764 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1767 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1772 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1776 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1778 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1780 if (__pOptionMenu->GetItemCount() == 9)
1782 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1786 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1791 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1795 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1796 if (__pOptionMenu->GetItemCount() != 9)
1798 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1799 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1800 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1801 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1802 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1803 __pOptionMenu->SetMaxVisibleItemsCount(6);
1805 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1807 AppLog(" Orientation landscape");
1808 __pOptionMenu->SetMaxVisibleItemsCount(5);
1812 AppLog(" Orientation potrait");
1813 __pOptionMenu->SetMaxVisibleItemsCount(6);
1816 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1819 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1820 __pOptionMenu->SetShowState(true);
1821 __pOptionMenu->Invalidate(true);
1822 __pOptionMenu->Show();
1826 case IDA_HISTORY_CLICKED:
1828 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1829 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1832 case IDA_SAVED_PAGES_CLICKED:
1837 case IDA_DESKTOP_VIEW_CLICKED:
1842 case IDA_SAVE_CLICKED:
1847 case IDA_MULTIWINDOWBTN_CLICKED:
1849 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1850 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1854 case IDA_NEWWINDOWBTN_CLICKED:
1856 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1858 if (pNewWindowInfo == null)
1862 result r = E_SUCCESS;
1863 SceneManager* pSceneManager = SceneManager::GetInstance();
1865 if (pSceneManager == NULL)
1869 ArrayList* pArgList = new(std::nothrow) ArrayList();
1870 if (pArgList == NULL)
1874 r = pArgList->Construct();
1877 pArgList->Add(*pNewWindowInfo);
1878 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1884 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1889 case IDA_SMALLFONT_BTN_CLICKED:
1891 WebSetting setting = __pWebReader->GetSetting();
1892 setting.SetFontSize(15);
1893 __pWebReader->SetSetting(setting);
1896 case IDA_LARGEFONT_BTN_CLICKED:
1898 WebSetting setting = __pWebReader->GetSetting();
1899 setting.SetFontSize(25);
1900 __pWebReader->SetSetting(setting);
1903 case IDA_READER_CLOSE_CLICKED:
1905 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1907 RemoveControl(__pBlankPanel);
1908 __pArticleReaderPanel = null;
1909 __pBlankPanel = null;
1910 __pArticleReaderLabel = null;
1912 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1915 case IDA_FINDWORD_CANCEL_CLICKED:
1917 __currentSearchStr = L"";
1918 __currentWordIndex = 0;
1919 __maxOccurrances = 0;
1921 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1923 __pFindWordEditField->SetText(L"");
1924 __pFindWordCountLabel->SetText(L"0/0");
1926 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1928 __pFindWordEditFieldRightToLeft->SetText(L"");
1929 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1932 __pFindWordNext->SetEnabled(false);
1933 __pFindWordPrev->SetEnabled(false);
1934 __pFindWordCountLabel->SetText(L"0/0");
1935 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1936 AppLog("akjshdasd 1");
1937 __pFooterPanel->SetShowState(true);
1938 ShowFindWordPanel(false);
1941 case IDA_FINDWORD_SEARCH_CLICKED:
1943 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1945 __currentSearchStr = __pFindWordEditField->GetText();
1947 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1949 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1952 if (__currentSearchStr.GetLength() > 0)
1958 AppLogDebug("Enter something");
1962 case IDA_FINDWORD_CLEAR_CLICKED:
1964 __pFindWordCountLabel->SetText(L"0/0");
1965 __pFindWordEditField->SetText(L"");
1966 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1968 __currentSearchStr = L"";
1969 __pFindWordNext->SetEnabled(false);
1970 __pFindWordPrev->SetEnabled(false);
1971 __pFindWordCountLabel->SetShowState(false);
1972 __pFindWordControl->Invalidate(true);
1975 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1977 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1978 __pFindWordEditFieldRightToLeft->SetText(L"");
1979 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1981 __currentSearchStr = L"";
1982 __pFindWordNext->SetEnabled(false);
1983 __pFindWordPrev->SetEnabled(false);
1984 __pFindWordCountLabelRightToLeft->SetShowState(false);
1985 __pFindWordControl->Invalidate(true);
1988 case IDA_FINDWORD_NEXT_CLICKED:
1993 case IDA_FINDWORD_PREV_CLICKED:
1995 FindNextWord(false);
1998 case IDA_BRIGHTNESS_BTN_CLICKED:
2000 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2001 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2004 case IDA_COPY_IMAGE_CLICKED:
2006 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2007 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2009 const Bitmap* pBitmap = null;
2010 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2012 pBitmap = __pHitElementResult->GetImage();
2015 String resourcePath = App::GetInstance()->GetAppResourcePath();
2016 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2017 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2018 // copying the item to clipboard
2019 Clipboard* pClipboard = Clipboard::GetInstance();
2020 if (pClipboard != null)
2022 r = pClipboard->CopyItem(item);
2023 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2027 case IDA_VIEW_IMAGE_CLICKED:
2029 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2030 WindowInfo* pNewWindowInfo = null;
2031 if (__pHitElementResult != null)
2033 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2034 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2040 case IDA_SAVE_IMAGE_CLICKED:
2042 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2043 const Bitmap* pSaveBitmap = null;
2044 String imageName = GetImagePath();
2045 AppLog("Content manager image name %ls",imageName.GetPointer());
2048 imagePath.Append(imageName);
2049 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2050 AppLog("Content manager image path %ls",imagePath.GetPointer());
2051 if (__pHitElementResult != null)
2053 pSaveBitmap = __pHitElementResult->GetImage();
2055 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2059 UpdateImageContent(pBuffer, imageName);
2061 if(__pNotification != null)
2063 delete __pNotification;
2064 __pNotification = null;
2066 __pNotification = new NotificationPanel(*this);
2068 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2069 msg.Append(imagePath);
2070 if (__pNotification != null)
2072 __pNotification->SetText(msg);
2073 if (__pFooterPanel->GetShowState() == true)
2075 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2079 __pNotification->SetPositionDiff(0);
2082 __pNotification->ShowNotification();
2087 int __modalMsgBoxResult;
2088 MessageBox* pMsgBox = new MessageBox();
2089 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2090 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2093 __modalMsgBoxResult = 0;
2097 case IDA_SHARE_IMAGE_CLICKED:
2099 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2100 if (__pPopUp != null)
2107 __pAddressbar->HideKeypad();
2109 __pPopUp = new(std::nothrow) SharePopup();
2110 __pPopUp->Initialize();
2111 if (__pHitElementResult != null)
2113 const Bitmap* pSaveBitmap = null;
2114 String imageName = GetImagePath();
2115 AppLog("Content manager image name %ls",imageName.GetPointer());
2118 imagePath.Append(imageName);
2119 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2120 AppLog("Content manager image path %ls",imagePath.GetPointer());
2121 if (__pHitElementResult != null)
2123 pSaveBitmap = __pHitElementResult->GetImage();
2125 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2127 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2128 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2130 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2131 pShareInfo->SetPageTitle(L"");
2132 pShareInfo->SetPageUrl(srcUrl);
2133 pShareInfo->SetImageAttached(true);
2134 pShareInfo->SetImagePath(imagePath);
2135 __pPopUp->RemoveAllShareInfo();
2136 __pPopUp->AddShareInfo(pShareInfo);
2137 __pPopUp->SetShowState(true);
2142 case IDA_HYPERLINK_OPEN_CLICKED:
2144 if (__pHitElementResult != null)
2146 String srcUrl = __pHitElementResult->GetUrl();
2148 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2150 if (pNewWindowInfo == null)
2154 result r = E_SUCCESS;
2155 SceneManager* pSceneManager = SceneManager::GetInstance();
2156 if (pSceneManager == NULL)
2160 ArrayList* pArgList = new(std::nothrow) ArrayList();
2161 if (pArgList == NULL)
2165 pArgList->Construct();
2167 pArgList->Add(*pNewWindowInfo);
2168 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2169 if (pArgList != null)
2176 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2182 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2184 if (__pHitElementResult == null)
2189 if(__pPopUp != null)
2196 __pAddressbar->HideKeypad();
2198 __pPopUp = new(std::nothrow) SharePopup();
2199 __pPopUp->Initialize();
2201 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2202 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2203 pShareInfo->SetImageAttached(false);
2204 __pPopUp->RemoveAllShareInfo();
2205 __pPopUp->AddShareInfo(pShareInfo);
2207 __pPopUp->SetShowState(true);
2211 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2215 if (__pHitElementResult != null)
2217 url = __pHitElementResult->GetUrl();
2220 String resourcePath = App::GetInstance()->GetAppResourcePath();
2221 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2223 // copying the item to clipboard
2224 Clipboard* pClipboard = Clipboard::GetInstance();
2225 if (pClipboard != null)
2227 pClipboard->CopyItem(item);
2231 case IDA_FIND_TEXT__CLICKED:
2233 // AddressBarCancelledClicked(*__pAddressbar);
2234 RelayoutControls(false);
2235 // __pFooterPanel->SetShowState(false);
2236 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2237 __currentSearchStr.Clear();
2238 __currentSearchStr.Append(__currentSelectedStr);
2239 InitFindWordPanel();
2240 __pFindWordEditField->SetText(__currentSearchStr);
2242 if(__pOptionMenu != null)
2244 __pOptionMenu->SetShowState(false);
2245 __pOptionMenu->Invalidate(false);
2247 __adressPanelPosition.y = 0;
2249 if (__pAddressbar != null && __pWebViewer != NULL)
2251 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2252 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2254 if (__pFooterPanel->GetShowState() == false)
2255 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2257 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2258 __pWebViewer->Invalidate(true);
2261 ShowFindWordPanel(true);
2262 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2264 __pFindWordEditField->SetText(__currentSearchStr);
2265 __pFindWordEditField->SetFocus();
2267 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2269 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2270 __pFindWordEditFieldRightToLeft->SetFocus();
2273 if (__currentSearchStr.GetLength() > 0)
2279 AppLogDebug("Enter something");
2282 if (__pWebViewer != null)
2284 // releasing the set block
2285 __pWebViewer->ReleaseBlock();
2290 case IDA_SHARE_TEXT_CLICKED:
2292 __pWebViewer->ReleaseBlock();
2293 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2294 if(__pPopUp != null)
2301 __pAddressbar->HideKeypad();
2303 __pPopUp = new(std::nothrow) SharePopup();
2304 __pPopUp->Initialize();
2305 if (__pHitElementResult != null)
2307 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2308 pShareInfo->SetPageTitle(L"");
2309 pShareInfo->SetPageUrl(__currentSelectedStr);
2310 pShareInfo->SetImageAttached(false);
2311 __pPopUp->RemoveAllShareInfo();
2312 __pPopUp->AddShareInfo(pShareInfo);
2313 __pPopUp->SetShowState(true);
2318 case IDA_COPY_TEXT_CLICKED:
2320 __pWebViewer->ReleaseBlock();
2321 // need to implement
2322 //__currentSelectedStr
2323 // Sets data to a clip board item
2325 String resourcePath = App::GetInstance()->GetAppResourcePath();
2326 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2328 // copying the item to clipboard
2329 Clipboard* pClipboard = Clipboard::GetInstance();
2330 if (pClipboard != null)
2332 pClipboard->CopyItem(item);
2336 case IDA_PASTE_TEXT_CLICKED:
2338 Clipboard* pClipboard = Clipboard::GetInstance();
2340 if(pClipboard == null)
2344 // Retrieves a latest item
2345 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2351 //Gets data from the clipboard item
2352 String* pString = dynamic_cast<String*>(pItem->GetData());
2354 if (pString != null)
2356 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2357 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2358 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2361 if(idElement.GetLength() != 0)
2363 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; } } ";
2364 script.Append("insertAtCursor('");
2365 script.Append(idElement);
2366 script.Append("',");
2367 script.Append("\"");
2368 script.Append(*pString);
2369 script.Append("\");");
2371 else if (nameElement.GetLength() != 0)
2373 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; } } ";
2374 script.Append("insertAtCursor(document.getElementsByName('");
2375 script.Append(nameElement);
2376 script.Append("')[0],");
2377 script.Append("\"");
2378 script.Append(*pString);
2379 script.Append("\");");
2381 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2382 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2393 case IDA_GO_FORWARD:
2398 case IDA_REFRESH_BTN_CLICKED:
2400 __isLoadingCompleted = false;
2401 __isLoadingData = true;
2402 __progressPercentage = 0;
2403 __displayUrl = __pFooterUrlField->GetText();
2405 String url = __pFooterUrlField->GetText();
2406 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2408 if (__pWebViewer != null && __pAddressbar != null)
2410 __pWebViewer->Reload();
2411 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2415 UpdateProgressBitmap();
2418 case IDA_STOP_BTN_CLICKED:
2420 __isLoadingCompleted = false;
2421 __isLoadingData = false;
2422 __progressPercentage = 0;
2423 __pFooterUrlField->HideKeypad();
2424 __displayUrl = __pFooterUrlField->GetText();
2428 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2429 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2430 __pWebViewer->StopLoading();
2431 RequestRedraw(true);
2434 UpdateProgressBitmap();
2439 if (__pFooterUrlField->GetText().IsEmpty() == false)
2441 //__displayUrl = __pUrlField->GetText();
2442 __pFooterUrlField->Clear();
2447 case IDA_READER_BTN_CLICKED:
2458 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2460 result r = E_FAILURE;
2461 if (__pWebViewer && __pWebViewer->CanGoBack())
2463 __pWebViewer->GoBack();
2465 else if(__pWindowInfo->isJavascriptInitiated == false)
2468 pApp = UiApp::GetInstance();
2471 r = pApp->Terminate();
2474 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2482 WindowInfo* pWindowInfo = null;
2484 SceneManager* pSceneManager = SceneManager::GetInstance();
2485 if (pSceneManager == null)
2489 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2490 if (pAllWindowList == NULL)
2492 pApp = UiApp::GetInstance();
2495 r = pApp->Terminate();
2498 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2503 if (pAllWindowList != null)
2505 totalCount = pAllWindowList->GetCount();
2507 for (int count = 0; count < totalCount; count++)
2509 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2510 if (pWindowInfo == null)
2512 pApp = UiApp::GetInstance();
2515 r = pApp->Terminate();
2518 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2525 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2527 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2530 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2533 r = pAllWindowList->RemoveAt(count, true);
2534 __pWindowInfo = null;
2537 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2542 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2546 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2548 if (pWindowInfo == null)
2550 pApp = UiApp::GetInstance();
2553 r = pApp->Terminate();
2559 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2562 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2574 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2575 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2577 AppLog("MainForm::OnSceneActivatedN called");
2578 String* pSelectedScene = NULL;
2579 Object* pValue = NULL;
2580 String* pUrl = null;
2581 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2582 pSelectedScene = (String*) pValue;
2584 if (pSelectedScene != null)
2586 delete pSelectedScene;
2588 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2589 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2590 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2591 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2593 // setting the current scene ID
2594 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2596 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2598 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2600 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2601 if(__pWindowInfo == null)
2603 // if(__pWindowInfo == null)
2605 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2608 else if ( pArgs != null && pArgs->GetCount() == 1)
2610 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2616 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2618 // hiding the address bar
2619 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2620 __pAddressbar->SetShowState(false);
2621 // if(__pWebViewer != null)
2623 // __pWebViewer->Resume();
2626 if(pUrl != null && pUrl->GetLength() > 0)
2630 else if(__pWindowInfo != null)
2632 if(__pWindowInfo->pageUrl.GetLength() > 0 &&previousSceneId != IDSCN_BRIGHTNESS && previousSceneId != IDSCN_HISTORY_LIST && previousSceneId != IDSCN_MULTIPLE_WINDOW && previousSceneId != IDSCN_MULTIPLE_WINDOW_GRID && previousSceneId != IDSCN_BOOKMARK_VIEW && previousSceneId != IDSCN_SETTINGS && previousSceneId != IDSCN_MAIN_VIEW)
2634 LoadUrl(__pWindowInfo->pageUrl);
2636 else if (__pWindowInfo->isJavascriptInitiated == true)
2640 __pWindowInfo->pCurrentWeb = __pWebViewer;
2644 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2645 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2646 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2648 InitMostVisitedSitesView(GetOrientationStatus());
2650 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2652 if(__pMostVisitedListView != null)
2654 __pMostVisitedListView->SetShowState(false);
2658 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2660 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2662 if (pBookmarkUrl == null)
2664 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2665 //__pAddressbar->SetUrl(*pBookmarkUrl);
2666 SetUrl(*pBookmarkUrl);
2668 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2669 __pWebViewer->LoadUrl(*pBookmarkUrl);
2670 delete pBookmarkUrl;
2673 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2674 Bitmap* pBitmap = null;
2675 if (isPrivateBrowsing == true)
2677 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2679 if (__pWebViewer != null)
2681 __pWebViewer->SetPrivateBrowsingEnabled(true);
2684 if (__pAddressbar != null)
2686 // __pAddressbar->UpdateFaviconBitmap(true);
2692 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2694 if (__pWebViewer != null)
2696 __pWebViewer->SetPrivateBrowsingEnabled(false);
2699 if (__pAddressbar != null)
2701 // __pAddressbar->UpdateFaviconBitmap(false);
2705 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2707 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2709 else if (__pOptionMenu != null )
2711 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2714 if (pBitmap != null)
2719 AppLog("ABC: OnSceneActivatedN started exit");
2724 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2725 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2727 Canvas* pWebCanvas = null;
2728 if (__pWebViewer != null)
2730 pWebCanvas = __pWebViewer->GetCanvasN();
2733 if (pWebCanvas == null)
2737 if (__pWindowInfo != null)
2739 if (__pWindowInfo->pWebCanvasBitmap != null)
2741 delete __pWindowInfo->pWebCanvasBitmap;
2743 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2744 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2745 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2747 Bitmap* pBitmap = GetCapturedBitmapN();
2748 AppLog("Coming here");
2749 Canvas* pCanvas = new(std::nothrow) Canvas();
2750 pCanvas->Construct(GetClientAreaBounds());
2753 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2756 if(__pWebViewer != null && __pWindowInfo != null)
2757 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2759 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2760 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2762 AppLog("Coming here");
2766 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2767 const Tizen::Base::String& realm,
2768 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2774 MainForm::OnHttpAuthenticationCanceled(void)
2779 MainForm::OnLoadingStarted(void)
2781 AppLogDebug("MainForm::OnLoadingStarted entered");
2783 if(__pAddressbar == NULL || __pWebViewer == null)
2788 // this is added in case if menu is opened and user load the page
2789 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2791 __pOptionMenu->SetShowState(false);
2792 __pOptionMenu->Invalidate(true);
2797 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2799 __pImageMenu->SetShowState(false);
2800 __pImageMenu->Invalidate(true);
2802 String url = __pWebViewer->GetUrl();
2803 if(url.Contains(IDS_TIZEN_SERVICE))
2806 String delim(L":;,");
2808 // Creates a StringTokenizer instance
2809 StringTokenizer strTok(url, delim);
2811 int count = strTok.GetTokenCount(); // count == 4
2813 HashMap *pMap = new HashMap();
2818 while (strTok.HasMoreTokens())
2820 AppLog("Token: %ls", token.GetPointer());
2821 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2822 if(token.Contains(IDS_APPID))
2824 token.SubString(6, appId);
2825 AppLog("AppID:%ls", appId.GetPointer());
2827 else if(token.Contains(IDS_KEY))
2829 token.SubString(4, key);
2830 AppLog("key:%ls", key.GetPointer());
2832 else if(token.Contains(IDS_VALUE))
2834 token.SubString(6, value);
2835 AppLog("value:%ls", value.GetPointer());
2838 pMap->Add(key, value);
2842 AppControl *pAppControl = null;
2843 String operationId = L"http://tizen.org/appcontrol/operation/main";
2844 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2847 AppLog("Starting AppControl");
2848 result r = pAppControl->Start(null, null, pMap, null);
2849 AppLog("Result of Start %s", GetErrorMessage(r));
2853 AppLogException("AppControl not found");
2858 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2860 __pAddressbar->SetShowState(false);
2861 AddressBarCancelledClicked(*__pAddressbar);
2862 __pAddressbar->Invalidate(true);
2864 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2867 __pAddressbar->SetFaviconBitmap(*pBitmap);
2870 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2872 // updating the address bar position with respect to web control
2873 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2874 __distanceMoved = 0;
2878 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2879 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2880 if (__pWebViewer != null)
2882 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2883 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2884 SetUrl(__pWebViewer->GetUrl());
2885 if (__pWindowInfo != NULL)
2887 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2888 __pWindowInfo->pageTitle = L"";
2889 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2891 __pAddressbar->Invalidate(true);
2897 MainForm::OnLoadingCanceled(void)
2904 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2906 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2911 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2913 AppLog("XYZ::MainForm::OnKeypadOpened");
2914 __pFooterPanel->SetShowState(false);
2919 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2921 AppLog("XYZ::MainForm::OnKeypadClosed");
2922 __pFooterPanel->SetShowState(true);
2923 RelayoutControls(true);
2927 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2929 AppLog("XYZ::KeypadBoundsChanged");
2930 RelayoutControls(false);
2934 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2935 const Tizen::Base::String& reason)
2937 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2941 MainForm::OnLoadingCompleted(void)
2943 AppLog("MainForm::OnLoadingCompleted start");
2945 result r = E_SUCCESS;
2947 if (__pWebViewer == null)
2952 if (__pAddressbar == null)
2956 if (__pWebViewer->CanGoForward())
2958 //__pAddressbar->SetForwardButtonEnabled(true);
2959 SetForwardButtonEnabled(true);
2963 //__pAddressbar->SetForwardButtonEnabled(false);
2964 SetForwardButtonEnabled(false);
2967 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2969 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2971 //__pAddressbar->UpdateProgress(0);
2975 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2977 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2981 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2982 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2983 if (isPrivateBrowsing == false)
2985 if(__pHistory != null)
2991 __pHistory = new(std::nothrow) History;
2992 HistoryPresentationModel::GetCurrentDateTime(date);
2995 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2996 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2998 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2999 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3001 __pHistory->SetVisitedTime(date);
3003 if (__pWebViewer != null)
3005 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3007 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3008 if (pTempBitmap != null)
3010 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3011 __pHistory->SetFavIconBitmap(*pTempBitmap);
3014 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3017 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3018 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3019 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3021 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3022 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3023 __pHistory->SetThumbnail(pBitmap);
3025 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3028 __pHistory->SetFavIconBitmap(*pFavIcon);
3032 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3039 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3041 // temperary fixed (webpage can be not loaded)
3045 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3046 if (isReaderEnabled == true)
3050 delete __pReaderData;
3051 __pReaderData = null;
3053 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3054 filePath.Append(L"data/reader.js");
3060 result r = E_SUCCESS;
3061 FileAttributes attr;
3063 File::GetAttributes(filePath,attr);
3065 r = file.Construct(filePath, L"r+");
3068 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3071 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3074 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3077 // file.Read(pScript,attr.GetFileSize());
3079 // AppLogDebug("scipt length %d",strlen(pScript));
3080 String strScript = L"";
3081 // strScript.Append(pScript);
3082 // for(int i=0; i<25; i++)
3084 file.Read(pScript,attr.GetFileSize());
3085 // AppLog("xyzz tell %d",file.Tell());
3086 // r = strScript.Append(pScript);
3087 // AppLog("xyzz append result %s",GetErrorMessage(r));
3088 // AppLog("xyzz strScript length %d",strScript.GetLength());
3090 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3092 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3093 if (__pReaderData == null)
3095 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3096 __pReaderData = new String(L"<meta name=\"viewport\" content=\"width=0, initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=medium-dpi\"> <h1>Chinese PM Li Keqiang vows to open up markets to India</h1><div><span class=\"arttle\"><h1>Chinese PM Li Keqiang vows to open up markets to India</h1></span></div>");
3099 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3100 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3102 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3103 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3109 AppLog("MainForm::OnLoadingCompleted done");
3113 MainForm::OnEstimatedProgress(int progress)
3115 AppLogDebug("MainForm::OnEstimatedProgress entered");
3116 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3117 progress = DEFAULT_PROGRESS_PERCENTAGE;
3119 // __pAddressbar->UpdateProgress(progress);
3120 UpdateProgress(progress);
3123 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3125 AppLog("MainForm::OnFaviconReceived");
3126 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3128 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3131 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3138 MainForm::OnUrlValueChanged(Addressbar&)
3144 MainForm::OnUrlSubmitted(Addressbar& addBar)
3146 AppLog("MainForm::OnUrlSubmitted");
3147 String url = addBar.GetUrl();
3148 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3150 if(__pFooterUrlField)
3151 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3152 AddressBarCancelledClicked(*__pAddressbar);
3157 MainForm::LoadUrl(String& url)
3161 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3162 AppLogDebug("MainForm::LoadUrl enter");
3164 if (__pWebViewer != null)
3166 __pWebViewer->SetShowState(true);
3167 __pWebViewer->Invalidate(true);
3170 if (url.CompareTo(L"") == 0)
3174 if(__pFooterPanel != null)
3176 __pFooterPanel->SetShowState(true);
3177 __pFooterPanel->Invalidate(true);
3184 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3185 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)
3187 RegularExpression firstRegex;
3188 RegularExpression secondRegex;
3190 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3191 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3194 ret = firstRegex.Match(url, false); // This returns true value
3195 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3197 if (ret == true && __pWebViewer != null)
3200 __pWebViewer->LoadUrl(url);
3202 else if(__pWebViewer != null)
3204 String tempUrl = L"http://";
3205 tempUrl.Append(url);
3209 __pWebViewer->LoadUrl(tempUrl);
3213 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3214 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3217 if (__pAddressbar != null)
3219 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3220 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3223 AppLogDebug("MainForm::LoadUrl exit");
3230 MainForm::OnStopClicked(Addressbar& addBar)
3232 AppLogDebug("MainForm::OnStopClicked called");
3235 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3236 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3237 __pWebViewer->StopLoading();
3238 RequestRedraw(true);
3243 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3245 // AppLog("MainForm::OnBackClicked");
3246 result r = E_FAILURE;
3248 if (__pWebViewer && __pWebViewer->CanGoBack())
3250 __pWebViewer->GoBack();
3252 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3255 pApp = UiApp::GetInstance();
3258 r = pApp->Terminate();
3261 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3269 WindowInfo* pWindowInfo = null;
3271 SceneManager* pSceneManager = SceneManager::GetInstance();
3272 if (pSceneManager == null)
3276 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3277 if (pAllWindowList == NULL)
3279 pApp = UiApp::GetInstance();
3282 r = pApp->Terminate();
3285 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3290 if (pAllWindowList != null)
3292 totalCount = pAllWindowList->GetCount();
3294 for (int count = 0; count < totalCount; count++)
3296 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3297 if (pWindowInfo == null)
3299 pApp = UiApp::GetInstance();
3302 r = pApp->Terminate();
3305 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3310 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3312 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3315 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3318 r = pAllWindowList->RemoveAt(count, true);
3319 __pWindowInfo = null;
3322 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3327 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3329 else if(pAllWindowList->GetCount() > 0)
3331 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3335 pApp = UiApp::GetInstance();
3338 r = pApp->Terminate();
3343 if (pWindowInfo == null)
3345 pApp = UiApp::GetInstance();
3348 r = pApp->Terminate();
3354 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3357 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3371 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3373 AppLog("MainForm::OnForwardClicked");
3374 if (__pWebViewer == null)
3377 if (__pWebViewer->CanGoForward())
3379 __pWebViewer->GoForward();
3384 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3386 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3387 if(__pFooterPanel != null)
3389 __pFooterPanel->SetShowState(false);
3392 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3394 __pAddressbar->SetShowState(true);
3395 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3398 RelayoutControls(false);
3402 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3404 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3406 int Height = GetClientAreaBounds().height;
3407 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3410 __pAddressbar->SetShowState(false);
3412 if (__pFooterPanel != null && addressbarKeyPadState == false)
3414 AppLog("akjshdasd 3");
3415 __pFooterPanel->SetShowState(true);
3418 RelayoutControls(false);
3422 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3424 AddressBarCancelledClicked(addBar);
3428 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3430 __prevAddressBarMode = __curAddressBarMode;
3432 if (__pAddressbar != null)
3434 __curAddressBarMode = GetAddressbarMode();
3437 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3439 __adressPanelPosition.y = 0;
3440 if (__pAddressbar != null)
3442 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3443 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3444 __pAddressbar->Invalidate(true);
3446 if (__pWebViewer != null)
3448 __pWebViewer->StopLoading();
3451 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3453 __adressPanelPosition.y = 0;
3454 if (__pAddressbar != null)
3456 __webControlPosition.y = 0;
3457 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3458 __pAddressbar->Invalidate(true);
3464 MainForm::OnClipboardClosed(const Addressbar& addBar)
3466 AppLog("XYZ::MainForm::OnClipboardClosed");
3467 RelayoutControls(false);
3471 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3473 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3474 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3476 AppLog("akjshdasd 3");
3477 __pFooterPanel->SetShowState(true);
3480 RelayoutControls(false,footerState);
3484 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3486 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3487 RelayoutControls(false);
3491 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3493 __pFooterPanel->SetShowState(false);
3497 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3499 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3500 RelayoutControls(false);
3504 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3506 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3509 __pWindowInfo->pageTitle = title;
3510 if (__pWebViewer != null)
3512 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3515 if (__pAddressbar != null && __pWebViewer != null)
3517 SetUrl(__pWebViewer->GetUrl());
3518 __pAddressbar->Invalidate(true);
3523 MainForm::UpdateFavicon(void)
3525 bool urlImageType = false;
3526 String *tempPath = null;
3528 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();");
3529 Bitmap* pBitmap = null;
3531 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3533 if (__pWindowInfo != null)
3536 url.SetUri(*tempPath);
3537 if (url.GetHost().GetLength() == 0)
3540 webUrl.SetUri(__pWebViewer->GetUrl());
3541 result r = url.SetHost(webUrl.GetHost());
3548 if (url.GetScheme().GetLength() == 0)
3551 webUrl.SetUri(__pWebViewer->GetUrl());
3552 url.SetScheme(webUrl.GetScheme());
3554 __pWindowInfo->faviconUrl = url.ToString();
3556 pBitmap = __pWebViewer->GetFaviconN();
3558 if (pBitmap != null)
3560 if (__pWindowInfo->pFavicon != NULL)
3562 __pWindowInfo->pFavicon = null;
3564 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3565 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3567 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3569 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3571 else if(__pWindowInfo->pFavicon != null)
3573 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3577 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3578 if(pDefaultBmp != null)
3580 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3589 if(tempPath != null)
3593 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3600 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3601 Tizen::Web::Controls::WebNavigationType type)
3603 // when load new page if find word panel is open its show state is false
3604 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3606 __currentSearchStr = L"";
3607 __currentWordIndex = 0;
3608 __maxOccurrances = 0;
3609 __pFindWordEditField->SetText(L"");
3610 __pFindWordNext->SetEnabled(false);
3611 __pFindWordPrev->SetEnabled(false);
3612 __pFindWordCountLabel->SetText(L"0/0");
3613 __pFindWordControl->SetShowState(false);
3614 __pFindWordEditField->HideKeypad();
3615 RelayoutControls(false);
3620 __pFooterPanel->Invalidate(true);
3623 uriInfo.SetUri(url);
3625 if(url.Contains(IDS_TIZEN_SERVICE))
3628 String delim(L":;,");
3630 // Creates a StringTokenizer instance
3631 StringTokenizer strTok(url, delim);
3633 int count = strTok.GetTokenCount(); // count == 4
3635 HashMap *pMap = new HashMap();
3641 while (strTok.HasMoreTokens())
3643 AppLog("Token: %ls", token.GetPointer());
3644 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3645 if(token.Contains(IDS_APPID))
3647 token.SubString(6, appId);
3648 AppLog("AppID:%ls", appId.GetPointer());
3650 else if(token.Contains(IDS_KEY))
3652 token.SubString(4, key);
3653 AppLog("key:%ls", key.GetPointer());
3655 else if(token.Contains(IDS_VALUE))
3657 token.SubString(6, value);
3658 AppLog("value:%ls", value.GetPointer());
3661 pMap->Add(key, value);
3665 AppControl *pAppControl = null;
3666 String operationId = L"http://tizen.org/appcontrol/operation/main";
3667 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3670 result r = pAppControl->Start(null, null, pMap, null);
3674 AppLogException("AppControl not found");
3684 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3685 const Tizen::Net::Http::HttpHeader& httpHeader)
3687 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3692 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3694 AppLog("MainForm::OnWebPageBlockSelected");
3695 if (__pHitElementResult != null)
3697 delete __pHitElementResult;
3698 __pHitElementResult = null;
3701 if (__pWebViewer != null)
3703 AppLog("MainForm::OnWebPageBlockSelected web not null");
3704 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3706 if(GetLastResult() == E_INVALID_ARG)
3708 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3709 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3710 if(GetLastResult() == E_INVALID_ARG)
3712 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3714 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3718 if (__pHitElementResult == null)
3723 if (__pHitElementResult->HasImage() != true)
3725 String tagName = __pHitElementResult->GetTagName();
3726 String type = __pHitElementResult->GetAttributeValue("type");
3729 AppLog("TagName %ls",tagName.GetPointer());
3730 __currentSelectedStr.Clear();
3731 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3732 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3733 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3735 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3737 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3739 InitSelectTextContextMenuF(endPoint,true);
3740 __pImageMenu->SetShowState(true);
3741 __pImageMenu->Show();
3742 __pImageMenu->Invalidate(true);
3744 else /*if(__isLongPressedDone == true)*/
3746 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3748 if(__pHitElementResult->GetUrl().GetLength() > 0)
3750 __currentSelectedStr.Clear();
3751 __currentSelectedStr = __pHitElementResult->GetUrl();
3753 InitSelectTextContextMenuF(endPoint,false);
3754 __pImageMenu->SetShowState(true);
3755 __pImageMenu->Show();
3756 __pImageMenu->Invalidate(true);
3759 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3760 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3761 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3767 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3773 MainForm::OnWebWindowCreateRequested(void)
3775 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3777 if (pNewWindowInfo == null)
3781 result r = E_SUCCESS;
3782 SceneManager* pSceneManager = SceneManager::GetInstance();
3783 if (pSceneManager == NULL)
3787 ArrayList* pArgList = new(std::nothrow) ArrayList();
3788 if (pArgList == NULL)
3792 r = pArgList->Construct();
3795 pNewWindowInfo->isJavascriptInitiated = true;
3796 pArgList->Add(*pNewWindowInfo);
3797 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3801 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3808 return pNewWindowInfo->pCurrentWeb;
3812 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3814 AppLog("xyz:: MainForm::RelayoutControls called");
3815 __webControlPosition.y = 0;
3816 __webControlHeight = GetClientAreaBounds().height;
3817 AppLog("Client area height: %d", __webControlHeight);
3819 AppLog("Client area height: %d", __webControlHeight);
3820 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3822 __webControlPosition.y += __pAddressbar->GetHeight();
3823 __webControlHeight -= __pAddressbar->GetHeight();
3824 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3826 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3828 __webControlPosition.y += __pFindWordControl->GetHeight();
3829 __webControlHeight -= __pFindWordControl->GetHeight();
3830 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3833 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3835 __webControlHeight -= __pFooterPanel->GetHeight();
3837 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3839 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3841 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3846 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3847 __pWebViewer->Invalidate(false);
3850 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3852 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3859 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3861 if (__pFindWordControl == null)
3866 Tizen::Locales::LocaleManager localeManager;
3867 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3869 String languageCode;
3870 result r = SettingInfo::GetValue(L"Language", languageCode);
3871 // int languagecode = local.GetLanguageCode();
3872 AppLog("rahul language is %S", languageCode.GetPointer());
3876 InitFindWordPanel();
3878 if (languageCode.CompareTo("ara") == 0)
3880 AppLog("rahul language is arabic");
3882 __pFindWordPanelLeftToRight->SetShowState(false);
3883 __pFindWordPanelRightToLeft->SetShowState(true);
3885 __pFindWordClear->SetShowState(false);
3886 __pFindWordCountLabel->SetShowState(false);
3887 __pFindWordEditField->SetShowState(false);
3889 __pFindWordClearRightToLeft->SetShowState(true);
3890 __pFindWordCountLabelRightToLeft->SetShowState(true);
3891 __pFindWordEditFieldRightToLeft->SetShowState(true);
3895 AppLog("rahul language is not arabic");
3898 __pFindWordPanelLeftToRight->SetShowState(true);
3899 __pFindWordPanelRightToLeft->SetShowState(false);
3901 __pFindWordClear->SetShowState(true);
3902 __pFindWordCountLabel->SetShowState(true);
3903 __pFindWordEditField->SetShowState(true);
3905 __pFindWordClearRightToLeft->SetShowState(false);
3906 __pFindWordCountLabelRightToLeft->SetShowState(false);
3907 __pFindWordEditFieldRightToLeft->SetShowState(false);
3909 __pFindWordControl->SetShowState(true);
3913 if(__pFindWordControl != null)
3915 __pFindWordControl->SetShowState(false);
3919 AppLog("MainForm::ShowFindWordPanel %d",show);
3920 if (show && !isTouchPressed)
3922 if (languageCode.CompareTo("ara") == 0)
3924 if (__pFindWordEditFieldRightToLeft)
3926 __pFindWordEditFieldRightToLeft->SetFocus();
3927 __pFindWordEditFieldRightToLeft->ShowKeypad();
3932 if (__pFindWordEditField)
3934 __pFindWordEditField->SetFocus();
3935 __pFindWordEditField->ShowKeypad();
3941 if (languageCode.CompareTo("ara") == 0)
3943 if (__pFindWordEditFieldRightToLeft)
3944 __pFindWordEditFieldRightToLeft->HideKeypad();
3948 if (__pFindWordEditField)
3949 __pFindWordEditField->HideKeypad();
3953 RelayoutControls(false);
3957 MainForm::StartWordSearch()
3959 //Get the count of occurances of the word in the current page
3960 __maxOccurrances = 0;
3961 __currentWordIndex = 0;
3963 __pFindWordPrev->SetEnabled(false);
3964 String *pCountStr = null;
3965 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3966 AppLog("Search Result %s",GetErrorMessage(r));
3967 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3968 if (pCountStr != null)
3970 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3974 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3979 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3981 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3982 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3984 if(totalCount == -1 || totalCount == 0)
3986 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3987 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3990 else if(totalCount > 100)
3992 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3993 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3997 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3998 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4001 __maxOccurrances = totalCount;
4002 __currentWordIndex = currentOrdinal;
4004 //Reset the UI controls as per the maxOccurrance value
4005 if (totalCount <= 0)
4007 AppLog("Word not found");
4008 //Show error notification to user
4009 __pFindWordNext->SetEnabled(false);
4010 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4012 __pFindWordCountLabel->SetText(L"0/0");
4013 __pFindWordCountLabel->Invalidate(false);
4015 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4017 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4018 __pFindWordCountLabelRightToLeft->Invalidate(false);
4020 __pFindWordNext->Invalidate(false);
4021 __pFindWordPrev->Invalidate(false);
4026 if (totalCount == 1)
4028 __pFindWordNext->SetEnabled(false);
4032 __pFindWordNext->SetEnabled(true);
4035 String countStr = L"";
4036 countStr.Append(__currentWordIndex);
4037 countStr.Append(L"/");
4038 countStr.Append(__maxOccurrances);
4039 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4041 __pFindWordCountLabel->SetText(countStr);
4042 __pFindWordCountLabel->Invalidate(false);
4043 __pFindWordCountLabel->Invalidate(false);
4045 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4047 __pFindWordCountLabelRightToLeft->SetText(countStr);
4048 __pFindWordCountLabelRightToLeft->Invalidate(false);
4049 __pFindWordCountLabelRightToLeft->Invalidate(false);
4051 //FindNextWord(true);
4052 //Update the controls
4053 __pFindWordNext->Invalidate(false);
4054 __pFindWordPrev->Invalidate(false);
4059 MainForm::FindNextWord(bool next)
4063 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4064 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4066 if (__currentWordIndex < __maxOccurrances)
4068 __currentWordIndex++;
4074 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4075 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4077 if(__currentWordIndex > 1)
4079 __currentWordIndex--;
4084 String countStr = L"";
4085 countStr.Append(__currentWordIndex);
4086 countStr.Append(L"/");
4087 countStr.Append(__maxOccurrances);
4089 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4091 __pFindWordCountLabel->SetText(countStr);
4092 __pFindWordCountLabel->Invalidate(false);
4094 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4096 __pFindWordCountLabelRightToLeft->SetText(countStr);
4097 __pFindWordCountLabelRightToLeft->Invalidate(false);
4100 if (__currentWordIndex >= __maxOccurrances)
4102 __pFindWordNext->SetEnabled(false);
4106 __pFindWordNext->SetEnabled(true);
4108 if (__currentWordIndex <= 1)
4110 __pFindWordPrev->SetEnabled(false);
4114 __pFindWordPrev->SetEnabled(true);
4116 __pFindWordPrev->Invalidate(false);
4117 __pFindWordNext->Invalidate(false);
4119 __pFindWordControl->Invalidate(true);
4123 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4125 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4126 __isWebKeypadOpened = true;
4127 __pFooterPanel->SetShowState(false);
4128 // OnAddressBarKeypadOpened(*__pAddressbar);
4132 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4134 AppLog("xyz::MainForm::OnWebKeypadOpened");
4136 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4138 __currentSearchStr = L"";
4139 __currentWordIndex = 0;
4140 __maxOccurrances = 0;
4141 __pFindWordEditField->SetText(L"");
4142 __pFindWordNext->SetEnabled(false);
4143 __pFindWordPrev->SetEnabled(false);
4144 __pFindWordCountLabel->SetText(L"0/0");
4145 __pWebViewer->SearchTextAllAsync(L"",false);
4146 __pFindWordControl->SetShowState(false);
4147 __pFindWordEditField->HideKeypad();
4151 if (__pWebViewer != null && __pFooterPanel != null)
4153 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4154 if(__pAddressbar != null)
4156 __pAddressbar->SetShowState(false);
4158 if(__pFindWordControl != null)
4160 __pFindWordControl->SetShowState(false);
4162 __pFooterPanel->SetShowState(false);
4163 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4165 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4167 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4168 // AppLog("omgomgomg");
4174 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4176 AppLog("xyz::MainForm::OnWebKeypadClosed");
4177 AppLog("akjshdasd 4");
4178 __pFooterPanel->SetShowState(true);
4179 // OnAddressBarKeypadClosed(*__pAddressbar);
4180 RelayoutControls(false);
4181 __isWebKeypadOpened = false;
4185 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4187 // RelativeLayout(false);
4188 if(__pWebViewer != null)
4190 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4195 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4197 Control* temp = const_cast< Control* >(&source);
4198 Header* pHeader = dynamic_cast< Header* >(temp);
4199 if (pHeader != null)
4201 //Header double - clicked
4202 AppLog("Header double clicked");
4204 if(__pFindWordControl)
4206 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4207 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4211 AppLog("MainScene::OnTouchDoublePressed");
4215 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4217 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4218 __longPressPoint = currentPosition;
4220 if (__pHitElementResult != null)
4222 delete __pHitElementResult;
4223 __pHitElementResult = null;
4226 if (__pWebViewer != null)
4228 AppLog("MainForm::OnTouchLongPressed web not null");
4229 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4232 if (__pHitElementResult == null)
4237 if (__pHitElementResult->HasImage() == true)
4239 InitImageContextMenu(currentPosition);
4240 __pImageMenu->SetShowState(true);
4241 __pImageMenu->Show();
4242 __pImageMenu->Invalidate(true);
4244 else if(__pHitElementResult->HasUrl() == true)
4246 String tempURl = __pHitElementResult->GetUrl();
4247 AppLog("tempURl is %ls", tempURl.GetPointer());
4248 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4249 if (pBitmap != null)
4257 InitImageLinkContextMenu(currentPosition);
4258 __pImageMenu->SetShowState(true);
4259 __pImageMenu->Show();
4260 __pImageMenu->Invalidate(true);
4264 String tagName = __pHitElementResult->GetTagName();
4265 String type = __pHitElementResult->GetAttributeValue("type");
4266 String value = __pHitElementResult->GetAttributeValue(L"value");
4267 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4269 __currentSelectedStr.Clear();
4270 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4272 AppLog("tag name is %ls", tagName.GetPointer());
4273 AppLog("type is %ls", type.GetPointer());
4277 //__isLongPressedDone = true;
4278 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4279 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4281 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4283 InitSelectTextContextMenu(currentPosition,true, true);
4286 __pImageMenu->SetShowState(true);
4287 __pImageMenu->Show();
4288 __pImageMenu->Invalidate(true);
4291 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4294 // __inputEventToBeSupressed = true;
4298 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4300 AppLog("xyz:: MainForm::OnTouchReleased called");
4302 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4304 __pAddressbar->SetShowState(false);
4308 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4309 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4311 __pWebViewer->ConsumeInputEvent();
4313 if(pHitElement != null)
4317 __inputEventToBeSupressed = false;*/
4321 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4328 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4330 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4332 __currentSearchStr = L"";
4333 __currentWordIndex = 0;
4334 __maxOccurrances = 0;
4336 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4338 __pFindWordEditField->SetText(L"");
4339 __pFindWordEditField->HideKeypad();
4340 __pFindWordControl->SetShowState(false);
4341 __pFindWordCountLabel->SetText(L"0/0");
4343 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4345 __pFindWordEditFieldRightToLeft->SetText(L"");
4346 __pFindWordEditFieldRightToLeft->HideKeypad();
4347 __pFindWordControl->SetShowState(false);
4348 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4351 __pFindWordNext->SetEnabled(false);
4352 __pFindWordPrev->SetEnabled(false);
4354 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4355 __pFindWordControl->SetShowState(false);
4357 if(__pAddressbar->GetShowState() == false)
4359 __pAddressbar->SetAddressbarURLFocus();
4360 __pFooterPanel->SetShowState(false);
4367 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4373 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4379 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4385 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4391 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4397 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4399 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4400 int widthContextItem = 0;
4402 // As per the platform engineer comment removed this line
4403 /*if(__pWebViewer != null)
4405 // 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
4406 __pWebViewer->ReleaseBlock();
4409 // if(__pFindWordControl != null)
4410 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4411 if(__pNotification && __pNotification->GetShowState() == true)
4413 __pNotification->SetShowState(false);
4414 __pNotification->Invalidate(false);
4416 if ( __pFooterLabel != null)
4418 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4421 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4427 if (__pFindWordBgLabel != null)
4429 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4430 if (pBitmap != null)
4432 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4437 if (__pFindWordBgLabelRightToLeft != null)
4439 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4440 if (pBitmap != null)
4442 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4448 if(__pOptionMenu != null)
4449 __pOptionMenu->SetShowState(false);
4451 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4453 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4457 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4462 AppLog("__pFooterPanel->GetShowState() is true");
4464 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4465 __pFooterPanel->Invalidate(true);
4469 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4470 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4472 InitMostVisitedSitesView(orientationStatus);
4475 RelayoutControls(false);
4476 if (__pArticleReaderPanel != null)
4478 if (__pArticleReaderPanel->GetShowState() == true)
4480 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4482 if (__pBlankPanel != null)
4483 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4485 if (__pWebReader != null)
4487 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4489 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4490 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4492 if ( pBitmap != null && pSrcBitmap != null)
4494 AppLog("CreateReaderPanel ninepatchbitmap found");
4495 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4498 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4499 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4500 if (pBitmap != null)
4505 if (pSrcBitmap != null)
4514 if (__pAddressbar != null)
4516 int width = GetClientAreaBounds().width;
4517 __pAddressbar->OrientationChanged(width);
4522 MainForm::OnSettingsChange(int settingvalue)
4524 AppLogDebug("MainForm::OnSettingsChange entered");
4526 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4528 __pAddressbar->ResetGuideText();
4530 if (__pWebViewer == null)
4532 AppLogDebug("Webviewer is not initialized yet.");
4536 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4538 WebSetting settings = __pWebViewer->GetSetting();
4539 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4541 settings.SetAutoFittingEnabled(true);
4543 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4545 settings.SetAutoFittingEnabled(false);
4547 __pWebViewer->SetSetting(settings);
4549 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4551 WebSetting settings = __pWebViewer->GetSetting();
4552 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4553 __pWebViewer->SetSetting(settings);
4555 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4557 WebSetting settings = __pWebViewer->GetSetting();
4558 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4559 __pWebViewer->SetSetting(settings);
4560 __pWebViewer->Reload();
4562 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4564 WebSetting settings = __pWebViewer->GetSetting();
4565 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4566 __pWebViewer->SetSetting(settings);
4568 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4572 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4575 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4579 WebSetting settings = __pWebViewer->GetSetting();
4580 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4581 __pWebViewer->SetSetting(settings);
4584 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4588 WebSetting settings = __pWebViewer->GetSetting();
4589 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4590 __pWebViewer->SetSetting(settings);
4593 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4595 WebSetting settings = __pWebViewer->GetSetting();
4596 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4598 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4602 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4604 __pWebViewer->SetSetting(settings);
4606 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4610 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4611 WebSetting settings = __pWebReader->GetSetting();
4612 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4613 __pWebReader->SetSetting(settings);
4619 MainForm::OnSettingsReset()
4623 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4624 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4629 MainForm::OnClearCache()
4631 result r = E_SUCCESS;
4633 if (__pWebViewer != NULL)
4635 r = __pWebViewer->ClearCache();
4638 AppLogDebug("Cache cleared success");
4642 AppLogDebug("Cache cleared fail");
4648 MainForm::OnClearCookie()
4650 result r = E_SUCCESS;
4652 if (__pWebViewer != NULL)
4654 __pWebViewer->ClearCookie();
4658 AppLogDebug("Cookie cleared success");
4662 AppLogDebug("Cache cleared fail");
4667 MainForm::OnClearFormData()
4669 result r = E_SUCCESS;
4671 if (__pWebViewer != NULL)
4673 __pWebViewer->ClearFormData();
4677 AppLogDebug("Cookie cleared success");
4681 AppLogDebug("Cache cleared fail");
4686 MainForm::OnClearPasswords()
4688 result r = E_SUCCESS;
4690 if (__pWebViewer != NULL)
4692 __pWebViewer->ClearLoginFormData();
4696 AppLogDebug("Cookie cleared success");
4700 AppLogDebug("Cache cleared fail");
4706 MainForm::findDistance(int x1,int y1,int x2, int y2)
4708 int deltaX = Math::Abs(x2 - x1);
4709 int deltaY = Math::Abs(y2 - y1);
4710 double num = deltaX*deltaX + deltaY*deltaY;
4716 for (i = 0; i < 20; i++)
4718 x = (((x*x)+ num)/(2*x));
4729 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4731 AppLog("xyz:: MainForm::OnTouchPressed called");
4732 if(__pFindWordControl)
4734 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4735 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4737 //__isLongPressedDone = false;
4742 IList* pList = null;
4743 pList = touch.GetTouchInfoListN(source);
4747 int count = pList->GetCount();
4750 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4751 __touchPoint1 = pTouchInfo->position;
4753 /*if (__pAddressbar != null)
4755 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4757 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4759 __pAddressbar->SaveAddressbarEditText();
4761 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4764 __pAddressbar->Invalidate(true);
4766 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4768 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4770 //__pAddressbar->SaveAddressbarEditText();
4772 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4775 else if (count == 2)
4777 AppLogDebug("MainForm::OnTouchPressed count is two");
4778 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4779 __touchPoint1 = pTouchInfo->position;
4781 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4782 __touchPoint2 = pTouchInfo->position;
4787 pList->RemoveAll(true);
4790 // RelayoutControls(false);
4795 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4797 // __currentWordIndex = 0;
4798 //__isLongPressedDone = false;
4803 MainForm::MoveUiControls()
4808 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4810 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4812 if(__pFooterUrlField->GetTextLength() == 0)
4814 __pFooterUrlField->SetKeypadActionEnabled(false);
4818 __pFooterUrlField->SetKeypadActionEnabled(true);
4821 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4823 __currentSearchStr = __pFindWordEditField->GetText();
4824 if (__currentSearchStr.GetLength() > 0)
4826 __pFindWordCountLabel->SetShowState(true);
4830 __pFindWordCountLabel->SetShowState(false);
4832 __pFindWordNext->SetEnabled(false);
4833 __pFindWordPrev->SetEnabled(false);
4834 __pFindWordNext->Invalidate(true);
4835 __pFindWordPrev->Invalidate(true);
4836 __pFindWordCountLabel->SetText(L"0/0");
4837 __pFindWordCountLabel->Invalidate(true);
4839 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4841 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4842 if (__currentSearchStr.GetLength() > 0)
4844 __pFindWordCountLabelRightToLeft->SetShowState(true);
4848 __pFindWordCountLabelRightToLeft->SetShowState(false);
4851 __pFindWordNext->SetEnabled(false);
4852 __pFindWordPrev->SetEnabled(false);
4853 __pFindWordNext->Invalidate(true);
4854 __pFindWordPrev->Invalidate(true);
4855 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4856 __pFindWordCountLabelRightToLeft->Invalidate(true);
4858 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4859 if (__currentSearchStr.GetLength() > 0)
4865 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4867 __currentSearchStr = L"";
4868 AppLogDebug("Enter something");
4873 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4880 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4882 if(__pWebViewer != null)
4885 AppLog("MainForm::InitMostVisitedSitesView");
4886 result r = E_SUCCESS;
4889 if (__pWebViewer != null && __pMostVisitedListView != null)
4894 if (__pMostVisitedListView != null)
4896 RemoveControl(__pMostVisitedListView);
4898 if(__pMostVisitedSites != null)
4900 __pMostVisitedSites->RemoveAll(true);
4903 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4905 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4906 __pMostVisitedListView = new(std::nothrow) ListView();
4908 int height = GetClientAreaBounds().height;
4910 if(__pFooterPanel->GetShowState() == true)
4912 height = height - __pFooterPanel->GetHeight();
4914 if(__pAddressbar->GetShowState() == true)
4916 height -= __pAddressbar->GetHeight();
4919 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4923 delete __pMostVisitedListView;
4924 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4927 __pMostVisitedListView->SetItemProvider(*this);
4928 __pMostVisitedListView->AddListViewItemEventListener(*this);
4929 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4930 AddControl(__pMostVisitedListView);
4931 __pMostVisitedListView->UpdateList();
4938 MainForm::GetImagePath(void)
4942 String formattedTime;
4943 DateTime currentTime;
4944 LocaleManager localManager;
4945 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4947 localManager.Construct();
4948 Locale locale = localManager.GetSystemLocale();
4949 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4951 // Get date formatter
4952 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4956 pTimeFormatter->Format(currentTime, formattedTime);
4959 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4960 String delim(L" :");
4961 StringTokenizer strTok(formattedTime, delim);
4964 String str1("GMT+00");
4965 while (strTok.HasMoreTokens())
4967 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4968 if(token.Equals(str1))
4970 AppLog("token is %ls", token.GetPointer());
4971 imageName.Append(token);
4977 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4979 result r = E_FAILURE;
4980 AppLog("Content manager 1");
4981 ContentId contentId;
4982 ContentManager contentManager;
4983 r = contentManager.Construct();
4986 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4989 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4990 Tizen::Io::Directory::Create(contentPath,true);
4991 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4993 AppLog("Already exists");
4995 else if(GetLastResult() == E_SUCCESS)
4997 AppLog("created success");
4999 contentPath.Append(imageName);
5000 contentPath.Append(".jpg");
5001 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5002 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5006 MainForm::SetForwardButtonEnabled(bool isEnabled)
5008 __pGoForwardBtn->SetEnabled(isEnabled);
5009 __pGoForwardBtn->Invalidate(true);
5013 MainForm::SetBackButtonEnabled(bool isEnabled)
5015 __pGoBackBtn->SetEnabled(isEnabled);
5016 __pGoBackBtn->Invalidate(true);
5020 MainForm::UpdateProgress(int percentage)
5022 __progressPercentage = percentage;
5023 if (percentage == 0 || percentage == 100)
5025 __isLoadingData = false;
5026 if (percentage == 100)
5028 __isLoadingCompleted = true;
5029 __progressPercentage = 0;
5033 __isLoadingCompleted = false;
5038 __isLoadingData = true;
5040 UpdateProgressBitmap();
5044 MainForm::GetProgress(void)
5046 return __progressPercentage;
5050 MainForm::UpdateProgressBitmap(void)
5052 result r = E_SUCCESS;
5053 if (__pProgressbarLabel == null)
5055 int w = __pProgressbarLabel->GetWidth();
5056 int h = __pProgressbarLabel->GetHeight();
5058 int progressWidth = 0;
5059 Bitmap* pRetBitmap = null;
5061 if (__progressPercentage == 0 || __progressPercentage == 100)
5063 __pProgressbarLabel->SetShowState(false);
5064 __pProgressbarLabel->Invalidate(false);
5069 __pProgressbarLabel->SetShowState(true);
5070 __pProgressbarLabel->Invalidate(false);
5073 r = canvas.Construct(Rectangle(0, 0, w, h));
5077 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5082 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5086 pBgBmp->Scale(Dimension(w, h));
5087 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5091 progressWidth = (double) (w) * __progressPercentage / 100;
5092 AppLogDebug("progressWidth: %d", progressWidth);
5093 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5095 if (pProgressBmp != null)
5097 pProgressBmp->Scale(Dimension(progressWidth, h));
5098 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5099 delete pProgressBmp;
5102 pRetBitmap = new (std::nothrow) Bitmap();
5104 if (pRetBitmap == null)
5106 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5110 pRetBitmap->Construct(canvas, canvas.GetBounds());
5112 if (__pProgressbarLabel != null && pRetBitmap != null)
5114 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5115 __pProgressbarLabel->Invalidate(false);
5118 if (pRetBitmap != null)
5127 MainForm::ReaderClicked()
5129 result r = E_SUCCESS;
5130 ArrayList* pArgList = new(std::nothrow) ArrayList();
5131 if (pArgList != null)
5133 r = pArgList->Construct();
5140 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5147 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5154 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5162 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5166 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
5168 CreateReaderPanel();
5169 AppLogDebug("MainScene::ReaderClicked entered");
5172 /*if (__pArticleReaderPanel)
5174 AppLogDebug("showstate true for reader panel");
5175 __pArticleReaderPanel->SetShowState(true);
5176 __pArticleReaderPanel->Show();
5178 int xPos = __pArticleReaderPanel->GetX();
5179 int yPos = __pArticleReaderPanel->GetY();
5180 AppLog("ReaderClicked() xPos = %d",xPos);
5181 AppLog("ReaderClicked() yPos = %d",yPos);
5183 if (__pReaderData == null)
5188 String loadData = L"<html>\
5190 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
5195 background-color: transparent;\
5214 <body style='width:'";
5215 loadData.Append(bodyWidth);
5216 loadData.Append(L"px'>");
5217 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5218 loadData.Append(*__pReaderData);
5219 loadData.Append(L"</body></html>");
5222 buf.Construct(loadData.GetLength());
5223 AppLogDebug("data->GetLength %d",loadData.GetLength());
5224 for (int z=0;z<loadData.GetLength();z++)
5227 loadData.GetCharAt(z,b);
5228 buf.SetByte((byte)b);
5232 if (__pWebReader != null)
5234 __pWebReader->LoadData(L"",buf,L"text/html");
5235 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5239 AppLogDebug("cannot LoadData __pWebReader is null");
5244 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5246 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5248 __currentAddMode = addMode;
5252 case ADDRESSBAR_MODE_INVALID:
5257 case ADDRESSBAR_MODE_READER:
5259 __pStopBtn->SetShowState(false);
5260 __pRefreshBtn->SetShowState(false);
5261 __pClearBtn->SetShowState(false);
5262 __pReaderBtn->SetShowState(false);
5265 case ADDRESSBAR_MODE_LOADING:
5267 __pRefreshBtn->SetShowState(false);
5268 __pStopBtn->SetShowState(true);
5269 __pClearBtn->SetShowState(false);
5270 __pReaderBtn->SetShowState(false);
5273 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5275 // SetUrl(__pAddressbar->GetUrl());
5277 __pRefreshBtn->SetShowState(true);
5278 __pStopBtn->SetShowState(false);
5279 __pClearBtn->SetShowState(false);
5280 __pReaderBtn->SetShowState(false);
5283 case ADDRESSBAR_MODE_EDIT:
5285 __pRefreshBtn->SetShowState(false);
5286 __pStopBtn->SetShowState(false);
5287 __pReaderBtn->SetShowState(false);
5288 __pClearBtn->SetShowState(true);
5295 OnAddressBarModeChanged();
5298 AddressBarMode MainForm::GetAddressbarMode(void)
5300 return __currentAddMode;
5303 void MainForm::SetUrl(const String& url)
5306 if(__displayUrl.GetLength() > 2048)
5307 __displayUrl.SubString(0,2048,__displayUrl);
5309 if (__pFooterUrlField != NULL)
5311 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5312 if (removedHttpUrl.IsEmpty() == false)
5314 __pFooterUrlField->SetText(removedHttpUrl);
5315 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5316 __pAddressbar->SetUrl(__displayUrl);
5320 __pFooterUrlField->SetText(__displayUrl);
5321 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5322 __pAddressbar->SetUrl(__displayUrl);
5324 if(__pFooterUrlField)
5325 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5326 __pFooterUrlField->Invalidate(false);
5327 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5328 __pAddressbar->Invalidate(true);
5329 // __pFooterUrlField->SetCursorPosition(0);
5334 MainForm::RemoveHttpTextFromDisplayURL(void)
5336 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5338 // bool isHttpText = __displayUrl.Contains(L"http://");
5339 String updatedDisplayUrl;
5340 updatedDisplayUrl.Clear();
5341 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5343 __displayUrl.SubString(7,updatedDisplayUrl);
5345 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5347 __displayUrl.SubString(8,updatedDisplayUrl);
5349 return updatedDisplayUrl;
5352 void MainForm::OnSharePopupControlStarted(void)
5354 __pWebViewer->AddTouchEventListener(*this);
5358 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5360 if (requestId == BACK_GROUND_APP_EVENT)
5362 if(__pWebViewer != null)
5364 __pWebViewer->Pause();
5366 if(__pAddressbar != null)
5368 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5371 else if(requestId == FORE_GROUND_APP_EVENT)
5373 if(__pWebViewer != null)
5375 __pWebViewer->Resume();
5377 if(__pAddressbar != null)
5379 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5385 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5387 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5388 result r = E_SUCCESS;
5391 __pAddressbar->SetShowState(false);
5393 //AppLog("akjshdasd 5");
5394 //__pFooterPanel->SetShowState(true);
5397 __pWebViewer->SetFocus();
5398 else if(__pMostVisitedListView)
5399 __pMostVisitedListView->SetFocus();
5400 else if(__pMultiWindowButton)
5401 __pMultiWindowButton->SetFocus();
5402 else if(__pMoreButton)
5403 __pMoreButton->SetFocus();
5405 __pAddressbar->SetShowState(false);
5407 RelayoutControls(false);
5411 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5413 AppLog("MainForm::OnFormMenuRequested called");
5415 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5417 int bookmarkCount=0;
5420 url=__pWindowInfo->pageUrl;
5421 result r = E_SUCCESS;
5422 Bitmap* pBitmap = null;
5424 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5427 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5432 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5436 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5438 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5440 if (__pOptionMenu->GetItemCount() == 9)
5442 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5446 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5451 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5455 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5456 if (__pOptionMenu->GetItemCount() != 9)
5458 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5459 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5460 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5461 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5462 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5463 __pOptionMenu->SetMaxVisibleItemsCount(6);
5465 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5467 AppLog(" Orientation landscape");
5468 __pOptionMenu->SetMaxVisibleItemsCount(5);
5472 AppLog(" Orientation potrait");
5473 __pOptionMenu->SetMaxVisibleItemsCount(6);
5476 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5479 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5480 __pOptionMenu->SetShowState(true);
5481 __pOptionMenu->Invalidate(true);
5482 __pOptionMenu->Show();