2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
17 //!Internet MainForm class
19 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
20 * loading,handling events etc.
24 #include <FGraphics.h>
29 #include "IntBookmarkData.h"
30 #include "IntBookmarkPresentationModel.h"
31 #include "IntCommonLib.h"
32 #include "IntFaviconManager.h"
33 #include "IntInternetApp.h"
34 #include "IntMainForm.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDS_KEY = L"key";
73 static const wchar_t* IDS_VALUE = L"value";
74 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
75 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
76 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
78 const int IDA_BACKBTN_CLICKED = 101;
79 const int IDA_BOOKMARKBTN_CLICKED = 102;
80 const int IDA_MOREBTN_CLICKED = 103;
81 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
82 const int IDA_NEWWINDOWBTN_CLICKED = 105;
83 const int IDA_FORWARD_CLICKED = 106;
84 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
85 const int IDA_SHARE_CLICKED = 108;
86 const int IDA_FINDONPAGE_CLICKED = 109;
87 const int IDA_PRIVATEON_CLICKED = 110;
88 const int IDA_SETTINGS_CLICKED = 111;
89 const int IDA_READER_CLOSE_CLICKED = 112;
90 const int IDA_SMALLFONT_BTN_CLICKED = 113;
91 const int IDA_LARGEFONT_BTN_CLICKED = 114;
92 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
93 const int IDA_HISTORY_CLICKED = 116;
94 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
95 const int IDA_ADD_TO_HOME_CLICKED = 118;
96 const int IDA_SAVED_PAGES_CLICKED = 119;
97 const int IDA_DESKTOP_VIEW_CLICKED = 120;
98 const int IDA_SAVE_CLICKED = 121;
99 const int IDA_PRINT_CLICKED = 122;
101 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
102 const int IDA_FINDWORD_NEXT_CLICKED = 202;
103 const int IDA_FINDWORD_PREV_CLICKED = 203;
104 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
105 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
107 const int IDA_COPY_IMAGE_CLICKED = 206;
108 const int IDA_VIEW_IMAGE_CLICKED = 207;
109 const int IDA_SAVE_IMAGE_CLICKED = 208;
110 const int IDA_SHARE_IMAGE_CLICKED = 209;
112 const int IDA_COPY_TEXT_CLICKED = 210;
113 const int IDA_PASTE_TEXT_CLICKED = 211;
114 const int IDA_FIND_TEXT__CLICKED = 212;
115 const int IDA_SHARE_TEXT_CLICKED = 213;
117 const int IDA_GO_BACK = 214;
118 const int IDA_GO_FORWARD = 215;
119 const int IDA_REFRESH_BTN_CLICKED = 216;
120 const int IDA_STOP_BTN_CLICKED = 217;
121 const int IDA_CLEAR_URL = 218;
122 const int IDA_READER_BTN_CLICKED = 219;
125 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
126 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
127 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
128 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
130 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
132 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
134 const int MainForm::IDA_FORMAT_BITMAP = 500;
135 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
136 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
137 const int MainForm::IDA_FORMAT_URL_STRING = 503;
138 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
140 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
141 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
142 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
144 MainForm::MainForm(void)
146 //__isLongPressedDone = false;
148 __pAddressbar = null;
149 // __pMostVisitedSitesPanel = null;
150 __pMostVisitedListView = null;
151 __pFooterPanel = null;
152 __pHitElementResult = null;
153 __pWindowInfo = null;
156 __pOptionMenu = null;
157 __pFindWordControl = null;
158 __pFindWordPanelLeftToRight = null;
159 __pFindWordPanelRightToLeft = null;
160 __pFindWordBgLabel = null;
161 __pFindWordBgLabelRightToLeft = null;
162 __pFindWordEditField = null;
163 __pFindWordEditFieldRightToLeft = null;
164 __pFindWordClear = null;
165 __pFindWordClearRightToLeft = null;
166 __pFindWordCountLabel = null;
167 __pFindWordClearRightToLeft = null;
168 __pFindWordNext = null;
169 __pFindWordPrev = null;
170 __previousZoomLevel = 1.0;
172 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
175 __currentSearchStr = L"";
176 __currentSelectedStr = L"";
177 __maxOccurrances = 0;
178 __currentWordIndex = 0;
181 //__inputEventToBeSupressed = false;
182 __isLoadingData = false;
183 __isLoadingCompleted = false;
184 __progressPercentage = 0;
185 __touchPoint1 = Point(-1,-1);
186 __touchPoint2 = Point(-1,-1);
187 __longPressPoint = Point(-1,-1);
189 // __pReaderPopup = null;
190 __pReaderData = null;
192 __pReaderCloseBtn = null;
193 //__pNewWindowButton = null;
194 __pMoreButton = null;
195 __pMultiWindowButton = null;
196 __pArticleReaderPanel = null;
197 __pBlankPanel = null;
198 __pArticleReaderLabel = null;
199 __webControlHeight = 0;
200 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
201 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
202 __pMostVisitedSites = null;
203 __pFooterUrlField = null;
205 __pGoForwardBtn = null;
206 __pRefreshBtn = null;
207 __pProgressbarLabel = null;
208 __pFooterLabel = null;
212 __isWebKeypadOpened = false;
214 __pNotification = null;
217 MainForm::~MainForm(void)
219 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
223 __pAddressbar->SetAddressbarEventListener(null);
226 if(__pHistory != null)
232 if (__pReaderData != null)
234 delete __pReaderData;
235 __pReaderData = null;
238 if (__pPopUp != null)
244 if (__pHitElementResult != null)
246 delete __pHitElementResult;
247 __pHitElementResult = null;
250 String* pSelectedScene = NULL;
251 Object* pValue = NULL;
252 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
253 pSelectedScene = (String*) pValue;
255 /*if (pSelectedScene != null)
257 delete pSelectedScene;
259 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
263 MainForm::Initialize(void)
265 InternetApp* pInternet = static_cast<InternetApp*> (Application::GetInstance());
266 Construct(L"IDL_FORM_HW_KEY");
268 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
273 MainForm::OnInitializing(void)
275 AppLog("get client area width = %d",GetClientAreaBounds().width);
276 AppLog("get client area height = %d",GetClientAreaBounds().height);
277 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
278 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
280 __fontSize = CommonUtil::GetFontSize();
281 Panel* pFooterPanel = null;
283 __pSaveImage = new Image();
284 __pSaveImage->Construct();
286 // Setup back event listener
287 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
288 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
289 AddOrientationEventListener(*this);
291 AppLogDebug(" MainForm::OnInitializing ended");
292 if (__pMostVisitedSites == null)
294 __pMostVisitedSites = new(std::nothrow) ArrayList();
295 __pMostVisitedSites->Construct();
297 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
299 __pItemContext= new(std::nothrow) ListContextItem();
300 __pItemContext->Construct();
302 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
305 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
306 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
307 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
309 __pItemContextLandscape= new(std::nothrow) ListContextItem();
310 __pItemContextLandscape->Construct();
312 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
313 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
314 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
315 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
316 SetFormMenuEventListener(this);
317 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
322 MainForm::InitAddressbar(void)
324 AppLogDebug("MainForm::InitAddressbar entered");
326 result r = E_SUCCESS;
328 if (__pAddressbar != null)
332 __pAddressbar = new(std::nothrow) Addressbar();
333 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
334 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
337 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
340 __pAddressbar->SetAddressbarEventListener(this);
341 AddControl(__pAddressbar);
342 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
343 SetControlAlwaysOnTop(*__pAddressbar, true);
344 __adressPanelPosition = __pAddressbar->GetPosition();
346 AppLogDebug("MainForm::InitAddressbar exit");
352 MainForm::CreateReaderPanel(void)
354 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
355 result r = E_FAILURE;
357 Button *pSmallFontBtn = null;
358 Button *pLargeFontBtn = null;
360 __pBlankPanel = new (std::nothrow) Panel();
361 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
363 __pArticleReaderPanel = new (std::nothrow) Panel();
364 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
366 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
367 if (__pReaderCloseBtn)
369 AppLogDebug("CreateReaderPanel() 6");
370 __pReaderCloseBtn->AddActionEventListener(*this);
371 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
374 __pWebReader = new (std::nothrow) Web();
375 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
377 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
378 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
380 r = __pWebReader->SetSetting(settings);
382 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
385 __pArticleReaderLabel = new Label();
386 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
388 __pBlankPanel->AddControl(__pArticleReaderLabel);
389 __pBlankPanel->AddControl(__pArticleReaderPanel);
390 AddControl(__pBlankPanel);
392 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
393 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
394 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
396 __pArticleReaderPanel->AddControl(__pWebReader);
397 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
398 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
399 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
401 if (pBitmap != null && pSrcBitmap != null)
403 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
405 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
407 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
410 pSmallFontBtn->AddActionEventListener(*this);
411 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
414 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
417 pLargeFontBtn->AddActionEventListener(*this);
418 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
427 if (pSrcBitmap != null)
433 SetControlAlwaysOnTop(*__pBlankPanel, true);
434 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
441 MainForm::InitWebControl()
443 AppLogDebug("MainForm::InitWebControl enter");
444 result r = E_SUCCESS;
445 AppLogDebug("InitWebControl");
447 if (__pAddressbar == null || __pFooterPanel == null)
450 const int Y_WEBCONTROL_POSITION = 0;
452 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
454 if (__pMostVisitedListView)
456 __pMostVisitedListView->SetShowState(false);
458 if (__pWebViewer != null)
460 AppLogDebug("Already initialized");
463 __pWebViewer = new(std::nothrow) Web();
464 if(__pWebViewer == NULL)
466 AppLogDebug("Initialization failed");
469 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
473 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
480 r = AddControl(__pWebViewer);
486 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
489 __webControlPosition = __pWebViewer->GetPosition();
490 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
493 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
497 __pWebViewer->SetLoadingListener(this);
498 __pWebViewer->SetWebUiEventListenerF(this);
499 __pWebViewer->SetWebKeypadEventListener(this);
500 __pWebViewer->SetFocus();
501 __pWebViewer->AddTouchEventListener(*this);
503 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
504 __pWebViewer->SetTextSearchListener(this);
507 AppLogDebug("MainForm :before return");
509 AppLogDebug("MainForm::InitWebControl Exit");
515 MainForm::SetJavascriptEnabled()
517 WebSetting settings = __pWebViewer->GetSetting();
518 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
519 __pWebViewer->SetSetting(settings);
523 MainForm::SetImageLoadEnabled()
525 WebSetting settings = __pWebViewer->GetSetting();
526 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
527 __pWebViewer->SetSetting(settings);
531 MainForm::InitFooter(void)
533 AppLogDebug("MainForm::InitFooter entered");
534 Button* pBackButton = null;
535 Button* pBookmarkButton = null;
536 Button* pMultiWindowButton = null;
537 Bitmap *pIconBitmap = null;
538 Bitmap *pBGBitmap = null;
539 Label *pBGLabel = null;
541 if (__pFooterPanel == null)
543 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
546 if (__pFooterPanel == null)
551 SetControlAlwaysOnTop(*__pFooterPanel, true);
553 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
554 if ( __pFooterLabel == NULL )
558 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
559 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
562 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
566 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
568 if ( __pMultiWindowButton == NULL )
574 SetFormBackEventListener(this);
575 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
576 if (__pMultiWindowButton != null)
578 Bitmap* pBitmap = null;
579 Bitmap* pPressedBitmap = null;
580 String imagePath = "I01_toolbar_icon_windows_manager_0";
581 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
582 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
583 imagePath.Append(totalCount);
584 imagePath.Append(".png");
586 pressedImagePath.Append(totalCount);
587 pressedImagePath.Append("_press.png");
589 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
590 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
591 if ( pBitmap == null )
596 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
599 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
600 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
605 __pMultiWindowButton->AddActionEventListener(*this);
606 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
611 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
612 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
615 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
616 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
617 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
621 __pMoreButton->AddActionEventListener(*this);
622 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
625 //Add the editfield for url
626 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
627 if (__pFooterUrlField == NULL)
629 return E_INVALID_KEY;
632 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
633 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
634 __pFooterUrlField->AddKeypadEventListener(*this);
635 __pFooterUrlField->SetPropagatedTouchEventListener(this);
637 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
639 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
641 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
643 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
647 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
648 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
652 //Add the go Back Button
653 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
654 if (__pGoBackBtn == NULL)
656 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
657 return E_INVALID_KEY;
659 __pGoBackBtn->SetActionId(IDA_GO_BACK);
660 __pGoBackBtn->AddActionEventListener(*this);
662 //Add the go forward Button
663 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
664 if (__pGoForwardBtn == NULL)
666 AppLogDebug("Control not found returning E_INVALID_KEY");
667 return E_INVALID_KEY;
669 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
670 __pGoForwardBtn->AddActionEventListener(*this);
671 if (__pWebViewer && __pWebViewer->CanGoForward())
673 SetForwardButtonEnabled(true);
677 SetForwardButtonEnabled(false);
680 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
681 if (__pRefreshBtn == NULL)
683 AppLogDebug("Control not found returning E_INVALID_KEY");
684 return E_INVALID_KEY;
687 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
688 __pRefreshBtn->AddActionEventListener(*this);
689 __pRefreshBtn->SetShowState(true);
691 //Add the backround label for displaying progressbar
692 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
693 if (__pProgressbarLabel == NULL)
695 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
696 return E_INVALID_KEY;
698 __pProgressbarLabel->SetShowState(false);
700 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
701 if (__pStopBtn == NULL)
703 AppLogDebug("Control not found returning E_INVALID_KEY");
704 return E_INVALID_KEY;
706 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
707 __pStopBtn->AddActionEventListener(*this);
708 __pStopBtn->SetShowState(false);
710 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
711 if (__pClearBtn == NULL)
713 AppLogDebug("Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
716 __pClearBtn->SetActionId(IDA_CLEAR_URL);
717 __pClearBtn->AddActionEventListener(*this);
718 __pClearBtn->SetShowState(false);
720 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
721 if (__pReaderBtn == NULL)
723 AppLogDebug("Control not found returning E_INVALID_KEY");
724 return E_INVALID_KEY;
726 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
727 __pReaderBtn->AddActionEventListener(*this);
728 __pReaderBtn->SetShowState(false);
730 // __pFooterPanel->Invalidate(true);
731 AppLogDebug("MainForm::InitFooter exit");
736 MainForm::InitOptionMenu()
738 result r = E_SUCCESS;
739 bool isPrivateBrowsing = false;
740 Bitmap* pBitmap = null;
742 if (__pOptionMenu != null)
744 __pOptionMenu->Invalidate(true);
748 __pOptionMenu = new(std::nothrow) OptionMenu();
749 r = __pOptionMenu->Construct();
750 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
752 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
755 if (isPrivateBrowsing == true)
757 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
761 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
764 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
766 if ( pBitmap != NULL)
768 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
771 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
772 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
773 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
776 __pOptionMenu->SetMaxVisibleItemsCount(6);
777 __pOptionMenu->SetShowState(false);
778 __pOptionMenu->AddActionEventListener(*this);
779 SetControlAlwaysOnTop(*__pOptionMenu, true);
785 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
787 result r = E_SUCCESS;
788 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
790 AppLog("MainForm::InitImageContextMenu clicked on image");
791 if (__pImageMenu != null)
797 __pImageMenu = new (std::nothrow) ContextMenu();
798 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
799 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
801 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
802 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
803 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
804 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
805 __pImageMenu->SetMaxVisibleItemsCount(4);
806 __pImageMenu->AddActionEventListener(*this);
807 SetControlAlwaysOnTop(*__pImageMenu, true);
813 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
815 result r = E_SUCCESS;
816 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
818 AppLog("MainForm::InitImageContextMenu clicked on image");
819 if (__pImageMenu != null)
825 if(__pAddressbar->GetShowState() == true)
826 p.y = p.y + __pAddressbar->GetHeight();
827 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
832 __pImageMenu = new (std::nothrow) ContextMenu();
833 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
834 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
836 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
837 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
838 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
839 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
841 __pImageMenu->SetMaxVisibleItemsCount(3);
842 __pImageMenu->AddActionEventListener(*this);
843 SetControlAlwaysOnTop(*__pImageMenu, true);
850 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
852 result r = E_SUCCESS;
853 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
855 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
856 if (__pImageMenu != null)
865 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
869 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
871 __pImageMenu = new (std::nothrow) ContextMenu();
872 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
873 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
875 if(onlyPasteOption == false)
877 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
879 if (pasteOption || onlyPasteOption)
881 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
883 if(onlyPasteOption == false)
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
886 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
889 __pImageMenu->SetMaxVisibleItemsCount(3);
890 __pImageMenu->AddActionEventListener(*this);
891 SetControlAlwaysOnTop(*__pImageMenu, true);
900 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
902 result r = E_SUCCESS;
903 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
905 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
906 if (__pImageMenu != null)
915 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
919 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
921 __pImageMenu = new (std::nothrow) ContextMenu();
922 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
923 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
925 if(onlyPasteOption == false)
927 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
929 if (pasteOption || onlyPasteOption)
931 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
933 if(onlyPasteOption == false)
935 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
936 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
939 __pImageMenu->SetMaxVisibleItemsCount(3);
940 __pImageMenu->AddActionEventListener(*this);
941 SetControlAlwaysOnTop(*__pImageMenu, true);
948 MainForm::InitFindWordPanel(void)
950 result r = E_SUCCESS;
951 Bitmap *pIconBitmap = null;
953 if (__pFindWordControl != null)
955 AppLogDebug("Findword panel already initialized");
956 if (__pFindWordBgLabel != null)
958 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
961 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
965 if (__pFindWordBgLabelRightToLeft != null)
967 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
970 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
977 __pFindWordControl = new (std::nothrow) Panel();
978 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
981 AppLogException("There is some problem in the xml file. Please check.");
984 AddControl(__pFindWordControl);
985 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
986 SetControlAlwaysOnTop(*__pFindWordControl,true);
987 __pFindWordControl->SetShowState(false);
988 __pFindWordControl->Invalidate(false);
990 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
991 __pFindWordPanelLeftToRight->SetShowState(true);
993 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
994 __pFindWordPanelRightToLeft->SetShowState(false);
996 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
997 if (__pFindWordBgLabel != null)
999 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1000 Rectangle pRect = pPanel1->GetBounds();
1001 pRect.x = pRect.y = 0;
1002 __pFindWordBgLabel->SetBounds(pRect);
1003 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1004 if (pBitmap != null)
1006 AppLogDebug("InitFindWordPanel: Coming here");
1007 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1012 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1016 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1017 if (__pFindWordBgLabelRightToLeft != null)
1019 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1020 Rectangle pRect = pPanel1->GetBounds();
1021 pRect.x = pRect.y = 0;
1022 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1023 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1024 if (pBitmap != null)
1026 AppLogDebug("InitFindWordPanel: Coming here");
1027 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1032 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1036 Button* pfindWordCancel = null;
1037 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1038 if (pfindWordCancel == null)
1040 AppLogException("There is some problem in the xml file. Please check.");
1043 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1044 pfindWordCancel->AddActionEventListener(*this);
1046 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1047 if (__pFindWordClear == null)
1049 AppLogException("There is some problem in the xml file. Please check.");
1053 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1054 if (__pFindWordClearRightToLeft == null)
1056 AppLogException("There is some problem in the xml file. Please check.");
1060 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1061 __pFindWordClear->AddActionEventListener(*this);
1063 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1064 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1066 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1067 if (__pFindWordNext == null)
1069 AppLogException("There is some problem in the xml file. Please check.");
1073 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1074 __pFindWordNext->AddActionEventListener(*this);
1076 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1077 if (__pFindWordPrev == null)
1079 AppLogException("There is some problem in the xml file. Please check.");
1083 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1084 __pFindWordPrev->AddActionEventListener(*this);
1086 __pFindWordNext->SetEnabled(false);
1087 __pFindWordPrev->SetEnabled(false);
1089 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1090 if (__pFindWordCountLabel == null)
1092 AppLogException("There is some problem in the xml file. Please check.");
1096 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1097 if (__pFindWordCountLabel == null)
1099 AppLogException("There is some problem in the xml file. Please check.");
1103 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1104 if (__pFindWordEditField == null)
1106 AppLogException("There is some problem in the xml file. Please check.");
1109 __pFindWordEditField->AddTextEventListener(*this);
1110 __pFindWordEditField->AddKeypadEventListener(*this);
1111 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1113 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1114 if (__pFindWordEditFieldRightToLeft == null)
1116 AppLogException("There is some problem in the xml file. Please check.");
1119 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1120 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1121 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1127 MainForm::CreateItem (int index, int itemWidth)
1129 Rectangle listImageRect;
1130 Rectangle pagetTitleRect;
1131 Rectangle pageURLRect;
1132 Rectangle deleteImageRect;
1133 String pageTitle(L"");
1134 String pageURL(L"");
1135 result r = E_SUCCESS;
1136 Bitmap* pListIconImage = null;
1139 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1140 if(pHistory == null)
1144 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1145 if ( pAppResource == NULL )
1149 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1151 CustomItem* pItem = new(std::nothrow) CustomItem();
1152 pageTitle = pHistory->GetHistoryTitle();
1153 pageURL = pHistory->GetHistoryUrl();
1155 if (pageURL.GetLength() == 0)
1158 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1159 pageURL = L"<"+ nourl +">";
1163 Rectangle screenBounds = GetBounds();
1166 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1175 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1177 if ( pBitmap != NULL)
1179 pListIconImage = new Bitmap();
1180 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1184 if(pListIconImage == null)
1186 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1189 if ( pListIconImage != NULL)
1191 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1192 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1193 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1196 if (pItem != null && pListIconImage != NULL)
1198 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1202 if (pageTitle.CompareTo(L"") != 0)
1206 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1210 if (pageURL.CompareTo(L"") != 0)
1214 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1219 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1221 if ( __pItemContext!= NULL)
1225 pItem->SetContextItem(__pItemContext);
1231 if ( __pItemContextLandscape!= NULL)
1235 pItem->SetContextItem(__pItemContextLandscape);
1239 if( pListIconImage != NULL)
1241 delete pListIconImage;
1242 pListIconImage = null;
1249 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1256 MainForm::GetItemCount (void)
1258 if(__pMostVisitedSites != null)
1260 __pMostVisitedSites->RemoveAll(true);
1262 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1263 if(__pMostVisitedSites != null)
1265 return __pMostVisitedSites->GetCount();
1272 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1274 if(__pMostVisitedSites != null)
1276 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1277 if (pHistory != null)
1279 String url = pHistory->GetHistoryUrl();
1281 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1282 __pMostVisitedListView->UpdateList();
1288 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1290 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1291 String url = pHistory->GetHistoryUrl();
1299 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1305 MainForm::OnTerminating(void)
1307 result r = E_SUCCESS;
1309 RemoveOrientationEventListener(*this);
1313 __pAddressbar->SetAddressbarEventListener(null);
1318 __pWebViewer->RemoveTouchEventListener(*this);
1323 delete __pItemContext;
1325 if(__pItemContextLandscape)
1327 delete __pItemContextLandscape;
1333 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1335 result r = E_SUCCESS;
1337 AppLogDebug("Clicked : %d", actionId);
1340 case IDA_BACKBTN_CLICKED:
1342 if (__pWebViewer && __pWebViewer->CanGoBack())
1344 __pWebViewer->GoBack();
1346 else if(__pWindowInfo->isJavascriptInitiated == false)
1349 pApp = UiApp::GetInstance();
1352 r = pApp->Terminate();
1355 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1363 WindowInfo* pWindowInfo = null;
1365 SceneManager* pSceneManager = SceneManager::GetInstance();
1366 if (pSceneManager == null)
1370 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1371 if (pAllWindowList == NULL)
1373 pApp = UiApp::GetInstance();
1376 r = pApp->Terminate();
1379 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1384 if (pAllWindowList != null)
1386 totalCount = pAllWindowList->GetCount();
1388 for (int count = 0; count < totalCount; count++)
1390 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1391 if (pWindowInfo == null)
1393 pApp = UiApp::GetInstance();
1396 r = pApp->Terminate();
1399 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1406 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1408 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1411 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1414 r = pAllWindowList->RemoveAt(count, true);
1415 __pWindowInfo = null;
1418 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1423 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1427 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1429 if (pWindowInfo == null)
1431 pApp = UiApp::GetInstance();
1434 r = pApp->Terminate();
1440 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1443 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1455 case IDA_FORWARD_CLICKED:
1456 if (__pWebViewer == null)
1459 if (__pWebViewer->CanGoForward())
1461 __pWebViewer->GoForward();
1463 __pOptionMenu->SetShowState(false);
1464 __pOptionMenu->Invalidate(false);
1467 case IDA_FINDONPAGE_CLICKED:
1469 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1470 __currentSearchStr.Clear();
1472 InitFindWordPanel();
1473 __pOptionMenu->SetShowState(false);
1474 __pOptionMenu->Invalidate(false);
1476 ShowFindWordPanel(true);
1478 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1480 __pFindWordEditField->SetFocus();
1481 __pFindWordCountLabel->SetShowState(false);
1485 __pFindWordEditFieldRightToLeft->SetFocus();
1486 __pFindWordCountLabelRightToLeft->SetShowState(false);
1490 case IDA_PRIVATEON_CLICKED:
1492 result r = E_SUCCESS;
1494 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1495 Bitmap* pBitmap = null;
1496 if (isPrivateBrowsing == true)
1498 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1501 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1505 if (__pWebViewer != NULL)
1507 __pWebViewer->SetPrivateBrowsingEnabled(false);
1510 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1512 if (__pAddressbar != null)
1514 __pAddressbar->UpdateFaviconBitmap(false);
1520 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1523 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1527 if (__pWebViewer != NULL)
1529 __pWebViewer->SetPrivateBrowsingEnabled(true);
1532 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1534 if (__pAddressbar != null)
1536 __pAddressbar->UpdateFaviconBitmap(true);
1540 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1541 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1542 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1543 __pOptionMenu->Invalidate(true);
1544 if ( pBitmap != NULL )
1551 case IDA_SETTINGS_CLICKED:
1554 ArrayList* pArgList = new(std::nothrow) ArrayList();
1557 pArgList->Construct();
1558 pArgList->Add(*__pWindowInfo);
1559 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1561 __pOptionMenu->SetShowState(false);
1562 __pOptionMenu->Invalidate(false);
1564 if (pArgList != null)
1573 case IDA_ADDTOBOOKMARK_CLICKED:
1576 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1578 int bookmarkCount=0;
1581 url=__pWindowInfo->pageUrl;
1582 result r = E_SUCCESS;
1583 Bitmap* pBitmap = null;
1584 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1592 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1593 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1594 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1596 if(__pNotification != null)
1598 delete __pNotification;
1599 __pNotification = null;
1601 __pNotification = new (std::nothrow) NotificationPanel(*this);
1602 if (__pNotification != null)
1604 __pNotification->SetText(message);
1605 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1606 __pNotification->ShowNotification();
1611 String title=__pWindowInfo->pageTitle;
1612 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1613 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1615 pBookmark->SetBookmarkTitle(title);
1616 pBookmark->SetUrl(url);
1617 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1619 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1621 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1622 pBookmark->SetFaviconId(id);
1623 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1624 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1626 if(__pNotification != null)
1628 delete __pNotification;
1629 __pNotification = null;
1631 __pNotification = new (std::nothrow) NotificationPanel(*this);
1632 if (__pNotification != null)
1634 __pNotification->SetText(message);
1635 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1636 __pNotification->ShowNotification();
1637 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1640 if (pBitmap != null)
1642 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1647 __pOptionMenu->Invalidate(true);
1652 case IDA_PRINT_CLICKED:
1654 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1655 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1657 AppLog("RequestPrint called!");
1658 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1659 result nResult = E_FAILURE;
1662 AppLog("TestPrint if (pAc) == true");
1667 String fileType = L"service_print_files_type";
1668 String typeVal = L"DOC";
1670 String fileCount = L"service_print_files_count";
1671 String countVal = L"1";
1672 String fileFolder= L"service_print_files_folder_name";
1673 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1675 map.Add(&fileCount, &countVal);
1676 map.Add(&fileFolder, &folderVal);
1677 map.Add(&fileType, &typeVal);
1679 String fileName = L"service_print_files_files_name";
1681 ArrayList fileNameList;
1682 fileNameList.Construct();
1683 String file1 = L"test.pdf";
1685 fileNameList.Add(&file1);
1686 map.Add(&fileName, &fileNameList);
1688 nResult = pAc->Start(NULL, NULL, &map, NULL);
1690 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1691 else if (nResult == E_MAX_EXCEEDED)
1692 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1693 else if (nResult == E_OBJ_NOT_FOUND)
1694 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1695 else if (nResult == E_IN_PROGRESS)
1696 AppLog("TestPrint ret == E_IN_PROGRESS");
1697 else if (nResult == E_PRIVILEGE_DENIED)
1698 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1699 else if(nResult == E_SYSTEM)
1700 AppLog("TestPrint ret == E_SYSTEM");
1706 int __modalMsgBoxResult;
1707 MessageBox* pMsgBox = new MessageBox();
1708 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1709 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1712 __modalMsgBoxResult = 0;
1716 case IDA_SHARE_CLICKED:
1718 if(__pPopUp != null)
1725 __pAddressbar->HideKeypad();
1727 __pPopUp = new(std::nothrow) SharePopup();
1728 __pPopUp->Initialize();
1729 if (__pWindowInfo != null)
1731 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1732 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1733 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1734 pShareInfo->SetImageAttached(false);
1735 __pPopUp->RemoveAllShareInfo();
1736 __pPopUp->AddShareInfo(pShareInfo);
1738 __pPopUp->SetShowState(true);
1742 case IDA_BOOKMARKBTN_CLICKED:
1744 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1745 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1748 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1753 case IDA_MOREBTN_CLICKED:
1755 AppLog("IDA_MOREBTN_CLICKED");
1757 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1759 int bookmarkCount=0;
1762 url=__pWindowInfo->pageUrl;
1763 result r = E_SUCCESS;
1764 Bitmap* pBitmap = null;
1766 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1769 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1774 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1778 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1780 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1782 if (__pOptionMenu->GetItemCount() == 9)
1784 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1788 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1793 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1797 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1798 if (__pOptionMenu->GetItemCount() != 9)
1800 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1801 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1802 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1803 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1804 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1805 __pOptionMenu->SetMaxVisibleItemsCount(6);
1807 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1809 AppLog(" Orientation landscape");
1810 __pOptionMenu->SetMaxVisibleItemsCount(5);
1814 AppLog(" Orientation potrait");
1815 __pOptionMenu->SetMaxVisibleItemsCount(6);
1818 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1821 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1822 __pOptionMenu->SetShowState(true);
1823 __pOptionMenu->Invalidate(true);
1824 __pOptionMenu->Show();
1828 case IDA_HISTORY_CLICKED:
1830 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1831 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1834 case IDA_SAVED_PAGES_CLICKED:
1839 case IDA_DESKTOP_VIEW_CLICKED:
1844 case IDA_SAVE_CLICKED:
1849 case IDA_MULTIWINDOWBTN_CLICKED:
1851 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1852 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1856 case IDA_NEWWINDOWBTN_CLICKED:
1858 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1860 if (pNewWindowInfo == null)
1864 result r = E_SUCCESS;
1865 SceneManager* pSceneManager = SceneManager::GetInstance();
1867 if (pSceneManager == NULL)
1871 ArrayList* pArgList = new(std::nothrow) ArrayList();
1872 if (pArgList == NULL)
1876 r = pArgList->Construct();
1879 pArgList->Add(*pNewWindowInfo);
1880 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1886 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1891 case IDA_SMALLFONT_BTN_CLICKED:
1893 WebSetting setting = __pWebReader->GetSetting();
1894 setting.SetFontSize(15);
1895 __pWebReader->SetSetting(setting);
1898 case IDA_LARGEFONT_BTN_CLICKED:
1900 WebSetting setting = __pWebReader->GetSetting();
1901 setting.SetFontSize(25);
1902 __pWebReader->SetSetting(setting);
1905 case IDA_READER_CLOSE_CLICKED:
1907 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1909 RemoveControl(__pBlankPanel);
1910 __pArticleReaderPanel = null;
1911 __pBlankPanel = null;
1912 __pArticleReaderLabel = null;
1914 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1917 case IDA_FINDWORD_CANCEL_CLICKED:
1919 __currentSearchStr = L"";
1920 __currentWordIndex = 0;
1921 __maxOccurrances = 0;
1923 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1925 __pFindWordEditField->SetText(L"");
1926 __pFindWordCountLabel->SetText(L"0/0");
1928 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1930 __pFindWordEditFieldRightToLeft->SetText(L"");
1931 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1934 __pFindWordNext->SetEnabled(false);
1935 __pFindWordPrev->SetEnabled(false);
1936 __pFindWordCountLabel->SetText(L"0/0");
1937 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1938 AppLog("akjshdasd 1");
1939 __pFooterPanel->SetShowState(true);
1940 ShowFindWordPanel(false);
1943 case IDA_FINDWORD_SEARCH_CLICKED:
1945 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1947 __currentSearchStr = __pFindWordEditField->GetText();
1949 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1951 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1954 if (__currentSearchStr.GetLength() > 0)
1960 AppLogDebug("Enter something");
1964 case IDA_FINDWORD_CLEAR_CLICKED:
1966 __pFindWordCountLabel->SetText(L"0/0");
1967 __pFindWordEditField->SetText(L"");
1968 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1970 __currentSearchStr = L"";
1971 __pFindWordNext->SetEnabled(false);
1972 __pFindWordPrev->SetEnabled(false);
1973 __pFindWordCountLabel->SetShowState(false);
1974 __pFindWordControl->Invalidate(true);
1977 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1979 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1980 __pFindWordEditFieldRightToLeft->SetText(L"");
1981 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1983 __currentSearchStr = L"";
1984 __pFindWordNext->SetEnabled(false);
1985 __pFindWordPrev->SetEnabled(false);
1986 __pFindWordCountLabelRightToLeft->SetShowState(false);
1987 __pFindWordControl->Invalidate(true);
1990 case IDA_FINDWORD_NEXT_CLICKED:
1995 case IDA_FINDWORD_PREV_CLICKED:
1997 FindNextWord(false);
2000 case IDA_BRIGHTNESS_BTN_CLICKED:
2002 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2003 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2006 case IDA_COPY_IMAGE_CLICKED:
2008 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2009 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2011 const Bitmap* pBitmap = null;
2012 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2014 pBitmap = __pHitElementResult->GetImage();
2017 String resourcePath = App::GetInstance()->GetAppResourcePath();
2018 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2019 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2020 // copying the item to clipboard
2021 Clipboard* pClipboard = Clipboard::GetInstance();
2022 if (pClipboard != null)
2024 r = pClipboard->CopyItem(item);
2025 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2029 case IDA_VIEW_IMAGE_CLICKED:
2031 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2032 WindowInfo* pNewWindowInfo = null;
2033 if (__pHitElementResult != null)
2035 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2036 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2042 case IDA_SAVE_IMAGE_CLICKED:
2044 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2045 const Bitmap* pSaveBitmap = null;
2046 String imageName = GetImagePath();
2047 AppLog("Content manager image name %ls",imageName.GetPointer());
2050 imagePath.Append(imageName);
2051 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2052 AppLog("Content manager image path %ls",imagePath.GetPointer());
2053 if (__pHitElementResult != null)
2055 pSaveBitmap = __pHitElementResult->GetImage();
2057 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2061 UpdateImageContent(pBuffer, imageName);
2063 if(__pNotification != null)
2065 delete __pNotification;
2066 __pNotification = null;
2068 __pNotification = new NotificationPanel(*this);
2070 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2071 msg.Append(imagePath);
2072 if (__pNotification != null)
2074 __pNotification->SetText(msg);
2075 if (__pFooterPanel->GetShowState() == true)
2077 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2081 __pNotification->SetPositionDiff(0);
2084 __pNotification->ShowNotification();
2089 int __modalMsgBoxResult;
2090 MessageBox* pMsgBox = new MessageBox();
2091 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2092 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2095 __modalMsgBoxResult = 0;
2099 case IDA_SHARE_IMAGE_CLICKED:
2101 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2102 if (__pPopUp != null)
2109 __pAddressbar->HideKeypad();
2111 __pPopUp = new(std::nothrow) SharePopup();
2112 __pPopUp->Initialize();
2113 if (__pHitElementResult != null)
2115 const Bitmap* pSaveBitmap = null;
2116 String imageName = GetImagePath();
2117 AppLog("Content manager image name %ls",imageName.GetPointer());
2120 imagePath.Append(imageName);
2121 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2122 AppLog("Content manager image path %ls",imagePath.GetPointer());
2123 if (__pHitElementResult != null)
2125 pSaveBitmap = __pHitElementResult->GetImage();
2127 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2129 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2130 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2132 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2133 pShareInfo->SetPageTitle(L"");
2134 pShareInfo->SetPageUrl(srcUrl);
2135 pShareInfo->SetImageAttached(true);
2136 pShareInfo->SetImagePath(imagePath);
2137 __pPopUp->RemoveAllShareInfo();
2138 __pPopUp->AddShareInfo(pShareInfo);
2139 __pPopUp->SetShowState(true);
2144 case IDA_HYPERLINK_OPEN_CLICKED:
2146 if (__pHitElementResult != null)
2148 String srcUrl = __pHitElementResult->GetUrl();
2150 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2152 if (pNewWindowInfo == null)
2156 result r = E_SUCCESS;
2157 SceneManager* pSceneManager = SceneManager::GetInstance();
2158 if (pSceneManager == NULL)
2162 ArrayList* pArgList = new(std::nothrow) ArrayList();
2163 if (pArgList == NULL)
2167 pArgList->Construct();
2169 pArgList->Add(*pNewWindowInfo);
2170 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2171 if (pArgList != null)
2178 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2184 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2186 if (__pHitElementResult == null)
2191 if(__pPopUp != null)
2198 __pAddressbar->HideKeypad();
2200 __pPopUp = new(std::nothrow) SharePopup();
2201 __pPopUp->Initialize();
2203 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2204 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2205 pShareInfo->SetImageAttached(false);
2206 __pPopUp->RemoveAllShareInfo();
2207 __pPopUp->AddShareInfo(pShareInfo);
2209 __pPopUp->SetShowState(true);
2213 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2217 if (__pHitElementResult != null)
2219 url = __pHitElementResult->GetUrl();
2222 String resourcePath = App::GetInstance()->GetAppResourcePath();
2223 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2225 // copying the item to clipboard
2226 Clipboard* pClipboard = Clipboard::GetInstance();
2227 if (pClipboard != null)
2229 pClipboard->CopyItem(item);
2233 case IDA_FIND_TEXT__CLICKED:
2235 // AddressBarCancelledClicked(*__pAddressbar);
2236 RelayoutControls(false);
2237 // __pFooterPanel->SetShowState(false);
2238 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2239 __currentSearchStr.Clear();
2240 __currentSearchStr.Append(__currentSelectedStr);
2241 InitFindWordPanel();
2242 __pFindWordEditField->SetText(__currentSearchStr);
2244 if(__pOptionMenu != null)
2246 __pOptionMenu->SetShowState(false);
2247 __pOptionMenu->Invalidate(false);
2249 __adressPanelPosition.y = 0;
2251 if (__pAddressbar != null && __pWebViewer != NULL)
2253 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2254 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2256 if (__pFooterPanel->GetShowState() == false)
2257 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2259 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2260 __pWebViewer->Invalidate(true);
2263 ShowFindWordPanel(true);
2264 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2266 __pFindWordEditField->SetText(__currentSearchStr);
2267 __pFindWordEditField->SetFocus();
2269 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2271 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2272 __pFindWordEditFieldRightToLeft->SetFocus();
2275 if (__currentSearchStr.GetLength() > 0)
2281 AppLogDebug("Enter something");
2284 if (__pWebViewer != null)
2286 // releasing the set block
2287 __pWebViewer->ReleaseBlock();
2292 case IDA_SHARE_TEXT_CLICKED:
2294 __pWebViewer->ReleaseBlock();
2295 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2296 if(__pPopUp != null)
2303 __pAddressbar->HideKeypad();
2305 __pPopUp = new(std::nothrow) SharePopup();
2306 __pPopUp->Initialize();
2307 if (__pHitElementResult != null)
2309 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2310 pShareInfo->SetPageTitle(L"");
2311 pShareInfo->SetPageUrl(__currentSelectedStr);
2312 pShareInfo->SetImageAttached(false);
2313 __pPopUp->RemoveAllShareInfo();
2314 __pPopUp->AddShareInfo(pShareInfo);
2315 __pPopUp->SetShowState(true);
2320 case IDA_COPY_TEXT_CLICKED:
2322 __pWebViewer->ReleaseBlock();
2323 // need to implement
2324 //__currentSelectedStr
2325 // Sets data to a clip board item
2327 String resourcePath = App::GetInstance()->GetAppResourcePath();
2328 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2330 // copying the item to clipboard
2331 Clipboard* pClipboard = Clipboard::GetInstance();
2332 if (pClipboard != null)
2334 pClipboard->CopyItem(item);
2338 case IDA_PASTE_TEXT_CLICKED:
2340 Clipboard* pClipboard = Clipboard::GetInstance();
2342 if(pClipboard == null)
2346 // Retrieves a latest item
2347 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2353 //Gets data from the clipboard item
2354 String* pString = dynamic_cast<String*>(pItem->GetData());
2356 if (pString != null)
2358 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2359 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2360 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2363 if(idElement.GetLength() != 0)
2365 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; } } ";
2366 script.Append("insertAtCursor('");
2367 script.Append(idElement);
2368 script.Append("',");
2369 script.Append("\"");
2370 script.Append(*pString);
2371 script.Append("\");");
2373 else if (nameElement.GetLength() != 0)
2375 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; } } ";
2376 script.Append("insertAtCursor(document.getElementsByName('");
2377 script.Append(nameElement);
2378 script.Append("')[0],");
2379 script.Append("\"");
2380 script.Append(*pString);
2381 script.Append("\");");
2383 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2384 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2395 case IDA_GO_FORWARD:
2400 case IDA_REFRESH_BTN_CLICKED:
2402 __isLoadingCompleted = false;
2403 __isLoadingData = true;
2404 __progressPercentage = 0;
2405 __displayUrl = __pFooterUrlField->GetText();
2407 String url = __pFooterUrlField->GetText();
2408 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2410 if (__pWebViewer != null && __pAddressbar != null)
2412 __pWebViewer->Reload();
2413 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2417 UpdateProgressBitmap();
2420 case IDA_STOP_BTN_CLICKED:
2422 __isLoadingCompleted = false;
2423 __isLoadingData = false;
2424 __progressPercentage = 0;
2425 __pFooterUrlField->HideKeypad();
2426 __displayUrl = __pFooterUrlField->GetText();
2430 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2431 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2432 __pWebViewer->StopLoading();
2433 RequestRedraw(true);
2436 UpdateProgressBitmap();
2441 if (__pFooterUrlField->GetText().IsEmpty() == false)
2443 //__displayUrl = __pUrlField->GetText();
2444 __pFooterUrlField->Clear();
2449 case IDA_READER_BTN_CLICKED:
2460 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2462 result r = E_FAILURE;
2463 if (__pWebViewer && __pWebViewer->CanGoBack())
2465 __pWebViewer->GoBack();
2467 else if(__pWindowInfo->isJavascriptInitiated == false)
2470 pApp = UiApp::GetInstance();
2473 r = pApp->Terminate();
2476 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2484 WindowInfo* pWindowInfo = null;
2486 SceneManager* pSceneManager = SceneManager::GetInstance();
2487 if (pSceneManager == null)
2491 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2492 if (pAllWindowList == NULL)
2494 pApp = UiApp::GetInstance();
2497 r = pApp->Terminate();
2500 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2505 if (pAllWindowList != null)
2507 totalCount = pAllWindowList->GetCount();
2509 for (int count = 0; count < totalCount; count++)
2511 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2512 if (pWindowInfo == null)
2514 pApp = UiApp::GetInstance();
2517 r = pApp->Terminate();
2520 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2527 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2529 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2532 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2535 r = pAllWindowList->RemoveAt(count, true);
2536 __pWindowInfo = null;
2539 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2544 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2548 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2550 if (pWindowInfo == null)
2552 pApp = UiApp::GetInstance();
2555 r = pApp->Terminate();
2561 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2564 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2576 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2577 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2580 AppLog("MainForm::OnSceneActivatedN called");
2581 String* pSelectedScene = NULL;
2582 Object* pValue = NULL;
2583 String* pUrl = null;
2584 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2585 pSelectedScene = (String*) pValue;
2587 if (pSelectedScene != null)
2589 delete pSelectedScene;
2591 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2592 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2593 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2594 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2596 // setting the current scene ID
2597 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2599 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2601 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2603 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2604 if(__pWindowInfo == null)
2606 // if(__pWindowInfo == null)
2608 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2611 else if ( pArgs != null && pArgs->GetCount() == 1)
2613 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2619 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2621 // hiding the address bar
2622 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2623 __pAddressbar->SetShowState(false);
2624 // if(__pWebViewer != null)
2626 // __pWebViewer->Resume();
2629 if(pUrl != null && pUrl->GetLength() > 0)
2633 else if(__pWindowInfo != null)
2635 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)
2637 LoadUrl(__pWindowInfo->pageUrl);
2639 else if (__pWindowInfo->isJavascriptInitiated == true)
2643 __pWindowInfo->pCurrentWeb = __pWebViewer;
2647 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2648 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2649 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2651 InitMostVisitedSitesView(GetOrientationStatus());
2653 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2655 if(__pMostVisitedListView != null)
2657 __pMostVisitedListView->SetShowState(false);
2661 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2663 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2665 if (pBookmarkUrl == null)
2667 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2668 //__pAddressbar->SetUrl(*pBookmarkUrl);
2669 SetUrl(*pBookmarkUrl);
2671 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2672 __pWebViewer->LoadUrl(*pBookmarkUrl);
2673 delete pBookmarkUrl;
2676 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2677 Bitmap* pBitmap = null;
2678 if (isPrivateBrowsing == true)
2680 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2682 if (__pWebViewer != null)
2684 __pWebViewer->SetPrivateBrowsingEnabled(true);
2687 if (__pAddressbar != null)
2689 // __pAddressbar->UpdateFaviconBitmap(true);
2695 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2697 if (__pWebViewer != null)
2699 __pWebViewer->SetPrivateBrowsingEnabled(false);
2702 if (__pAddressbar != null)
2704 // __pAddressbar->UpdateFaviconBitmap(false);
2708 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2710 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2712 else if (__pOptionMenu != null )
2714 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2717 if (pBitmap != null)
2722 AppLog("ABC: OnSceneActivatedN started exit");
2727 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2728 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2730 Canvas* pWebCanvas = null;
2731 if (__pWebViewer != null)
2733 pWebCanvas = __pWebViewer->GetCanvasN();
2736 if (pWebCanvas == null)
2740 if (__pWindowInfo != null)
2742 if (__pWindowInfo->pWebCanvasBitmap != null)
2744 delete __pWindowInfo->pWebCanvasBitmap;
2746 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2747 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2748 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2750 Bitmap* pBitmap = GetCapturedBitmapN();
2751 AppLog("Coming here");
2752 Canvas* pCanvas = new(std::nothrow) Canvas();
2753 pCanvas->Construct(GetClientAreaBounds());
2756 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2759 if(__pWebViewer != null && __pWindowInfo != null)
2760 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2762 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2763 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2765 AppLog("Coming here");
2769 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2770 const Tizen::Base::String& realm,
2771 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2777 MainForm::OnHttpAuthenticationCanceled(void)
2782 MainForm::OnLoadingStarted(void)
2784 AppLogDebug("MainForm::OnLoadingStarted entered");
2786 if(__pAddressbar == NULL || __pWebViewer == null)
2791 // this is added in case if menu is opened and user load the page
2792 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2794 __pOptionMenu->SetShowState(false);
2795 __pOptionMenu->Invalidate(true);
2800 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2802 __pImageMenu->SetShowState(false);
2803 __pImageMenu->Invalidate(true);
2805 String url = __pWebViewer->GetUrl();
2806 if(url.Contains(IDS_TIZEN_SERVICE))
2809 String delim(L":;,");
2811 // Creates a StringTokenizer instance
2812 StringTokenizer strTok(url, delim);
2814 int count = strTok.GetTokenCount(); // count == 4
2816 HashMap *pMap = new HashMap();
2821 while (strTok.HasMoreTokens())
2823 AppLog("Token: %ls", token.GetPointer());
2824 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2825 if(token.Contains(IDS_APPID))
2827 token.SubString(6, appId);
2828 AppLog("AppID:%ls", appId.GetPointer());
2830 else if(token.Contains(IDS_KEY))
2832 token.SubString(4, key);
2833 AppLog("key:%ls", key.GetPointer());
2835 else if(token.Contains(IDS_VALUE))
2837 token.SubString(6, value);
2838 AppLog("value:%ls", value.GetPointer());
2841 pMap->Add(key, value);
2845 AppControl *pAppControl = null;
2846 String operationId = L"http://tizen.org/appcontrol/operation/main";
2847 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2850 AppLog("Starting AppControl");
2851 result r = pAppControl->Start(null, null, pMap, null);
2852 AppLog("Result of Start %s", GetErrorMessage(r));
2856 AppLogException("AppControl not found");
2861 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2863 __pAddressbar->SetShowState(false);
2864 AddressBarCancelledClicked(*__pAddressbar);
2865 __pAddressbar->Invalidate(true);
2867 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2870 __pAddressbar->SetFaviconBitmap(*pBitmap);
2873 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2875 // updating the address bar position with respect to web control
2876 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2877 __distanceMoved = 0;
2881 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2882 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2883 if (__pWebViewer != null)
2885 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2886 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2887 SetUrl(__pWebViewer->GetUrl());
2888 if (__pWindowInfo != NULL)
2890 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2891 __pWindowInfo->pageTitle = L"";
2892 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2894 __pAddressbar->Invalidate(true);
2900 MainForm::OnLoadingCanceled(void)
2907 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2909 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2914 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2916 AppLog("XYZ::MainForm::OnKeypadOpened");
2917 __pFooterPanel->SetShowState(false);
2922 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2924 AppLog("XYZ::MainForm::OnKeypadClosed");
2925 __pFooterPanel->SetShowState(true);
2926 RelayoutControls(true);
2930 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2932 AppLog("XYZ::KeypadBoundsChanged");
2933 RelayoutControls(false);
2937 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2938 const Tizen::Base::String& reason)
2940 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2944 MainForm::OnLoadingCompleted(void)
2946 AppLog("MainForm::OnLoadingCompleted start");
2948 result r = E_SUCCESS;
2950 if (__pWebViewer == null)
2955 if (__pAddressbar == null)
2959 if (__pWebViewer->CanGoForward())
2961 //__pAddressbar->SetForwardButtonEnabled(true);
2962 SetForwardButtonEnabled(true);
2966 //__pAddressbar->SetForwardButtonEnabled(false);
2967 SetForwardButtonEnabled(false);
2970 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2972 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2974 //__pAddressbar->UpdateProgress(0);
2978 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2980 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2984 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2985 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2986 if (isPrivateBrowsing == false)
2988 if(__pHistory != null)
2994 __pHistory = new(std::nothrow) History;
2995 HistoryPresentationModel::GetCurrentDateTime(date);
2998 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2999 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3001 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3002 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3004 __pHistory->SetVisitedTime(date);
3006 if (__pWebViewer != null)
3008 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3010 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3011 if (pTempBitmap != null)
3013 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3014 __pHistory->SetFavIconBitmap(*pTempBitmap);
3017 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3020 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3021 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3022 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3024 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3025 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3026 __pHistory->SetThumbnail(pBitmap);
3028 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3031 __pHistory->SetFavIconBitmap(*pFavIcon);
3035 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3042 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3044 // temperary fixed (webpage can be not loaded)
3048 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3049 if (isReaderEnabled == true)
3053 delete __pReaderData;
3054 __pReaderData = null;
3056 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3057 filePath.Append(L"data/reader.js");
3063 result r = E_SUCCESS;
3064 FileAttributes attr;
3066 File::GetAttributes(filePath,attr);
3068 r = file.Construct(filePath, L"r+");
3071 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3074 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3077 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3080 // file.Read(pScript,attr.GetFileSize());
3082 // AppLogDebug("scipt length %d",strlen(pScript));
3083 String strScript = L"";
3084 // strScript.Append(pScript);
3085 // for(int i=0; i<25; i++)
3087 file.Read(pScript,attr.GetFileSize());
3088 // AppLog("xyzz tell %d",file.Tell());
3089 // r = strScript.Append(pScript);
3090 // AppLog("xyzz append result %s",GetErrorMessage(r));
3091 // AppLog("xyzz strScript length %d",strScript.GetLength());
3093 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3095 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3096 if (__pReaderData == null)
3098 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3099 __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>");
3102 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3103 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3105 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3106 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3112 AppLog("MainForm::OnLoadingCompleted done");
3116 MainForm::OnEstimatedProgress(int progress)
3118 AppLogDebug("MainForm::OnEstimatedProgress entered");
3119 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3120 progress = DEFAULT_PROGRESS_PERCENTAGE;
3122 // __pAddressbar->UpdateProgress(progress);
3123 UpdateProgress(progress);
3126 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3128 AppLog("MainForm::OnFaviconReceived");
3129 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3131 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3134 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3141 MainForm::OnUrlValueChanged(Addressbar&)
3147 MainForm::OnUrlSubmitted(Addressbar& addBar)
3149 AppLog("MainForm::OnUrlSubmitted");
3150 String url = addBar.GetUrl();
3151 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3153 if(__pFooterUrlField)
3154 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3155 AddressBarCancelledClicked(*__pAddressbar);
3160 MainForm::LoadUrl(String& url)
3164 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3165 AppLogDebug("MainForm::LoadUrl enter");
3167 if (__pWebViewer != null)
3169 __pWebViewer->SetShowState(true);
3170 __pWebViewer->Invalidate(true);
3173 if (url.CompareTo(L"") == 0)
3177 if(__pFooterPanel != null)
3179 __pFooterPanel->SetShowState(true);
3180 __pFooterPanel->Invalidate(true);
3187 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3188 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)
3190 RegularExpression firstRegex;
3191 RegularExpression secondRegex;
3193 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3194 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3197 ret = firstRegex.Match(url, false); // This returns true value
3198 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3200 if (ret == true && __pWebViewer != null)
3203 __pWebViewer->LoadUrl(url);
3205 else if(__pWebViewer != null)
3207 String tempUrl = L"http://";
3208 tempUrl.Append(url);
3212 __pWebViewer->LoadUrl(tempUrl);
3216 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3217 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3220 if (__pAddressbar != null)
3222 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3223 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3226 AppLogDebug("MainForm::LoadUrl exit");
3233 MainForm::OnStopClicked(Addressbar& addBar)
3235 AppLogDebug("MainForm::OnStopClicked called");
3238 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3239 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3240 __pWebViewer->StopLoading();
3241 RequestRedraw(true);
3246 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3248 // AppLog("MainForm::OnBackClicked");
3249 result r = E_FAILURE;
3251 if (__pWebViewer && __pWebViewer->CanGoBack())
3253 __pWebViewer->GoBack();
3255 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3258 pApp = UiApp::GetInstance();
3261 r = pApp->Terminate();
3264 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3272 WindowInfo* pWindowInfo = null;
3274 SceneManager* pSceneManager = SceneManager::GetInstance();
3275 if (pSceneManager == null)
3279 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3280 if (pAllWindowList == NULL)
3282 pApp = UiApp::GetInstance();
3285 r = pApp->Terminate();
3288 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3293 if (pAllWindowList != null)
3295 totalCount = pAllWindowList->GetCount();
3297 for (int count = 0; count < totalCount; count++)
3299 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3300 if (pWindowInfo == null)
3302 pApp = UiApp::GetInstance();
3305 r = pApp->Terminate();
3308 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3313 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3315 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3318 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3321 r = pAllWindowList->RemoveAt(count, true);
3322 __pWindowInfo = null;
3325 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3330 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3332 else if(pAllWindowList->GetCount() > 0)
3334 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3338 pApp = UiApp::GetInstance();
3341 r = pApp->Terminate();
3346 if (pWindowInfo == null)
3348 pApp = UiApp::GetInstance();
3351 r = pApp->Terminate();
3357 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3360 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3374 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3376 AppLog("MainForm::OnForwardClicked");
3377 if (__pWebViewer == null)
3380 if (__pWebViewer->CanGoForward())
3382 __pWebViewer->GoForward();
3387 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3389 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3390 if(__pFooterPanel != null)
3392 __pFooterPanel->SetShowState(false);
3395 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3397 __pAddressbar->SetShowState(true);
3398 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3401 RelayoutControls(false);
3405 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3407 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3409 int Height = GetClientAreaBounds().height;
3410 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3413 __pAddressbar->SetShowState(false);
3415 if (__pFooterPanel != null && addressbarKeyPadState == false)
3417 AppLog("akjshdasd 3");
3418 __pFooterPanel->SetShowState(true);
3421 RelayoutControls(false);
3425 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3427 AddressBarCancelledClicked(addBar);
3431 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3433 __prevAddressBarMode = __curAddressBarMode;
3435 if (__pAddressbar != null)
3437 __curAddressBarMode = GetAddressbarMode();
3440 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3442 __adressPanelPosition.y = 0;
3443 if (__pAddressbar != null)
3445 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3446 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3447 __pAddressbar->Invalidate(true);
3449 if (__pWebViewer != null)
3451 __pWebViewer->StopLoading();
3454 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3456 __adressPanelPosition.y = 0;
3457 if (__pAddressbar != null)
3459 __webControlPosition.y = 0;
3460 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3461 __pAddressbar->Invalidate(true);
3467 MainForm::OnClipboardClosed(const Addressbar& addBar)
3469 AppLog("XYZ::MainForm::OnClipboardClosed");
3470 RelayoutControls(false);
3474 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3476 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3477 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3479 AppLog("akjshdasd 3");
3480 __pFooterPanel->SetShowState(true);
3483 RelayoutControls(false,footerState);
3487 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3489 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3490 RelayoutControls(false);
3494 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3496 __pFooterPanel->SetShowState(false);
3500 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3502 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3503 RelayoutControls(false);
3507 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3509 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3512 __pWindowInfo->pageTitle = title;
3513 if (__pWebViewer != null)
3515 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3518 if (__pAddressbar != null && __pWebViewer != null)
3520 SetUrl(__pWebViewer->GetUrl());
3521 __pAddressbar->Invalidate(true);
3526 MainForm::UpdateFavicon(void)
3528 bool urlImageType = false;
3529 String *tempPath = null;
3531 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();");
3532 Bitmap* pBitmap = null;
3534 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3536 if (__pWindowInfo != null)
3539 url.SetUri(*tempPath);
3540 if (url.GetHost().GetLength() == 0)
3543 webUrl.SetUri(__pWebViewer->GetUrl());
3544 result r = url.SetHost(webUrl.GetHost());
3551 if (url.GetScheme().GetLength() == 0)
3554 webUrl.SetUri(__pWebViewer->GetUrl());
3555 url.SetScheme(webUrl.GetScheme());
3557 __pWindowInfo->faviconUrl = url.ToString();
3559 pBitmap = __pWebViewer->GetFaviconN();
3561 if (pBitmap != null)
3563 if (__pWindowInfo->pFavicon != NULL)
3565 __pWindowInfo->pFavicon = null;
3567 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3568 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3570 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3572 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3574 else if(__pWindowInfo->pFavicon != null)
3576 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3580 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3581 if(pDefaultBmp != null)
3583 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3592 if(tempPath != null)
3596 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3603 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3604 Tizen::Web::Controls::WebNavigationType type)
3606 // when load new page if find word panel is open its show state is false
3607 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3609 __currentSearchStr = L"";
3610 __currentWordIndex = 0;
3611 __maxOccurrances = 0;
3612 __pFindWordEditField->SetText(L"");
3613 __pFindWordNext->SetEnabled(false);
3614 __pFindWordPrev->SetEnabled(false);
3615 __pFindWordCountLabel->SetText(L"0/0");
3616 __pFindWordControl->SetShowState(false);
3617 __pFindWordEditField->HideKeypad();
3618 RelayoutControls(false);
3623 __pFooterPanel->Invalidate(true);
3626 uriInfo.SetUri(url);
3628 if(url.Contains(IDS_TIZEN_SERVICE))
3631 String delim(L":;,");
3633 // Creates a StringTokenizer instance
3634 StringTokenizer strTok(url, delim);
3636 int count = strTok.GetTokenCount(); // count == 4
3638 HashMap *pMap = new HashMap();
3644 while (strTok.HasMoreTokens())
3646 AppLog("Token: %ls", token.GetPointer());
3647 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3648 if(token.Contains(IDS_APPID))
3650 token.SubString(6, appId);
3651 AppLog("AppID:%ls", appId.GetPointer());
3653 else if(token.Contains(IDS_KEY))
3655 token.SubString(4, key);
3656 AppLog("key:%ls", key.GetPointer());
3658 else if(token.Contains(IDS_VALUE))
3660 token.SubString(6, value);
3661 AppLog("value:%ls", value.GetPointer());
3664 pMap->Add(key, value);
3668 AppControl *pAppControl = null;
3669 String operationId = L"http://tizen.org/appcontrol/operation/main";
3670 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3673 result r = pAppControl->Start(null, null, pMap, null);
3677 AppLogException("AppControl not found");
3687 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3688 const Tizen::Net::Http::HttpHeader& httpHeader)
3690 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3695 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3697 AppLog("MainForm::OnWebPageBlockSelected");
3698 if (__pHitElementResult != null)
3700 delete __pHitElementResult;
3701 __pHitElementResult = null;
3704 if (__pWebViewer != null)
3706 AppLog("MainForm::OnWebPageBlockSelected web not null");
3707 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3709 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3711 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3712 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3713 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3715 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3717 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3721 if (__pHitElementResult == null)
3726 if (__pHitElementResult->HasImage() != true)
3728 String tagName = __pHitElementResult->GetTagName();
3729 String type = __pHitElementResult->GetAttributeValue("type");
3732 AppLog("TagName %ls",tagName.GetPointer());
3733 __currentSelectedStr.Clear();
3734 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3735 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3736 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3738 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3740 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3742 InitSelectTextContextMenuF(endPoint,true);
3743 __pImageMenu->SetShowState(true);
3744 __pImageMenu->Show();
3745 __pImageMenu->Invalidate(true);
3747 else /*if(__isLongPressedDone == true)*/
3749 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3751 if(__pHitElementResult->GetUrl().GetLength() > 0)
3753 __currentSelectedStr.Clear();
3754 __currentSelectedStr = __pHitElementResult->GetUrl();
3756 InitSelectTextContextMenuF(endPoint,false);
3757 __pImageMenu->SetShowState(true);
3758 __pImageMenu->Show();
3759 __pImageMenu->Invalidate(true);
3762 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3763 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3764 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3770 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3776 MainForm::OnWebWindowCreateRequested(void)
3778 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3780 if (pNewWindowInfo == null)
3784 result r = E_SUCCESS;
3785 SceneManager* pSceneManager = SceneManager::GetInstance();
3786 if (pSceneManager == NULL)
3790 ArrayList* pArgList = new(std::nothrow) ArrayList();
3791 if (pArgList == NULL)
3795 r = pArgList->Construct();
3798 pNewWindowInfo->isJavascriptInitiated = true;
3799 pArgList->Add(*pNewWindowInfo);
3800 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3804 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3811 return pNewWindowInfo->pCurrentWeb;
3815 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3817 AppLog("xyz:: MainForm::RelayoutControls called");
3818 __webControlPosition.y = 0;
3819 __webControlHeight = GetClientAreaBounds().height;
3820 AppLog("Client area height: %d", __webControlHeight);
3822 AppLog("Client area height: %d", __webControlHeight);
3823 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3825 __webControlPosition.y += __pAddressbar->GetHeight();
3826 __webControlHeight -= __pAddressbar->GetHeight();
3827 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3829 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3831 __webControlPosition.y += __pFindWordControl->GetHeight();
3832 __webControlHeight -= __pFindWordControl->GetHeight();
3833 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3836 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3838 __webControlHeight -= __pFooterPanel->GetHeight();
3840 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3842 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3844 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3849 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3850 __pWebViewer->Invalidate(false);
3853 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3855 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3862 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3864 if (__pFindWordControl == null)
3869 Tizen::Locales::LocaleManager localeManager;
3870 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3872 String languageCode;
3873 result r = SettingInfo::GetValue(L"Language", languageCode);
3874 // int languagecode = local.GetLanguageCode();
3875 AppLog("rahul language is %S", languageCode.GetPointer());
3879 InitFindWordPanel();
3881 if (languageCode.CompareTo("ara") == 0)
3883 AppLog("rahul language is arabic");
3885 __pFindWordPanelLeftToRight->SetShowState(false);
3886 __pFindWordPanelRightToLeft->SetShowState(true);
3888 __pFindWordClear->SetShowState(false);
3889 __pFindWordCountLabel->SetShowState(false);
3890 __pFindWordEditField->SetShowState(false);
3892 __pFindWordClearRightToLeft->SetShowState(true);
3893 __pFindWordCountLabelRightToLeft->SetShowState(true);
3894 __pFindWordEditFieldRightToLeft->SetShowState(true);
3898 AppLog("rahul language is not arabic");
3901 __pFindWordPanelLeftToRight->SetShowState(true);
3902 __pFindWordPanelRightToLeft->SetShowState(false);
3904 __pFindWordClear->SetShowState(true);
3905 __pFindWordCountLabel->SetShowState(true);
3906 __pFindWordEditField->SetShowState(true);
3908 __pFindWordClearRightToLeft->SetShowState(false);
3909 __pFindWordCountLabelRightToLeft->SetShowState(false);
3910 __pFindWordEditFieldRightToLeft->SetShowState(false);
3912 __pFindWordControl->SetShowState(true);
3916 if(__pFindWordControl != null)
3918 __pFindWordControl->SetShowState(false);
3922 AppLog("MainForm::ShowFindWordPanel %d",show);
3923 if (show && !isTouchPressed)
3925 if (languageCode.CompareTo("ara") == 0)
3927 if (__pFindWordEditFieldRightToLeft)
3929 __pFindWordEditFieldRightToLeft->SetFocus();
3930 __pFindWordEditFieldRightToLeft->ShowKeypad();
3935 if (__pFindWordEditField)
3937 __pFindWordEditField->SetFocus();
3938 __pFindWordEditField->ShowKeypad();
3944 if (languageCode.CompareTo("ara") == 0)
3946 if (__pFindWordEditFieldRightToLeft)
3947 __pFindWordEditFieldRightToLeft->HideKeypad();
3951 if (__pFindWordEditField)
3952 __pFindWordEditField->HideKeypad();
3956 RelayoutControls(false);
3960 MainForm::StartWordSearch()
3962 //Get the count of occurances of the word in the current page
3963 __maxOccurrances = 0;
3964 __currentWordIndex = 0;
3966 __pFindWordPrev->SetEnabled(false);
3967 String *pCountStr = null;
3968 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3969 AppLog("Search Result %s",GetErrorMessage(r));
3970 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3971 if (pCountStr != null)
3973 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3977 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3982 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3984 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3985 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3987 if(totalCount == -1 || totalCount == 0)
3989 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3990 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3993 else if(totalCount > 100)
3995 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3996 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4000 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4001 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4004 __maxOccurrances = totalCount;
4005 __currentWordIndex = currentOrdinal;
4007 //Reset the UI controls as per the maxOccurrance value
4008 if (totalCount <= 0)
4010 AppLog("Word not found");
4011 //Show error notification to user
4012 __pFindWordNext->SetEnabled(false);
4013 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4015 __pFindWordCountLabel->SetText(L"0/0");
4016 __pFindWordCountLabel->Invalidate(false);
4018 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4020 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4021 __pFindWordCountLabelRightToLeft->Invalidate(false);
4023 __pFindWordNext->Invalidate(false);
4024 __pFindWordPrev->Invalidate(false);
4029 if (totalCount == 1)
4031 __pFindWordNext->SetEnabled(false);
4035 __pFindWordNext->SetEnabled(true);
4038 String countStr = L"";
4039 countStr.Append(__currentWordIndex);
4040 countStr.Append(L"/");
4041 countStr.Append(__maxOccurrances);
4042 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4044 __pFindWordCountLabel->SetText(countStr);
4045 __pFindWordCountLabel->Invalidate(false);
4046 __pFindWordCountLabel->Invalidate(false);
4048 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4050 __pFindWordCountLabelRightToLeft->SetText(countStr);
4051 __pFindWordCountLabelRightToLeft->Invalidate(false);
4052 __pFindWordCountLabelRightToLeft->Invalidate(false);
4054 //FindNextWord(true);
4055 //Update the controls
4056 __pFindWordNext->Invalidate(false);
4057 __pFindWordPrev->Invalidate(false);
4062 MainForm::FindNextWord(bool next)
4066 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4067 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4069 if (__currentWordIndex < __maxOccurrances)
4071 __currentWordIndex++;
4077 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4078 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4080 if(__currentWordIndex > 1)
4082 __currentWordIndex--;
4087 String countStr = L"";
4088 countStr.Append(__currentWordIndex);
4089 countStr.Append(L"/");
4090 countStr.Append(__maxOccurrances);
4092 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4094 __pFindWordCountLabel->SetText(countStr);
4095 __pFindWordCountLabel->Invalidate(false);
4097 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4099 __pFindWordCountLabelRightToLeft->SetText(countStr);
4100 __pFindWordCountLabelRightToLeft->Invalidate(false);
4103 if (__currentWordIndex >= __maxOccurrances)
4105 __pFindWordNext->SetEnabled(false);
4109 __pFindWordNext->SetEnabled(true);
4111 if (__currentWordIndex <= 1)
4113 __pFindWordPrev->SetEnabled(false);
4117 __pFindWordPrev->SetEnabled(true);
4119 __pFindWordPrev->Invalidate(false);
4120 __pFindWordNext->Invalidate(false);
4122 __pFindWordControl->Invalidate(true);
4126 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4128 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4129 __isWebKeypadOpened = true;
4130 __pFooterPanel->SetShowState(false);
4131 // OnAddressBarKeypadOpened(*__pAddressbar);
4135 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4137 AppLog("xyz::MainForm::OnWebKeypadOpened");
4139 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4141 __currentSearchStr = L"";
4142 __currentWordIndex = 0;
4143 __maxOccurrances = 0;
4144 __pFindWordEditField->SetText(L"");
4145 __pFindWordNext->SetEnabled(false);
4146 __pFindWordPrev->SetEnabled(false);
4147 __pFindWordCountLabel->SetText(L"0/0");
4148 __pWebViewer->SearchTextAllAsync(L"",false);
4149 __pFindWordControl->SetShowState(false);
4150 __pFindWordEditField->HideKeypad();
4154 if (__pWebViewer != null && __pFooterPanel != null)
4156 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4157 if(__pAddressbar != null)
4159 __pAddressbar->SetShowState(false);
4161 if(__pFindWordControl != null)
4163 __pFindWordControl->SetShowState(false);
4165 __pFooterPanel->SetShowState(false);
4166 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4168 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4170 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4171 // AppLog("omgomgomg");
4177 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4179 AppLog("xyz::MainForm::OnWebKeypadClosed");
4180 AppLog("akjshdasd 4");
4181 __pFooterPanel->SetShowState(true);
4182 // OnAddressBarKeypadClosed(*__pAddressbar);
4183 RelayoutControls(false);
4184 __isWebKeypadOpened = false;
4188 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4190 // RelativeLayout(false);
4191 if(__pWebViewer != null)
4193 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4198 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4200 Control* temp = const_cast< Control* >(&source);
4201 Header* pHeader = dynamic_cast< Header* >(temp);
4202 if (pHeader != null)
4204 //Header double - clicked
4205 AppLog("Header double clicked");
4207 if(__pFindWordControl)
4209 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4210 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4214 AppLog("MainScene::OnTouchDoublePressed");
4218 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4220 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4221 __longPressPoint = currentPosition;
4223 if (__pHitElementResult != null)
4225 delete __pHitElementResult;
4226 __pHitElementResult = null;
4229 if (__pWebViewer != null)
4231 AppLog("MainForm::OnTouchLongPressed web not null");
4232 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4235 if (__pHitElementResult == null)
4240 if (__pHitElementResult->HasImage() == true)
4242 InitImageContextMenu(currentPosition);
4243 __pImageMenu->SetShowState(true);
4244 __pImageMenu->Show();
4245 __pImageMenu->Invalidate(true);
4247 else if(__pHitElementResult->HasUrl() == true)
4249 String tempURl = __pHitElementResult->GetUrl();
4250 AppLog("tempURl is %ls", tempURl.GetPointer());
4251 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4252 if (pBitmap != null)
4260 InitImageLinkContextMenu(currentPosition);
4261 __pImageMenu->SetShowState(true);
4262 __pImageMenu->Show();
4263 __pImageMenu->Invalidate(true);
4267 String tagName = __pHitElementResult->GetTagName();
4268 String type = __pHitElementResult->GetAttributeValue("type");
4269 String value = __pHitElementResult->GetAttributeValue(L"value");
4270 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4272 __currentSelectedStr.Clear();
4273 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4275 AppLog("tag name is %ls", tagName.GetPointer());
4276 AppLog("type is %ls", type.GetPointer());
4280 //__isLongPressedDone = true;
4281 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4282 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4284 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4286 InitSelectTextContextMenu(currentPosition,true, true);
4289 __pImageMenu->SetShowState(true);
4290 __pImageMenu->Show();
4291 __pImageMenu->Invalidate(true);
4294 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4297 // __inputEventToBeSupressed = true;
4301 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4303 AppLog("xyz:: MainForm::OnTouchReleased called");
4305 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4307 __pAddressbar->SetShowState(false);
4311 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4312 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4314 __pWebViewer->ConsumeInputEvent();
4316 if(pHitElement != null)
4320 __inputEventToBeSupressed = false;*/
4324 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4331 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4333 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4335 __currentSearchStr = L"";
4336 __currentWordIndex = 0;
4337 __maxOccurrances = 0;
4339 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4341 __pFindWordEditField->SetText(L"");
4342 __pFindWordEditField->HideKeypad();
4343 __pFindWordControl->SetShowState(false);
4344 __pFindWordCountLabel->SetText(L"0/0");
4346 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4348 __pFindWordEditFieldRightToLeft->SetText(L"");
4349 __pFindWordEditFieldRightToLeft->HideKeypad();
4350 __pFindWordControl->SetShowState(false);
4351 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4354 __pFindWordNext->SetEnabled(false);
4355 __pFindWordPrev->SetEnabled(false);
4357 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4358 __pFindWordControl->SetShowState(false);
4360 if(__pAddressbar->GetShowState() == false)
4362 __pAddressbar->SetAddressbarURLFocus();
4363 __pFooterPanel->SetShowState(false);
4370 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4376 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4382 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4388 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4394 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4400 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4402 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4403 int widthContextItem = 0;
4405 // As per the platform engineer comment removed this line
4406 /*if(__pWebViewer != null)
4408 // 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
4409 __pWebViewer->ReleaseBlock();
4412 // if(__pFindWordControl != null)
4413 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4414 if(__pNotification && __pNotification->GetShowState() == true)
4416 __pNotification->SetShowState(false);
4417 __pNotification->Invalidate(false);
4419 if ( __pFooterLabel != null)
4421 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4424 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4430 if (__pFindWordBgLabel != null)
4432 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4433 if (pBitmap != null)
4435 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4440 if (__pFindWordBgLabelRightToLeft != null)
4442 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4443 if (pBitmap != null)
4445 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4451 if(__pOptionMenu != null)
4452 __pOptionMenu->SetShowState(false);
4454 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4456 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4460 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4465 AppLog("__pFooterPanel->GetShowState() is true");
4467 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4468 __pFooterPanel->Invalidate(true);
4472 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4473 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4475 InitMostVisitedSitesView(orientationStatus);
4478 RelayoutControls(false);
4479 if (__pArticleReaderPanel != null)
4481 if (__pArticleReaderPanel->GetShowState() == true)
4483 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4485 if (__pBlankPanel != null)
4486 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4488 if (__pWebReader != null)
4490 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4492 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4493 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4495 if ( pBitmap != null && pSrcBitmap != null)
4497 AppLog("CreateReaderPanel ninepatchbitmap found");
4498 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4501 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4502 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4503 if (pBitmap != null)
4508 if (pSrcBitmap != null)
4517 if (__pAddressbar != null)
4519 int width = GetClientAreaBounds().width;
4520 __pAddressbar->OrientationChanged(width);
4525 MainForm::OnSettingsChange(int settingvalue)
4527 AppLogDebug("MainForm::OnSettingsChange entered");
4529 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4531 __pAddressbar->ResetGuideText();
4533 if (__pWebViewer == null)
4535 AppLogDebug("Webviewer is not initialized yet.");
4539 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4541 WebSetting settings = __pWebViewer->GetSetting();
4542 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4544 settings.SetAutoFittingEnabled(true);
4546 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4548 settings.SetAutoFittingEnabled(false);
4550 __pWebViewer->SetSetting(settings);
4552 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4554 WebSetting settings = __pWebViewer->GetSetting();
4555 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4556 __pWebViewer->SetSetting(settings);
4558 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4560 WebSetting settings = __pWebViewer->GetSetting();
4561 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4562 __pWebViewer->SetSetting(settings);
4563 __pWebViewer->Reload();
4565 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4567 WebSetting settings = __pWebViewer->GetSetting();
4568 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4569 __pWebViewer->SetSetting(settings);
4571 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4575 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4578 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4582 WebSetting settings = __pWebViewer->GetSetting();
4583 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4584 __pWebViewer->SetSetting(settings);
4587 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4591 WebSetting settings = __pWebViewer->GetSetting();
4592 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4593 __pWebViewer->SetSetting(settings);
4596 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4598 WebSetting settings = __pWebViewer->GetSetting();
4599 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4601 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4605 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4607 __pWebViewer->SetSetting(settings);
4609 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4613 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4614 WebSetting settings = __pWebReader->GetSetting();
4615 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4616 __pWebReader->SetSetting(settings);
4622 MainForm::OnSettingsReset()
4626 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4627 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4632 MainForm::OnClearCache()
4634 result r = E_SUCCESS;
4636 if (__pWebViewer != NULL)
4638 r = __pWebViewer->ClearCache();
4641 AppLogDebug("Cache cleared success");
4645 AppLogDebug("Cache cleared fail");
4651 MainForm::OnClearCookie()
4653 result r = E_SUCCESS;
4655 if (__pWebViewer != NULL)
4657 __pWebViewer->ClearCookie();
4661 AppLogDebug("Cookie cleared success");
4665 AppLogDebug("Cache cleared fail");
4670 MainForm::OnClearFormData()
4672 result r = E_SUCCESS;
4674 if (__pWebViewer != NULL)
4676 __pWebViewer->ClearFormData();
4680 AppLogDebug("Cookie cleared success");
4684 AppLogDebug("Cache cleared fail");
4689 MainForm::OnClearPasswords()
4691 result r = E_SUCCESS;
4693 if (__pWebViewer != NULL)
4695 __pWebViewer->ClearLoginFormData();
4699 AppLogDebug("Cookie cleared success");
4703 AppLogDebug("Cache cleared fail");
4709 MainForm::findDistance(int x1,int y1,int x2, int y2)
4711 int deltaX = Math::Abs(x2 - x1);
4712 int deltaY = Math::Abs(y2 - y1);
4713 double num = deltaX*deltaX + deltaY*deltaY;
4719 for (i = 0; i < 20; i++)
4721 x = (((x*x)+ num)/(2*x));
4732 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4734 AppLog("xyz:: MainForm::OnTouchPressed called");
4735 if(__pFindWordControl)
4737 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4738 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4740 //__isLongPressedDone = false;
4745 IList* pList = null;
4746 pList = touch.GetTouchInfoListN(source);
4750 int count = pList->GetCount();
4753 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4754 __touchPoint1 = pTouchInfo->position;
4756 /*if (__pAddressbar != null)
4758 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4760 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4762 __pAddressbar->SaveAddressbarEditText();
4764 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4767 __pAddressbar->Invalidate(true);
4769 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4771 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4773 //__pAddressbar->SaveAddressbarEditText();
4775 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4778 else if (count == 2)
4780 AppLogDebug("MainForm::OnTouchPressed count is two");
4781 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4782 __touchPoint1 = pTouchInfo->position;
4784 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4785 __touchPoint2 = pTouchInfo->position;
4790 pList->RemoveAll(true);
4793 // RelayoutControls(false);
4798 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4800 // __currentWordIndex = 0;
4801 //__isLongPressedDone = false;
4806 MainForm::MoveUiControls()
4811 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4813 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4815 if(__pFooterUrlField->GetTextLength() == 0)
4817 __pFooterUrlField->SetKeypadActionEnabled(false);
4821 __pFooterUrlField->SetKeypadActionEnabled(true);
4824 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4826 __currentSearchStr = __pFindWordEditField->GetText();
4827 if (__currentSearchStr.GetLength() > 0)
4829 __pFindWordCountLabel->SetShowState(true);
4833 __pFindWordCountLabel->SetShowState(false);
4835 __pFindWordNext->SetEnabled(false);
4836 __pFindWordPrev->SetEnabled(false);
4837 __pFindWordNext->Invalidate(true);
4838 __pFindWordPrev->Invalidate(true);
4839 __pFindWordCountLabel->SetText(L"0/0");
4840 __pFindWordCountLabel->Invalidate(true);
4842 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4844 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4845 if (__currentSearchStr.GetLength() > 0)
4847 __pFindWordCountLabelRightToLeft->SetShowState(true);
4851 __pFindWordCountLabelRightToLeft->SetShowState(false);
4854 __pFindWordNext->SetEnabled(false);
4855 __pFindWordPrev->SetEnabled(false);
4856 __pFindWordNext->Invalidate(true);
4857 __pFindWordPrev->Invalidate(true);
4858 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4859 __pFindWordCountLabelRightToLeft->Invalidate(true);
4861 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4862 if (__currentSearchStr.GetLength() > 0)
4868 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4870 __currentSearchStr = L"";
4871 AppLogDebug("Enter something");
4876 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4883 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4885 if(__pWebViewer != null)
4888 AppLog("MainForm::InitMostVisitedSitesView");
4889 result r = E_SUCCESS;
4892 if (__pWebViewer != null && __pMostVisitedListView != null)
4897 if (__pMostVisitedListView != null)
4899 RemoveControl(__pMostVisitedListView);
4901 if(__pMostVisitedSites != null)
4903 __pMostVisitedSites->RemoveAll(true);
4906 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4908 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4909 __pMostVisitedListView = new(std::nothrow) ListView();
4911 int height = GetClientAreaBounds().height;
4913 if(__pFooterPanel->GetShowState() == true)
4915 height = height - __pFooterPanel->GetHeight();
4917 if(__pAddressbar->GetShowState() == true)
4919 height -= __pAddressbar->GetHeight();
4922 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4926 delete __pMostVisitedListView;
4927 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4930 __pMostVisitedListView->SetItemProvider(*this);
4931 __pMostVisitedListView->AddListViewItemEventListener(*this);
4932 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4933 AddControl(__pMostVisitedListView);
4934 __pMostVisitedListView->UpdateList();
4941 MainForm::GetImagePath(void)
4945 String formattedTime;
4946 DateTime currentTime;
4947 LocaleManager localManager;
4948 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4950 localManager.Construct();
4951 Locale locale = localManager.GetSystemLocale();
4952 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4954 // Get date formatter
4955 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4959 pTimeFormatter->Format(currentTime, formattedTime);
4962 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4963 String delim(L" :");
4964 StringTokenizer strTok(formattedTime, delim);
4967 String str1("GMT+00");
4968 while (strTok.HasMoreTokens())
4970 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4971 if(token.Equals(str1))
4973 AppLog("token is %ls", token.GetPointer());
4974 imageName.Append(token);
4980 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4982 result r = E_FAILURE;
4983 AppLog("Content manager 1");
4984 ContentId contentId;
4985 ContentManager contentManager;
4986 r = contentManager.Construct();
4989 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4992 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4993 Tizen::Io::Directory::Create(contentPath,true);
4994 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4996 AppLog("Already exists");
4998 else if(GetLastResult() == E_SUCCESS)
5000 AppLog("created success");
5002 contentPath.Append(imageName);
5003 contentPath.Append(".jpg");
5004 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5005 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5009 MainForm::SetForwardButtonEnabled(bool isEnabled)
5011 __pGoForwardBtn->SetEnabled(isEnabled);
5012 __pGoForwardBtn->Invalidate(true);
5016 MainForm::SetBackButtonEnabled(bool isEnabled)
5018 __pGoBackBtn->SetEnabled(isEnabled);
5019 __pGoBackBtn->Invalidate(true);
5023 MainForm::UpdateProgress(int percentage)
5025 __progressPercentage = percentage;
5026 if (percentage == 0 || percentage == 100)
5028 __isLoadingData = false;
5029 if (percentage == 100)
5031 __isLoadingCompleted = true;
5032 __progressPercentage = 0;
5036 __isLoadingCompleted = false;
5041 __isLoadingData = true;
5043 UpdateProgressBitmap();
5047 MainForm::GetProgress(void)
5049 return __progressPercentage;
5053 MainForm::UpdateProgressBitmap(void)
5055 result r = E_SUCCESS;
5056 if (__pProgressbarLabel == null)
5058 int w = __pProgressbarLabel->GetWidth();
5059 int h = __pProgressbarLabel->GetHeight();
5061 int progressWidth = 0;
5062 Bitmap* pRetBitmap = null;
5064 if (__progressPercentage == 0 || __progressPercentage == 100)
5066 __pProgressbarLabel->SetShowState(false);
5067 __pProgressbarLabel->Invalidate(false);
5072 __pProgressbarLabel->SetShowState(true);
5073 __pProgressbarLabel->Invalidate(false);
5076 r = canvas.Construct(Rectangle(0, 0, w, h));
5080 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5085 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5089 pBgBmp->Scale(Dimension(w, h));
5090 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5094 progressWidth = (double) (w) * __progressPercentage / 100;
5095 AppLogDebug("progressWidth: %d", progressWidth);
5096 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5098 if (pProgressBmp != null)
5100 pProgressBmp->Scale(Dimension(progressWidth, h));
5101 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5102 delete pProgressBmp;
5105 pRetBitmap = new (std::nothrow) Bitmap();
5107 if (pRetBitmap == null)
5109 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5113 pRetBitmap->Construct(canvas, canvas.GetBounds());
5115 if (__pProgressbarLabel != null && pRetBitmap != null)
5117 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5118 __pProgressbarLabel->Invalidate(false);
5121 if (pRetBitmap != null)
5130 MainForm::ReaderClicked()
5132 result r = E_SUCCESS;
5133 ArrayList* pArgList = new(std::nothrow) ArrayList();
5134 if (pArgList != null)
5136 r = pArgList->Construct();
5143 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5150 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5157 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5165 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5169 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
5171 CreateReaderPanel();
5172 AppLogDebug("MainScene::ReaderClicked entered");
5175 /*if (__pArticleReaderPanel)
5177 AppLogDebug("showstate true for reader panel");
5178 __pArticleReaderPanel->SetShowState(true);
5179 __pArticleReaderPanel->Show();
5181 int xPos = __pArticleReaderPanel->GetX();
5182 int yPos = __pArticleReaderPanel->GetY();
5183 AppLog("ReaderClicked() xPos = %d",xPos);
5184 AppLog("ReaderClicked() yPos = %d",yPos);
5186 if (__pReaderData == null)
5191 String loadData = L"<html>\
5193 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
5198 background-color: transparent;\
5217 <body style='width:'";
5218 loadData.Append(bodyWidth);
5219 loadData.Append(L"px'>");
5220 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5221 loadData.Append(*__pReaderData);
5222 loadData.Append(L"</body></html>");
5225 buf.Construct(loadData.GetLength());
5226 AppLogDebug("data->GetLength %d",loadData.GetLength());
5227 for (int z=0;z<loadData.GetLength();z++)
5230 loadData.GetCharAt(z,b);
5231 buf.SetByte((byte)b);
5235 if (__pWebReader != null)
5237 __pWebReader->LoadData(L"",buf,L"text/html");
5238 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5242 AppLogDebug("cannot LoadData __pWebReader is null");
5247 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5249 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5251 __currentAddMode = addMode;
5255 case ADDRESSBAR_MODE_INVALID:
5260 case ADDRESSBAR_MODE_READER:
5262 __pStopBtn->SetShowState(false);
5263 __pRefreshBtn->SetShowState(false);
5264 __pClearBtn->SetShowState(false);
5265 __pReaderBtn->SetShowState(false);
5268 case ADDRESSBAR_MODE_LOADING:
5270 __pRefreshBtn->SetShowState(false);
5271 __pStopBtn->SetShowState(true);
5272 __pClearBtn->SetShowState(false);
5273 __pReaderBtn->SetShowState(false);
5276 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5278 // SetUrl(__pAddressbar->GetUrl());
5280 __pRefreshBtn->SetShowState(true);
5281 __pStopBtn->SetShowState(false);
5282 __pClearBtn->SetShowState(false);
5283 __pReaderBtn->SetShowState(false);
5286 case ADDRESSBAR_MODE_EDIT:
5288 __pRefreshBtn->SetShowState(false);
5289 __pStopBtn->SetShowState(false);
5290 __pReaderBtn->SetShowState(false);
5291 __pClearBtn->SetShowState(true);
5298 OnAddressBarModeChanged();
5301 AddressBarMode MainForm::GetAddressbarMode(void)
5303 return __currentAddMode;
5306 void MainForm::SetUrl(const String& url)
5309 if(__displayUrl.GetLength() > 2048)
5310 __displayUrl.SubString(0,2048,__displayUrl);
5312 if (__pFooterUrlField != NULL)
5314 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5315 if (removedHttpUrl.IsEmpty() == false)
5317 __pFooterUrlField->SetText(removedHttpUrl);
5318 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5319 __pAddressbar->SetUrl(__displayUrl);
5323 __pFooterUrlField->SetText(__displayUrl);
5324 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5325 __pAddressbar->SetUrl(__displayUrl);
5327 if(__pFooterUrlField)
5328 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5329 __pFooterUrlField->Invalidate(false);
5330 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5331 __pAddressbar->Invalidate(true);
5332 // __pFooterUrlField->SetCursorPosition(0);
5337 MainForm::RemoveHttpTextFromDisplayURL(void)
5339 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5341 // bool isHttpText = __displayUrl.Contains(L"http://");
5342 String updatedDisplayUrl;
5343 updatedDisplayUrl.Clear();
5344 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5346 __displayUrl.SubString(7,updatedDisplayUrl);
5348 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5350 __displayUrl.SubString(8,updatedDisplayUrl);
5352 return updatedDisplayUrl;
5355 void MainForm::OnSharePopupControlStarted(void)
5357 __pWebViewer->AddTouchEventListener(*this);
5361 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5363 if (requestId == BACK_GROUND_APP_EVENT)
5365 if(__pWebViewer != null)
5367 __pWebViewer->Pause();
5369 if(__pAddressbar != null)
5371 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5374 else if(requestId == FORE_GROUND_APP_EVENT)
5376 if(__pWebViewer != null)
5378 __pWebViewer->Resume();
5380 if(__pAddressbar != null)
5382 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5388 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5390 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5391 result r = E_SUCCESS;
5394 __pAddressbar->SetShowState(false);
5396 //AppLog("akjshdasd 5");
5397 //__pFooterPanel->SetShowState(true);
5400 __pWebViewer->SetFocus();
5401 else if(__pMostVisitedListView)
5402 __pMostVisitedListView->SetFocus();
5403 else if(__pMultiWindowButton)
5404 __pMultiWindowButton->SetFocus();
5405 else if(__pMoreButton)
5406 __pMoreButton->SetFocus();
5408 __pAddressbar->SetShowState(false);
5410 RelayoutControls(false);
5414 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5416 AppLog("MainForm::OnFormMenuRequested called");
5418 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5420 int bookmarkCount=0;
5423 url=__pWindowInfo->pageUrl;
5424 result r = E_SUCCESS;
5425 Bitmap* pBitmap = null;
5427 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5430 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5435 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5439 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5441 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5443 if (__pOptionMenu->GetItemCount() == 9)
5445 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5449 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5454 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5458 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5459 if (__pOptionMenu->GetItemCount() != 9)
5461 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5462 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5463 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5464 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5465 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5466 __pOptionMenu->SetMaxVisibleItemsCount(6);
5468 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5470 AppLog(" Orientation landscape");
5471 __pOptionMenu->SetMaxVisibleItemsCount(5);
5475 AppLog(" Orientation potrait");
5476 __pOptionMenu->SetMaxVisibleItemsCount(6);
5479 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5482 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5483 __pOptionMenu->SetShowState(true);
5484 __pOptionMenu->Invalidate(true);
5485 __pOptionMenu->Show();