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()+"//shared//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()+"//shared//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)
2578 AppLog("MainForm::OnSceneActivatedN called");
2579 String* pSelectedScene = NULL;
2580 Object* pValue = NULL;
2581 String* pUrl = null;
2582 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2583 pSelectedScene = (String*) pValue;
2585 if (pSelectedScene != null)
2587 delete pSelectedScene;
2589 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2590 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2591 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2592 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2594 // setting the current scene ID
2595 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2597 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2599 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2601 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2602 if(__pWindowInfo == null)
2604 // if(__pWindowInfo == null)
2606 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2609 else if ( pArgs != null && pArgs->GetCount() == 1)
2611 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2617 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2619 // hiding the address bar
2620 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2621 __pAddressbar->SetShowState(false);
2622 // if(__pWebViewer != null)
2624 // __pWebViewer->Resume();
2627 if(pUrl != null && pUrl->GetLength() > 0)
2631 else if(__pWindowInfo != null)
2633 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)
2635 LoadUrl(__pWindowInfo->pageUrl);
2637 else if (__pWindowInfo->isJavascriptInitiated == true)
2641 __pWindowInfo->pCurrentWeb = __pWebViewer;
2645 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2646 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2647 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2649 InitMostVisitedSitesView(GetOrientationStatus());
2651 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2653 if(__pMostVisitedListView != null)
2655 __pMostVisitedListView->SetShowState(false);
2659 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2661 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2663 if (pBookmarkUrl == null)
2665 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2666 //__pAddressbar->SetUrl(*pBookmarkUrl);
2667 SetUrl(*pBookmarkUrl);
2669 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2670 __pWebViewer->LoadUrl(*pBookmarkUrl);
2671 delete pBookmarkUrl;
2674 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2675 Bitmap* pBitmap = null;
2676 if (isPrivateBrowsing == true)
2678 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2680 if (__pWebViewer != null)
2682 __pWebViewer->SetPrivateBrowsingEnabled(true);
2685 if (__pAddressbar != null)
2687 // __pAddressbar->UpdateFaviconBitmap(true);
2693 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2695 if (__pWebViewer != null)
2697 __pWebViewer->SetPrivateBrowsingEnabled(false);
2700 if (__pAddressbar != null)
2702 // __pAddressbar->UpdateFaviconBitmap(false);
2706 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2708 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2710 else if (__pOptionMenu != null )
2712 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2715 if (pBitmap != null)
2720 AppLog("ABC: OnSceneActivatedN started exit");
2725 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2726 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2728 Canvas* pWebCanvas = null;
2729 if (__pWebViewer != null)
2731 pWebCanvas = __pWebViewer->GetCanvasN();
2734 if (pWebCanvas == null)
2738 if (__pWindowInfo != null)
2740 if (__pWindowInfo->pWebCanvasBitmap != null)
2742 delete __pWindowInfo->pWebCanvasBitmap;
2744 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2745 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2746 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2748 Bitmap* pBitmap = GetCapturedBitmapN();
2749 AppLog("Coming here");
2750 Canvas* pCanvas = new(std::nothrow) Canvas();
2751 pCanvas->Construct(GetClientAreaBounds());
2754 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2757 if(__pWebViewer != null && __pWindowInfo != null)
2758 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2760 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2761 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2763 AppLog("Coming here");
2767 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2768 const Tizen::Base::String& realm,
2769 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2775 MainForm::OnHttpAuthenticationCanceled(void)
2780 MainForm::OnLoadingStarted(void)
2782 AppLogDebug("MainForm::OnLoadingStarted entered");
2784 if(__pAddressbar == NULL || __pWebViewer == null)
2789 // this is added in case if menu is opened and user load the page
2790 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2792 __pOptionMenu->SetShowState(false);
2793 __pOptionMenu->Invalidate(true);
2798 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2800 __pImageMenu->SetShowState(false);
2801 __pImageMenu->Invalidate(true);
2803 String url = __pWebViewer->GetUrl();
2804 if(url.Contains(IDS_TIZEN_SERVICE))
2807 String delim(L":;,");
2809 // Creates a StringTokenizer instance
2810 StringTokenizer strTok(url, delim);
2812 int count = strTok.GetTokenCount(); // count == 4
2814 HashMap *pMap = new HashMap();
2819 while (strTok.HasMoreTokens())
2821 AppLog("Token: %ls", token.GetPointer());
2822 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2823 if(token.Contains(IDS_APPID))
2825 token.SubString(6, appId);
2826 AppLog("AppID:%ls", appId.GetPointer());
2828 else if(token.Contains(IDS_KEY))
2830 token.SubString(4, key);
2831 AppLog("key:%ls", key.GetPointer());
2833 else if(token.Contains(IDS_VALUE))
2835 token.SubString(6, value);
2836 AppLog("value:%ls", value.GetPointer());
2839 pMap->Add(key, value);
2843 AppControl *pAppControl = null;
2844 String operationId = L"http://tizen.org/appcontrol/operation/main";
2845 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2848 AppLog("Starting AppControl");
2849 result r = pAppControl->Start(null, null, pMap, null);
2850 AppLog("Result of Start %s", GetErrorMessage(r));
2854 AppLogException("AppControl not found");
2859 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2861 __pAddressbar->SetShowState(false);
2862 AddressBarCancelledClicked(*__pAddressbar);
2863 __pAddressbar->Invalidate(true);
2865 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2868 __pAddressbar->SetFaviconBitmap(*pBitmap);
2871 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2873 // updating the address bar position with respect to web control
2874 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2875 __distanceMoved = 0;
2879 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2880 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2881 if (__pWebViewer != null)
2883 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2884 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2885 SetUrl(__pWebViewer->GetUrl());
2886 if (__pWindowInfo != NULL)
2888 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2889 __pWindowInfo->pageTitle = L"";
2890 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2892 __pAddressbar->Invalidate(true);
2898 MainForm::OnLoadingCanceled(void)
2905 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2907 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2912 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2914 AppLog("XYZ::MainForm::OnKeypadOpened");
2915 __pFooterPanel->SetShowState(false);
2920 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2922 AppLog("XYZ::MainForm::OnKeypadClosed");
2923 __pFooterPanel->SetShowState(true);
2924 RelayoutControls(true);
2928 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2930 AppLog("XYZ::KeypadBoundsChanged");
2931 RelayoutControls(false);
2935 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2936 const Tizen::Base::String& reason)
2938 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2942 MainForm::OnLoadingCompleted(void)
2944 AppLog("MainForm::OnLoadingCompleted start");
2946 result r = E_SUCCESS;
2948 if (__pWebViewer == null)
2953 if (__pAddressbar == null)
2957 if (__pWebViewer->CanGoForward())
2959 //__pAddressbar->SetForwardButtonEnabled(true);
2960 SetForwardButtonEnabled(true);
2964 //__pAddressbar->SetForwardButtonEnabled(false);
2965 SetForwardButtonEnabled(false);
2968 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2970 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2972 //__pAddressbar->UpdateProgress(0);
2976 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2978 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2982 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2983 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2984 if (isPrivateBrowsing == false)
2986 if(__pHistory != null)
2992 __pHistory = new(std::nothrow) History;
2993 HistoryPresentationModel::GetCurrentDateTime(date);
2996 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2997 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2999 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3000 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3002 __pHistory->SetVisitedTime(date);
3004 if (__pWebViewer != null)
3006 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3008 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3009 if (pTempBitmap != null)
3011 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3012 __pHistory->SetFavIconBitmap(*pTempBitmap);
3015 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3018 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3019 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3020 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3022 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3023 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3024 __pHistory->SetThumbnail(pBitmap);
3026 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3029 __pHistory->SetFavIconBitmap(*pFavIcon);
3033 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3040 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3042 // temperary fixed (webpage can be not loaded)
3046 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3047 if (isReaderEnabled == true)
3051 delete __pReaderData;
3052 __pReaderData = null;
3054 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3055 filePath.Append(L"data/reader.js");
3061 result r = E_SUCCESS;
3062 FileAttributes attr;
3064 File::GetAttributes(filePath,attr);
3066 r = file.Construct(filePath, L"r+");
3069 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3072 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3075 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3078 // file.Read(pScript,attr.GetFileSize());
3080 // AppLogDebug("scipt length %d",strlen(pScript));
3081 String strScript = L"";
3082 // strScript.Append(pScript);
3083 // for(int i=0; i<25; i++)
3085 file.Read(pScript,attr.GetFileSize());
3086 // AppLog("xyzz tell %d",file.Tell());
3087 // r = strScript.Append(pScript);
3088 // AppLog("xyzz append result %s",GetErrorMessage(r));
3089 // AppLog("xyzz strScript length %d",strScript.GetLength());
3091 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3093 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3094 if (__pReaderData == null)
3096 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3097 __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>");
3100 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3101 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3103 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3104 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3110 AppLog("MainForm::OnLoadingCompleted done");
3114 MainForm::OnEstimatedProgress(int progress)
3116 AppLogDebug("MainForm::OnEstimatedProgress entered");
3117 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3118 progress = DEFAULT_PROGRESS_PERCENTAGE;
3120 // __pAddressbar->UpdateProgress(progress);
3121 UpdateProgress(progress);
3124 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3126 AppLog("MainForm::OnFaviconReceived");
3127 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3129 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3132 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3139 MainForm::OnUrlValueChanged(Addressbar&)
3145 MainForm::OnUrlSubmitted(Addressbar& addBar)
3147 AppLog("MainForm::OnUrlSubmitted");
3148 String url = addBar.GetUrl();
3149 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3151 if(__pFooterUrlField)
3152 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3153 AddressBarCancelledClicked(*__pAddressbar);
3158 MainForm::LoadUrl(String& url)
3162 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3163 AppLogDebug("MainForm::LoadUrl enter");
3165 if (__pWebViewer != null)
3167 __pWebViewer->SetShowState(true);
3168 __pWebViewer->Invalidate(true);
3171 if (url.CompareTo(L"") == 0)
3175 if(__pFooterPanel != null)
3177 __pFooterPanel->SetShowState(true);
3178 __pFooterPanel->Invalidate(true);
3185 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3186 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)
3188 RegularExpression firstRegex;
3189 RegularExpression secondRegex;
3191 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3192 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3195 ret = firstRegex.Match(url, false); // This returns true value
3196 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3198 if (ret == true && __pWebViewer != null)
3201 __pWebViewer->LoadUrl(url);
3203 else if(__pWebViewer != null)
3205 String tempUrl = L"http://";
3206 tempUrl.Append(url);
3210 __pWebViewer->LoadUrl(tempUrl);
3214 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3215 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3218 if (__pAddressbar != null)
3220 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3221 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3224 AppLogDebug("MainForm::LoadUrl exit");
3231 MainForm::OnStopClicked(Addressbar& addBar)
3233 AppLogDebug("MainForm::OnStopClicked called");
3236 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3237 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3238 __pWebViewer->StopLoading();
3239 RequestRedraw(true);
3244 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3246 // AppLog("MainForm::OnBackClicked");
3247 result r = E_FAILURE;
3249 if (__pWebViewer && __pWebViewer->CanGoBack())
3251 __pWebViewer->GoBack();
3253 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3256 pApp = UiApp::GetInstance();
3259 r = pApp->Terminate();
3262 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3270 WindowInfo* pWindowInfo = null;
3272 SceneManager* pSceneManager = SceneManager::GetInstance();
3273 if (pSceneManager == null)
3277 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3278 if (pAllWindowList == NULL)
3280 pApp = UiApp::GetInstance();
3283 r = pApp->Terminate();
3286 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3291 if (pAllWindowList != null)
3293 totalCount = pAllWindowList->GetCount();
3295 for (int count = 0; count < totalCount; count++)
3297 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3298 if (pWindowInfo == null)
3300 pApp = UiApp::GetInstance();
3303 r = pApp->Terminate();
3306 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3311 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3313 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3316 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3319 r = pAllWindowList->RemoveAt(count, true);
3320 __pWindowInfo = null;
3323 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3328 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3330 else if(pAllWindowList->GetCount() > 0)
3332 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3336 pApp = UiApp::GetInstance();
3339 r = pApp->Terminate();
3344 if (pWindowInfo == null)
3346 pApp = UiApp::GetInstance();
3349 r = pApp->Terminate();
3355 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3358 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3372 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3374 AppLog("MainForm::OnForwardClicked");
3375 if (__pWebViewer == null)
3378 if (__pWebViewer->CanGoForward())
3380 __pWebViewer->GoForward();
3385 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3387 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3388 if(__pFooterPanel != null)
3390 __pFooterPanel->SetShowState(false);
3393 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3395 __pAddressbar->SetShowState(true);
3396 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3399 RelayoutControls(false);
3403 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3405 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3407 int Height = GetClientAreaBounds().height;
3408 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3411 __pAddressbar->SetShowState(false);
3413 if (__pFooterPanel != null && addressbarKeyPadState == false)
3415 AppLog("akjshdasd 3");
3416 __pFooterPanel->SetShowState(true);
3419 RelayoutControls(false);
3423 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3425 AddressBarCancelledClicked(addBar);
3429 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3431 __prevAddressBarMode = __curAddressBarMode;
3433 if (__pAddressbar != null)
3435 __curAddressBarMode = GetAddressbarMode();
3438 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3440 __adressPanelPosition.y = 0;
3441 if (__pAddressbar != null)
3443 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3444 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3445 __pAddressbar->Invalidate(true);
3447 if (__pWebViewer != null)
3449 __pWebViewer->StopLoading();
3452 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3454 __adressPanelPosition.y = 0;
3455 if (__pAddressbar != null)
3457 __webControlPosition.y = 0;
3458 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3459 __pAddressbar->Invalidate(true);
3465 MainForm::OnClipboardClosed(const Addressbar& addBar)
3467 AppLog("XYZ::MainForm::OnClipboardClosed");
3468 RelayoutControls(false);
3472 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3474 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3475 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3477 AppLog("akjshdasd 3");
3478 __pFooterPanel->SetShowState(true);
3481 RelayoutControls(false,footerState);
3485 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3487 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3488 RelayoutControls(false);
3492 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3494 __pFooterPanel->SetShowState(false);
3498 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3500 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3501 RelayoutControls(false);
3505 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3507 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3510 __pWindowInfo->pageTitle = title;
3511 if (__pWebViewer != null)
3513 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3516 if (__pAddressbar != null && __pWebViewer != null)
3518 SetUrl(__pWebViewer->GetUrl());
3519 __pAddressbar->Invalidate(true);
3524 MainForm::UpdateFavicon(void)
3526 bool urlImageType = false;
3527 String *tempPath = null;
3529 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();");
3530 Bitmap* pBitmap = null;
3532 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3534 if (__pWindowInfo != null)
3537 url.SetUri(*tempPath);
3538 if (url.GetHost().GetLength() == 0)
3541 webUrl.SetUri(__pWebViewer->GetUrl());
3542 result r = url.SetHost(webUrl.GetHost());
3549 if (url.GetScheme().GetLength() == 0)
3552 webUrl.SetUri(__pWebViewer->GetUrl());
3553 url.SetScheme(webUrl.GetScheme());
3555 __pWindowInfo->faviconUrl = url.ToString();
3557 pBitmap = __pWebViewer->GetFaviconN();
3559 if (pBitmap != null)
3561 if (__pWindowInfo->pFavicon != NULL)
3563 __pWindowInfo->pFavicon = null;
3565 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3566 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3568 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3570 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3572 else if(__pWindowInfo->pFavicon != null)
3574 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3578 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3579 if(pDefaultBmp != null)
3581 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3590 if(tempPath != null)
3594 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3601 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3602 Tizen::Web::Controls::WebNavigationType type)
3604 // when load new page if find word panel is open its show state is false
3605 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3607 __currentSearchStr = L"";
3608 __currentWordIndex = 0;
3609 __maxOccurrances = 0;
3610 __pFindWordEditField->SetText(L"");
3611 __pFindWordNext->SetEnabled(false);
3612 __pFindWordPrev->SetEnabled(false);
3613 __pFindWordCountLabel->SetText(L"0/0");
3614 __pFindWordControl->SetShowState(false);
3615 __pFindWordEditField->HideKeypad();
3616 RelayoutControls(false);
3621 __pFooterPanel->Invalidate(true);
3624 uriInfo.SetUri(url);
3626 if(url.Contains(IDS_TIZEN_SERVICE))
3629 String delim(L":;,");
3631 // Creates a StringTokenizer instance
3632 StringTokenizer strTok(url, delim);
3634 int count = strTok.GetTokenCount(); // count == 4
3636 HashMap *pMap = new HashMap();
3642 while (strTok.HasMoreTokens())
3644 AppLog("Token: %ls", token.GetPointer());
3645 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3646 if(token.Contains(IDS_APPID))
3648 token.SubString(6, appId);
3649 AppLog("AppID:%ls", appId.GetPointer());
3651 else if(token.Contains(IDS_KEY))
3653 token.SubString(4, key);
3654 AppLog("key:%ls", key.GetPointer());
3656 else if(token.Contains(IDS_VALUE))
3658 token.SubString(6, value);
3659 AppLog("value:%ls", value.GetPointer());
3662 pMap->Add(key, value);
3666 AppControl *pAppControl = null;
3667 String operationId = L"http://tizen.org/appcontrol/operation/main";
3668 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3671 result r = pAppControl->Start(null, null, pMap, null);
3675 AppLogException("AppControl not found");
3685 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3686 const Tizen::Net::Http::HttpHeader& httpHeader)
3688 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3693 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3695 AppLog("MainForm::OnWebPageBlockSelected");
3696 if (__pHitElementResult != null)
3698 delete __pHitElementResult;
3699 __pHitElementResult = null;
3702 if (__pWebViewer != null)
3704 AppLog("MainForm::OnWebPageBlockSelected web not null");
3705 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3707 if(GetLastResult() == E_INVALID_ARG)
3709 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3710 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3711 if(GetLastResult() == E_INVALID_ARG)
3713 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3715 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3719 if (__pHitElementResult == null)
3724 if (__pHitElementResult->HasImage() != true)
3726 String tagName = __pHitElementResult->GetTagName();
3727 String type = __pHitElementResult->GetAttributeValue("type");
3730 AppLog("TagName %ls",tagName.GetPointer());
3731 __currentSelectedStr.Clear();
3732 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3733 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3734 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3736 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3738 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3740 InitSelectTextContextMenuF(endPoint,true);
3741 __pImageMenu->SetShowState(true);
3742 __pImageMenu->Show();
3743 __pImageMenu->Invalidate(true);
3745 else /*if(__isLongPressedDone == true)*/
3747 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3749 if(__pHitElementResult->GetUrl().GetLength() > 0)
3751 __currentSelectedStr.Clear();
3752 __currentSelectedStr = __pHitElementResult->GetUrl();
3754 InitSelectTextContextMenuF(endPoint,false);
3755 __pImageMenu->SetShowState(true);
3756 __pImageMenu->Show();
3757 __pImageMenu->Invalidate(true);
3760 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3761 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3762 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3768 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3774 MainForm::OnWebWindowCreateRequested(void)
3776 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3778 if (pNewWindowInfo == null)
3782 result r = E_SUCCESS;
3783 SceneManager* pSceneManager = SceneManager::GetInstance();
3784 if (pSceneManager == NULL)
3788 ArrayList* pArgList = new(std::nothrow) ArrayList();
3789 if (pArgList == NULL)
3793 r = pArgList->Construct();
3796 pNewWindowInfo->isJavascriptInitiated = true;
3797 pArgList->Add(*pNewWindowInfo);
3798 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3802 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3809 return pNewWindowInfo->pCurrentWeb;
3813 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3815 AppLog("xyz:: MainForm::RelayoutControls called");
3816 __webControlPosition.y = 0;
3817 __webControlHeight = GetClientAreaBounds().height;
3818 AppLog("Client area height: %d", __webControlHeight);
3820 AppLog("Client area height: %d", __webControlHeight);
3821 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3823 __webControlPosition.y += __pAddressbar->GetHeight();
3824 __webControlHeight -= __pAddressbar->GetHeight();
3825 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3827 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3829 __webControlPosition.y += __pFindWordControl->GetHeight();
3830 __webControlHeight -= __pFindWordControl->GetHeight();
3831 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3834 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3836 __webControlHeight -= __pFooterPanel->GetHeight();
3838 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3840 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3842 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3847 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3848 __pWebViewer->Invalidate(false);
3851 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3853 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3860 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3862 if (__pFindWordControl == null)
3867 Tizen::Locales::LocaleManager localeManager;
3868 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3870 String languageCode;
3871 result r = SettingInfo::GetValue(L"Language", languageCode);
3872 // int languagecode = local.GetLanguageCode();
3873 AppLog("rahul language is %S", languageCode.GetPointer());
3877 InitFindWordPanel();
3879 if (languageCode.CompareTo("ara") == 0)
3881 AppLog("rahul language is arabic");
3883 __pFindWordPanelLeftToRight->SetShowState(false);
3884 __pFindWordPanelRightToLeft->SetShowState(true);
3886 __pFindWordClear->SetShowState(false);
3887 __pFindWordCountLabel->SetShowState(false);
3888 __pFindWordEditField->SetShowState(false);
3890 __pFindWordClearRightToLeft->SetShowState(true);
3891 __pFindWordCountLabelRightToLeft->SetShowState(true);
3892 __pFindWordEditFieldRightToLeft->SetShowState(true);
3896 AppLog("rahul language is not arabic");
3899 __pFindWordPanelLeftToRight->SetShowState(true);
3900 __pFindWordPanelRightToLeft->SetShowState(false);
3902 __pFindWordClear->SetShowState(true);
3903 __pFindWordCountLabel->SetShowState(true);
3904 __pFindWordEditField->SetShowState(true);
3906 __pFindWordClearRightToLeft->SetShowState(false);
3907 __pFindWordCountLabelRightToLeft->SetShowState(false);
3908 __pFindWordEditFieldRightToLeft->SetShowState(false);
3910 __pFindWordControl->SetShowState(true);
3914 if(__pFindWordControl != null)
3916 __pFindWordControl->SetShowState(false);
3920 AppLog("MainForm::ShowFindWordPanel %d",show);
3921 if (show && !isTouchPressed)
3923 if (languageCode.CompareTo("ara") == 0)
3925 if (__pFindWordEditFieldRightToLeft)
3927 __pFindWordEditFieldRightToLeft->SetFocus();
3928 __pFindWordEditFieldRightToLeft->ShowKeypad();
3933 if (__pFindWordEditField)
3935 __pFindWordEditField->SetFocus();
3936 __pFindWordEditField->ShowKeypad();
3942 if (languageCode.CompareTo("ara") == 0)
3944 if (__pFindWordEditFieldRightToLeft)
3945 __pFindWordEditFieldRightToLeft->HideKeypad();
3949 if (__pFindWordEditField)
3950 __pFindWordEditField->HideKeypad();
3954 RelayoutControls(false);
3958 MainForm::StartWordSearch()
3960 //Get the count of occurances of the word in the current page
3961 __maxOccurrances = 0;
3962 __currentWordIndex = 0;
3964 __pFindWordPrev->SetEnabled(false);
3965 String *pCountStr = null;
3966 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3967 AppLog("Search Result %s",GetErrorMessage(r));
3968 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3969 if (pCountStr != null)
3971 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3975 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3980 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3982 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3983 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3985 if(totalCount == -1 || totalCount == 0)
3987 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3988 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3991 else if(totalCount > 100)
3993 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3994 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3998 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3999 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4002 __maxOccurrances = totalCount;
4003 __currentWordIndex = currentOrdinal;
4005 //Reset the UI controls as per the maxOccurrance value
4006 if (totalCount <= 0)
4008 AppLog("Word not found");
4009 //Show error notification to user
4010 __pFindWordNext->SetEnabled(false);
4011 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4013 __pFindWordCountLabel->SetText(L"0/0");
4014 __pFindWordCountLabel->Invalidate(false);
4016 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4018 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4019 __pFindWordCountLabelRightToLeft->Invalidate(false);
4021 __pFindWordNext->Invalidate(false);
4022 __pFindWordPrev->Invalidate(false);
4027 if (totalCount == 1)
4029 __pFindWordNext->SetEnabled(false);
4033 __pFindWordNext->SetEnabled(true);
4036 String countStr = L"";
4037 countStr.Append(__currentWordIndex);
4038 countStr.Append(L"/");
4039 countStr.Append(__maxOccurrances);
4040 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4042 __pFindWordCountLabel->SetText(countStr);
4043 __pFindWordCountLabel->Invalidate(false);
4044 __pFindWordCountLabel->Invalidate(false);
4046 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4048 __pFindWordCountLabelRightToLeft->SetText(countStr);
4049 __pFindWordCountLabelRightToLeft->Invalidate(false);
4050 __pFindWordCountLabelRightToLeft->Invalidate(false);
4052 //FindNextWord(true);
4053 //Update the controls
4054 __pFindWordNext->Invalidate(false);
4055 __pFindWordPrev->Invalidate(false);
4060 MainForm::FindNextWord(bool next)
4064 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4065 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4067 if (__currentWordIndex < __maxOccurrances)
4069 __currentWordIndex++;
4075 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4076 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4078 if(__currentWordIndex > 1)
4080 __currentWordIndex--;
4085 String countStr = L"";
4086 countStr.Append(__currentWordIndex);
4087 countStr.Append(L"/");
4088 countStr.Append(__maxOccurrances);
4090 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4092 __pFindWordCountLabel->SetText(countStr);
4093 __pFindWordCountLabel->Invalidate(false);
4095 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4097 __pFindWordCountLabelRightToLeft->SetText(countStr);
4098 __pFindWordCountLabelRightToLeft->Invalidate(false);
4101 if (__currentWordIndex >= __maxOccurrances)
4103 __pFindWordNext->SetEnabled(false);
4107 __pFindWordNext->SetEnabled(true);
4109 if (__currentWordIndex <= 1)
4111 __pFindWordPrev->SetEnabled(false);
4115 __pFindWordPrev->SetEnabled(true);
4117 __pFindWordPrev->Invalidate(false);
4118 __pFindWordNext->Invalidate(false);
4120 __pFindWordControl->Invalidate(true);
4124 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4126 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4127 __isWebKeypadOpened = true;
4128 __pFooterPanel->SetShowState(false);
4129 // OnAddressBarKeypadOpened(*__pAddressbar);
4133 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4135 AppLog("xyz::MainForm::OnWebKeypadOpened");
4137 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4139 __currentSearchStr = L"";
4140 __currentWordIndex = 0;
4141 __maxOccurrances = 0;
4142 __pFindWordEditField->SetText(L"");
4143 __pFindWordNext->SetEnabled(false);
4144 __pFindWordPrev->SetEnabled(false);
4145 __pFindWordCountLabel->SetText(L"0/0");
4146 __pWebViewer->SearchTextAllAsync(L"",false);
4147 __pFindWordControl->SetShowState(false);
4148 __pFindWordEditField->HideKeypad();
4152 if (__pWebViewer != null && __pFooterPanel != null)
4154 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4155 if(__pAddressbar != null)
4157 __pAddressbar->SetShowState(false);
4159 if(__pFindWordControl != null)
4161 __pFindWordControl->SetShowState(false);
4163 __pFooterPanel->SetShowState(false);
4164 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4166 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4168 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4169 // AppLog("omgomgomg");
4175 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4177 AppLog("xyz::MainForm::OnWebKeypadClosed");
4178 AppLog("akjshdasd 4");
4179 __pFooterPanel->SetShowState(true);
4180 // OnAddressBarKeypadClosed(*__pAddressbar);
4181 RelayoutControls(false);
4182 __isWebKeypadOpened = false;
4186 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4188 // RelativeLayout(false);
4189 if(__pWebViewer != null)
4191 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4196 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4198 Control* temp = const_cast< Control* >(&source);
4199 Header* pHeader = dynamic_cast< Header* >(temp);
4200 if (pHeader != null)
4202 //Header double - clicked
4203 AppLog("Header double clicked");
4205 if(__pFindWordControl)
4207 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4208 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4212 AppLog("MainScene::OnTouchDoublePressed");
4216 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4218 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4219 __longPressPoint = currentPosition;
4221 if (__pHitElementResult != null)
4223 delete __pHitElementResult;
4224 __pHitElementResult = null;
4227 if (__pWebViewer != null)
4229 AppLog("MainForm::OnTouchLongPressed web not null");
4230 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4233 if (__pHitElementResult == null)
4238 if (__pHitElementResult->HasImage() == true)
4240 InitImageContextMenu(currentPosition);
4241 __pImageMenu->SetShowState(true);
4242 __pImageMenu->Show();
4243 __pImageMenu->Invalidate(true);
4245 else if(__pHitElementResult->HasUrl() == true)
4247 String tempURl = __pHitElementResult->GetUrl();
4248 AppLog("tempURl is %ls", tempURl.GetPointer());
4249 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4250 if (pBitmap != null)
4258 InitImageLinkContextMenu(currentPosition);
4259 __pImageMenu->SetShowState(true);
4260 __pImageMenu->Show();
4261 __pImageMenu->Invalidate(true);
4265 String tagName = __pHitElementResult->GetTagName();
4266 String type = __pHitElementResult->GetAttributeValue("type");
4267 String value = __pHitElementResult->GetAttributeValue(L"value");
4268 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4270 __currentSelectedStr.Clear();
4271 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4273 AppLog("tag name is %ls", tagName.GetPointer());
4274 AppLog("type is %ls", type.GetPointer());
4278 //__isLongPressedDone = true;
4279 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4280 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4282 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4284 InitSelectTextContextMenu(currentPosition,true, true);
4287 __pImageMenu->SetShowState(true);
4288 __pImageMenu->Show();
4289 __pImageMenu->Invalidate(true);
4292 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4295 // __inputEventToBeSupressed = true;
4299 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4301 AppLog("xyz:: MainForm::OnTouchReleased called");
4303 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4305 __pAddressbar->SetShowState(false);
4309 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4310 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4312 __pWebViewer->ConsumeInputEvent();
4314 if(pHitElement != null)
4318 __inputEventToBeSupressed = false;*/
4322 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4329 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4331 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4333 __currentSearchStr = L"";
4334 __currentWordIndex = 0;
4335 __maxOccurrances = 0;
4337 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4339 __pFindWordEditField->SetText(L"");
4340 __pFindWordEditField->HideKeypad();
4341 __pFindWordControl->SetShowState(false);
4342 __pFindWordCountLabel->SetText(L"0/0");
4344 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4346 __pFindWordEditFieldRightToLeft->SetText(L"");
4347 __pFindWordEditFieldRightToLeft->HideKeypad();
4348 __pFindWordControl->SetShowState(false);
4349 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4352 __pFindWordNext->SetEnabled(false);
4353 __pFindWordPrev->SetEnabled(false);
4355 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4356 __pFindWordControl->SetShowState(false);
4358 if(__pAddressbar->GetShowState() == false)
4360 __pAddressbar->SetAddressbarURLFocus();
4361 __pFooterPanel->SetShowState(false);
4368 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4374 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4380 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4386 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4392 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4398 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4400 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4401 int widthContextItem = 0;
4403 // As per the platform engineer comment removed this line
4404 /*if(__pWebViewer != null)
4406 // 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
4407 __pWebViewer->ReleaseBlock();
4410 // if(__pFindWordControl != null)
4411 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4412 if(__pNotification && __pNotification->GetShowState() == true)
4414 __pNotification->SetShowState(false);
4415 __pNotification->Invalidate(false);
4417 if ( __pFooterLabel != null)
4419 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4422 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4428 if (__pFindWordBgLabel != null)
4430 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4431 if (pBitmap != null)
4433 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4438 if (__pFindWordBgLabelRightToLeft != null)
4440 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4441 if (pBitmap != null)
4443 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4449 if(__pOptionMenu != null)
4450 __pOptionMenu->SetShowState(false);
4452 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4454 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4458 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4463 AppLog("__pFooterPanel->GetShowState() is true");
4465 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4466 __pFooterPanel->Invalidate(true);
4470 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4471 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4473 InitMostVisitedSitesView(orientationStatus);
4476 RelayoutControls(false);
4477 if (__pArticleReaderPanel != null)
4479 if (__pArticleReaderPanel->GetShowState() == true)
4481 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4483 if (__pBlankPanel != null)
4484 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4486 if (__pWebReader != null)
4488 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4490 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4491 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4493 if ( pBitmap != null && pSrcBitmap != null)
4495 AppLog("CreateReaderPanel ninepatchbitmap found");
4496 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4499 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4500 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4501 if (pBitmap != null)
4506 if (pSrcBitmap != null)
4515 if (__pAddressbar != null)
4517 int width = GetClientAreaBounds().width;
4518 __pAddressbar->OrientationChanged(width);
4523 MainForm::OnSettingsChange(int settingvalue)
4525 AppLogDebug("MainForm::OnSettingsChange entered");
4527 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4529 __pAddressbar->ResetGuideText();
4531 if (__pWebViewer == null)
4533 AppLogDebug("Webviewer is not initialized yet.");
4537 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4539 WebSetting settings = __pWebViewer->GetSetting();
4540 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4542 settings.SetAutoFittingEnabled(true);
4544 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4546 settings.SetAutoFittingEnabled(false);
4548 __pWebViewer->SetSetting(settings);
4550 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4552 WebSetting settings = __pWebViewer->GetSetting();
4553 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4554 __pWebViewer->SetSetting(settings);
4556 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4558 WebSetting settings = __pWebViewer->GetSetting();
4559 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4560 __pWebViewer->SetSetting(settings);
4561 __pWebViewer->Reload();
4563 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4565 WebSetting settings = __pWebViewer->GetSetting();
4566 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4567 __pWebViewer->SetSetting(settings);
4569 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4573 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4576 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4580 WebSetting settings = __pWebViewer->GetSetting();
4581 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4582 __pWebViewer->SetSetting(settings);
4585 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4589 WebSetting settings = __pWebViewer->GetSetting();
4590 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4591 __pWebViewer->SetSetting(settings);
4594 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4596 WebSetting settings = __pWebViewer->GetSetting();
4597 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4599 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4603 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4605 __pWebViewer->SetSetting(settings);
4607 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4611 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4612 WebSetting settings = __pWebReader->GetSetting();
4613 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4614 __pWebReader->SetSetting(settings);
4620 MainForm::OnSettingsReset()
4624 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4625 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4630 MainForm::OnClearCache()
4632 result r = E_SUCCESS;
4634 if (__pWebViewer != NULL)
4636 r = __pWebViewer->ClearCache();
4639 AppLogDebug("Cache cleared success");
4643 AppLogDebug("Cache cleared fail");
4649 MainForm::OnClearCookie()
4651 result r = E_SUCCESS;
4653 if (__pWebViewer != NULL)
4655 __pWebViewer->ClearCookie();
4659 AppLogDebug("Cookie cleared success");
4663 AppLogDebug("Cache cleared fail");
4668 MainForm::OnClearFormData()
4670 result r = E_SUCCESS;
4672 if (__pWebViewer != NULL)
4674 __pWebViewer->ClearFormData();
4678 AppLogDebug("Cookie cleared success");
4682 AppLogDebug("Cache cleared fail");
4687 MainForm::OnClearPasswords()
4689 result r = E_SUCCESS;
4691 if (__pWebViewer != NULL)
4693 __pWebViewer->ClearLoginFormData();
4697 AppLogDebug("Cookie cleared success");
4701 AppLogDebug("Cache cleared fail");
4707 MainForm::findDistance(int x1,int y1,int x2, int y2)
4709 int deltaX = Math::Abs(x2 - x1);
4710 int deltaY = Math::Abs(y2 - y1);
4711 double num = deltaX*deltaX + deltaY*deltaY;
4717 for (i = 0; i < 20; i++)
4719 x = (((x*x)+ num)/(2*x));
4730 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4732 AppLog("xyz:: MainForm::OnTouchPressed called");
4733 if(__pFindWordControl)
4735 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4736 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4738 //__isLongPressedDone = false;
4743 IList* pList = null;
4744 pList = touch.GetTouchInfoListN(source);
4748 int count = pList->GetCount();
4751 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4752 __touchPoint1 = pTouchInfo->position;
4754 /*if (__pAddressbar != null)
4756 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4758 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4760 __pAddressbar->SaveAddressbarEditText();
4762 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4765 __pAddressbar->Invalidate(true);
4767 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4769 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4771 //__pAddressbar->SaveAddressbarEditText();
4773 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4776 else if (count == 2)
4778 AppLogDebug("MainForm::OnTouchPressed count is two");
4779 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4780 __touchPoint1 = pTouchInfo->position;
4782 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4783 __touchPoint2 = pTouchInfo->position;
4788 pList->RemoveAll(true);
4791 // RelayoutControls(false);
4796 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4798 // __currentWordIndex = 0;
4799 //__isLongPressedDone = false;
4804 MainForm::MoveUiControls()
4809 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4811 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4813 if(__pFooterUrlField->GetTextLength() == 0)
4815 __pFooterUrlField->SetKeypadActionEnabled(false);
4819 __pFooterUrlField->SetKeypadActionEnabled(true);
4822 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4824 __currentSearchStr = __pFindWordEditField->GetText();
4825 if (__currentSearchStr.GetLength() > 0)
4827 __pFindWordCountLabel->SetShowState(true);
4831 __pFindWordCountLabel->SetShowState(false);
4833 __pFindWordNext->SetEnabled(false);
4834 __pFindWordPrev->SetEnabled(false);
4835 __pFindWordNext->Invalidate(true);
4836 __pFindWordPrev->Invalidate(true);
4837 __pFindWordCountLabel->SetText(L"0/0");
4838 __pFindWordCountLabel->Invalidate(true);
4840 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4842 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4843 if (__currentSearchStr.GetLength() > 0)
4845 __pFindWordCountLabelRightToLeft->SetShowState(true);
4849 __pFindWordCountLabelRightToLeft->SetShowState(false);
4852 __pFindWordNext->SetEnabled(false);
4853 __pFindWordPrev->SetEnabled(false);
4854 __pFindWordNext->Invalidate(true);
4855 __pFindWordPrev->Invalidate(true);
4856 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4857 __pFindWordCountLabelRightToLeft->Invalidate(true);
4859 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4860 if (__currentSearchStr.GetLength() > 0)
4866 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4868 __currentSearchStr = L"";
4869 AppLogDebug("Enter something");
4874 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4881 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4883 if(__pWebViewer != null)
4886 AppLog("MainForm::InitMostVisitedSitesView");
4887 result r = E_SUCCESS;
4890 if (__pWebViewer != null && __pMostVisitedListView != null)
4895 if (__pMostVisitedListView != null)
4897 RemoveControl(__pMostVisitedListView);
4899 if(__pMostVisitedSites != null)
4901 __pMostVisitedSites->RemoveAll(true);
4904 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4906 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4907 __pMostVisitedListView = new(std::nothrow) ListView();
4909 int height = GetClientAreaBounds().height;
4911 if(__pFooterPanel->GetShowState() == true)
4913 height = height - __pFooterPanel->GetHeight();
4915 if(__pAddressbar->GetShowState() == true)
4917 height -= __pAddressbar->GetHeight();
4920 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4924 delete __pMostVisitedListView;
4925 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4928 __pMostVisitedListView->SetItemProvider(*this);
4929 __pMostVisitedListView->AddListViewItemEventListener(*this);
4930 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4931 AddControl(__pMostVisitedListView);
4932 __pMostVisitedListView->UpdateList();
4939 MainForm::GetImagePath(void)
4943 String formattedTime;
4944 DateTime currentTime;
4945 LocaleManager localManager;
4946 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4948 localManager.Construct();
4949 Locale locale = localManager.GetSystemLocale();
4950 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4952 // Get date formatter
4953 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4957 pTimeFormatter->Format(currentTime, formattedTime);
4960 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4961 String delim(L" :");
4962 StringTokenizer strTok(formattedTime, delim);
4965 String str1("GMT+00");
4966 while (strTok.HasMoreTokens())
4968 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4969 if(token.Equals(str1))
4971 AppLog("token is %ls", token.GetPointer());
4972 imageName.Append(token);
4978 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4980 result r = E_FAILURE;
4981 AppLog("Content manager 1");
4982 ContentId contentId;
4983 ContentManager contentManager;
4984 r = contentManager.Construct();
4987 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4990 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4991 Tizen::Io::Directory::Create(contentPath,true);
4992 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4994 AppLog("Already exists");
4996 else if(GetLastResult() == E_SUCCESS)
4998 AppLog("created success");
5000 contentPath.Append(imageName);
5001 contentPath.Append(".jpg");
5002 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5003 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5007 MainForm::SetForwardButtonEnabled(bool isEnabled)
5009 __pGoForwardBtn->SetEnabled(isEnabled);
5010 __pGoForwardBtn->Invalidate(true);
5014 MainForm::SetBackButtonEnabled(bool isEnabled)
5016 __pGoBackBtn->SetEnabled(isEnabled);
5017 __pGoBackBtn->Invalidate(true);
5021 MainForm::UpdateProgress(int percentage)
5023 __progressPercentage = percentage;
5024 if (percentage == 0 || percentage == 100)
5026 __isLoadingData = false;
5027 if (percentage == 100)
5029 __isLoadingCompleted = true;
5030 __progressPercentage = 0;
5034 __isLoadingCompleted = false;
5039 __isLoadingData = true;
5041 UpdateProgressBitmap();
5045 MainForm::GetProgress(void)
5047 return __progressPercentage;
5051 MainForm::UpdateProgressBitmap(void)
5053 result r = E_SUCCESS;
5054 if (__pProgressbarLabel == null)
5056 int w = __pProgressbarLabel->GetWidth();
5057 int h = __pProgressbarLabel->GetHeight();
5059 int progressWidth = 0;
5060 Bitmap* pRetBitmap = null;
5062 if (__progressPercentage == 0 || __progressPercentage == 100)
5064 __pProgressbarLabel->SetShowState(false);
5065 __pProgressbarLabel->Invalidate(false);
5070 __pProgressbarLabel->SetShowState(true);
5071 __pProgressbarLabel->Invalidate(false);
5074 r = canvas.Construct(Rectangle(0, 0, w, h));
5078 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5083 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5087 pBgBmp->Scale(Dimension(w, h));
5088 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5092 progressWidth = (double) (w) * __progressPercentage / 100;
5093 AppLogDebug("progressWidth: %d", progressWidth);
5094 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5096 if (pProgressBmp != null)
5098 pProgressBmp->Scale(Dimension(progressWidth, h));
5099 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5100 delete pProgressBmp;
5103 pRetBitmap = new (std::nothrow) Bitmap();
5105 if (pRetBitmap == null)
5107 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5111 pRetBitmap->Construct(canvas, canvas.GetBounds());
5113 if (__pProgressbarLabel != null && pRetBitmap != null)
5115 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5116 __pProgressbarLabel->Invalidate(false);
5119 if (pRetBitmap != null)
5128 MainForm::ReaderClicked()
5130 result r = E_SUCCESS;
5131 ArrayList* pArgList = new(std::nothrow) ArrayList();
5132 if (pArgList != null)
5134 r = pArgList->Construct();
5141 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5148 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5155 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5163 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5167 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
5169 CreateReaderPanel();
5170 AppLogDebug("MainScene::ReaderClicked entered");
5173 /*if (__pArticleReaderPanel)
5175 AppLogDebug("showstate true for reader panel");
5176 __pArticleReaderPanel->SetShowState(true);
5177 __pArticleReaderPanel->Show();
5179 int xPos = __pArticleReaderPanel->GetX();
5180 int yPos = __pArticleReaderPanel->GetY();
5181 AppLog("ReaderClicked() xPos = %d",xPos);
5182 AppLog("ReaderClicked() yPos = %d",yPos);
5184 if (__pReaderData == null)
5189 String loadData = L"<html>\
5191 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
5196 background-color: transparent;\
5215 <body style='width:'";
5216 loadData.Append(bodyWidth);
5217 loadData.Append(L"px'>");
5218 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5219 loadData.Append(*__pReaderData);
5220 loadData.Append(L"</body></html>");
5223 buf.Construct(loadData.GetLength());
5224 AppLogDebug("data->GetLength %d",loadData.GetLength());
5225 for (int z=0;z<loadData.GetLength();z++)
5228 loadData.GetCharAt(z,b);
5229 buf.SetByte((byte)b);
5233 if (__pWebReader != null)
5235 __pWebReader->LoadData(L"",buf,L"text/html");
5236 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5240 AppLogDebug("cannot LoadData __pWebReader is null");
5245 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5247 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5249 __currentAddMode = addMode;
5253 case ADDRESSBAR_MODE_INVALID:
5258 case ADDRESSBAR_MODE_READER:
5260 __pStopBtn->SetShowState(false);
5261 __pRefreshBtn->SetShowState(false);
5262 __pClearBtn->SetShowState(false);
5263 __pReaderBtn->SetShowState(false);
5266 case ADDRESSBAR_MODE_LOADING:
5268 __pRefreshBtn->SetShowState(false);
5269 __pStopBtn->SetShowState(true);
5270 __pClearBtn->SetShowState(false);
5271 __pReaderBtn->SetShowState(false);
5274 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5276 // SetUrl(__pAddressbar->GetUrl());
5278 __pRefreshBtn->SetShowState(true);
5279 __pStopBtn->SetShowState(false);
5280 __pClearBtn->SetShowState(false);
5281 __pReaderBtn->SetShowState(false);
5284 case ADDRESSBAR_MODE_EDIT:
5286 __pRefreshBtn->SetShowState(false);
5287 __pStopBtn->SetShowState(false);
5288 __pReaderBtn->SetShowState(false);
5289 __pClearBtn->SetShowState(true);
5296 OnAddressBarModeChanged();
5299 AddressBarMode MainForm::GetAddressbarMode(void)
5301 return __currentAddMode;
5304 void MainForm::SetUrl(const String& url)
5307 if(__displayUrl.GetLength() > 2048)
5308 __displayUrl.SubString(0,2048,__displayUrl);
5310 if (__pFooterUrlField != NULL)
5312 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5313 if (removedHttpUrl.IsEmpty() == false)
5315 __pFooterUrlField->SetText(removedHttpUrl);
5316 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5317 __pAddressbar->SetUrl(__displayUrl);
5321 __pFooterUrlField->SetText(__displayUrl);
5322 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5323 __pAddressbar->SetUrl(__displayUrl);
5325 if(__pFooterUrlField)
5326 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5327 __pFooterUrlField->Invalidate(false);
5328 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5329 __pAddressbar->Invalidate(true);
5330 // __pFooterUrlField->SetCursorPosition(0);
5335 MainForm::RemoveHttpTextFromDisplayURL(void)
5337 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5339 // bool isHttpText = __displayUrl.Contains(L"http://");
5340 String updatedDisplayUrl;
5341 updatedDisplayUrl.Clear();
5342 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5344 __displayUrl.SubString(7,updatedDisplayUrl);
5346 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5348 __displayUrl.SubString(8,updatedDisplayUrl);
5350 return updatedDisplayUrl;
5353 void MainForm::OnSharePopupControlStarted(void)
5355 __pWebViewer->AddTouchEventListener(*this);
5359 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5361 if (requestId == BACK_GROUND_APP_EVENT)
5363 if(__pWebViewer != null)
5365 __pWebViewer->Pause();
5367 if(__pAddressbar != null)
5369 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5372 else if(requestId == FORE_GROUND_APP_EVENT)
5374 if(__pWebViewer != null)
5376 __pWebViewer->Resume();
5378 if(__pAddressbar != null)
5380 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5386 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5388 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5389 result r = E_SUCCESS;
5392 __pAddressbar->SetShowState(false);
5394 //AppLog("akjshdasd 5");
5395 //__pFooterPanel->SetShowState(true);
5398 __pWebViewer->SetFocus();
5399 else if(__pMostVisitedListView)
5400 __pMostVisitedListView->SetFocus();
5401 else if(__pMultiWindowButton)
5402 __pMultiWindowButton->SetFocus();
5403 else if(__pMoreButton)
5404 __pMoreButton->SetFocus();
5406 __pAddressbar->SetShowState(false);
5408 RelayoutControls(false);
5412 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5414 AppLog("MainForm::OnFormMenuRequested called");
5416 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5418 int bookmarkCount=0;
5421 url=__pWindowInfo->pageUrl;
5422 result r = E_SUCCESS;
5423 Bitmap* pBitmap = null;
5425 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5428 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5433 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5437 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5439 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5441 if (__pOptionMenu->GetItemCount() == 9)
5443 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5447 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5452 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5456 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5457 if (__pOptionMenu->GetItemCount() != 9)
5459 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5460 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5461 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5462 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5463 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5464 __pOptionMenu->SetMaxVisibleItemsCount(6);
5466 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5468 AppLog(" Orientation landscape");
5469 __pOptionMenu->SetMaxVisibleItemsCount(5);
5473 AppLog(" Orientation potrait");
5474 __pOptionMenu->SetMaxVisibleItemsCount(6);
5477 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5480 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5481 __pOptionMenu->SetShowState(true);
5482 __pOptionMenu->Invalidate(true);
5483 __pOptionMenu->Show();