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 __isHwKeySupported = false;
215 __pNotification = null;
218 MainForm::~MainForm(void)
220 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
224 __pAddressbar->SetAddressbarEventListener(null);
227 if(__pHistory != null)
233 if (__pReaderData != null)
235 delete __pReaderData;
236 __pReaderData = null;
239 if (__pPopUp != null)
245 if (__pHitElementResult != null)
247 delete __pHitElementResult;
248 __pHitElementResult = null;
251 String* pSelectedScene = NULL;
252 Object* pValue = NULL;
253 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
254 pSelectedScene = (String*) pValue;
256 /*if (pSelectedScene != null)
258 delete pSelectedScene;
260 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
264 MainForm::Initialize(void)
266 InternetApp* pInternet = static_cast<InternetApp*> (Application::GetInstance());
271 __isHwKeySupported = pInternet->IsHwBackKeyExists();
273 if(__isHwKeySupported)
275 Construct(L"IDL_FORM_HW_KEY");
279 Construct(L"IDL_FORM");
281 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER);
286 MainForm::OnInitializing(void)
288 AppLog("get client area width = %d",GetClientAreaBounds().width);
289 AppLog("get client area height = %d",GetClientAreaBounds().height);
290 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
291 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
293 __fontSize = CommonUtil::GetFontSize();
294 Panel* pFooterPanel = null;
296 __pSaveImage = new Image();
297 __pSaveImage->Construct();
299 // Setup back event listener
300 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
301 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
302 AddOrientationEventListener(*this);
304 AppLogDebug(" MainForm::OnInitializing ended");
305 if (__pMostVisitedSites == null)
307 __pMostVisitedSites = new(std::nothrow) ArrayList();
308 __pMostVisitedSites->Construct();
310 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
312 __pItemContext= new(std::nothrow) ListContextItem();
313 __pItemContext->Construct();
315 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
318 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
319 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
320 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
322 __pItemContextLandscape= new(std::nothrow) ListContextItem();
323 __pItemContextLandscape->Construct();
325 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
326 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
327 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
328 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
329 SetFormMenuEventListener(this);
334 MainForm::InitAddressbar(void)
336 AppLogDebug("MainForm::InitAddressbar entered");
338 result r = E_SUCCESS;
340 if (__pAddressbar != null)
344 __pAddressbar = new(std::nothrow) Addressbar();
345 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
346 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
349 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
352 __pAddressbar->SetAddressbarEventListener(this);
353 AddControl(__pAddressbar);
354 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
355 SetControlAlwaysOnTop(*__pAddressbar, true);
356 __adressPanelPosition = __pAddressbar->GetPosition();
358 AppLogDebug("MainForm::InitAddressbar exit");
364 MainForm::CreateReaderPanel(void)
366 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
367 result r = E_FAILURE;
369 Button *pSmallFontBtn = null;
370 Button *pLargeFontBtn = null;
372 __pBlankPanel = new (std::nothrow) Panel();
373 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
375 __pArticleReaderPanel = new (std::nothrow) Panel();
376 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
378 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
379 if (__pReaderCloseBtn)
381 AppLogDebug("CreateReaderPanel() 6");
382 __pReaderCloseBtn->AddActionEventListener(*this);
383 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
386 __pWebReader = new (std::nothrow) Web();
387 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
389 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
390 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
392 r = __pWebReader->SetSetting(settings);
394 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
397 __pArticleReaderLabel = new Label();
398 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
400 __pBlankPanel->AddControl(__pArticleReaderLabel);
401 __pBlankPanel->AddControl(__pArticleReaderPanel);
402 AddControl(__pBlankPanel);
404 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
405 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
406 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
408 __pArticleReaderPanel->AddControl(__pWebReader);
409 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
410 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
411 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
413 if (pBitmap != null && pSrcBitmap != null)
415 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
417 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
419 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
422 pSmallFontBtn->AddActionEventListener(*this);
423 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
426 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
429 pLargeFontBtn->AddActionEventListener(*this);
430 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
439 if (pSrcBitmap != null)
445 SetControlAlwaysOnTop(*__pBlankPanel, true);
446 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
453 MainForm::InitWebControl()
455 AppLogDebug("MainForm::InitWebControl enter");
456 result r = E_SUCCESS;
457 AppLogDebug("InitWebControl");
459 if (__pAddressbar == null || __pFooterPanel == null)
462 const int Y_WEBCONTROL_POSITION = 0;
464 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
466 if (__pMostVisitedListView)
468 __pMostVisitedListView->SetShowState(false);
470 if (__pWebViewer != null)
472 AppLogDebug("Already initialized");
475 __pWebViewer = new(std::nothrow) Web();
476 if(__pWebViewer == NULL)
478 AppLogDebug("Initialization failed");
481 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
485 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
492 r = AddControl(__pWebViewer);
498 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
501 __webControlPosition = __pWebViewer->GetPosition();
502 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
505 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
509 __pWebViewer->SetLoadingListener(this);
510 __pWebViewer->SetWebUiEventListenerF(this);
511 __pWebViewer->SetWebKeypadEventListener(this);
512 __pWebViewer->SetFocus();
513 __pWebViewer->AddTouchEventListener(*this);
515 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
516 __pWebViewer->SetTextSearchListener(this);
519 AppLogDebug("MainForm :before return");
521 AppLogDebug("MainForm::InitWebControl Exit");
527 MainForm::SetJavascriptEnabled()
529 WebSetting settings = __pWebViewer->GetSetting();
530 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
531 __pWebViewer->SetSetting(settings);
535 MainForm::SetImageLoadEnabled()
537 WebSetting settings = __pWebViewer->GetSetting();
538 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
539 __pWebViewer->SetSetting(settings);
543 MainForm::InitFooter(void)
545 AppLogDebug("MainForm::InitFooter entered");
546 Button* pBackButton = null;
547 Button* pBookmarkButton = null;
548 Button* pMultiWindowButton = null;
549 Bitmap *pIconBitmap = null;
550 Bitmap *pBGBitmap = null;
551 Label *pBGLabel = null;
553 if (__pFooterPanel == null)
555 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
558 if (__pFooterPanel == null)
563 SetControlAlwaysOnTop(*__pFooterPanel, true);
565 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
566 if ( __pFooterLabel == NULL )
570 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
571 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
574 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
578 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
580 if ( __pMultiWindowButton == NULL )
585 if(__isHwKeySupported == false)
587 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
589 if ( __pMoreButton == NULL )
596 SetFormBackEventListener(this);
599 if (__pMultiWindowButton != null)
601 Bitmap* pBitmap = null;
602 Bitmap* pPressedBitmap = null;
603 String imagePath = "I01_toolbar_icon_windows_manager_0";
604 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
605 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
606 imagePath.Append(totalCount);
607 imagePath.Append(".png");
609 pressedImagePath.Append(totalCount);
610 pressedImagePath.Append("_press.png");
612 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
613 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
614 if ( pBitmap == null )
619 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
622 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
623 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
628 __pMultiWindowButton->AddActionEventListener(*this);
629 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
634 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
635 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
638 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
639 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
640 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
644 __pMoreButton->AddActionEventListener(*this);
645 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
648 //Add the editfield for url
649 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
650 if (__pFooterUrlField == NULL)
652 return E_INVALID_KEY;
655 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
656 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
657 __pFooterUrlField->AddKeypadEventListener(*this);
658 __pFooterUrlField->SetPropagatedTouchEventListener(this);
660 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
662 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
664 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
666 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
670 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
671 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
675 //Add the go Back Button
676 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
677 if (__pGoBackBtn == NULL)
679 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
680 return E_INVALID_KEY;
682 __pGoBackBtn->SetActionId(IDA_GO_BACK);
683 __pGoBackBtn->AddActionEventListener(*this);
685 //Add the go forward Button
686 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
687 if (__pGoForwardBtn == NULL)
689 AppLogDebug("Control not found returning E_INVALID_KEY");
690 return E_INVALID_KEY;
692 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
693 __pGoForwardBtn->AddActionEventListener(*this);
694 if (__pWebViewer && __pWebViewer->CanGoForward())
696 SetForwardButtonEnabled(true);
700 SetForwardButtonEnabled(false);
703 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
704 if (__pRefreshBtn == NULL)
706 AppLogDebug("Control not found returning E_INVALID_KEY");
707 return E_INVALID_KEY;
710 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
711 __pRefreshBtn->AddActionEventListener(*this);
712 __pRefreshBtn->SetShowState(true);
714 //Add the backround label for displaying progressbar
715 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
716 if (__pProgressbarLabel == NULL)
718 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
719 return E_INVALID_KEY;
721 __pProgressbarLabel->SetShowState(false);
723 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
724 if (__pStopBtn == NULL)
726 AppLogDebug("Control not found returning E_INVALID_KEY");
727 return E_INVALID_KEY;
729 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
730 __pStopBtn->AddActionEventListener(*this);
731 __pStopBtn->SetShowState(false);
733 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
734 if (__pClearBtn == NULL)
736 AppLogDebug("Control not found returning E_INVALID_KEY");
737 return E_INVALID_KEY;
739 __pClearBtn->SetActionId(IDA_CLEAR_URL);
740 __pClearBtn->AddActionEventListener(*this);
741 __pClearBtn->SetShowState(false);
743 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
744 if (__pReaderBtn == NULL)
746 AppLogDebug("Control not found returning E_INVALID_KEY");
747 return E_INVALID_KEY;
749 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
750 __pReaderBtn->AddActionEventListener(*this);
751 __pReaderBtn->SetShowState(false);
753 // __pFooterPanel->Invalidate(true);
754 AppLogDebug("MainForm::InitFooter exit");
759 MainForm::InitOptionMenu()
761 result r = E_SUCCESS;
762 bool isPrivateBrowsing = false;
763 Bitmap* pBitmap = null;
765 if (__pOptionMenu != null)
767 __pOptionMenu->Invalidate(true);
771 __pOptionMenu = new(std::nothrow) OptionMenu();
772 r = __pOptionMenu->Construct();
773 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
775 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
778 if (isPrivateBrowsing == true)
780 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
784 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
787 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
789 if ( pBitmap != NULL)
791 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
794 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
795 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
796 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
799 __pOptionMenu->SetMaxVisibleItemsCount(6);
800 __pOptionMenu->SetShowState(false);
801 __pOptionMenu->AddActionEventListener(*this);
802 SetControlAlwaysOnTop(*__pOptionMenu, true);
808 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
810 result r = E_SUCCESS;
811 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
813 AppLog("MainForm::InitImageContextMenu clicked on image");
814 if (__pImageMenu != null)
820 __pImageMenu = new (std::nothrow) ContextMenu();
821 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
822 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
824 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
825 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
826 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
827 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
828 __pImageMenu->SetMaxVisibleItemsCount(4);
829 __pImageMenu->AddActionEventListener(*this);
830 SetControlAlwaysOnTop(*__pImageMenu, true);
836 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
838 result r = E_SUCCESS;
839 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
841 AppLog("MainForm::InitImageContextMenu clicked on image");
842 if (__pImageMenu != null)
848 if(__pAddressbar->GetShowState() == true)
849 p.y = p.y + __pAddressbar->GetHeight();
850 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
855 __pImageMenu = new (std::nothrow) ContextMenu();
856 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
857 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
859 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
860 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
861 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
862 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
864 __pImageMenu->SetMaxVisibleItemsCount(3);
865 __pImageMenu->AddActionEventListener(*this);
866 SetControlAlwaysOnTop(*__pImageMenu, true);
873 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
875 result r = E_SUCCESS;
876 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
878 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
879 if (__pImageMenu != null)
888 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
892 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
894 __pImageMenu = new (std::nothrow) ContextMenu();
895 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
896 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
898 if(onlyPasteOption == false)
900 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
902 if (pasteOption || onlyPasteOption)
904 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
906 if(onlyPasteOption == false)
908 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
909 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
912 __pImageMenu->SetMaxVisibleItemsCount(3);
913 __pImageMenu->AddActionEventListener(*this);
914 SetControlAlwaysOnTop(*__pImageMenu, true);
923 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
925 result r = E_SUCCESS;
926 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
928 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
929 if (__pImageMenu != null)
938 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
942 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
944 __pImageMenu = new (std::nothrow) ContextMenu();
945 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
946 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
948 if(onlyPasteOption == false)
950 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
952 if (pasteOption || onlyPasteOption)
954 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
956 if(onlyPasteOption == false)
958 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
959 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
962 __pImageMenu->SetMaxVisibleItemsCount(3);
963 __pImageMenu->AddActionEventListener(*this);
964 SetControlAlwaysOnTop(*__pImageMenu, true);
971 MainForm::InitFindWordPanel(void)
973 result r = E_SUCCESS;
974 Bitmap *pIconBitmap = null;
976 if (__pFindWordControl != null)
978 AppLogDebug("Findword panel already initialized");
979 if (__pFindWordBgLabel != null)
981 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
984 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
988 if (__pFindWordBgLabelRightToLeft != null)
990 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
993 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1000 __pFindWordControl = new (std::nothrow) Panel();
1001 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1004 AppLogException("There is some problem in the xml file. Please check.");
1007 AddControl(__pFindWordControl);
1008 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1009 SetControlAlwaysOnTop(*__pFindWordControl,true);
1010 __pFindWordControl->SetShowState(false);
1011 __pFindWordControl->Invalidate(false);
1013 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1014 __pFindWordPanelLeftToRight->SetShowState(true);
1016 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1017 __pFindWordPanelRightToLeft->SetShowState(false);
1019 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1020 if (__pFindWordBgLabel != null)
1022 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1023 Rectangle pRect = pPanel1->GetBounds();
1024 pRect.x = pRect.y = 0;
1025 __pFindWordBgLabel->SetBounds(pRect);
1026 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1027 if (pBitmap != null)
1029 AppLogDebug("InitFindWordPanel: Coming here");
1030 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1035 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1039 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1040 if (__pFindWordBgLabelRightToLeft != null)
1042 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1043 Rectangle pRect = pPanel1->GetBounds();
1044 pRect.x = pRect.y = 0;
1045 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1046 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1047 if (pBitmap != null)
1049 AppLogDebug("InitFindWordPanel: Coming here");
1050 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1055 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1059 Button* pfindWordCancel = null;
1060 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1061 if (pfindWordCancel == null)
1063 AppLogException("There is some problem in the xml file. Please check.");
1066 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1067 pfindWordCancel->AddActionEventListener(*this);
1069 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1070 if (__pFindWordClear == null)
1072 AppLogException("There is some problem in the xml file. Please check.");
1076 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1077 if (__pFindWordClearRightToLeft == null)
1079 AppLogException("There is some problem in the xml file. Please check.");
1083 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1084 __pFindWordClear->AddActionEventListener(*this);
1086 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1087 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1089 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1090 if (__pFindWordNext == null)
1092 AppLogException("There is some problem in the xml file. Please check.");
1096 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1097 __pFindWordNext->AddActionEventListener(*this);
1099 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1100 if (__pFindWordPrev == null)
1102 AppLogException("There is some problem in the xml file. Please check.");
1106 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1107 __pFindWordPrev->AddActionEventListener(*this);
1109 __pFindWordNext->SetEnabled(false);
1110 __pFindWordPrev->SetEnabled(false);
1112 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1113 if (__pFindWordCountLabel == null)
1115 AppLogException("There is some problem in the xml file. Please check.");
1119 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1120 if (__pFindWordCountLabel == null)
1122 AppLogException("There is some problem in the xml file. Please check.");
1126 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1127 if (__pFindWordEditField == null)
1129 AppLogException("There is some problem in the xml file. Please check.");
1132 __pFindWordEditField->AddTextEventListener(*this);
1133 __pFindWordEditField->AddKeypadEventListener(*this);
1134 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1136 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1137 if (__pFindWordEditFieldRightToLeft == null)
1139 AppLogException("There is some problem in the xml file. Please check.");
1142 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1143 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1144 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1150 MainForm::CreateItem (int index, int itemWidth)
1152 Rectangle listImageRect;
1153 Rectangle pagetTitleRect;
1154 Rectangle pageURLRect;
1155 Rectangle deleteImageRect;
1156 String pageTitle(L"");
1157 String pageURL(L"");
1158 result r = E_SUCCESS;
1159 Bitmap* pListIconImage = null;
1162 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1163 if(pHistory == null)
1167 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1168 if ( pAppResource == NULL )
1172 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1174 CustomItem* pItem = new(std::nothrow) CustomItem();
1175 pageTitle = pHistory->GetHistoryTitle();
1176 pageURL = pHistory->GetHistoryUrl();
1178 if (pageURL.GetLength() == 0)
1181 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1182 pageURL = L"<"+ nourl +">";
1186 Rectangle screenBounds = GetBounds();
1189 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1198 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1200 if ( pBitmap != NULL)
1202 pListIconImage = new Bitmap();
1203 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1207 if(pListIconImage == null)
1209 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1212 if ( pListIconImage != NULL)
1214 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1215 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1216 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1219 if (pItem != null && pListIconImage != NULL)
1221 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1225 if (pageTitle.CompareTo(L"") != 0)
1229 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1233 if (pageURL.CompareTo(L"") != 0)
1237 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1242 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1244 if ( __pItemContext!= NULL)
1248 pItem->SetContextItem(__pItemContext);
1254 if ( __pItemContextLandscape!= NULL)
1258 pItem->SetContextItem(__pItemContextLandscape);
1262 if( pListIconImage != NULL)
1264 delete pListIconImage;
1265 pListIconImage = null;
1272 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1279 MainForm::GetItemCount (void)
1281 if(__pMostVisitedSites != null)
1283 __pMostVisitedSites->RemoveAll(true);
1285 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1286 if(__pMostVisitedSites != null)
1288 return __pMostVisitedSites->GetCount();
1295 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1297 if(__pMostVisitedSites != null)
1299 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1300 if (pHistory != null)
1302 String url = pHistory->GetHistoryUrl();
1304 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1305 __pMostVisitedListView->UpdateList();
1311 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1313 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1314 String url = pHistory->GetHistoryUrl();
1322 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1328 MainForm::OnTerminating(void)
1330 result r = E_SUCCESS;
1332 RemoveOrientationEventListener(*this);
1336 __pAddressbar->SetAddressbarEventListener(null);
1341 __pWebViewer->RemoveTouchEventListener(*this);
1346 delete __pItemContext;
1348 if(__pItemContextLandscape)
1350 delete __pItemContextLandscape;
1356 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1358 result r = E_SUCCESS;
1360 AppLogDebug("Clicked : %d", actionId);
1363 case IDA_BACKBTN_CLICKED:
1365 if (__pWebViewer && __pWebViewer->CanGoBack())
1367 __pWebViewer->GoBack();
1369 else if(__pWindowInfo->isJavascriptInitiated == false)
1372 pApp = UiApp::GetInstance();
1375 r = pApp->Terminate();
1378 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1386 WindowInfo* pWindowInfo = null;
1388 SceneManager* pSceneManager = SceneManager::GetInstance();
1389 if (pSceneManager == null)
1393 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1394 if (pAllWindowList == NULL)
1396 pApp = UiApp::GetInstance();
1399 r = pApp->Terminate();
1402 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1407 if (pAllWindowList != null)
1409 totalCount = pAllWindowList->GetCount();
1411 for (int count = 0; count < totalCount; count++)
1413 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1414 if (pWindowInfo == null)
1416 pApp = UiApp::GetInstance();
1419 r = pApp->Terminate();
1422 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1429 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1431 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1434 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1437 r = pAllWindowList->RemoveAt(count, true);
1438 __pWindowInfo = null;
1441 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1446 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1450 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1452 if (pWindowInfo == null)
1454 pApp = UiApp::GetInstance();
1457 r = pApp->Terminate();
1463 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1466 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1478 case IDA_FORWARD_CLICKED:
1479 if (__pWebViewer == null)
1482 if (__pWebViewer->CanGoForward())
1484 __pWebViewer->GoForward();
1486 __pOptionMenu->SetShowState(false);
1487 __pOptionMenu->Invalidate(false);
1490 case IDA_FINDONPAGE_CLICKED:
1492 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1493 __currentSearchStr.Clear();
1495 InitFindWordPanel();
1496 __pOptionMenu->SetShowState(false);
1497 __pOptionMenu->Invalidate(false);
1499 ShowFindWordPanel(true);
1501 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1503 __pFindWordEditField->SetFocus();
1504 __pFindWordCountLabel->SetShowState(false);
1508 __pFindWordEditFieldRightToLeft->SetFocus();
1509 __pFindWordCountLabelRightToLeft->SetShowState(false);
1513 case IDA_PRIVATEON_CLICKED:
1515 result r = E_SUCCESS;
1517 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1518 Bitmap* pBitmap = null;
1519 if (isPrivateBrowsing == true)
1521 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1524 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1528 if (__pWebViewer != NULL)
1530 __pWebViewer->SetPrivateBrowsingEnabled(false);
1533 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1535 if (__pAddressbar != null)
1537 __pAddressbar->UpdateFaviconBitmap(false);
1543 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1546 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1550 if (__pWebViewer != NULL)
1552 __pWebViewer->SetPrivateBrowsingEnabled(true);
1555 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1557 if (__pAddressbar != null)
1559 __pAddressbar->UpdateFaviconBitmap(true);
1563 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1564 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1565 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1566 __pOptionMenu->Invalidate(true);
1567 if ( pBitmap != NULL )
1574 case IDA_SETTINGS_CLICKED:
1577 ArrayList* pArgList = new(std::nothrow) ArrayList();
1580 pArgList->Construct();
1581 pArgList->Add(*__pWindowInfo);
1582 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1584 __pOptionMenu->SetShowState(false);
1585 __pOptionMenu->Invalidate(false);
1587 if (pArgList != null)
1596 case IDA_ADDTOBOOKMARK_CLICKED:
1599 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1601 int bookmarkCount=0;
1604 url=__pWindowInfo->pageUrl;
1605 result r = E_SUCCESS;
1606 Bitmap* pBitmap = null;
1607 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1615 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1616 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1617 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1619 if(__pNotification != null)
1621 delete __pNotification;
1622 __pNotification = null;
1624 __pNotification = new (std::nothrow) NotificationPanel(*this);
1625 if (__pNotification != null)
1627 __pNotification->SetText(message);
1628 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1629 __pNotification->ShowNotification();
1634 String title=__pWindowInfo->pageTitle;
1635 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1636 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1638 pBookmark->SetBookmarkTitle(title);
1639 pBookmark->SetUrl(url);
1640 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1642 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1644 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1645 pBookmark->SetFaviconId(id);
1646 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1647 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1649 if(__pNotification != null)
1651 delete __pNotification;
1652 __pNotification = null;
1654 __pNotification = new (std::nothrow) NotificationPanel(*this);
1655 if (__pNotification != null)
1657 __pNotification->SetText(message);
1658 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1659 __pNotification->ShowNotification();
1660 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1663 if (pBitmap != null)
1665 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1670 __pOptionMenu->Invalidate(true);
1675 case IDA_PRINT_CLICKED:
1677 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1678 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1680 AppLog("RequestPrint called!");
1681 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1682 result nResult = E_FAILURE;
1685 AppLog("TestPrint if (pAc) == true");
1690 String fileType = L"service_print_files_type";
1691 String typeVal = L"DOC";
1693 String fileCount = L"service_print_files_count";
1694 String countVal = L"1";
1695 String fileFolder= L"service_print_files_folder_name";
1696 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1698 map.Add(&fileCount, &countVal);
1699 map.Add(&fileFolder, &folderVal);
1700 map.Add(&fileType, &typeVal);
1702 String fileName = L"service_print_files_files_name";
1704 ArrayList fileNameList;
1705 fileNameList.Construct();
1706 String file1 = L"test.pdf";
1708 fileNameList.Add(&file1);
1709 map.Add(&fileName, &fileNameList);
1711 nResult = pAc->Start(NULL, NULL, &map, NULL);
1713 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1714 else if (nResult == E_MAX_EXCEEDED)
1715 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1716 else if (nResult == E_OBJ_NOT_FOUND)
1717 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1718 else if (nResult == E_IN_PROGRESS)
1719 AppLog("TestPrint ret == E_IN_PROGRESS");
1720 else if (nResult == E_PRIVILEGE_DENIED)
1721 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1722 else if(nResult == E_SYSTEM)
1723 AppLog("TestPrint ret == E_SYSTEM");
1729 int __modalMsgBoxResult;
1730 MessageBox* pMsgBox = new MessageBox();
1731 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1732 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1735 __modalMsgBoxResult = 0;
1739 case IDA_SHARE_CLICKED:
1741 if(__pPopUp != null)
1748 __pAddressbar->HideKeypad();
1750 __pPopUp = new(std::nothrow) SharePopup();
1751 __pPopUp->Initialize();
1752 if (__pWindowInfo != null)
1754 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1755 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1756 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1757 pShareInfo->SetImageAttached(false);
1758 __pPopUp->RemoveAllShareInfo();
1759 __pPopUp->AddShareInfo(pShareInfo);
1761 __pPopUp->SetShowState(true);
1765 case IDA_BOOKMARKBTN_CLICKED:
1767 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1768 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1771 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1776 case IDA_MOREBTN_CLICKED:
1778 AppLog("IDA_MOREBTN_CLICKED");
1780 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1782 int bookmarkCount=0;
1785 url=__pWindowInfo->pageUrl;
1786 result r = E_SUCCESS;
1787 Bitmap* pBitmap = null;
1789 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1792 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1797 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1801 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1803 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1805 if (__pOptionMenu->GetItemCount() == 9)
1807 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1811 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1816 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1820 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1821 if (__pOptionMenu->GetItemCount() != 9)
1823 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1824 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1825 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1826 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1827 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1828 __pOptionMenu->SetMaxVisibleItemsCount(6);
1830 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1832 AppLog(" Orientation landscape");
1833 __pOptionMenu->SetMaxVisibleItemsCount(5);
1837 AppLog(" Orientation potrait");
1838 __pOptionMenu->SetMaxVisibleItemsCount(6);
1841 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1844 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1845 __pOptionMenu->SetShowState(true);
1846 __pOptionMenu->Invalidate(true);
1847 __pOptionMenu->Show();
1851 case IDA_HISTORY_CLICKED:
1853 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1854 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1857 case IDA_SAVED_PAGES_CLICKED:
1862 case IDA_DESKTOP_VIEW_CLICKED:
1867 case IDA_SAVE_CLICKED:
1872 case IDA_MULTIWINDOWBTN_CLICKED:
1874 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1875 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1879 case IDA_NEWWINDOWBTN_CLICKED:
1881 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1883 if (pNewWindowInfo == null)
1887 result r = E_SUCCESS;
1888 SceneManager* pSceneManager = SceneManager::GetInstance();
1890 if (pSceneManager == NULL)
1894 ArrayList* pArgList = new(std::nothrow) ArrayList();
1895 if (pArgList == NULL)
1899 r = pArgList->Construct();
1902 pArgList->Add(*pNewWindowInfo);
1903 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1909 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1914 case IDA_SMALLFONT_BTN_CLICKED:
1916 WebSetting setting = __pWebReader->GetSetting();
1917 setting.SetFontSize(15);
1918 __pWebReader->SetSetting(setting);
1921 case IDA_LARGEFONT_BTN_CLICKED:
1923 WebSetting setting = __pWebReader->GetSetting();
1924 setting.SetFontSize(25);
1925 __pWebReader->SetSetting(setting);
1928 case IDA_READER_CLOSE_CLICKED:
1930 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1932 RemoveControl(__pBlankPanel);
1933 __pArticleReaderPanel = null;
1934 __pBlankPanel = null;
1935 __pArticleReaderLabel = null;
1937 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1940 case IDA_FINDWORD_CANCEL_CLICKED:
1942 __currentSearchStr = L"";
1943 __currentWordIndex = 0;
1944 __maxOccurrances = 0;
1946 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1948 __pFindWordEditField->SetText(L"");
1949 __pFindWordCountLabel->SetText(L"0/0");
1951 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1953 __pFindWordEditFieldRightToLeft->SetText(L"");
1954 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1957 __pFindWordNext->SetEnabled(false);
1958 __pFindWordPrev->SetEnabled(false);
1959 __pFindWordCountLabel->SetText(L"0/0");
1960 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1961 AppLog("akjshdasd 1");
1962 __pFooterPanel->SetShowState(true);
1963 ShowFindWordPanel(false);
1966 case IDA_FINDWORD_SEARCH_CLICKED:
1968 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1970 __currentSearchStr = __pFindWordEditField->GetText();
1972 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1974 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1977 if (__currentSearchStr.GetLength() > 0)
1983 AppLogDebug("Enter something");
1987 case IDA_FINDWORD_CLEAR_CLICKED:
1989 __pFindWordCountLabel->SetText(L"0/0");
1990 __pFindWordEditField->SetText(L"");
1991 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1993 __currentSearchStr = L"";
1994 __pFindWordNext->SetEnabled(false);
1995 __pFindWordPrev->SetEnabled(false);
1996 __pFindWordCountLabel->SetShowState(false);
1997 __pFindWordControl->Invalidate(true);
2000 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2002 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2003 __pFindWordEditFieldRightToLeft->SetText(L"");
2004 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2006 __currentSearchStr = L"";
2007 __pFindWordNext->SetEnabled(false);
2008 __pFindWordPrev->SetEnabled(false);
2009 __pFindWordCountLabelRightToLeft->SetShowState(false);
2010 __pFindWordControl->Invalidate(true);
2013 case IDA_FINDWORD_NEXT_CLICKED:
2018 case IDA_FINDWORD_PREV_CLICKED:
2020 FindNextWord(false);
2023 case IDA_BRIGHTNESS_BTN_CLICKED:
2025 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2026 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2029 case IDA_COPY_IMAGE_CLICKED:
2031 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2032 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2034 const Bitmap* pBitmap = null;
2035 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2037 pBitmap = __pHitElementResult->GetImage();
2040 String resourcePath = App::GetInstance()->GetAppResourcePath();
2041 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2042 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2043 // copying the item to clipboard
2044 Clipboard* pClipboard = Clipboard::GetInstance();
2045 if (pClipboard != null)
2047 r = pClipboard->CopyItem(item);
2048 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2052 case IDA_VIEW_IMAGE_CLICKED:
2054 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2055 WindowInfo* pNewWindowInfo = null;
2056 if (__pHitElementResult != null)
2058 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2059 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2065 case IDA_SAVE_IMAGE_CLICKED:
2067 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2068 const Bitmap* pSaveBitmap = null;
2069 String imageName = GetImagePath();
2070 AppLog("Content manager image name %ls",imageName.GetPointer());
2073 imagePath.Append(imageName);
2074 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2075 AppLog("Content manager image path %ls",imagePath.GetPointer());
2076 if (__pHitElementResult != null)
2078 pSaveBitmap = __pHitElementResult->GetImage();
2080 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2084 UpdateImageContent(pBuffer, imageName);
2086 if(__pNotification != null)
2088 delete __pNotification;
2089 __pNotification = null;
2091 __pNotification = new NotificationPanel(*this);
2093 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2094 msg.Append(imagePath);
2095 if (__pNotification != null)
2097 __pNotification->SetText(msg);
2098 if (__pFooterPanel->GetShowState() == true)
2100 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2104 __pNotification->SetPositionDiff(0);
2107 __pNotification->ShowNotification();
2112 int __modalMsgBoxResult;
2113 MessageBox* pMsgBox = new MessageBox();
2114 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2115 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2118 __modalMsgBoxResult = 0;
2122 case IDA_SHARE_IMAGE_CLICKED:
2124 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2125 if (__pPopUp != null)
2132 __pAddressbar->HideKeypad();
2134 __pPopUp = new(std::nothrow) SharePopup();
2135 __pPopUp->Initialize();
2136 if (__pHitElementResult != null)
2138 const Bitmap* pSaveBitmap = null;
2139 String imageName = GetImagePath();
2140 AppLog("Content manager image name %ls",imageName.GetPointer());
2143 imagePath.Append(imageName);
2144 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2145 AppLog("Content manager image path %ls",imagePath.GetPointer());
2146 if (__pHitElementResult != null)
2148 pSaveBitmap = __pHitElementResult->GetImage();
2150 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2152 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2153 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2155 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2156 pShareInfo->SetPageTitle(L"");
2157 pShareInfo->SetPageUrl(srcUrl);
2158 pShareInfo->SetImageAttached(true);
2159 pShareInfo->SetImagePath(imagePath);
2160 __pPopUp->RemoveAllShareInfo();
2161 __pPopUp->AddShareInfo(pShareInfo);
2162 __pPopUp->SetShowState(true);
2167 case IDA_HYPERLINK_OPEN_CLICKED:
2169 if (__pHitElementResult != null)
2171 String srcUrl = __pHitElementResult->GetUrl();
2173 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2175 if (pNewWindowInfo == null)
2179 result r = E_SUCCESS;
2180 SceneManager* pSceneManager = SceneManager::GetInstance();
2181 if (pSceneManager == NULL)
2185 ArrayList* pArgList = new(std::nothrow) ArrayList();
2186 if (pArgList == NULL)
2190 pArgList->Construct();
2192 pArgList->Add(*pNewWindowInfo);
2193 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2194 if (pArgList != null)
2201 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2207 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2209 if (__pHitElementResult == null)
2214 if(__pPopUp != null)
2221 __pAddressbar->HideKeypad();
2223 __pPopUp = new(std::nothrow) SharePopup();
2224 __pPopUp->Initialize();
2226 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2227 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2228 pShareInfo->SetImageAttached(false);
2229 __pPopUp->RemoveAllShareInfo();
2230 __pPopUp->AddShareInfo(pShareInfo);
2232 __pPopUp->SetShowState(true);
2236 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2240 if (__pHitElementResult != null)
2242 url = __pHitElementResult->GetUrl();
2245 String resourcePath = App::GetInstance()->GetAppResourcePath();
2246 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2248 // copying the item to clipboard
2249 Clipboard* pClipboard = Clipboard::GetInstance();
2250 if (pClipboard != null)
2252 pClipboard->CopyItem(item);
2256 case IDA_FIND_TEXT__CLICKED:
2258 // AddressBarCancelledClicked(*__pAddressbar);
2259 RelayoutControls(false);
2260 // __pFooterPanel->SetShowState(false);
2261 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2262 __currentSearchStr.Clear();
2263 __currentSearchStr.Append(__currentSelectedStr);
2264 InitFindWordPanel();
2265 __pFindWordEditField->SetText(__currentSearchStr);
2267 if(__pOptionMenu != null)
2269 __pOptionMenu->SetShowState(false);
2270 __pOptionMenu->Invalidate(false);
2272 __adressPanelPosition.y = 0;
2274 if (__pAddressbar != null && __pWebViewer != NULL)
2276 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2277 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2279 if (__pFooterPanel->GetShowState() == false)
2280 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2282 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2283 __pWebViewer->Invalidate(true);
2286 ShowFindWordPanel(true);
2287 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2289 __pFindWordEditField->SetText(__currentSearchStr);
2290 __pFindWordEditField->SetFocus();
2292 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2294 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2295 __pFindWordEditFieldRightToLeft->SetFocus();
2298 if (__currentSearchStr.GetLength() > 0)
2304 AppLogDebug("Enter something");
2307 if (__pWebViewer != null)
2309 // releasing the set block
2310 __pWebViewer->ReleaseBlock();
2315 case IDA_SHARE_TEXT_CLICKED:
2317 __pWebViewer->ReleaseBlock();
2318 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2319 if(__pPopUp != null)
2326 __pAddressbar->HideKeypad();
2328 __pPopUp = new(std::nothrow) SharePopup();
2329 __pPopUp->Initialize();
2330 if (__pHitElementResult != null)
2332 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2333 pShareInfo->SetPageTitle(L"");
2334 pShareInfo->SetPageUrl(__currentSelectedStr);
2335 pShareInfo->SetImageAttached(false);
2336 __pPopUp->RemoveAllShareInfo();
2337 __pPopUp->AddShareInfo(pShareInfo);
2338 __pPopUp->SetShowState(true);
2343 case IDA_COPY_TEXT_CLICKED:
2345 __pWebViewer->ReleaseBlock();
2346 // need to implement
2347 //__currentSelectedStr
2348 // Sets data to a clip board item
2350 String resourcePath = App::GetInstance()->GetAppResourcePath();
2351 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2353 // copying the item to clipboard
2354 Clipboard* pClipboard = Clipboard::GetInstance();
2355 if (pClipboard != null)
2357 pClipboard->CopyItem(item);
2361 case IDA_PASTE_TEXT_CLICKED:
2363 Clipboard* pClipboard = Clipboard::GetInstance();
2365 if(pClipboard == null)
2369 // Retrieves a latest item
2370 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2376 //Gets data from the clipboard item
2377 String* pString = dynamic_cast<String*>(pItem->GetData());
2379 if (pString != null)
2381 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2382 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2383 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2386 if(idElement.GetLength() != 0)
2388 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; } } ";
2389 script.Append("insertAtCursor('");
2390 script.Append(idElement);
2391 script.Append("',");
2392 script.Append("\"");
2393 script.Append(*pString);
2394 script.Append("\");");
2396 else if (nameElement.GetLength() != 0)
2398 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; } } ";
2399 script.Append("insertAtCursor(document.getElementsByName('");
2400 script.Append(nameElement);
2401 script.Append("')[0],");
2402 script.Append("\"");
2403 script.Append(*pString);
2404 script.Append("\");");
2406 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2407 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2418 case IDA_GO_FORWARD:
2423 case IDA_REFRESH_BTN_CLICKED:
2425 __isLoadingCompleted = false;
2426 __isLoadingData = true;
2427 __progressPercentage = 0;
2428 __displayUrl = __pFooterUrlField->GetText();
2430 String url = __pFooterUrlField->GetText();
2431 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2433 if (__pWebViewer != null && __pAddressbar != null)
2435 __pWebViewer->Reload();
2436 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2440 UpdateProgressBitmap();
2443 case IDA_STOP_BTN_CLICKED:
2445 __isLoadingCompleted = false;
2446 __isLoadingData = false;
2447 __progressPercentage = 0;
2448 __pFooterUrlField->HideKeypad();
2449 __displayUrl = __pFooterUrlField->GetText();
2453 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2454 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2455 __pWebViewer->StopLoading();
2456 RequestRedraw(true);
2459 UpdateProgressBitmap();
2464 if (__pFooterUrlField->GetText().IsEmpty() == false)
2466 //__displayUrl = __pUrlField->GetText();
2467 __pFooterUrlField->Clear();
2472 case IDA_READER_BTN_CLICKED:
2483 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2485 result r = E_FAILURE;
2486 if (__pWebViewer && __pWebViewer->CanGoBack())
2488 __pWebViewer->GoBack();
2490 else if(__pWindowInfo->isJavascriptInitiated == false)
2493 pApp = UiApp::GetInstance();
2496 r = pApp->Terminate();
2499 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2507 WindowInfo* pWindowInfo = null;
2509 SceneManager* pSceneManager = SceneManager::GetInstance();
2510 if (pSceneManager == null)
2514 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2515 if (pAllWindowList == NULL)
2517 pApp = UiApp::GetInstance();
2520 r = pApp->Terminate();
2523 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2528 if (pAllWindowList != null)
2530 totalCount = pAllWindowList->GetCount();
2532 for (int count = 0; count < totalCount; count++)
2534 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2535 if (pWindowInfo == null)
2537 pApp = UiApp::GetInstance();
2540 r = pApp->Terminate();
2543 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2550 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2552 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2555 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2558 r = pAllWindowList->RemoveAt(count, true);
2559 __pWindowInfo = null;
2562 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2567 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2571 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2573 if (pWindowInfo == null)
2575 pApp = UiApp::GetInstance();
2578 r = pApp->Terminate();
2584 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2587 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2599 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2600 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2602 AppLog("MainForm::OnSceneActivatedN called");
2603 String* pSelectedScene = NULL;
2604 Object* pValue = NULL;
2605 String* pUrl = null;
2606 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2607 pSelectedScene = (String*) pValue;
2609 if (pSelectedScene != null)
2611 delete pSelectedScene;
2613 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2614 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2615 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2616 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2618 // setting the current scene ID
2619 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2621 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2623 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2625 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2626 if(__pWindowInfo == null)
2628 // if(__pWindowInfo == null)
2630 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2633 else if ( pArgs != null && pArgs->GetCount() == 1)
2635 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2641 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2643 // hiding the address bar
2644 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2645 __pAddressbar->SetShowState(false);
2646 // if(__pWebViewer != null)
2648 // __pWebViewer->Resume();
2651 if(pUrl != null && pUrl->GetLength() > 0)
2655 else if(__pWindowInfo != null)
2657 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)
2659 LoadUrl(__pWindowInfo->pageUrl);
2661 else if (__pWindowInfo->isJavascriptInitiated == true)
2665 __pWindowInfo->pCurrentWeb = __pWebViewer;
2669 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2670 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2671 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2673 InitMostVisitedSitesView(GetOrientationStatus());
2675 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2677 if(__pMostVisitedListView != null)
2679 __pMostVisitedListView->SetShowState(false);
2683 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2685 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2687 if (pBookmarkUrl == null)
2689 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2690 //__pAddressbar->SetUrl(*pBookmarkUrl);
2691 SetUrl(*pBookmarkUrl);
2693 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2694 __pWebViewer->LoadUrl(*pBookmarkUrl);
2695 delete pBookmarkUrl;
2698 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2699 Bitmap* pBitmap = null;
2700 if (isPrivateBrowsing == true)
2702 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2704 if (__pWebViewer != null)
2706 __pWebViewer->SetPrivateBrowsingEnabled(true);
2709 if (__pAddressbar != null)
2711 // __pAddressbar->UpdateFaviconBitmap(true);
2717 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2719 if (__pWebViewer != null)
2721 __pWebViewer->SetPrivateBrowsingEnabled(false);
2724 if (__pAddressbar != null)
2726 // __pAddressbar->UpdateFaviconBitmap(false);
2730 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2732 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2734 else if (__pOptionMenu != null )
2736 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2739 if (pBitmap != null)
2744 AppLog("ABC: OnSceneActivatedN started exit");
2749 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2750 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2752 Canvas* pWebCanvas = null;
2753 if (__pWebViewer != null)
2755 pWebCanvas = __pWebViewer->GetCanvasN();
2758 if (pWebCanvas == null)
2762 if (__pWindowInfo != null)
2764 if (__pWindowInfo->pWebCanvasBitmap != null)
2766 delete __pWindowInfo->pWebCanvasBitmap;
2768 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2769 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2770 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2772 Bitmap* pBitmap = GetCapturedBitmapN();
2773 AppLog("Coming here");
2774 Canvas* pCanvas = new(std::nothrow) Canvas();
2775 pCanvas->Construct(GetClientAreaBounds());
2778 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2781 if(__pWebViewer != null && __pWindowInfo != null)
2782 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2784 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2785 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2787 AppLog("Coming here");
2791 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2792 const Tizen::Base::String& realm,
2793 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2799 MainForm::OnHttpAuthenticationCanceled(void)
2804 MainForm::OnLoadingStarted(void)
2806 AppLogDebug("MainForm::OnLoadingStarted entered");
2808 if(__pAddressbar == NULL || __pWebViewer == null)
2813 // this is added in case if menu is opened and user load the page
2814 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2816 __pOptionMenu->SetShowState(false);
2817 __pOptionMenu->Invalidate(true);
2822 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2824 __pImageMenu->SetShowState(false);
2825 __pImageMenu->Invalidate(true);
2827 String url = __pWebViewer->GetUrl();
2828 if(url.Contains(IDS_TIZEN_SERVICE))
2831 String delim(L":;,");
2833 // Creates a StringTokenizer instance
2834 StringTokenizer strTok(url, delim);
2836 int count = strTok.GetTokenCount(); // count == 4
2838 HashMap *pMap = new HashMap();
2843 while (strTok.HasMoreTokens())
2845 AppLog("Token: %ls", token.GetPointer());
2846 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2847 if(token.Contains(IDS_APPID))
2849 token.SubString(6, appId);
2850 AppLog("AppID:%ls", appId.GetPointer());
2852 else if(token.Contains(IDS_KEY))
2854 token.SubString(4, key);
2855 AppLog("key:%ls", key.GetPointer());
2857 else if(token.Contains(IDS_VALUE))
2859 token.SubString(6, value);
2860 AppLog("value:%ls", value.GetPointer());
2863 pMap->Add(key, value);
2867 AppControl *pAppControl = null;
2868 String operationId = L"http://tizen.org/appcontrol/operation/main";
2869 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2872 AppLog("Starting AppControl");
2873 result r = pAppControl->Start(null, null, pMap, null);
2874 AppLog("Result of Start %s", GetErrorMessage(r));
2878 AppLogException("AppControl not found");
2883 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2885 __pAddressbar->SetShowState(false);
2886 AddressBarCancelledClicked(*__pAddressbar);
2887 __pAddressbar->Invalidate(true);
2889 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2892 __pAddressbar->SetFaviconBitmap(*pBitmap);
2895 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2897 // updating the address bar position with respect to web control
2898 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2899 __distanceMoved = 0;
2903 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2904 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2905 if (__pWebViewer != null)
2907 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2908 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2909 SetUrl(__pWebViewer->GetUrl());
2910 if (__pWindowInfo != NULL)
2912 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2913 __pWindowInfo->pageTitle = L"";
2914 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2916 __pAddressbar->Invalidate(true);
2922 MainForm::OnLoadingCanceled(void)
2929 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2931 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2936 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2938 AppLog("XYZ::MainForm::OnKeypadOpened");
2939 __pFooterPanel->SetShowState(false);
2944 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2946 AppLog("XYZ::MainForm::OnKeypadClosed");
2947 __pFooterPanel->SetShowState(true);
2948 RelayoutControls(true);
2952 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2954 AppLog("XYZ::KeypadBoundsChanged");
2955 RelayoutControls(false);
2959 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2960 const Tizen::Base::String& reason)
2962 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2966 MainForm::OnLoadingCompleted(void)
2968 AppLog("MainForm::OnLoadingCompleted start");
2970 result r = E_SUCCESS;
2972 if (__pWebViewer == null)
2977 if (__pAddressbar == null)
2981 if (__pWebViewer->CanGoForward())
2983 //__pAddressbar->SetForwardButtonEnabled(true);
2984 SetForwardButtonEnabled(true);
2988 //__pAddressbar->SetForwardButtonEnabled(false);
2989 SetForwardButtonEnabled(false);
2992 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2994 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2996 //__pAddressbar->UpdateProgress(0);
3000 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3002 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3006 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3007 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3008 if (isPrivateBrowsing == false)
3010 if(__pHistory != null)
3016 __pHistory = new(std::nothrow) History;
3017 HistoryPresentationModel::GetCurrentDateTime(date);
3020 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3021 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3023 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3024 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3026 __pHistory->SetVisitedTime(date);
3028 if (__pWebViewer != null)
3030 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3032 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3033 if (pTempBitmap != null)
3035 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3036 __pHistory->SetFavIconBitmap(*pTempBitmap);
3039 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3042 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3043 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3044 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3046 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3047 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3048 __pHistory->SetThumbnail(pBitmap);
3050 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3053 __pHistory->SetFavIconBitmap(*pFavIcon);
3057 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3064 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3066 // temperary fixed (webpage can be not loaded)
3070 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3071 if (isReaderEnabled == true)
3075 delete __pReaderData;
3076 __pReaderData = null;
3078 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3079 filePath.Append(L"data/reader.js");
3085 result r = E_SUCCESS;
3086 FileAttributes attr;
3088 File::GetAttributes(filePath,attr);
3090 r = file.Construct(filePath, L"r+");
3093 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3096 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3099 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3102 // file.Read(pScript,attr.GetFileSize());
3104 // AppLogDebug("scipt length %d",strlen(pScript));
3105 String strScript = L"";
3106 // strScript.Append(pScript);
3107 // for(int i=0; i<25; i++)
3109 file.Read(pScript,attr.GetFileSize());
3110 // AppLog("xyzz tell %d",file.Tell());
3111 // r = strScript.Append(pScript);
3112 // AppLog("xyzz append result %s",GetErrorMessage(r));
3113 // AppLog("xyzz strScript length %d",strScript.GetLength());
3115 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3117 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3118 if (__pReaderData == null)
3120 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3121 __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>");
3124 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3125 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3127 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3128 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3134 AppLog("MainForm::OnLoadingCompleted done");
3138 MainForm::OnEstimatedProgress(int progress)
3140 AppLogDebug("MainForm::OnEstimatedProgress entered");
3141 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3142 progress = DEFAULT_PROGRESS_PERCENTAGE;
3144 // __pAddressbar->UpdateProgress(progress);
3145 UpdateProgress(progress);
3148 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3150 AppLog("MainForm::OnFaviconReceived");
3151 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3153 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3156 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3163 MainForm::OnUrlValueChanged(Addressbar&)
3169 MainForm::OnUrlSubmitted(Addressbar& addBar)
3171 AppLog("MainForm::OnUrlSubmitted");
3172 String url = addBar.GetUrl();
3173 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3175 if(__pFooterUrlField)
3176 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3177 AddressBarCancelledClicked(*__pAddressbar);
3182 MainForm::LoadUrl(String& url)
3186 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3187 AppLogDebug("MainForm::LoadUrl enter");
3189 if (__pWebViewer != null)
3191 __pWebViewer->SetShowState(true);
3192 __pWebViewer->Invalidate(true);
3195 if (url.CompareTo(L"") == 0)
3199 if(__pFooterPanel != null)
3201 __pFooterPanel->SetShowState(true);
3202 __pFooterPanel->Invalidate(true);
3209 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3210 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)
3212 RegularExpression firstRegex;
3213 RegularExpression secondRegex;
3215 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3216 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3219 ret = firstRegex.Match(url, false); // This returns true value
3220 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3222 if (ret == true && __pWebViewer != null)
3225 __pWebViewer->LoadUrl(url);
3227 else if(__pWebViewer != null)
3229 String tempUrl = L"http://";
3230 tempUrl.Append(url);
3234 __pWebViewer->LoadUrl(tempUrl);
3238 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3239 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3242 if (__pAddressbar != null)
3244 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3245 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3248 AppLogDebug("MainForm::LoadUrl exit");
3255 MainForm::OnStopClicked(Addressbar& addBar)
3257 AppLogDebug("MainForm::OnStopClicked called");
3260 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3261 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3262 __pWebViewer->StopLoading();
3263 RequestRedraw(true);
3268 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3270 // AppLog("MainForm::OnBackClicked");
3271 result r = E_FAILURE;
3273 if (__pWebViewer && __pWebViewer->CanGoBack())
3275 __pWebViewer->GoBack();
3277 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3280 pApp = UiApp::GetInstance();
3283 r = pApp->Terminate();
3286 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3294 WindowInfo* pWindowInfo = null;
3296 SceneManager* pSceneManager = SceneManager::GetInstance();
3297 if (pSceneManager == null)
3301 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3302 if (pAllWindowList == NULL)
3304 pApp = UiApp::GetInstance();
3307 r = pApp->Terminate();
3310 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3315 if (pAllWindowList != null)
3317 totalCount = pAllWindowList->GetCount();
3319 for (int count = 0; count < totalCount; count++)
3321 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3322 if (pWindowInfo == null)
3324 pApp = UiApp::GetInstance();
3327 r = pApp->Terminate();
3330 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3335 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3337 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3340 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3343 r = pAllWindowList->RemoveAt(count, true);
3344 __pWindowInfo = null;
3347 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3352 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3354 else if(pAllWindowList->GetCount() > 0)
3356 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3360 pApp = UiApp::GetInstance();
3363 r = pApp->Terminate();
3368 if (pWindowInfo == null)
3370 pApp = UiApp::GetInstance();
3373 r = pApp->Terminate();
3379 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3382 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3396 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3398 AppLog("MainForm::OnForwardClicked");
3399 if (__pWebViewer == null)
3402 if (__pWebViewer->CanGoForward())
3404 __pWebViewer->GoForward();
3409 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3411 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3412 if(__pFooterPanel != null)
3414 __pFooterPanel->SetShowState(false);
3417 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3419 __pAddressbar->SetShowState(true);
3420 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3423 RelayoutControls(false);
3427 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3429 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3431 int Height = GetClientAreaBounds().height;
3432 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3435 __pAddressbar->SetShowState(false);
3437 if (__pFooterPanel != null && addressbarKeyPadState == false)
3439 AppLog("akjshdasd 3");
3440 __pFooterPanel->SetShowState(true);
3443 RelayoutControls(false);
3447 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3449 AddressBarCancelledClicked(addBar);
3453 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3455 __prevAddressBarMode = __curAddressBarMode;
3457 if (__pAddressbar != null)
3459 __curAddressBarMode = GetAddressbarMode();
3462 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3464 __adressPanelPosition.y = 0;
3465 if (__pAddressbar != null)
3467 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3468 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3469 __pAddressbar->Invalidate(true);
3471 if (__pWebViewer != null)
3473 __pWebViewer->StopLoading();
3476 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3478 __adressPanelPosition.y = 0;
3479 if (__pAddressbar != null)
3481 __webControlPosition.y = 0;
3482 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3483 __pAddressbar->Invalidate(true);
3489 MainForm::OnClipboardClosed(const Addressbar& addBar)
3491 AppLog("XYZ::MainForm::OnClipboardClosed");
3492 RelayoutControls(false);
3496 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3498 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3499 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3501 AppLog("akjshdasd 3");
3502 __pFooterPanel->SetShowState(true);
3505 RelayoutControls(false,footerState);
3509 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3511 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3512 RelayoutControls(false);
3516 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3518 __pFooterPanel->SetShowState(false);
3522 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3524 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3525 RelayoutControls(false);
3529 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3531 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3534 __pWindowInfo->pageTitle = title;
3535 if (__pWebViewer != null)
3537 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3540 if (__pAddressbar != null && __pWebViewer != null)
3542 SetUrl(__pWebViewer->GetUrl());
3543 __pAddressbar->Invalidate(true);
3548 MainForm::UpdateFavicon(void)
3550 bool urlImageType = false;
3551 String *tempPath = null;
3553 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();");
3554 Bitmap* pBitmap = null;
3556 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3558 if (__pWindowInfo != null)
3561 url.SetUri(*tempPath);
3562 if (url.GetHost().GetLength() == 0)
3565 webUrl.SetUri(__pWebViewer->GetUrl());
3566 result r = url.SetHost(webUrl.GetHost());
3573 if (url.GetScheme().GetLength() == 0)
3576 webUrl.SetUri(__pWebViewer->GetUrl());
3577 url.SetScheme(webUrl.GetScheme());
3579 __pWindowInfo->faviconUrl = url.ToString();
3581 pBitmap = __pWebViewer->GetFaviconN();
3583 if (pBitmap != null)
3585 if (__pWindowInfo->pFavicon != NULL)
3587 __pWindowInfo->pFavicon = null;
3589 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3590 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3592 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3594 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3596 else if(__pWindowInfo->pFavicon != null)
3598 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3602 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3603 if(pDefaultBmp != null)
3605 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3614 if(tempPath != null)
3618 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3625 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3626 Tizen::Web::Controls::WebNavigationType type)
3628 // when load new page if find word panel is open its show state is false
3629 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3631 __currentSearchStr = L"";
3632 __currentWordIndex = 0;
3633 __maxOccurrances = 0;
3634 __pFindWordEditField->SetText(L"");
3635 __pFindWordNext->SetEnabled(false);
3636 __pFindWordPrev->SetEnabled(false);
3637 __pFindWordCountLabel->SetText(L"0/0");
3638 __pFindWordControl->SetShowState(false);
3639 __pFindWordEditField->HideKeypad();
3640 RelayoutControls(false);
3645 __pFooterPanel->Invalidate(true);
3648 uriInfo.SetUri(url);
3650 if(url.Contains(IDS_TIZEN_SERVICE))
3653 String delim(L":;,");
3655 // Creates a StringTokenizer instance
3656 StringTokenizer strTok(url, delim);
3658 int count = strTok.GetTokenCount(); // count == 4
3660 HashMap *pMap = new HashMap();
3666 while (strTok.HasMoreTokens())
3668 AppLog("Token: %ls", token.GetPointer());
3669 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3670 if(token.Contains(IDS_APPID))
3672 token.SubString(6, appId);
3673 AppLog("AppID:%ls", appId.GetPointer());
3675 else if(token.Contains(IDS_KEY))
3677 token.SubString(4, key);
3678 AppLog("key:%ls", key.GetPointer());
3680 else if(token.Contains(IDS_VALUE))
3682 token.SubString(6, value);
3683 AppLog("value:%ls", value.GetPointer());
3686 pMap->Add(key, value);
3690 AppControl *pAppControl = null;
3691 String operationId = L"http://tizen.org/appcontrol/operation/main";
3692 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3695 result r = pAppControl->Start(null, null, pMap, null);
3699 AppLogException("AppControl not found");
3709 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3710 const Tizen::Net::Http::HttpHeader& httpHeader)
3712 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3717 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3719 AppLog("MainForm::OnWebPageBlockSelected");
3720 if (__pHitElementResult != null)
3722 delete __pHitElementResult;
3723 __pHitElementResult = null;
3726 if (__pWebViewer != null)
3728 AppLog("MainForm::OnWebPageBlockSelected web not null");
3729 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3731 if(GetLastResult() == E_INVALID_ARG)
3733 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3734 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3735 if(GetLastResult() == E_INVALID_ARG)
3737 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3739 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3743 if (__pHitElementResult == null)
3748 if (__pHitElementResult->HasImage() != true)
3750 String tagName = __pHitElementResult->GetTagName();
3751 String type = __pHitElementResult->GetAttributeValue("type");
3754 AppLog("TagName %ls",tagName.GetPointer());
3755 __currentSelectedStr.Clear();
3756 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3757 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3758 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3760 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3762 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3764 InitSelectTextContextMenuF(endPoint,true);
3765 __pImageMenu->SetShowState(true);
3766 __pImageMenu->Show();
3767 __pImageMenu->Invalidate(true);
3769 else /*if(__isLongPressedDone == true)*/
3771 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3773 if(__pHitElementResult->GetUrl().GetLength() > 0)
3775 __currentSelectedStr.Clear();
3776 __currentSelectedStr = __pHitElementResult->GetUrl();
3778 InitSelectTextContextMenuF(endPoint,false);
3779 __pImageMenu->SetShowState(true);
3780 __pImageMenu->Show();
3781 __pImageMenu->Invalidate(true);
3784 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3785 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3786 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3792 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3798 MainForm::OnWebWindowCreateRequested(void)
3800 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3802 if (pNewWindowInfo == null)
3806 result r = E_SUCCESS;
3807 SceneManager* pSceneManager = SceneManager::GetInstance();
3808 if (pSceneManager == NULL)
3812 ArrayList* pArgList = new(std::nothrow) ArrayList();
3813 if (pArgList == NULL)
3817 r = pArgList->Construct();
3820 pNewWindowInfo->isJavascriptInitiated = true;
3821 pArgList->Add(*pNewWindowInfo);
3822 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3826 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3833 return pNewWindowInfo->pCurrentWeb;
3837 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3839 AppLog("xyz:: MainForm::RelayoutControls called");
3840 __webControlPosition.y = 0;
3841 __webControlHeight = GetClientAreaBounds().height;
3842 AppLog("Client area height: %d", __webControlHeight);
3844 AppLog("Client area height: %d", __webControlHeight);
3845 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3847 __webControlPosition.y += __pAddressbar->GetHeight();
3848 __webControlHeight -= __pAddressbar->GetHeight();
3849 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3851 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3853 __webControlPosition.y += __pFindWordControl->GetHeight();
3854 __webControlHeight -= __pFindWordControl->GetHeight();
3855 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3858 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3860 __webControlHeight -= __pFooterPanel->GetHeight();
3862 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3864 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3866 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3871 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3872 __pWebViewer->Invalidate(false);
3875 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3877 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3884 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3886 if (__pFindWordControl == null)
3891 Tizen::Locales::LocaleManager localeManager;
3892 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3894 String languageCode;
3895 result r = SettingInfo::GetValue(L"Language", languageCode);
3896 // int languagecode = local.GetLanguageCode();
3897 AppLog("rahul language is %S", languageCode.GetPointer());
3901 InitFindWordPanel();
3903 if (languageCode.CompareTo("ara") == 0)
3905 AppLog("rahul language is arabic");
3907 __pFindWordPanelLeftToRight->SetShowState(false);
3908 __pFindWordPanelRightToLeft->SetShowState(true);
3910 __pFindWordClear->SetShowState(false);
3911 __pFindWordCountLabel->SetShowState(false);
3912 __pFindWordEditField->SetShowState(false);
3914 __pFindWordClearRightToLeft->SetShowState(true);
3915 __pFindWordCountLabelRightToLeft->SetShowState(true);
3916 __pFindWordEditFieldRightToLeft->SetShowState(true);
3920 AppLog("rahul language is not arabic");
3923 __pFindWordPanelLeftToRight->SetShowState(true);
3924 __pFindWordPanelRightToLeft->SetShowState(false);
3926 __pFindWordClear->SetShowState(true);
3927 __pFindWordCountLabel->SetShowState(true);
3928 __pFindWordEditField->SetShowState(true);
3930 __pFindWordClearRightToLeft->SetShowState(false);
3931 __pFindWordCountLabelRightToLeft->SetShowState(false);
3932 __pFindWordEditFieldRightToLeft->SetShowState(false);
3934 __pFindWordControl->SetShowState(true);
3938 if(__pFindWordControl != null)
3940 __pFindWordControl->SetShowState(false);
3944 AppLog("MainForm::ShowFindWordPanel %d",show);
3945 if (show && !isTouchPressed)
3947 if (languageCode.CompareTo("ara") == 0)
3949 if (__pFindWordEditFieldRightToLeft)
3951 __pFindWordEditFieldRightToLeft->SetFocus();
3952 __pFindWordEditFieldRightToLeft->ShowKeypad();
3957 if (__pFindWordEditField)
3959 __pFindWordEditField->SetFocus();
3960 __pFindWordEditField->ShowKeypad();
3966 if (languageCode.CompareTo("ara") == 0)
3968 if (__pFindWordEditFieldRightToLeft)
3969 __pFindWordEditFieldRightToLeft->HideKeypad();
3973 if (__pFindWordEditField)
3974 __pFindWordEditField->HideKeypad();
3978 RelayoutControls(false);
3982 MainForm::StartWordSearch()
3984 //Get the count of occurances of the word in the current page
3985 __maxOccurrances = 0;
3986 __currentWordIndex = 0;
3988 __pFindWordPrev->SetEnabled(false);
3989 String *pCountStr = null;
3990 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3991 AppLog("Search Result %s",GetErrorMessage(r));
3992 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3993 if (pCountStr != null)
3995 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3999 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4004 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4006 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4007 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4009 if(totalCount == -1 || totalCount == 0)
4011 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4012 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4015 else if(totalCount > 100)
4017 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4018 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4022 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4023 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4026 __maxOccurrances = totalCount;
4027 __currentWordIndex = currentOrdinal;
4029 //Reset the UI controls as per the maxOccurrance value
4030 if (totalCount <= 0)
4032 AppLog("Word not found");
4033 //Show error notification to user
4034 __pFindWordNext->SetEnabled(false);
4035 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4037 __pFindWordCountLabel->SetText(L"0/0");
4038 __pFindWordCountLabel->Invalidate(false);
4040 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4042 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4043 __pFindWordCountLabelRightToLeft->Invalidate(false);
4045 __pFindWordNext->Invalidate(false);
4046 __pFindWordPrev->Invalidate(false);
4051 if (totalCount == 1)
4053 __pFindWordNext->SetEnabled(false);
4057 __pFindWordNext->SetEnabled(true);
4060 String countStr = L"";
4061 countStr.Append(__currentWordIndex);
4062 countStr.Append(L"/");
4063 countStr.Append(__maxOccurrances);
4064 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4066 __pFindWordCountLabel->SetText(countStr);
4067 __pFindWordCountLabel->Invalidate(false);
4068 __pFindWordCountLabel->Invalidate(false);
4070 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4072 __pFindWordCountLabelRightToLeft->SetText(countStr);
4073 __pFindWordCountLabelRightToLeft->Invalidate(false);
4074 __pFindWordCountLabelRightToLeft->Invalidate(false);
4076 //FindNextWord(true);
4077 //Update the controls
4078 __pFindWordNext->Invalidate(false);
4079 __pFindWordPrev->Invalidate(false);
4084 MainForm::FindNextWord(bool next)
4088 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4089 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4091 if (__currentWordIndex < __maxOccurrances)
4093 __currentWordIndex++;
4099 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4100 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4102 if(__currentWordIndex > 1)
4104 __currentWordIndex--;
4109 String countStr = L"";
4110 countStr.Append(__currentWordIndex);
4111 countStr.Append(L"/");
4112 countStr.Append(__maxOccurrances);
4114 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4116 __pFindWordCountLabel->SetText(countStr);
4117 __pFindWordCountLabel->Invalidate(false);
4119 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4121 __pFindWordCountLabelRightToLeft->SetText(countStr);
4122 __pFindWordCountLabelRightToLeft->Invalidate(false);
4125 if (__currentWordIndex >= __maxOccurrances)
4127 __pFindWordNext->SetEnabled(false);
4131 __pFindWordNext->SetEnabled(true);
4133 if (__currentWordIndex <= 1)
4135 __pFindWordPrev->SetEnabled(false);
4139 __pFindWordPrev->SetEnabled(true);
4141 __pFindWordPrev->Invalidate(false);
4142 __pFindWordNext->Invalidate(false);
4144 __pFindWordControl->Invalidate(true);
4148 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4150 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4151 __isWebKeypadOpened = true;
4152 __pFooterPanel->SetShowState(false);
4153 // OnAddressBarKeypadOpened(*__pAddressbar);
4157 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4159 AppLog("xyz::MainForm::OnWebKeypadOpened");
4161 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4163 __currentSearchStr = L"";
4164 __currentWordIndex = 0;
4165 __maxOccurrances = 0;
4166 __pFindWordEditField->SetText(L"");
4167 __pFindWordNext->SetEnabled(false);
4168 __pFindWordPrev->SetEnabled(false);
4169 __pFindWordCountLabel->SetText(L"0/0");
4170 __pWebViewer->SearchTextAllAsync(L"",false);
4171 __pFindWordControl->SetShowState(false);
4172 __pFindWordEditField->HideKeypad();
4176 if (__pWebViewer != null && __pFooterPanel != null)
4178 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4179 if(__pAddressbar != null)
4181 __pAddressbar->SetShowState(false);
4183 if(__pFindWordControl != null)
4185 __pFindWordControl->SetShowState(false);
4187 __pFooterPanel->SetShowState(false);
4188 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4190 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4192 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4193 // AppLog("omgomgomg");
4199 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4201 AppLog("xyz::MainForm::OnWebKeypadClosed");
4202 AppLog("akjshdasd 4");
4203 __pFooterPanel->SetShowState(true);
4204 // OnAddressBarKeypadClosed(*__pAddressbar);
4205 RelayoutControls(false);
4206 __isWebKeypadOpened = false;
4210 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4212 // RelativeLayout(false);
4213 if(__pWebViewer != null)
4215 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4220 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4222 Control* temp = const_cast< Control* >(&source);
4223 Header* pHeader = dynamic_cast< Header* >(temp);
4224 if (pHeader != null)
4226 //Header double - clicked
4227 AppLog("Header double clicked");
4229 if(__pFindWordControl)
4231 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4232 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4236 AppLog("MainScene::OnTouchDoublePressed");
4240 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4242 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4243 __longPressPoint = currentPosition;
4245 if (__pHitElementResult != null)
4247 delete __pHitElementResult;
4248 __pHitElementResult = null;
4251 if (__pWebViewer != null)
4253 AppLog("MainForm::OnTouchLongPressed web not null");
4254 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4257 if (__pHitElementResult == null)
4262 if (__pHitElementResult->HasImage() == true)
4264 InitImageContextMenu(currentPosition);
4265 __pImageMenu->SetShowState(true);
4266 __pImageMenu->Show();
4267 __pImageMenu->Invalidate(true);
4269 else if(__pHitElementResult->HasUrl() == true)
4271 String tempURl = __pHitElementResult->GetUrl();
4272 AppLog("tempURl is %ls", tempURl.GetPointer());
4273 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4274 if (pBitmap != null)
4282 InitImageLinkContextMenu(currentPosition);
4283 __pImageMenu->SetShowState(true);
4284 __pImageMenu->Show();
4285 __pImageMenu->Invalidate(true);
4289 String tagName = __pHitElementResult->GetTagName();
4290 String type = __pHitElementResult->GetAttributeValue("type");
4291 String value = __pHitElementResult->GetAttributeValue(L"value");
4292 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4294 __currentSelectedStr.Clear();
4295 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4297 AppLog("tag name is %ls", tagName.GetPointer());
4298 AppLog("type is %ls", type.GetPointer());
4302 //__isLongPressedDone = true;
4303 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4304 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4306 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4308 InitSelectTextContextMenu(currentPosition,true, true);
4311 __pImageMenu->SetShowState(true);
4312 __pImageMenu->Show();
4313 __pImageMenu->Invalidate(true);
4316 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4319 // __inputEventToBeSupressed = true;
4323 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4325 AppLog("xyz:: MainForm::OnTouchReleased called");
4327 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4329 __pAddressbar->SetShowState(false);
4333 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4334 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4336 __pWebViewer->ConsumeInputEvent();
4338 if(pHitElement != null)
4342 __inputEventToBeSupressed = false;*/
4346 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4353 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4355 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4357 __currentSearchStr = L"";
4358 __currentWordIndex = 0;
4359 __maxOccurrances = 0;
4361 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4363 __pFindWordEditField->SetText(L"");
4364 __pFindWordEditField->HideKeypad();
4365 __pFindWordControl->SetShowState(false);
4366 __pFindWordCountLabel->SetText(L"0/0");
4368 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4370 __pFindWordEditFieldRightToLeft->SetText(L"");
4371 __pFindWordEditFieldRightToLeft->HideKeypad();
4372 __pFindWordControl->SetShowState(false);
4373 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4376 __pFindWordNext->SetEnabled(false);
4377 __pFindWordPrev->SetEnabled(false);
4379 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4380 __pFindWordControl->SetShowState(false);
4382 if(__pAddressbar->GetShowState() == false)
4384 __pAddressbar->SetAddressbarURLFocus();
4385 __pFooterPanel->SetShowState(false);
4392 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4398 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4404 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4410 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4416 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4422 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4424 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4425 int widthContextItem = 0;
4427 // As per the platform engineer comment removed this line
4428 /*if(__pWebViewer != null)
4430 // 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
4431 __pWebViewer->ReleaseBlock();
4434 // if(__pFindWordControl != null)
4435 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4436 if(__pNotification && __pNotification->GetShowState() == true)
4438 __pNotification->SetShowState(false);
4439 __pNotification->Invalidate(false);
4441 if ( __pFooterLabel != null)
4443 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4446 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4452 if (__pFindWordBgLabel != null)
4454 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4455 if (pBitmap != null)
4457 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4462 if (__pFindWordBgLabelRightToLeft != null)
4464 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4465 if (pBitmap != null)
4467 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4473 if(__pOptionMenu != null)
4474 __pOptionMenu->SetShowState(false);
4476 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4478 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4482 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4487 AppLog("__pFooterPanel->GetShowState() is true");
4489 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4490 __pFooterPanel->Invalidate(true);
4494 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4495 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4497 InitMostVisitedSitesView(orientationStatus);
4500 RelayoutControls(false);
4501 if (__pArticleReaderPanel != null)
4503 if (__pArticleReaderPanel->GetShowState() == true)
4505 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4507 if (__pBlankPanel != null)
4508 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4510 if (__pWebReader != null)
4512 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4514 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4515 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4517 if ( pBitmap != null && pSrcBitmap != null)
4519 AppLog("CreateReaderPanel ninepatchbitmap found");
4520 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4523 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4524 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4525 if (pBitmap != null)
4530 if (pSrcBitmap != null)
4539 if (__pAddressbar != null)
4541 int width = GetClientAreaBounds().width;
4542 __pAddressbar->OrientationChanged(width);
4547 MainForm::OnSettingsChange(int settingvalue)
4549 AppLogDebug("MainForm::OnSettingsChange entered");
4551 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4553 __pAddressbar->ResetGuideText();
4555 if (__pWebViewer == null)
4557 AppLogDebug("Webviewer is not initialized yet.");
4561 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4563 WebSetting settings = __pWebViewer->GetSetting();
4564 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4566 settings.SetAutoFittingEnabled(true);
4568 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4570 settings.SetAutoFittingEnabled(false);
4572 __pWebViewer->SetSetting(settings);
4574 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4576 WebSetting settings = __pWebViewer->GetSetting();
4577 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4578 __pWebViewer->SetSetting(settings);
4580 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4582 WebSetting settings = __pWebViewer->GetSetting();
4583 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4584 __pWebViewer->SetSetting(settings);
4585 __pWebViewer->Reload();
4587 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4589 WebSetting settings = __pWebViewer->GetSetting();
4590 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4591 __pWebViewer->SetSetting(settings);
4593 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4597 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4600 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4604 WebSetting settings = __pWebViewer->GetSetting();
4605 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4606 __pWebViewer->SetSetting(settings);
4609 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4613 WebSetting settings = __pWebViewer->GetSetting();
4614 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4615 __pWebViewer->SetSetting(settings);
4618 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4620 WebSetting settings = __pWebViewer->GetSetting();
4621 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4623 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4627 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4629 __pWebViewer->SetSetting(settings);
4631 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4635 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4636 WebSetting settings = __pWebReader->GetSetting();
4637 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4638 __pWebReader->SetSetting(settings);
4644 MainForm::OnSettingsReset()
4648 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4649 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4654 MainForm::OnClearCache()
4656 result r = E_SUCCESS;
4658 if (__pWebViewer != NULL)
4660 r = __pWebViewer->ClearCache();
4663 AppLogDebug("Cache cleared success");
4667 AppLogDebug("Cache cleared fail");
4673 MainForm::OnClearCookie()
4675 result r = E_SUCCESS;
4677 if (__pWebViewer != NULL)
4679 __pWebViewer->ClearCookie();
4683 AppLogDebug("Cookie cleared success");
4687 AppLogDebug("Cache cleared fail");
4692 MainForm::OnClearFormData()
4694 result r = E_SUCCESS;
4696 if (__pWebViewer != NULL)
4698 __pWebViewer->ClearFormData();
4702 AppLogDebug("Cookie cleared success");
4706 AppLogDebug("Cache cleared fail");
4711 MainForm::OnClearPasswords()
4713 result r = E_SUCCESS;
4715 if (__pWebViewer != NULL)
4717 __pWebViewer->ClearLoginFormData();
4721 AppLogDebug("Cookie cleared success");
4725 AppLogDebug("Cache cleared fail");
4731 MainForm::findDistance(int x1,int y1,int x2, int y2)
4733 int deltaX = Math::Abs(x2 - x1);
4734 int deltaY = Math::Abs(y2 - y1);
4735 double num = deltaX*deltaX + deltaY*deltaY;
4741 for (i = 0; i < 20; i++)
4743 x = (((x*x)+ num)/(2*x));
4754 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4756 AppLog("xyz:: MainForm::OnTouchPressed called");
4757 if(__pFindWordControl)
4759 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4760 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4762 //__isLongPressedDone = false;
4767 IList* pList = null;
4768 pList = touch.GetTouchInfoListN(source);
4772 int count = pList->GetCount();
4775 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4776 __touchPoint1 = pTouchInfo->position;
4778 /*if (__pAddressbar != null)
4780 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4782 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4784 __pAddressbar->SaveAddressbarEditText();
4786 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4789 __pAddressbar->Invalidate(true);
4791 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4793 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4795 //__pAddressbar->SaveAddressbarEditText();
4797 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4800 else if (count == 2)
4802 AppLogDebug("MainForm::OnTouchPressed count is two");
4803 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4804 __touchPoint1 = pTouchInfo->position;
4806 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4807 __touchPoint2 = pTouchInfo->position;
4812 pList->RemoveAll(true);
4815 // RelayoutControls(false);
4820 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4822 // __currentWordIndex = 0;
4823 //__isLongPressedDone = false;
4828 MainForm::MoveUiControls()
4833 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4835 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4837 if(__pFooterUrlField->GetTextLength() == 0)
4839 __pFooterUrlField->SetKeypadActionEnabled(false);
4843 __pFooterUrlField->SetKeypadActionEnabled(true);
4846 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4848 __currentSearchStr = __pFindWordEditField->GetText();
4849 if (__currentSearchStr.GetLength() > 0)
4851 __pFindWordCountLabel->SetShowState(true);
4855 __pFindWordCountLabel->SetShowState(false);
4857 __pFindWordNext->SetEnabled(false);
4858 __pFindWordPrev->SetEnabled(false);
4859 __pFindWordNext->Invalidate(true);
4860 __pFindWordPrev->Invalidate(true);
4861 __pFindWordCountLabel->SetText(L"0/0");
4862 __pFindWordCountLabel->Invalidate(true);
4864 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4866 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4867 if (__currentSearchStr.GetLength() > 0)
4869 __pFindWordCountLabelRightToLeft->SetShowState(true);
4873 __pFindWordCountLabelRightToLeft->SetShowState(false);
4876 __pFindWordNext->SetEnabled(false);
4877 __pFindWordPrev->SetEnabled(false);
4878 __pFindWordNext->Invalidate(true);
4879 __pFindWordPrev->Invalidate(true);
4880 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4881 __pFindWordCountLabelRightToLeft->Invalidate(true);
4883 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4884 if (__currentSearchStr.GetLength() > 0)
4890 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4892 __currentSearchStr = L"";
4893 AppLogDebug("Enter something");
4898 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4905 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4907 if(__pWebViewer != null)
4910 AppLog("MainForm::InitMostVisitedSitesView");
4911 result r = E_SUCCESS;
4914 if (__pWebViewer != null && __pMostVisitedListView != null)
4919 if (__pMostVisitedListView != null)
4921 RemoveControl(__pMostVisitedListView);
4923 if(__pMostVisitedSites != null)
4925 __pMostVisitedSites->RemoveAll(true);
4928 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4930 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4931 __pMostVisitedListView = new(std::nothrow) ListView();
4933 int height = GetClientAreaBounds().height;
4935 if(__pFooterPanel->GetShowState() == true)
4937 height = height - __pFooterPanel->GetHeight();
4939 if(__pAddressbar->GetShowState() == true)
4941 height -= __pAddressbar->GetHeight();
4944 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4948 delete __pMostVisitedListView;
4949 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4952 __pMostVisitedListView->SetItemProvider(*this);
4953 __pMostVisitedListView->AddListViewItemEventListener(*this);
4954 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4955 AddControl(__pMostVisitedListView);
4956 __pMostVisitedListView->UpdateList();
4963 MainForm::GetImagePath(void)
4967 String formattedTime;
4968 DateTime currentTime;
4969 LocaleManager localManager;
4970 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4972 localManager.Construct();
4973 Locale locale = localManager.GetSystemLocale();
4974 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4976 // Get date formatter
4977 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4981 pTimeFormatter->Format(currentTime, formattedTime);
4984 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4985 String delim(L" :");
4986 StringTokenizer strTok(formattedTime, delim);
4989 String str1("GMT+00");
4990 while (strTok.HasMoreTokens())
4992 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4993 if(token.Equals(str1))
4995 AppLog("token is %ls", token.GetPointer());
4996 imageName.Append(token);
5002 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5004 result r = E_FAILURE;
5005 AppLog("Content manager 1");
5006 ContentId contentId;
5007 ContentManager contentManager;
5008 r = contentManager.Construct();
5011 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5014 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5015 Tizen::Io::Directory::Create(contentPath,true);
5016 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5018 AppLog("Already exists");
5020 else if(GetLastResult() == E_SUCCESS)
5022 AppLog("created success");
5024 contentPath.Append(imageName);
5025 contentPath.Append(".jpg");
5026 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5027 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5031 MainForm::SetForwardButtonEnabled(bool isEnabled)
5033 __pGoForwardBtn->SetEnabled(isEnabled);
5034 __pGoForwardBtn->Invalidate(true);
5038 MainForm::SetBackButtonEnabled(bool isEnabled)
5040 __pGoBackBtn->SetEnabled(isEnabled);
5041 __pGoBackBtn->Invalidate(true);
5045 MainForm::UpdateProgress(int percentage)
5047 __progressPercentage = percentage;
5048 if (percentage == 0 || percentage == 100)
5050 __isLoadingData = false;
5051 if (percentage == 100)
5053 __isLoadingCompleted = true;
5054 __progressPercentage = 0;
5058 __isLoadingCompleted = false;
5063 __isLoadingData = true;
5065 UpdateProgressBitmap();
5069 MainForm::GetProgress(void)
5071 return __progressPercentage;
5075 MainForm::UpdateProgressBitmap(void)
5077 result r = E_SUCCESS;
5078 if (__pProgressbarLabel == null)
5080 int w = __pProgressbarLabel->GetWidth();
5081 int h = __pProgressbarLabel->GetHeight();
5083 int progressWidth = 0;
5084 Bitmap* pRetBitmap = null;
5086 if (__progressPercentage == 0 || __progressPercentage == 100)
5088 __pProgressbarLabel->SetShowState(false);
5089 __pProgressbarLabel->Invalidate(false);
5094 __pProgressbarLabel->SetShowState(true);
5095 __pProgressbarLabel->Invalidate(false);
5098 r = canvas.Construct(Rectangle(0, 0, w, h));
5102 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5107 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5111 pBgBmp->Scale(Dimension(w, h));
5112 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5116 progressWidth = (double) (w) * __progressPercentage / 100;
5117 AppLogDebug("progressWidth: %d", progressWidth);
5118 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5120 if (pProgressBmp != null)
5122 pProgressBmp->Scale(Dimension(progressWidth, h));
5123 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5124 delete pProgressBmp;
5127 pRetBitmap = new (std::nothrow) Bitmap();
5129 if (pRetBitmap == null)
5131 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5135 pRetBitmap->Construct(canvas, canvas.GetBounds());
5137 if (__pProgressbarLabel != null && pRetBitmap != null)
5139 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5140 __pProgressbarLabel->Invalidate(false);
5143 if (pRetBitmap != null)
5152 MainForm::ReaderClicked()
5154 result r = E_SUCCESS;
5155 ArrayList* pArgList = new(std::nothrow) ArrayList();
5156 if (pArgList != null)
5158 r = pArgList->Construct();
5165 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5172 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5179 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5187 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5191 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
5193 CreateReaderPanel();
5194 AppLogDebug("MainScene::ReaderClicked entered");
5197 /*if (__pArticleReaderPanel)
5199 AppLogDebug("showstate true for reader panel");
5200 __pArticleReaderPanel->SetShowState(true);
5201 __pArticleReaderPanel->Show();
5203 int xPos = __pArticleReaderPanel->GetX();
5204 int yPos = __pArticleReaderPanel->GetY();
5205 AppLog("ReaderClicked() xPos = %d",xPos);
5206 AppLog("ReaderClicked() yPos = %d",yPos);
5208 if (__pReaderData == null)
5213 String loadData = L"<html>\
5215 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
5220 background-color: transparent;\
5239 <body style='width:'";
5240 loadData.Append(bodyWidth);
5241 loadData.Append(L"px'>");
5242 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5243 loadData.Append(*__pReaderData);
5244 loadData.Append(L"</body></html>");
5247 buf.Construct(loadData.GetLength());
5248 AppLogDebug("data->GetLength %d",loadData.GetLength());
5249 for (int z=0;z<loadData.GetLength();z++)
5252 loadData.GetCharAt(z,b);
5253 buf.SetByte((byte)b);
5257 if (__pWebReader != null)
5259 __pWebReader->LoadData(L"",buf,L"text/html");
5260 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5264 AppLogDebug("cannot LoadData __pWebReader is null");
5269 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5271 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5273 __currentAddMode = addMode;
5277 case ADDRESSBAR_MODE_INVALID:
5282 case ADDRESSBAR_MODE_READER:
5284 __pStopBtn->SetShowState(false);
5285 __pRefreshBtn->SetShowState(false);
5286 __pClearBtn->SetShowState(false);
5287 __pReaderBtn->SetShowState(false);
5290 case ADDRESSBAR_MODE_LOADING:
5292 __pRefreshBtn->SetShowState(false);
5293 __pStopBtn->SetShowState(true);
5294 __pClearBtn->SetShowState(false);
5295 __pReaderBtn->SetShowState(false);
5298 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5300 // SetUrl(__pAddressbar->GetUrl());
5302 __pRefreshBtn->SetShowState(true);
5303 __pStopBtn->SetShowState(false);
5304 __pClearBtn->SetShowState(false);
5305 __pReaderBtn->SetShowState(false);
5308 case ADDRESSBAR_MODE_EDIT:
5310 __pRefreshBtn->SetShowState(false);
5311 __pStopBtn->SetShowState(false);
5312 __pReaderBtn->SetShowState(false);
5313 __pClearBtn->SetShowState(true);
5320 OnAddressBarModeChanged();
5323 AddressBarMode MainForm::GetAddressbarMode(void)
5325 return __currentAddMode;
5328 void MainForm::SetUrl(const String& url)
5331 if(__displayUrl.GetLength() > 2048)
5332 __displayUrl.SubString(0,2048,__displayUrl);
5334 if (__pFooterUrlField != NULL)
5336 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5337 if (removedHttpUrl.IsEmpty() == false)
5339 __pFooterUrlField->SetText(removedHttpUrl);
5340 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5341 __pAddressbar->SetUrl(__displayUrl);
5345 __pFooterUrlField->SetText(__displayUrl);
5346 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5347 __pAddressbar->SetUrl(__displayUrl);
5349 if(__pFooterUrlField)
5350 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5351 __pFooterUrlField->Invalidate(false);
5352 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5353 __pAddressbar->Invalidate(true);
5354 // __pFooterUrlField->SetCursorPosition(0);
5359 MainForm::RemoveHttpTextFromDisplayURL(void)
5361 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5363 // bool isHttpText = __displayUrl.Contains(L"http://");
5364 String updatedDisplayUrl;
5365 updatedDisplayUrl.Clear();
5366 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5368 __displayUrl.SubString(7,updatedDisplayUrl);
5370 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5372 __displayUrl.SubString(8,updatedDisplayUrl);
5374 return updatedDisplayUrl;
5377 void MainForm::OnSharePopupControlStarted(void)
5379 __pWebViewer->AddTouchEventListener(*this);
5383 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5385 if (requestId == BACK_GROUND_APP_EVENT)
5387 if(__pWebViewer != null)
5389 __pWebViewer->Pause();
5391 if(__pAddressbar != null)
5393 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5396 else if(requestId == FORE_GROUND_APP_EVENT)
5398 if(__pWebViewer != null)
5400 __pWebViewer->Resume();
5402 if(__pAddressbar != null)
5404 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5410 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5412 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5413 result r = E_SUCCESS;
5416 __pAddressbar->SetShowState(false);
5418 //AppLog("akjshdasd 5");
5419 //__pFooterPanel->SetShowState(true);
5422 __pWebViewer->SetFocus();
5423 else if(__pMostVisitedListView)
5424 __pMostVisitedListView->SetFocus();
5425 else if(__pMultiWindowButton)
5426 __pMultiWindowButton->SetFocus();
5427 else if(__pMoreButton)
5428 __pMoreButton->SetFocus();
5430 __pAddressbar->SetShowState(false);
5432 RelayoutControls(false);
5436 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5438 AppLog("MainForm::OnFormMenuRequested called");
5440 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5442 int bookmarkCount=0;
5445 url=__pWindowInfo->pageUrl;
5446 result r = E_SUCCESS;
5447 Bitmap* pBitmap = null;
5449 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5452 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5457 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5461 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5463 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5465 if (__pOptionMenu->GetItemCount() == 9)
5467 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5471 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5476 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5480 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5481 if (__pOptionMenu->GetItemCount() != 9)
5483 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5484 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5485 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5486 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5487 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5488 __pOptionMenu->SetMaxVisibleItemsCount(6);
5490 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5492 AppLog(" Orientation landscape");
5493 __pOptionMenu->SetMaxVisibleItemsCount(5);
5497 AppLog(" Orientation potrait");
5498 __pOptionMenu->SetMaxVisibleItemsCount(6);
5501 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5504 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5505 __pOptionMenu->SetShowState(true);
5506 __pOptionMenu->Invalidate(true);
5507 __pOptionMenu->Show();