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;
251 delete __pOptionMenu;
252 __pOptionMenu = null;
255 String* pSelectedScene = NULL;
256 Object* pValue = NULL;
257 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
258 pSelectedScene = (String*) pValue;
260 /*if (pSelectedScene != null)
262 delete pSelectedScene;
264 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
268 MainForm::Initialize(void)
270 Construct(L"IDL_FORM");
272 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_FOOTER);
277 MainForm::OnInitializing(void)
279 AppLog("get client area width = %d",GetClientAreaBounds().width);
280 AppLog("get client area height = %d",GetClientAreaBounds().height);
281 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
282 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
284 __fontSize = CommonUtil::GetFontSize();
285 Panel* pFooterPanel = null;
287 __pSaveImage = new Image();
288 __pSaveImage->Construct();
290 // Setup back event listener
291 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
292 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
293 AddOrientationEventListener(*this);
295 AppLogDebug(" MainForm::OnInitializing ended");
296 if (__pMostVisitedSites == null)
298 __pMostVisitedSites = new(std::nothrow) ArrayList();
299 __pMostVisitedSites->Construct();
301 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
303 __pItemContext= new(std::nothrow) ListContextItem();
304 __pItemContext->Construct();
306 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"),true);
309 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
310 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
311 __pItemContext->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
313 __pItemContextLandscape= new(std::nothrow) ListContextItem();
314 __pItemContextLandscape->Construct();
316 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), true);
317 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_NORMAL , CONTEXT_ITEM_DELETE_COLOR);
318 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_HIGHLIGHTED , CONTEXT_ITEM_DELETE_COLOR);
319 __pItemContextLandscape->SetElementBackgroundColor(IDA_CONTEXT_ITEM_DELETE,LIST_CONTEXT_ITEM_ELEMENT_STATUS_PRESSED , CONTEXT_ITEM_DELETE_COLOR);
320 SetFormMenuEventListener(this);
321 AppLog("SetFormMenuEventListener result %s",GetErrorMessage(GetLastResult()));
326 MainForm::InitAddressbar(void)
328 AppLogDebug("MainForm::InitAddressbar entered");
330 result r = E_SUCCESS;
332 if (__pAddressbar != null)
336 __pAddressbar = new(std::nothrow) Addressbar();
337 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
338 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
341 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
344 __pAddressbar->SetAddressbarEventListener(this);
345 AddControl(__pAddressbar);
346 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
347 SetControlAlwaysOnTop(*__pAddressbar, true);
348 __adressPanelPosition = __pAddressbar->GetPosition();
350 AppLogDebug("MainForm::InitAddressbar exit");
356 MainForm::CreateReaderPanel(void)
358 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
359 result r = E_FAILURE;
361 Button *pSmallFontBtn = null;
362 Button *pLargeFontBtn = null;
364 __pBlankPanel = new (std::nothrow) Panel();
365 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
367 __pArticleReaderPanel = new (std::nothrow) Panel();
368 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
370 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
371 if (__pReaderCloseBtn)
373 AppLogDebug("CreateReaderPanel() 6");
374 __pReaderCloseBtn->AddActionEventListener(*this);
375 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
378 __pWebReader = new (std::nothrow) Web();
379 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
381 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
382 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
384 r = __pWebReader->SetSetting(settings);
386 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
389 __pArticleReaderLabel = new Label();
390 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
392 __pBlankPanel->AddControl(__pArticleReaderLabel);
393 __pBlankPanel->AddControl(__pArticleReaderPanel);
394 AddControl(__pBlankPanel);
396 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
397 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
398 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
400 __pArticleReaderPanel->AddControl(__pWebReader);
401 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
402 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
403 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
405 if (pBitmap != null && pSrcBitmap != null)
407 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
409 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
411 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
414 pSmallFontBtn->AddActionEventListener(*this);
415 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
418 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
421 pLargeFontBtn->AddActionEventListener(*this);
422 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
431 if (pSrcBitmap != null)
437 SetControlAlwaysOnTop(*__pBlankPanel, true);
438 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
445 MainForm::InitWebControl()
447 AppLogDebug("MainForm::InitWebControl enter");
448 result r = E_SUCCESS;
449 AppLogDebug("InitWebControl");
451 if (__pAddressbar == null || __pFooterPanel == null)
454 const int Y_WEBCONTROL_POSITION = 0;
456 __webControlHeight = GetHeight() - __pFooterPanel->GetHeight();
458 if (__pMostVisitedListView)
460 __pMostVisitedListView->SetShowState(false);
462 if (__pWebViewer != null)
464 AppLogDebug("Already initialized");
467 __pWebViewer = new(std::nothrow) Web();
468 if(__pWebViewer == NULL)
470 AppLogDebug("Initialization failed");
473 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
477 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
484 r = AddControl(__pWebViewer);
490 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
493 __webControlPosition = __pWebViewer->GetPosition();
494 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
497 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
501 __pWebViewer->SetLoadingListener(this);
502 __pWebViewer->SetWebUiEventListenerF(this);
503 __pWebViewer->SetWebKeypadEventListener(this);
504 __pWebViewer->SetFocus();
505 __pWebViewer->AddTouchEventListener(*this);
507 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
508 __pWebViewer->SetTextSearchListener(this);
511 AppLogDebug("MainForm :before return");
513 AppLogDebug("MainForm::InitWebControl Exit");
519 MainForm::SetJavascriptEnabled()
521 WebSetting settings = __pWebViewer->GetSetting();
522 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
523 __pWebViewer->SetSetting(settings);
527 MainForm::SetImageLoadEnabled()
529 WebSetting settings = __pWebViewer->GetSetting();
530 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
531 __pWebViewer->SetSetting(settings);
535 MainForm::InitFooter(void)
537 AppLogDebug("MainForm::InitFooter entered");
538 Button* pBackButton = null;
539 Button* pBookmarkButton = null;
540 Button* pMultiWindowButton = null;
541 Bitmap *pIconBitmap = null;
542 Bitmap *pBGBitmap = null;
543 Label *pBGLabel = null;
545 if (__pFooterPanel == null)
547 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
550 if (__pFooterPanel == null)
555 SetControlAlwaysOnTop(*__pFooterPanel, true);
557 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
558 if ( __pFooterLabel == NULL )
562 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
563 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
566 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
570 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
572 if ( __pMultiWindowButton == NULL )
578 SetFormBackEventListener(this);
579 AppLog("SetFormBackEventListener result %s",GetErrorMessage(GetLastResult()));
580 if (__pMultiWindowButton != null)
582 Bitmap* pBitmap = null;
583 Bitmap* pPressedBitmap = null;
584 String imagePath = "I01_toolbar_icon_windows_manager_0";
585 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
586 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
587 imagePath.Append(totalCount);
588 imagePath.Append(".png");
590 pressedImagePath.Append(totalCount);
591 pressedImagePath.Append("_press.png");
593 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
594 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
595 if ( pBitmap == null )
600 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
603 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
604 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
609 __pMultiWindowButton->AddActionEventListener(*this);
610 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
615 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
616 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
619 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
620 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
621 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
625 __pMoreButton->AddActionEventListener(*this);
626 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
629 //Add the editfield for url
630 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
631 if (__pFooterUrlField == NULL)
633 return E_INVALID_KEY;
636 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
637 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
638 __pFooterUrlField->AddKeypadEventListener(*this);
639 __pFooterUrlField->SetPropagatedTouchEventListener(this);
641 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
643 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
645 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
647 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
651 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
652 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
656 //Add the go Back Button
657 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
658 if (__pGoBackBtn == NULL)
660 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
661 return E_INVALID_KEY;
663 __pGoBackBtn->SetActionId(IDA_GO_BACK);
664 __pGoBackBtn->AddActionEventListener(*this);
666 //Add the go forward Button
667 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
668 if (__pGoForwardBtn == NULL)
670 AppLogDebug("Control not found returning E_INVALID_KEY");
671 return E_INVALID_KEY;
673 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
674 __pGoForwardBtn->AddActionEventListener(*this);
675 if (__pWebViewer && __pWebViewer->CanGoForward())
677 SetForwardButtonEnabled(true);
681 SetForwardButtonEnabled(false);
684 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
685 if (__pRefreshBtn == NULL)
687 AppLogDebug("Control not found returning E_INVALID_KEY");
688 return E_INVALID_KEY;
691 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
692 __pRefreshBtn->AddActionEventListener(*this);
693 __pRefreshBtn->SetShowState(true);
695 //Add the backround label for displaying progressbar
696 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
697 if (__pProgressbarLabel == NULL)
699 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
700 return E_INVALID_KEY;
702 __pProgressbarLabel->SetShowState(false);
704 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
705 if (__pStopBtn == NULL)
707 AppLogDebug("Control not found returning E_INVALID_KEY");
708 return E_INVALID_KEY;
710 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
711 __pStopBtn->AddActionEventListener(*this);
712 __pStopBtn->SetShowState(false);
714 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
715 if (__pClearBtn == NULL)
717 AppLogDebug("Control not found returning E_INVALID_KEY");
718 return E_INVALID_KEY;
720 __pClearBtn->SetActionId(IDA_CLEAR_URL);
721 __pClearBtn->AddActionEventListener(*this);
722 __pClearBtn->SetShowState(false);
724 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
725 if (__pReaderBtn == NULL)
727 AppLogDebug("Control not found returning E_INVALID_KEY");
728 return E_INVALID_KEY;
730 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
731 __pReaderBtn->AddActionEventListener(*this);
732 __pReaderBtn->SetShowState(false);
734 // __pFooterPanel->Invalidate(true);
735 AppLogDebug("MainForm::InitFooter exit");
740 MainForm::InitOptionMenu()
742 result r = E_SUCCESS;
743 bool isPrivateBrowsing = false;
744 Bitmap* pBitmap = null;
746 if (__pOptionMenu != null)
748 __pOptionMenu->Invalidate(true);
752 __pOptionMenu = new(std::nothrow) OptionMenu();
753 r = __pOptionMenu->Construct();
754 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
756 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
759 if (isPrivateBrowsing == true)
761 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
765 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
768 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
770 if ( pBitmap != NULL)
772 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
775 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
776 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
777 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
780 __pOptionMenu->SetMaxVisibleItemsCount(6);
781 __pOptionMenu->SetShowState(false);
782 __pOptionMenu->AddActionEventListener(*this);
783 SetControlAlwaysOnTop(*__pOptionMenu, true);
789 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
791 result r = E_SUCCESS;
792 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
794 AppLog("MainForm::InitImageContextMenu clicked on image");
795 if (__pImageMenu != null)
800 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
805 __pImageMenu = new (std::nothrow) ContextMenu();
806 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
807 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
809 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
810 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
811 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
812 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
813 __pImageMenu->SetMaxVisibleItemsCount(4);
814 __pImageMenu->AddActionEventListener(*this);
815 SetControlAlwaysOnTop(*__pImageMenu, true);
821 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
823 result r = E_SUCCESS;
824 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
826 AppLog("MainForm::InitImageContextMenu clicked on image");
827 if (__pImageMenu != null)
833 // if(__pAddressbar->GetShowState() == true)
834 // p.y = p.y + __pAddressbar->GetHeight();
835 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
840 __pImageMenu = new (std::nothrow) ContextMenu();
841 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
842 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
844 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
845 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
846 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
847 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
849 __pImageMenu->SetMaxVisibleItemsCount(3);
850 __pImageMenu->AddActionEventListener(*this);
851 SetControlAlwaysOnTop(*__pImageMenu, true);
858 MainForm::InitSelectTextContextMenu(Point p, bool pasteOption, bool onlyPasteOption = false)
860 result r = E_SUCCESS;
861 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
863 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
864 if (__pImageMenu != null)
873 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
877 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
879 __pImageMenu = new (std::nothrow) ContextMenu();
880 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
881 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
883 if(onlyPasteOption == false)
885 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
887 if (pasteOption || onlyPasteOption)
889 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
891 if(onlyPasteOption == false)
893 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
894 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
897 __pImageMenu->SetMaxVisibleItemsCount(3);
898 __pImageMenu->AddActionEventListener(*this);
899 SetControlAlwaysOnTop(*__pImageMenu, true);
906 MainForm::InitSelectTextContextMenuF(FloatPoint p, bool pasteOption, bool onlyPasteOption = false)
908 result r = E_SUCCESS;
909 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
911 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
912 if (__pImageMenu != null)
921 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
925 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
927 __pImageMenu = new (std::nothrow) ContextMenu();
928 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
929 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
931 if(onlyPasteOption == false)
933 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
935 if (pasteOption || onlyPasteOption)
937 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
939 if(onlyPasteOption == false)
941 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
942 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
945 __pImageMenu->SetMaxVisibleItemsCount(3);
946 __pImageMenu->AddActionEventListener(*this);
947 SetControlAlwaysOnTop(*__pImageMenu, true);
954 MainForm::InitFindWordPanel(void)
956 result r = E_SUCCESS;
957 Bitmap *pIconBitmap = null;
959 if (__pFindWordControl != null)
961 AppLogDebug("Findword panel already initialized");
962 if (__pFindWordBgLabel != null)
964 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
967 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
971 if (__pFindWordBgLabelRightToLeft != null)
973 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
976 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
983 __pFindWordControl = new (std::nothrow) Panel();
984 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
987 AppLogException("There is some problem in the xml file. Please check.");
990 AddControl(__pFindWordControl);
991 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
992 SetControlAlwaysOnTop(*__pFindWordControl,true);
993 __pFindWordControl->SetShowState(false);
994 __pFindWordControl->Invalidate(false);
996 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
997 __pFindWordPanelLeftToRight->SetShowState(true);
999 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1000 __pFindWordPanelRightToLeft->SetShowState(false);
1002 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1003 if (__pFindWordBgLabel != null)
1005 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1006 Rectangle pRect = pPanel1->GetBounds();
1007 pRect.x = pRect.y = 0;
1008 __pFindWordBgLabel->SetBounds(pRect);
1009 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1010 if (pBitmap != null)
1012 AppLogDebug("InitFindWordPanel: Coming here");
1013 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1018 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1022 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1023 if (__pFindWordBgLabelRightToLeft != null)
1025 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1026 Rectangle pRect = pPanel1->GetBounds();
1027 pRect.x = pRect.y = 0;
1028 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1029 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1030 if (pBitmap != null)
1032 AppLogDebug("InitFindWordPanel: Coming here");
1033 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1038 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1042 Button* pfindWordCancel = null;
1043 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1044 if (pfindWordCancel == null)
1046 AppLogException("There is some problem in the xml file. Please check.");
1049 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1050 pfindWordCancel->AddActionEventListener(*this);
1052 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1053 if (__pFindWordClear == null)
1055 AppLogException("There is some problem in the xml file. Please check.");
1059 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1060 if (__pFindWordClearRightToLeft == null)
1062 AppLogException("There is some problem in the xml file. Please check.");
1066 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1067 __pFindWordClear->AddActionEventListener(*this);
1069 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1070 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1072 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1073 if (__pFindWordNext == null)
1075 AppLogException("There is some problem in the xml file. Please check.");
1079 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1080 __pFindWordNext->AddActionEventListener(*this);
1082 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1083 if (__pFindWordPrev == null)
1085 AppLogException("There is some problem in the xml file. Please check.");
1089 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1090 __pFindWordPrev->AddActionEventListener(*this);
1092 __pFindWordNext->SetEnabled(false);
1093 __pFindWordPrev->SetEnabled(false);
1095 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1096 if (__pFindWordCountLabel == null)
1098 AppLogException("There is some problem in the xml file. Please check.");
1102 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1103 if (__pFindWordCountLabel == null)
1105 AppLogException("There is some problem in the xml file. Please check.");
1109 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1110 if (__pFindWordEditField == null)
1112 AppLogException("There is some problem in the xml file. Please check.");
1115 __pFindWordEditField->AddTextEventListener(*this);
1116 __pFindWordEditField->AddKeypadEventListener(*this);
1117 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1119 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1120 if (__pFindWordEditFieldRightToLeft == null)
1122 AppLogException("There is some problem in the xml file. Please check.");
1125 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1126 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1127 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1133 MainForm::CreateItem (int index, int itemWidth)
1135 Rectangle listImageRect;
1136 Rectangle pagetTitleRect;
1137 Rectangle pageURLRect;
1138 Rectangle deleteImageRect;
1139 String pageTitle(L"");
1140 String pageURL(L"");
1141 result r = E_SUCCESS;
1142 Bitmap* pListIconImage = null;
1145 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1146 if(pHistory == null)
1150 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1151 if ( pAppResource == NULL )
1155 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1157 CustomItem* pItem = new(std::nothrow) CustomItem();
1158 pageTitle = pHistory->GetHistoryTitle();
1159 pageURL = pHistory->GetHistoryUrl();
1161 if (pageURL.GetLength() == 0)
1164 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1165 pageURL = L"<"+ nourl +">";
1169 Rectangle screenBounds = GetBounds();
1172 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1181 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1183 if ( pBitmap != NULL)
1185 pListIconImage = new Bitmap();
1186 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1190 if(pListIconImage == null)
1192 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1195 if ( pListIconImage != NULL)
1197 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1198 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1199 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1202 if (pItem != null && pListIconImage != NULL)
1204 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1208 if (pageTitle.CompareTo(L"") != 0)
1212 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1216 if (pageURL.CompareTo(L"") != 0)
1220 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1225 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1227 if ( __pItemContext!= NULL)
1231 pItem->SetContextItem(__pItemContext);
1237 if ( __pItemContextLandscape!= NULL)
1241 pItem->SetContextItem(__pItemContextLandscape);
1245 if( pListIconImage != NULL)
1247 delete pListIconImage;
1248 pListIconImage = null;
1255 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1262 MainForm::GetItemCount (void)
1264 if(__pMostVisitedSites != null)
1266 __pMostVisitedSites->RemoveAll(true);
1268 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1269 if(__pMostVisitedSites != null)
1271 return __pMostVisitedSites->GetCount();
1278 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1280 if(__pMostVisitedSites != null)
1282 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1283 if (pHistory != null)
1285 String url = pHistory->GetHistoryUrl();
1287 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1288 __pMostVisitedListView->UpdateList();
1294 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1296 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1297 String url = pHistory->GetHistoryUrl();
1305 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1311 MainForm::OnTerminating(void)
1313 result r = E_SUCCESS;
1315 RemoveOrientationEventListener(*this);
1319 __pAddressbar->SetAddressbarEventListener(null);
1324 __pWebViewer->RemoveTouchEventListener(*this);
1329 delete __pItemContext;
1331 if(__pItemContextLandscape)
1333 delete __pItemContextLandscape;
1339 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1341 result r = E_SUCCESS;
1343 AppLogDebug("Clicked : %d", actionId);
1346 case IDA_BACKBTN_CLICKED:
1348 if (__pWebViewer && __pWebViewer->CanGoBack())
1350 __pWebViewer->GoBack();
1352 else if(__pWindowInfo->isJavascriptInitiated == false)
1355 pApp = UiApp::GetInstance();
1358 r = pApp->Terminate();
1361 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1369 WindowInfo* pWindowInfo = null;
1371 SceneManager* pSceneManager = SceneManager::GetInstance();
1372 if (pSceneManager == null)
1376 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1377 if (pAllWindowList == NULL)
1379 pApp = UiApp::GetInstance();
1382 r = pApp->Terminate();
1385 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1390 if (pAllWindowList != null)
1392 totalCount = pAllWindowList->GetCount();
1394 for (int count = 0; count < totalCount; count++)
1396 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1397 if (pWindowInfo == null)
1399 pApp = UiApp::GetInstance();
1402 r = pApp->Terminate();
1405 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1412 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1414 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1417 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1420 r = pAllWindowList->RemoveAt(count, true);
1421 __pWindowInfo = null;
1424 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1429 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1433 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1435 if (pWindowInfo == null)
1437 pApp = UiApp::GetInstance();
1440 r = pApp->Terminate();
1446 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1449 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1461 case IDA_FORWARD_CLICKED:
1462 if (__pWebViewer == null)
1465 if (__pWebViewer->CanGoForward())
1467 __pWebViewer->GoForward();
1469 __pOptionMenu->SetShowState(false);
1470 __pOptionMenu->Invalidate(false);
1473 case IDA_FINDONPAGE_CLICKED:
1475 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1476 __currentSearchStr.Clear();
1478 InitFindWordPanel();
1479 __pOptionMenu->SetShowState(false);
1480 __pOptionMenu->Invalidate(false);
1482 ShowFindWordPanel(true);
1484 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1486 __pFindWordEditField->SetFocus();
1487 __pFindWordCountLabel->SetShowState(false);
1491 __pFindWordEditFieldRightToLeft->SetFocus();
1492 __pFindWordCountLabelRightToLeft->SetShowState(false);
1496 case IDA_PRIVATEON_CLICKED:
1498 result r = E_SUCCESS;
1500 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1501 Bitmap* pBitmap = null;
1502 if (isPrivateBrowsing == true)
1504 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1507 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1511 if (__pWebViewer != NULL)
1513 __pWebViewer->SetPrivateBrowsingEnabled(false);
1516 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1518 if (__pAddressbar != null)
1520 __pAddressbar->UpdateFaviconBitmap(false);
1526 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1529 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1533 if (__pWebViewer != NULL)
1535 __pWebViewer->SetPrivateBrowsingEnabled(true);
1538 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1540 if (__pAddressbar != null)
1542 __pAddressbar->UpdateFaviconBitmap(true);
1546 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1547 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1548 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1549 __pOptionMenu->Invalidate(true);
1550 if ( pBitmap != NULL )
1557 case IDA_SETTINGS_CLICKED:
1560 ArrayList* pArgList = new(std::nothrow) ArrayList();
1563 pArgList->Construct();
1564 pArgList->Add(*__pWindowInfo);
1565 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1567 __pOptionMenu->SetShowState(false);
1568 __pOptionMenu->Invalidate(false);
1570 if (pArgList != null)
1579 case IDA_ADDTOBOOKMARK_CLICKED:
1582 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1584 int bookmarkCount=0;
1587 url=__pWindowInfo->pageUrl;
1588 result r = E_SUCCESS;
1589 Bitmap* pBitmap = null;
1590 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1598 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1599 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1600 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1602 if(__pNotification != null)
1604 RemoveControl(__pNotification);
1605 __pNotification = null;
1607 __pNotification = new (std::nothrow) NotificationPanel(*this);
1608 if (__pNotification != null)
1610 __pNotification->SetText(message);
1611 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1612 __pNotification->ShowNotification();
1617 String title=__pWindowInfo->pageTitle;
1618 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1619 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1621 pBookmark->SetBookmarkTitle(title);
1622 pBookmark->SetUrl(url);
1623 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1625 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1627 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1628 pBookmark->SetFaviconId(id);
1629 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1630 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1632 if(__pNotification != null)
1634 RemoveControl(__pNotification);
1635 __pNotification = null;
1637 __pNotification = new (std::nothrow) NotificationPanel(*this);
1638 if (__pNotification != null)
1640 __pNotification->SetText(message);
1641 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1642 __pNotification->ShowNotification();
1643 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1646 if (pBitmap != null)
1648 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1653 __pOptionMenu->Invalidate(true);
1658 case IDA_PRINT_CLICKED:
1660 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//shared//data//test.pdf");
1661 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1663 AppLog("RequestPrint called!");
1664 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1665 result nResult = E_FAILURE;
1668 AppLog("TestPrint if (pAc) == true");
1673 String fileType = L"service_print_files_type";
1674 String typeVal = L"DOC";
1676 String fileCount = L"service_print_files_count";
1677 String countVal = L"1";
1678 String fileFolder= L"service_print_files_folder_name";
1679 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//shared//data";
1681 map.Add(&fileCount, &countVal);
1682 map.Add(&fileFolder, &folderVal);
1683 map.Add(&fileType, &typeVal);
1685 String fileName = L"service_print_files_files_name";
1687 ArrayList fileNameList;
1688 fileNameList.Construct();
1689 String file1 = L"test.pdf";
1691 fileNameList.Add(&file1);
1692 map.Add(&fileName, &fileNameList);
1694 nResult = pAc->Start(NULL, NULL, &map, NULL);
1696 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1697 else if (nResult == E_MAX_EXCEEDED)
1698 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1699 else if (nResult == E_OBJ_NOT_FOUND)
1700 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1701 else if (nResult == E_IN_PROGRESS)
1702 AppLog("TestPrint ret == E_IN_PROGRESS");
1703 else if (nResult == E_PRIVILEGE_DENIED)
1704 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1705 else if(nResult == E_SYSTEM)
1706 AppLog("TestPrint ret == E_SYSTEM");
1712 int __modalMsgBoxResult;
1713 MessageBox* pMsgBox = new MessageBox();
1714 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1715 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1718 __modalMsgBoxResult = 0;
1722 case IDA_SHARE_CLICKED:
1724 if(__pPopUp != null)
1731 __pAddressbar->HideKeypad();
1733 __pPopUp = new(std::nothrow) SharePopup();
1734 __pPopUp->Initialize();
1735 if (__pWindowInfo != null)
1737 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1738 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1739 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1740 pShareInfo->SetImageAttached(false);
1741 __pPopUp->RemoveAllShareInfo();
1742 __pPopUp->AddShareInfo(pShareInfo);
1744 __pPopUp->SetShowState(true);
1748 case IDA_BOOKMARKBTN_CLICKED:
1750 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1751 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1754 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1759 case IDA_MOREBTN_CLICKED:
1761 AppLog("IDA_MOREBTN_CLICKED");
1763 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1765 int bookmarkCount=0;
1768 url=__pWindowInfo->pageUrl;
1769 result r = E_SUCCESS;
1770 Bitmap* pBitmap = null;
1772 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1775 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1780 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1784 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1786 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1788 if (__pOptionMenu->GetItemCount() == 9)
1790 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1794 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1799 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1803 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1804 if (__pOptionMenu->GetItemCount() != 9)
1806 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1807 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1808 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1809 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1810 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1811 __pOptionMenu->SetMaxVisibleItemsCount(6);
1813 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1815 AppLog(" Orientation landscape");
1816 __pOptionMenu->SetMaxVisibleItemsCount(5);
1820 AppLog(" Orientation potrait");
1821 __pOptionMenu->SetMaxVisibleItemsCount(6);
1824 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1827 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1828 __pOptionMenu->SetShowState(true);
1829 __pOptionMenu->Invalidate(true);
1830 __pOptionMenu->Show();
1834 case IDA_HISTORY_CLICKED:
1836 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1837 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1840 case IDA_SAVED_PAGES_CLICKED:
1845 case IDA_DESKTOP_VIEW_CLICKED:
1850 case IDA_SAVE_CLICKED:
1855 case IDA_MULTIWINDOWBTN_CLICKED:
1857 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1858 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1862 case IDA_NEWWINDOWBTN_CLICKED:
1864 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1866 if (pNewWindowInfo == null)
1870 result r = E_SUCCESS;
1871 SceneManager* pSceneManager = SceneManager::GetInstance();
1873 if (pSceneManager == NULL)
1877 ArrayList* pArgList = new(std::nothrow) ArrayList();
1878 if (pArgList == NULL)
1882 r = pArgList->Construct();
1885 pArgList->Add(*pNewWindowInfo);
1886 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1892 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1897 case IDA_SMALLFONT_BTN_CLICKED:
1899 WebSetting setting = __pWebReader->GetSetting();
1900 setting.SetFontSize(15);
1901 __pWebReader->SetSetting(setting);
1904 case IDA_LARGEFONT_BTN_CLICKED:
1906 WebSetting setting = __pWebReader->GetSetting();
1907 setting.SetFontSize(25);
1908 __pWebReader->SetSetting(setting);
1911 case IDA_READER_CLOSE_CLICKED:
1913 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1915 RemoveControl(__pBlankPanel);
1916 __pArticleReaderPanel = null;
1917 __pBlankPanel = null;
1918 __pArticleReaderLabel = null;
1920 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1923 case IDA_FINDWORD_CANCEL_CLICKED:
1925 __currentSearchStr = L"";
1926 __currentWordIndex = 0;
1927 __maxOccurrances = 0;
1929 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1931 __pFindWordEditField->SetText(L"");
1932 __pFindWordCountLabel->SetText(L"0/0");
1934 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1936 __pFindWordEditFieldRightToLeft->SetText(L"");
1937 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1940 __pFindWordNext->SetEnabled(false);
1941 __pFindWordPrev->SetEnabled(false);
1942 __pFindWordCountLabel->SetText(L"0/0");
1943 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1944 AppLog("akjshdasd 1");
1945 __pFooterPanel->SetShowState(true);
1946 ShowFindWordPanel(false);
1949 case IDA_FINDWORD_SEARCH_CLICKED:
1951 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1953 __currentSearchStr = __pFindWordEditField->GetText();
1955 else if (__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
1957 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
1960 if (__currentSearchStr.GetLength() > 0)
1966 AppLogDebug("Enter something");
1970 case IDA_FINDWORD_CLEAR_CLICKED:
1972 __pFindWordCountLabel->SetText(L"0/0");
1973 __pFindWordEditField->SetText(L"");
1974 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1976 __currentSearchStr = L"";
1977 __pFindWordNext->SetEnabled(false);
1978 __pFindWordPrev->SetEnabled(false);
1979 __pFindWordCountLabel->SetShowState(false);
1980 __pFindWordControl->Invalidate(true);
1983 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1985 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1986 __pFindWordEditFieldRightToLeft->SetText(L"");
1987 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1989 __currentSearchStr = L"";
1990 __pFindWordNext->SetEnabled(false);
1991 __pFindWordPrev->SetEnabled(false);
1992 __pFindWordCountLabelRightToLeft->SetShowState(false);
1993 __pFindWordControl->Invalidate(true);
1996 case IDA_FINDWORD_NEXT_CLICKED:
2001 case IDA_FINDWORD_PREV_CLICKED:
2003 FindNextWord(false);
2006 case IDA_BRIGHTNESS_BTN_CLICKED:
2008 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2009 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2012 case IDA_COPY_IMAGE_CLICKED:
2014 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2015 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2017 const Bitmap* pBitmap = null;
2018 if (__pHitElementResult != null && __pHitElementResult->HasImage())
2020 pBitmap = __pHitElementResult->GetImage();
2023 String resourcePath = App::GetInstance()->GetAppResourcePath();
2024 r = item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2025 AppLog("Platofrm construct failed result %s",GetErrorMessage(r));
2026 // copying the item to clipboard
2027 Clipboard* pClipboard = Clipboard::GetInstance();
2028 if (pClipboard != null)
2030 r = pClipboard->CopyItem(item);
2031 AppLog("Platofrm copy failed result %s",GetErrorMessage(r));
2035 case IDA_VIEW_IMAGE_CLICKED:
2037 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2038 WindowInfo* pNewWindowInfo = null;
2039 if (__pHitElementResult != null)
2041 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2042 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2048 case IDA_SAVE_IMAGE_CLICKED:
2050 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2051 const Bitmap* pSaveBitmap = null;
2052 String imageName = GetImagePath();
2053 AppLog("Content manager image name %ls",imageName.GetPointer());
2056 imagePath.Append(imageName);
2057 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2058 AppLog("Content manager image path %ls",imagePath.GetPointer());
2059 if (__pHitElementResult != null)
2061 pSaveBitmap = __pHitElementResult->GetImage();
2063 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2067 UpdateImageContent(pBuffer, imageName);
2069 if(__pNotification != null)
2071 RemoveControl(__pNotification);
2072 __pNotification = null;
2074 __pNotification = new NotificationPanel(*this);
2076 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2077 msg.Append(imagePath);
2078 if (__pNotification != null)
2080 __pNotification->SetText(msg);
2081 if (__pFooterPanel->GetShowState() == true)
2083 __pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2087 __pNotification->SetPositionDiff(0);
2090 __pNotification->ShowNotification();
2095 int __modalMsgBoxResult;
2096 MessageBox* pMsgBox = new MessageBox();
2097 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2098 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2101 __modalMsgBoxResult = 0;
2105 case IDA_SHARE_IMAGE_CLICKED:
2107 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2108 if (__pPopUp != null)
2115 __pAddressbar->HideKeypad();
2117 __pPopUp = new(std::nothrow) SharePopup();
2118 __pPopUp->Initialize();
2119 if (__pHitElementResult != null)
2121 const Bitmap* pSaveBitmap = null;
2122 String imageName = GetImagePath();
2123 AppLog("Content manager image name %ls",imageName.GetPointer());
2126 imagePath.Append(imageName);
2127 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2128 AppLog("Content manager image path %ls",imagePath.GetPointer());
2129 if (__pHitElementResult != null)
2131 pSaveBitmap = __pHitElementResult->GetImage();
2133 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2135 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2136 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2138 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2139 pShareInfo->SetPageTitle(L"");
2140 pShareInfo->SetPageUrl(srcUrl);
2141 pShareInfo->SetImageAttached(true);
2142 pShareInfo->SetImagePath(imagePath);
2143 __pPopUp->RemoveAllShareInfo();
2144 __pPopUp->AddShareInfo(pShareInfo);
2145 __pPopUp->SetShowState(true);
2150 case IDA_HYPERLINK_OPEN_CLICKED:
2152 if (__pHitElementResult != null)
2154 String srcUrl = __pHitElementResult->GetUrl();
2156 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2158 if (pNewWindowInfo == null)
2162 result r = E_SUCCESS;
2163 SceneManager* pSceneManager = SceneManager::GetInstance();
2164 if (pSceneManager == NULL)
2168 ArrayList* pArgList = new(std::nothrow) ArrayList();
2169 if (pArgList == NULL)
2173 pArgList->Construct();
2175 pArgList->Add(*pNewWindowInfo);
2176 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2177 if (pArgList != null)
2184 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2190 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2192 if (__pHitElementResult == null)
2197 if(__pPopUp != null)
2204 __pAddressbar->HideKeypad();
2206 __pPopUp = new(std::nothrow) SharePopup();
2207 __pPopUp->Initialize();
2209 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2210 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2211 pShareInfo->SetImageAttached(false);
2212 __pPopUp->RemoveAllShareInfo();
2213 __pPopUp->AddShareInfo(pShareInfo);
2215 __pPopUp->SetShowState(true);
2219 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2223 if (__pHitElementResult != null)
2225 url = __pHitElementResult->GetUrl();
2228 String resourcePath = App::GetInstance()->GetAppResourcePath();
2229 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2231 // copying the item to clipboard
2232 Clipboard* pClipboard = Clipboard::GetInstance();
2233 if (pClipboard != null)
2235 pClipboard->CopyItem(item);
2239 case IDA_FIND_TEXT__CLICKED:
2241 // AddressBarCancelledClicked(*__pAddressbar);
2242 RelayoutControls(false);
2243 // __pFooterPanel->SetShowState(false);
2244 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2245 __currentSearchStr.Clear();
2246 __currentSearchStr.Append(__currentSelectedStr);
2247 InitFindWordPanel();
2248 __pFindWordEditField->SetText(__currentSearchStr);
2250 if(__pOptionMenu != null)
2252 __pOptionMenu->SetShowState(false);
2253 __pOptionMenu->Invalidate(false);
2255 __adressPanelPosition.y = 0;
2257 if (__pAddressbar != null && __pWebViewer != NULL)
2259 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2260 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2262 if (__pFooterPanel->GetShowState() == false)
2263 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2265 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2266 __pWebViewer->Invalidate(true);
2269 ShowFindWordPanel(true);
2270 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
2272 __pFindWordEditField->SetText(__currentSearchStr);
2273 __pFindWordEditField->SetFocus();
2275 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
2277 __pFindWordEditFieldRightToLeft->SetText(__currentSearchStr);
2278 __pFindWordEditFieldRightToLeft->SetFocus();
2281 if (__currentSearchStr.GetLength() > 0)
2287 AppLogDebug("Enter something");
2290 if (__pWebViewer != null)
2292 // releasing the set block
2293 __pWebViewer->ReleaseBlock();
2298 case IDA_SHARE_TEXT_CLICKED:
2300 __pWebViewer->ReleaseBlock();
2301 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2302 if(__pPopUp != null)
2309 __pAddressbar->HideKeypad();
2311 __pPopUp = new(std::nothrow) SharePopup();
2312 __pPopUp->Initialize();
2313 if (__pHitElementResult != null)
2315 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2316 pShareInfo->SetPageTitle(L"");
2317 pShareInfo->SetPageUrl(__currentSelectedStr);
2318 pShareInfo->SetImageAttached(false);
2319 __pPopUp->RemoveAllShareInfo();
2320 __pPopUp->AddShareInfo(pShareInfo);
2321 __pPopUp->SetShowState(true);
2326 case IDA_COPY_TEXT_CLICKED:
2328 __pWebViewer->ReleaseBlock();
2329 // need to implement
2330 //__currentSelectedStr
2331 // Sets data to a clip board item
2333 String resourcePath = App::GetInstance()->GetAppResourcePath();
2334 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2336 // copying the item to clipboard
2337 Clipboard* pClipboard = Clipboard::GetInstance();
2338 if (pClipboard != null)
2340 pClipboard->CopyItem(item);
2344 case IDA_PASTE_TEXT_CLICKED:
2346 Clipboard* pClipboard = Clipboard::GetInstance();
2348 if(pClipboard == null)
2352 // Retrieves a latest item
2353 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2359 //Gets data from the clipboard item
2360 String* pString = dynamic_cast<String*>(pItem->GetData());
2362 if (pString != null)
2364 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2365 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2366 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2369 if(idElement.GetLength() != 0)
2371 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; } } ";
2372 script.Append("insertAtCursor('");
2373 script.Append(idElement);
2374 script.Append("',");
2375 script.Append("\"");
2376 script.Append(*pString);
2377 script.Append("\");");
2379 else if (nameElement.GetLength() != 0)
2381 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; } } ";
2382 script.Append("insertAtCursor(document.getElementsByName('");
2383 script.Append(nameElement);
2384 script.Append("')[0],");
2385 script.Append("\"");
2386 script.Append(*pString);
2387 script.Append("\");");
2389 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2390 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2401 case IDA_GO_FORWARD:
2406 case IDA_REFRESH_BTN_CLICKED:
2408 __isLoadingCompleted = false;
2409 __isLoadingData = true;
2410 __progressPercentage = 0;
2411 __displayUrl = __pFooterUrlField->GetText();
2413 String url = __pFooterUrlField->GetText();
2414 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2416 if (__pWebViewer != null && __pAddressbar != null)
2418 __pWebViewer->Reload();
2419 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2423 UpdateProgressBitmap();
2426 case IDA_STOP_BTN_CLICKED:
2428 __isLoadingCompleted = false;
2429 __isLoadingData = false;
2430 __progressPercentage = 0;
2431 __pFooterUrlField->HideKeypad();
2432 __displayUrl = __pFooterUrlField->GetText();
2436 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2437 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2438 __pWebViewer->StopLoading();
2439 RequestRedraw(true);
2442 UpdateProgressBitmap();
2447 if (__pFooterUrlField->GetText().IsEmpty() == false)
2449 //__displayUrl = __pUrlField->GetText();
2450 __pFooterUrlField->Clear();
2455 case IDA_READER_BTN_CLICKED:
2466 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2468 result r = E_FAILURE;
2469 if (__pWebViewer && __pWebViewer->CanGoBack())
2471 __pWebViewer->GoBack();
2473 else if(__pWindowInfo->isJavascriptInitiated == false)
2476 pApp = UiApp::GetInstance();
2479 r = pApp->Terminate();
2482 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2490 WindowInfo* pWindowInfo = null;
2492 SceneManager* pSceneManager = SceneManager::GetInstance();
2493 if (pSceneManager == null)
2497 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2498 if (pAllWindowList == NULL)
2500 pApp = UiApp::GetInstance();
2503 r = pApp->Terminate();
2506 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2511 if (pAllWindowList != null)
2513 totalCount = pAllWindowList->GetCount();
2515 for (int count = 0; count < totalCount; count++)
2517 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2518 if (pWindowInfo == null)
2520 pApp = UiApp::GetInstance();
2523 r = pApp->Terminate();
2526 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2533 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2535 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2538 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2541 r = pAllWindowList->RemoveAt(count, true);
2542 __pWindowInfo = null;
2545 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2550 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2554 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2556 if (pWindowInfo == null)
2558 pApp = UiApp::GetInstance();
2561 r = pApp->Terminate();
2567 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2570 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2582 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2583 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2586 AppLog("MainForm::OnSceneActivatedN called");
2587 String* pSelectedScene = NULL;
2588 Object* pValue = NULL;
2589 String* pUrl = null;
2590 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2591 pSelectedScene = (String*) pValue;
2593 if (pSelectedScene != null)
2595 delete pSelectedScene;
2597 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2598 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2599 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2600 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2602 // setting the current scene ID
2603 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2605 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2607 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2609 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2610 if(__pWindowInfo == null)
2612 // if(__pWindowInfo == null)
2614 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2617 else if ( pArgs != null && pArgs->GetCount() == 1)
2619 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2625 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2627 // hiding the address bar
2628 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2629 __pAddressbar->SetShowState(false);
2630 // if(__pWebViewer != null)
2632 // __pWebViewer->Resume();
2635 if(pUrl != null && pUrl->GetLength() > 0)
2639 else if(__pWindowInfo != null)
2641 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)
2643 LoadUrl(__pWindowInfo->pageUrl);
2645 else if (__pWindowInfo->isJavascriptInitiated == true)
2649 __pWindowInfo->pCurrentWeb = __pWebViewer;
2653 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2654 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2655 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2657 InitMostVisitedSitesView(GetOrientationStatus());
2659 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2661 if(__pMostVisitedListView != null)
2663 __pMostVisitedListView->SetShowState(false);
2667 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2669 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2671 if (pBookmarkUrl == null)
2673 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2674 //__pAddressbar->SetUrl(*pBookmarkUrl);
2675 SetUrl(*pBookmarkUrl);
2677 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2678 __pWebViewer->LoadUrl(*pBookmarkUrl);
2679 delete pBookmarkUrl;
2682 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2683 Bitmap* pBitmap = null;
2684 if (isPrivateBrowsing == true)
2686 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2688 if (__pWebViewer != null)
2690 __pWebViewer->SetPrivateBrowsingEnabled(true);
2693 if (__pAddressbar != null)
2695 // __pAddressbar->UpdateFaviconBitmap(true);
2701 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2703 if (__pWebViewer != null)
2705 __pWebViewer->SetPrivateBrowsingEnabled(false);
2708 if (__pAddressbar != null)
2710 // __pAddressbar->UpdateFaviconBitmap(false);
2714 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() != 9)
2716 __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2718 else if (__pOptionMenu != null )
2720 __pOptionMenu->SetItemAt(5,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2723 if (pBitmap != null)
2728 AppLog("ABC: OnSceneActivatedN started exit");
2733 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2734 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2736 Canvas* pWebCanvas = null;
2737 if (__pWebViewer != null)
2739 pWebCanvas = __pWebViewer->GetCanvasN();
2742 if (pWebCanvas == null)
2746 if (__pWindowInfo != null)
2748 if (__pWindowInfo->pWebCanvasBitmap != null)
2750 delete __pWindowInfo->pWebCanvasBitmap;
2752 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2753 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2754 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2756 Bitmap* pBitmap = GetCapturedBitmapN();
2757 AppLog("Coming here");
2758 Canvas* pCanvas = new(std::nothrow) Canvas();
2759 pCanvas->Construct(GetClientAreaBounds());
2762 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2765 if(__pWebViewer != null && __pWindowInfo != null)
2766 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2768 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2769 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2771 AppLog("Coming here");
2775 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2776 const Tizen::Base::String& realm,
2777 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2783 MainForm::OnHttpAuthenticationCanceled(void)
2788 MainForm::OnLoadingStarted(void)
2790 AppLogDebug("MainForm::OnLoadingStarted entered");
2792 if(__pAddressbar == NULL || __pWebViewer == null)
2797 // this is added in case if menu is opened and user load the page
2798 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2800 __pOptionMenu->SetShowState(false);
2801 __pOptionMenu->Invalidate(true);
2806 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2808 __pImageMenu->SetShowState(false);
2809 __pImageMenu->Invalidate(true);
2811 String url = __pWebViewer->GetUrl();
2812 if(url.Contains(IDS_TIZEN_SERVICE))
2815 String delim(L":;,");
2817 // Creates a StringTokenizer instance
2818 StringTokenizer strTok(url, delim);
2820 int count = strTok.GetTokenCount(); // count == 4
2822 HashMap *pMap = new HashMap();
2827 while (strTok.HasMoreTokens())
2829 AppLog("Token: %ls", token.GetPointer());
2830 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2831 if(token.Contains(IDS_APPID))
2833 token.SubString(6, appId);
2834 AppLog("AppID:%ls", appId.GetPointer());
2836 else if(token.Contains(IDS_KEY))
2838 token.SubString(4, key);
2839 AppLog("key:%ls", key.GetPointer());
2841 else if(token.Contains(IDS_VALUE))
2843 token.SubString(6, value);
2844 AppLog("value:%ls", value.GetPointer());
2847 pMap->Add(key, value);
2851 AppControl *pAppControl = null;
2852 String operationId = L"http://tizen.org/appcontrol/operation/main";
2853 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2856 AppLog("Starting AppControl");
2857 result r = pAppControl->Start(null, null, pMap, null);
2858 AppLog("Result of Start %s", GetErrorMessage(r));
2862 AppLogException("AppControl not found");
2867 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2869 __pAddressbar->SetShowState(false);
2870 AddressBarCancelledClicked(*__pAddressbar);
2871 __pAddressbar->Invalidate(true);
2873 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2876 __pAddressbar->SetFaviconBitmap(*pBitmap);
2879 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2881 // updating the address bar position with respect to web control
2882 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2883 __distanceMoved = 0;
2887 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2888 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2889 if (__pWebViewer != null)
2891 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2892 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2893 SetUrl(__pWebViewer->GetUrl());
2894 if (__pWindowInfo != NULL)
2896 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2897 __pWindowInfo->pageTitle = L"";
2898 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2900 __pAddressbar->Invalidate(true);
2906 MainForm::OnLoadingCanceled(void)
2913 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2915 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2920 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2922 AppLog("XYZ::MainForm::OnKeypadOpened");
2923 __pFooterPanel->SetShowState(false);
2928 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2930 AppLog("XYZ::MainForm::OnKeypadClosed");
2931 __pFooterPanel->SetShowState(true);
2932 RelayoutControls(true);
2936 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2938 AppLog("XYZ::KeypadBoundsChanged");
2939 RelayoutControls(false);
2943 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2944 const Tizen::Base::String& reason)
2946 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2950 MainForm::OnLoadingCompleted(void)
2952 AppLog("MainForm::OnLoadingCompleted start");
2954 result r = E_SUCCESS;
2956 if (__pWebViewer == null)
2961 if (__pAddressbar == null)
2966 if(__pImageMenu && __pImageMenu->GetShowState())
2968 __pImageMenu->SetShowState(false);
2969 __pImageMenu->Invalidate(true);
2972 if (__pWebViewer->CanGoForward())
2974 //__pAddressbar->SetForwardButtonEnabled(true);
2975 SetForwardButtonEnabled(true);
2979 //__pAddressbar->SetForwardButtonEnabled(false);
2980 SetForwardButtonEnabled(false);
2983 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2985 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2987 //__pAddressbar->UpdateProgress(0);
2991 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2993 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2997 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2998 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2999 if (isPrivateBrowsing == false)
3001 if(__pHistory != null)
3007 __pHistory = new(std::nothrow) History;
3008 HistoryPresentationModel::GetCurrentDateTime(date);
3011 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3012 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3014 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3015 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3017 __pHistory->SetVisitedTime(date);
3019 if (__pWebViewer != null)
3021 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3023 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3024 if (pTempBitmap != null)
3026 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3027 __pHistory->SetFavIconBitmap(*pTempBitmap);
3030 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3033 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3034 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3035 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3037 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3038 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3039 __pHistory->SetThumbnail(pBitmap);
3041 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3044 __pHistory->SetFavIconBitmap(*pFavIcon);
3048 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3055 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3057 // temperary fixed (webpage can be not loaded)
3061 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3062 if (isReaderEnabled == true)
3066 delete __pReaderData;
3067 __pReaderData = null;
3069 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3070 filePath.Append(L"data/reader.js");
3076 result r = E_SUCCESS;
3077 FileAttributes attr;
3079 File::GetAttributes(filePath,attr);
3081 r = file.Construct(filePath, L"r+");
3084 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3087 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3090 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3093 // file.Read(pScript,attr.GetFileSize());
3095 // AppLogDebug("scipt length %d",strlen(pScript));
3096 String strScript = L"";
3097 // strScript.Append(pScript);
3098 // for(int i=0; i<25; i++)
3100 file.Read(pScript,attr.GetFileSize());
3101 // AppLog("xyzz tell %d",file.Tell());
3102 // r = strScript.Append(pScript);
3103 // AppLog("xyzz append result %s",GetErrorMessage(r));
3104 // AppLog("xyzz strScript length %d",strScript.GetLength());
3106 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3108 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3109 if (__pReaderData == null)
3111 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3112 __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>");
3115 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3116 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3118 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3119 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3125 AppLog("MainForm::OnLoadingCompleted done");
3129 MainForm::OnEstimatedProgress(int progress)
3131 AppLogDebug("MainForm::OnEstimatedProgress entered");
3133 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3134 progress = DEFAULT_PROGRESS_PERCENTAGE;
3136 // __pAddressbar->UpdateProgress(progress);
3137 UpdateProgress(progress);
3140 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3142 AppLog("MainForm::OnFaviconReceived");
3143 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3145 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3148 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3155 MainForm::OnUrlValueChanged(Addressbar&)
3161 MainForm::OnUrlSubmitted(Addressbar& addBar)
3163 AppLog("MainForm::OnUrlSubmitted");
3164 String url = addBar.GetUrl();
3165 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3167 if(__pFooterUrlField)
3168 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3169 AddressBarCancelledClicked(*__pAddressbar);
3174 MainForm::LoadUrl(String& url)
3178 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3179 AppLogDebug("MainForm::LoadUrl enter");
3181 if (__pWebViewer != null)
3183 __pWebViewer->SetShowState(true);
3184 __pWebViewer->Invalidate(true);
3187 if (url.CompareTo(L"") == 0)
3191 if(__pFooterPanel != null)
3193 __pFooterPanel->SetShowState(true);
3194 __pFooterPanel->Invalidate(true);
3201 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3202 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)
3204 RegularExpression firstRegex;
3205 RegularExpression secondRegex;
3207 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3208 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3211 ret = firstRegex.Match(url, false); // This returns true value
3212 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3214 if (ret == true && __pWebViewer != null)
3217 __pWebViewer->LoadUrl(url);
3219 else if(__pWebViewer != null)
3221 String tempUrl = L"http://";
3222 tempUrl.Append(url);
3226 __pWebViewer->LoadUrl(tempUrl);
3230 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3231 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3234 if (__pAddressbar != null)
3236 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3237 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3240 AppLogDebug("MainForm::LoadUrl exit");
3247 MainForm::OnStopClicked(Addressbar& addBar)
3249 AppLogDebug("MainForm::OnStopClicked called");
3252 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3253 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3254 __pWebViewer->StopLoading();
3255 RequestRedraw(true);
3260 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3262 // AppLog("MainForm::OnBackClicked");
3263 result r = E_FAILURE;
3265 if (__pWebViewer && __pWebViewer->CanGoBack())
3267 __pWebViewer->GoBack();
3269 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3272 pApp = UiApp::GetInstance();
3275 r = pApp->Terminate();
3278 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3286 WindowInfo* pWindowInfo = null;
3288 SceneManager* pSceneManager = SceneManager::GetInstance();
3289 if (pSceneManager == null)
3293 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3294 if (pAllWindowList == NULL)
3296 pApp = UiApp::GetInstance();
3299 r = pApp->Terminate();
3302 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3307 if (pAllWindowList != null)
3309 totalCount = pAllWindowList->GetCount();
3311 for (int count = 0; count < totalCount; count++)
3313 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3314 if (pWindowInfo == null)
3316 pApp = UiApp::GetInstance();
3319 r = pApp->Terminate();
3322 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3327 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3329 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3332 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3335 r = pAllWindowList->RemoveAt(count, true);
3336 __pWindowInfo = null;
3339 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3344 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3346 else if(pAllWindowList->GetCount() > 0)
3348 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3352 pApp = UiApp::GetInstance();
3355 r = pApp->Terminate();
3360 if (pWindowInfo == null)
3362 pApp = UiApp::GetInstance();
3365 r = pApp->Terminate();
3371 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3374 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3388 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3390 AppLog("MainForm::OnForwardClicked");
3391 if (__pWebViewer == null)
3394 if (__pWebViewer->CanGoForward())
3396 __pWebViewer->GoForward();
3401 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3403 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3404 if(__pFooterPanel != null)
3406 __pFooterPanel->SetShowState(false);
3409 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3411 __pAddressbar->SetShowState(true);
3412 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3415 RelayoutControls(false);
3419 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3421 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3423 int Height = GetClientAreaBounds().height;
3424 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3427 __pAddressbar->SetShowState(false);
3429 if (__pFooterPanel != null && addressbarKeyPadState == false)
3431 AppLog("akjshdasd 3");
3432 __pFooterPanel->SetShowState(true);
3435 RelayoutControls(false);
3439 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3441 AddressBarCancelledClicked(addBar);
3445 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3447 __prevAddressBarMode = __curAddressBarMode;
3449 if (__pAddressbar != null)
3451 __curAddressBarMode = GetAddressbarMode();
3454 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3456 __adressPanelPosition.y = 0;
3457 if (__pAddressbar != null)
3459 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3460 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3461 __pAddressbar->Invalidate(true);
3463 if (__pWebViewer != null)
3465 __pWebViewer->StopLoading();
3468 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3470 __adressPanelPosition.y = 0;
3471 if (__pAddressbar != null)
3473 __webControlPosition.y = 0;
3474 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3475 __pAddressbar->Invalidate(true);
3481 MainForm::OnClipboardClosed(const Addressbar& addBar)
3483 AppLog("XYZ::MainForm::OnClipboardClosed");
3484 RelayoutControls(false);
3488 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3490 AppLog("XYZ::MainForm::OnAddressBarKeypadClosed");
3491 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3493 AppLog("akjshdasd 3");
3494 __pFooterPanel->SetShowState(true);
3497 RelayoutControls(false,footerState);
3501 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3503 AppLog("XYZ::MainForm::OnAddressBarKeypadOpened");
3504 RelayoutControls(false);
3508 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3510 __pFooterPanel->SetShowState(false);
3514 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3516 AppLog("XYZ::MainForm::OnAddressBarKeypadBoundsChanged");
3517 RelayoutControls(false);
3521 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3523 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3526 __pWindowInfo->pageTitle = title;
3527 if (__pWebViewer != null)
3529 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3532 if (__pAddressbar != null && __pWebViewer != null)
3534 SetUrl(__pWebViewer->GetUrl());
3535 __pAddressbar->Invalidate(true);
3540 MainForm::UpdateFavicon(void)
3542 bool urlImageType = false;
3543 String *tempPath = null;
3545 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();");
3546 Bitmap* pBitmap = null;
3548 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3550 if (__pWindowInfo != null)
3553 url.SetUri(*tempPath);
3554 if (url.GetHost().GetLength() == 0)
3557 webUrl.SetUri(__pWebViewer->GetUrl());
3558 result r = url.SetHost(webUrl.GetHost());
3565 if (url.GetScheme().GetLength() == 0)
3568 webUrl.SetUri(__pWebViewer->GetUrl());
3569 url.SetScheme(webUrl.GetScheme());
3571 __pWindowInfo->faviconUrl = url.ToString();
3573 pBitmap = __pWebViewer->GetFaviconN();
3575 if (pBitmap != null)
3577 if (__pWindowInfo->pFavicon != NULL)
3579 __pWindowInfo->pFavicon = null;
3581 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3582 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3584 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3586 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3588 else if(__pWindowInfo->pFavicon != null)
3590 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3594 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3595 if(pDefaultBmp != null)
3597 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3606 if(tempPath != null)
3610 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3616 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3617 Tizen::Web::Controls::WebNavigationType type)
3619 AppLog("urlk %ls",url.GetPointer());
3620 // when load new page if find word panel is open its show state is false
3621 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3623 __currentSearchStr = L"";
3624 __currentWordIndex = 0;
3625 __maxOccurrances = 0;
3626 __pFindWordEditField->SetText(L"");
3627 __pFindWordNext->SetEnabled(false);
3628 __pFindWordPrev->SetEnabled(false);
3629 __pFindWordCountLabel->SetText(L"0/0");
3630 __pFindWordControl->SetShowState(false);
3631 __pFindWordEditField->HideKeypad();
3632 RelayoutControls(false);
3635 __pFooterPanel->Invalidate(true);
3638 uriInfo.SetUri(url);
3640 if(url.Contains(IDS_TIZEN_SERVICE))
3643 String delim(L":;,");
3645 // Creates a StringTokenizer instance
3646 StringTokenizer strTok(url, delim);
3648 int count = strTok.GetTokenCount(); // count == 4
3650 HashMap *pMap = new HashMap();
3656 while (strTok.HasMoreTokens())
3658 AppLog("Token: %ls", token.GetPointer());
3659 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3660 if(token.Contains(IDS_APPID))
3662 token.SubString(6, appId);
3663 AppLog("AppID:%ls", appId.GetPointer());
3665 else if(token.Contains(IDS_KEY))
3667 token.SubString(4, key);
3668 AppLog("key:%ls", key.GetPointer());
3670 else if(token.Contains(IDS_VALUE))
3672 token.SubString(6, value);
3673 AppLog("value:%ls", value.GetPointer());
3676 pMap->Add(key, value);
3680 AppControl *pAppControl = null;
3681 String operationId = L"http://tizen.org/appcontrol/operation/main";
3682 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3685 result r = pAppControl->Start(null, null, pMap, null);
3689 AppLogException("AppControl not found");
3699 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3700 const Tizen::Net::Http::HttpHeader& httpHeader)
3702 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3706 MainForm::OnWebPageBlockSelected(Web& source, FloatPoint& startPoint, FloatPoint& endPoint)
3708 AppLog("MainForm::OnWebPageBlockSelected");
3709 if (__pHitElementResult != null)
3711 delete __pHitElementResult;
3712 __pHitElementResult = null;
3715 if (__pWebViewer != null)
3717 AppLog("MainForm::OnWebPageBlockSelected web not null");
3718 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3720 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3722 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3723 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3724 if(GetLastResult() == E_INVALID_ARG || (__pHitElementResult->GetTagName().CompareTo(L"INPUT") != 0 && __pHitElementResult->GetTagName().CompareTo(L"TEXTAREA") != 0))
3726 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3728 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3732 if (__pHitElementResult == null)
3737 if (__pHitElementResult->HasImage() != true)
3739 String tagName = __pHitElementResult->GetTagName();
3740 String type = __pHitElementResult->GetAttributeValue("type");
3743 AppLog("TagName %ls",tagName.GetPointer());
3744 __currentSelectedStr.Clear();
3745 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3746 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3747 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3749 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3751 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3753 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),true);
3754 __pImageMenu->SetShowState(true);
3755 __pImageMenu->Show();
3756 __pImageMenu->Invalidate(true);
3758 else /*if(__isLongPressedDone == true)*/
3760 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3762 if(__pHitElementResult->GetUrl().GetLength() > 0)
3764 __currentSelectedStr.Clear();
3765 __currentSelectedStr = __pHitElementResult->GetUrl();
3767 InitSelectTextContextMenuF(FloatPoint(endPoint.x,endPoint.y + __pWebViewer->GetY()),false);
3768 __pImageMenu->SetShowState(true);
3769 __pImageMenu->Show();
3770 __pImageMenu->Invalidate(true);
3773 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3774 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3775 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3781 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3787 MainForm::OnWebWindowCreateRequested(void)
3789 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3791 if (pNewWindowInfo == null)
3795 result r = E_SUCCESS;
3796 SceneManager* pSceneManager = SceneManager::GetInstance();
3797 if (pSceneManager == NULL)
3801 ArrayList* pArgList = new(std::nothrow) ArrayList();
3802 if (pArgList == NULL)
3806 r = pArgList->Construct();
3809 pNewWindowInfo->isJavascriptInitiated = true;
3810 pArgList->Add(*pNewWindowInfo);
3811 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3815 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3822 return pNewWindowInfo->pCurrentWeb;
3826 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3828 AppLog("xyz:: MainForm::RelayoutControls called");
3829 __webControlPosition.y = 0;
3830 __webControlHeight = GetClientAreaBounds().height;
3831 AppLog("Client area height: %d", __webControlHeight);
3833 AppLog("Client area height: %d", __webControlHeight);
3834 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3836 __webControlPosition.y += __pAddressbar->GetHeight();
3837 __webControlHeight -= __pAddressbar->GetHeight();
3838 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3840 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3842 __webControlPosition.y += __pFindWordControl->GetHeight();
3843 __webControlHeight -= __pFindWordControl->GetHeight();
3844 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3847 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3849 __webControlHeight -= __pFooterPanel->GetHeight();
3851 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3853 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3855 if(__pWebViewer->GetX() == 0 && __pWebViewer->GetY() == __webControlPosition.y &&__pWebViewer->GetWidth() == GetClientAreaBounds().width &&__pWebViewer->GetHeight() == __webControlHeight + 12 )
3860 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3861 __pWebViewer->Invalidate(false);
3864 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3866 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3873 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3875 if (__pFindWordControl == null)
3880 Tizen::Locales::LocaleManager localeManager;
3881 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3883 String languageCode;
3884 result r = SettingInfo::GetValue(L"Language", languageCode);
3885 // int languagecode = local.GetLanguageCode();
3886 AppLog("rahul language is %S", languageCode.GetPointer());
3890 InitFindWordPanel();
3892 if (languageCode.CompareTo("ara") == 0)
3894 AppLog("rahul language is arabic");
3896 __pFindWordPanelLeftToRight->SetShowState(false);
3897 __pFindWordPanelRightToLeft->SetShowState(true);
3899 __pFindWordClear->SetShowState(false);
3900 __pFindWordCountLabel->SetShowState(false);
3901 __pFindWordEditField->SetShowState(false);
3903 __pFindWordClearRightToLeft->SetShowState(true);
3904 __pFindWordCountLabelRightToLeft->SetShowState(true);
3905 __pFindWordEditFieldRightToLeft->SetShowState(true);
3909 AppLog("rahul language is not arabic");
3912 __pFindWordPanelLeftToRight->SetShowState(true);
3913 __pFindWordPanelRightToLeft->SetShowState(false);
3915 __pFindWordClear->SetShowState(true);
3916 __pFindWordCountLabel->SetShowState(true);
3917 __pFindWordEditField->SetShowState(true);
3919 __pFindWordClearRightToLeft->SetShowState(false);
3920 __pFindWordCountLabelRightToLeft->SetShowState(false);
3921 __pFindWordEditFieldRightToLeft->SetShowState(false);
3923 __pFindWordControl->SetShowState(true);
3927 if(__pFindWordControl != null)
3929 __pFindWordControl->SetShowState(false);
3933 AppLog("MainForm::ShowFindWordPanel %d",show);
3934 if (show && !isTouchPressed)
3936 if (languageCode.CompareTo("ara") == 0)
3938 if (__pFindWordEditFieldRightToLeft)
3940 __pFindWordEditFieldRightToLeft->SetFocus();
3941 __pFindWordEditFieldRightToLeft->ShowKeypad();
3946 if (__pFindWordEditField)
3948 __pFindWordEditField->SetFocus();
3949 __pFindWordEditField->ShowKeypad();
3955 if (languageCode.CompareTo("ara") == 0)
3957 if (__pFindWordEditFieldRightToLeft)
3958 __pFindWordEditFieldRightToLeft->HideKeypad();
3962 if (__pFindWordEditField)
3963 __pFindWordEditField->HideKeypad();
3967 RelayoutControls(false);
3971 MainForm::StartWordSearch()
3973 //Get the count of occurances of the word in the current page
3974 __maxOccurrances = 0;
3975 __currentWordIndex = 0;
3977 __pFindWordPrev->SetEnabled(false);
3978 String *pCountStr = null;
3979 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3980 AppLog("Search Result %s",GetErrorMessage(r));
3981 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3982 if (pCountStr != null)
3984 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3988 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3993 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3995 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3996 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3998 if(totalCount == -1 || totalCount == 0)
4000 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4001 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4004 else if(totalCount > 100)
4006 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4007 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4011 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4012 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4015 __maxOccurrances = totalCount;
4016 __currentWordIndex = currentOrdinal;
4018 //Reset the UI controls as per the maxOccurrance value
4019 if (totalCount <= 0)
4021 AppLog("Word not found");
4022 //Show error notification to user
4023 __pFindWordNext->SetEnabled(false);
4024 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4026 __pFindWordCountLabel->SetText(L"0/0");
4027 __pFindWordCountLabel->Invalidate(false);
4029 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4031 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4032 __pFindWordCountLabelRightToLeft->Invalidate(false);
4034 __pFindWordNext->Invalidate(false);
4035 __pFindWordPrev->Invalidate(false);
4040 if (totalCount == 1)
4042 __pFindWordNext->SetEnabled(false);
4046 __pFindWordNext->SetEnabled(true);
4049 String countStr = L"";
4050 countStr.Append(__currentWordIndex);
4051 countStr.Append(L"/");
4052 countStr.Append(__maxOccurrances);
4053 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4055 __pFindWordCountLabel->SetText(countStr);
4056 __pFindWordCountLabel->Invalidate(false);
4057 __pFindWordCountLabel->Invalidate(false);
4059 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4061 __pFindWordCountLabelRightToLeft->SetText(countStr);
4062 __pFindWordCountLabelRightToLeft->Invalidate(false);
4063 __pFindWordCountLabelRightToLeft->Invalidate(false);
4065 //FindNextWord(true);
4066 //Update the controls
4067 __pFindWordNext->Invalidate(false);
4068 __pFindWordPrev->Invalidate(false);
4073 MainForm::FindNextWord(bool next)
4077 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4078 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4080 if (__currentWordIndex < __maxOccurrances)
4082 __currentWordIndex++;
4088 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4089 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4091 if(__currentWordIndex > 1)
4093 __currentWordIndex--;
4098 String countStr = L"";
4099 countStr.Append(__currentWordIndex);
4100 countStr.Append(L"/");
4101 countStr.Append(__maxOccurrances);
4103 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4105 __pFindWordCountLabel->SetText(countStr);
4106 __pFindWordCountLabel->Invalidate(false);
4108 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4110 __pFindWordCountLabelRightToLeft->SetText(countStr);
4111 __pFindWordCountLabelRightToLeft->Invalidate(false);
4114 if (__currentWordIndex >= __maxOccurrances)
4116 __pFindWordNext->SetEnabled(false);
4120 __pFindWordNext->SetEnabled(true);
4122 if (__currentWordIndex <= 1)
4124 __pFindWordPrev->SetEnabled(false);
4128 __pFindWordPrev->SetEnabled(true);
4130 __pFindWordPrev->Invalidate(false);
4131 __pFindWordNext->Invalidate(false);
4133 __pFindWordControl->Invalidate(true);
4137 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4139 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4140 __isWebKeypadOpened = true;
4141 __pFooterPanel->SetShowState(false);
4142 // OnAddressBarKeypadOpened(*__pAddressbar);
4146 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4148 AppLog("xyz::MainForm::OnWebKeypadOpened");
4150 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4152 __currentSearchStr = L"";
4153 __currentWordIndex = 0;
4154 __maxOccurrances = 0;
4155 __pFindWordEditField->SetText(L"");
4156 __pFindWordNext->SetEnabled(false);
4157 __pFindWordPrev->SetEnabled(false);
4158 __pFindWordCountLabel->SetText(L"0/0");
4159 __pWebViewer->SearchTextAllAsync(L"",false);
4160 __pFindWordControl->SetShowState(false);
4161 __pFindWordEditField->HideKeypad();
4165 if (__pWebViewer != null && __pFooterPanel != null)
4167 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4168 if(__pAddressbar != null)
4170 __pAddressbar->SetShowState(false);
4172 if(__pFindWordControl != null)
4174 __pFindWordControl->SetShowState(false);
4176 __pFooterPanel->SetShowState(false);
4177 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4179 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4181 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4182 // AppLog("omgomgomg");
4188 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4190 AppLog("xyz::MainForm::OnWebKeypadClosed");
4191 AppLog("akjshdasd 4");
4192 __pFooterPanel->SetShowState(true);
4193 // OnAddressBarKeypadClosed(*__pAddressbar);
4194 RelayoutControls(false);
4195 __isWebKeypadOpened = false;
4199 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4201 // RelativeLayout(false);
4202 if(__pWebViewer != null)
4204 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width,GetClientAreaBounds().height));
4209 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4211 Control* temp = const_cast< Control* >(&source);
4212 Header* pHeader = dynamic_cast< Header* >(temp);
4213 if (pHeader != null)
4215 //Header double - clicked
4216 AppLog("Header double clicked");
4218 if(__pFindWordControl)
4220 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4221 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4225 AppLog("MainScene::OnTouchDoublePressed");
4229 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4231 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4232 __longPressPoint = currentPosition;
4234 if (__pHitElementResult != null)
4236 delete __pHitElementResult;
4237 __pHitElementResult = null;
4240 if (__pWebViewer != null)
4242 AppLog("MainForm::OnTouchLongPressed web not null");
4243 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4246 if (__pHitElementResult == null)
4251 if (__pHitElementResult->HasImage() == true)
4253 if(__pWebViewer != null)
4254 InitImageContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4255 __pImageMenu->SetShowState(true);
4256 __pImageMenu->Show();
4257 __pImageMenu->Invalidate(true);
4259 else if(__pHitElementResult->HasUrl() == true)
4261 String tempURl = __pHitElementResult->GetUrl();
4262 AppLog("tempURl is %ls", tempURl.GetPointer());
4263 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4264 if (pBitmap != null)
4272 InitImageLinkContextMenu(Point(currentPosition.x,currentPosition.y + __pWebViewer->GetY()));
4273 __pImageMenu->SetShowState(true);
4274 __pImageMenu->Show();
4275 __pImageMenu->Invalidate(true);
4279 String tagName = __pHitElementResult->GetTagName();
4280 String type = __pHitElementResult->GetAttributeValue("type");
4281 String value = __pHitElementResult->GetAttributeValue(L"value");
4282 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4284 __currentSelectedStr.Clear();
4285 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4287 AppLog("tag name is %ls", tagName.GetPointer());
4288 AppLog("type is %ls", type.GetPointer());
4292 //__isLongPressedDone = true;
4293 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4294 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4296 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4298 InitSelectTextContextMenu(Point(currentPosition.x , currentPosition.y + __pWebViewer->GetY()),true, true);
4301 __pImageMenu->SetShowState(true);
4302 __pImageMenu->Show();
4303 __pImageMenu->Invalidate(true);
4306 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4309 // __inputEventToBeSupressed = true;
4313 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4315 AppLog("xyz:: MainForm::OnTouchReleased called");
4317 if (__pAddressbar && __pAddressbar->GetShowState() == true)
4319 __pAddressbar->SetShowState(false);
4323 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4324 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4326 __pWebViewer->ConsumeInputEvent();
4328 if(pHitElement != null)
4332 __inputEventToBeSupressed = false;*/
4336 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4343 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4345 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4347 __currentSearchStr = L"";
4348 __currentWordIndex = 0;
4349 __maxOccurrances = 0;
4351 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4353 __pFindWordEditField->SetText(L"");
4354 __pFindWordEditField->HideKeypad();
4355 __pFindWordControl->SetShowState(false);
4356 __pFindWordCountLabel->SetText(L"0/0");
4358 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4360 __pFindWordEditFieldRightToLeft->SetText(L"");
4361 __pFindWordEditFieldRightToLeft->HideKeypad();
4362 __pFindWordControl->SetShowState(false);
4363 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4366 __pFindWordNext->SetEnabled(false);
4367 __pFindWordPrev->SetEnabled(false);
4369 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4370 __pFindWordControl->SetShowState(false);
4372 if(__pAddressbar->GetShowState() == false)
4374 __pAddressbar->SetAddressbarURLFocus();
4375 __pFooterPanel->SetShowState(false);
4382 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4388 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4394 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4400 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4406 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4412 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4414 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4415 int widthContextItem = 0;
4417 // As per the platform engineer comment removed this line
4418 /*if(__pWebViewer != null)
4420 // 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
4421 __pWebViewer->ReleaseBlock();
4424 // if(__pFindWordControl != null)
4425 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4426 if(__pNotification && __pNotification->GetShowState() == true)
4428 __pNotification->SetShowState(false);
4429 __pNotification->Invalidate(false);
4431 if ( __pFooterLabel != null)
4433 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4436 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4442 if (__pFindWordBgLabel != null)
4444 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4445 if (pBitmap != null)
4447 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4452 if (__pFindWordBgLabelRightToLeft != null)
4454 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4455 if (pBitmap != null)
4457 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4463 if(__pOptionMenu != null)
4464 __pOptionMenu->SetShowState(false);
4466 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4468 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4472 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4477 AppLog("__pFooterPanel->GetShowState() is true");
4479 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4480 __pFooterPanel->Invalidate(true);
4484 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4485 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4487 InitMostVisitedSitesView(orientationStatus);
4490 RelayoutControls(false);
4491 if (__pArticleReaderPanel != null)
4493 if (__pArticleReaderPanel->GetShowState() == true)
4495 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4497 if (__pBlankPanel != null)
4498 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4500 if (__pWebReader != null)
4502 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4504 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4505 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4507 if ( pBitmap != null && pSrcBitmap != null)
4509 AppLog("CreateReaderPanel ninepatchbitmap found");
4510 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4513 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4514 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4515 if (pBitmap != null)
4520 if (pSrcBitmap != null)
4529 if (__pAddressbar != null)
4531 int width = GetClientAreaBounds().width;
4532 __pAddressbar->OrientationChanged(width);
4537 MainForm::OnSettingsChange(int settingvalue)
4539 AppLogDebug("MainForm::OnSettingsChange entered");
4541 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4543 __pAddressbar->ResetGuideText();
4545 if (__pWebViewer == null)
4547 AppLogDebug("Webviewer is not initialized yet.");
4551 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4553 WebSetting settings = __pWebViewer->GetSetting();
4554 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4556 settings.SetAutoFittingEnabled(true);
4558 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4560 settings.SetAutoFittingEnabled(false);
4562 __pWebViewer->SetSetting(settings);
4564 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4566 WebSetting settings = __pWebViewer->GetSetting();
4567 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4568 __pWebViewer->SetSetting(settings);
4570 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4572 WebSetting settings = __pWebViewer->GetSetting();
4573 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4574 __pWebViewer->SetSetting(settings);
4575 __pWebViewer->Reload();
4577 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4579 WebSetting settings = __pWebViewer->GetSetting();
4580 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4581 __pWebViewer->SetSetting(settings);
4583 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4587 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4590 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4594 WebSetting settings = __pWebViewer->GetSetting();
4595 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4596 __pWebViewer->SetSetting(settings);
4599 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4603 WebSetting settings = __pWebViewer->GetSetting();
4604 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4605 __pWebViewer->SetSetting(settings);
4608 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4610 WebSetting settings = __pWebViewer->GetSetting();
4611 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4613 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4617 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4619 __pWebViewer->SetSetting(settings);
4621 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4625 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4626 WebSetting settings = __pWebReader->GetSetting();
4627 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4628 __pWebReader->SetSetting(settings);
4634 MainForm::OnSettingsReset()
4638 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4639 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4644 MainForm::OnClearCache()
4646 result r = E_SUCCESS;
4648 if (__pWebViewer != NULL)
4650 r = __pWebViewer->ClearCache();
4653 AppLogDebug("Cache cleared success");
4657 AppLogDebug("Cache cleared fail");
4663 MainForm::OnClearCookie()
4665 result r = E_SUCCESS;
4667 if (__pWebViewer != NULL)
4669 __pWebViewer->ClearCookie();
4673 AppLogDebug("Cookie cleared success");
4677 AppLogDebug("Cache cleared fail");
4682 MainForm::OnClearFormData()
4684 result r = E_SUCCESS;
4686 if (__pWebViewer != NULL)
4688 __pWebViewer->ClearFormData();
4692 AppLogDebug("Cookie cleared success");
4696 AppLogDebug("Cache cleared fail");
4701 MainForm::OnClearPasswords()
4703 result r = E_SUCCESS;
4705 if (__pWebViewer != NULL)
4707 __pWebViewer->ClearLoginFormData();
4711 AppLogDebug("Cookie cleared success");
4715 AppLogDebug("Cache cleared fail");
4721 MainForm::findDistance(int x1,int y1,int x2, int y2)
4723 int deltaX = Math::Abs(x2 - x1);
4724 int deltaY = Math::Abs(y2 - y1);
4725 double num = deltaX*deltaX + deltaY*deltaY;
4731 for (i = 0; i < 20; i++)
4733 x = (((x*x)+ num)/(2*x));
4744 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4746 AppLog("xyz:: MainForm::OnTouchPressed called");
4747 if(__pFindWordControl)
4749 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4750 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4752 //__isLongPressedDone = false;
4757 IList* pList = null;
4758 pList = touch.GetTouchInfoListN(source);
4762 int count = pList->GetCount();
4765 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4766 __touchPoint1 = pTouchInfo->position;
4768 /*if (__pAddressbar != null)
4770 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4772 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4774 __pAddressbar->SaveAddressbarEditText();
4776 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4779 __pAddressbar->Invalidate(true);
4781 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4783 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4785 //__pAddressbar->SaveAddressbarEditText();
4787 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4790 else if (count == 2)
4792 AppLogDebug("MainForm::OnTouchPressed count is two");
4793 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4794 __touchPoint1 = pTouchInfo->position;
4796 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4797 __touchPoint2 = pTouchInfo->position;
4802 pList->RemoveAll(true);
4806 __pAddressbar->SetShowState(false);
4807 RelayoutControls(false);
4812 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4814 // __currentWordIndex = 0;
4815 //__isLongPressedDone = false;
4820 MainForm::MoveUiControls()
4825 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4827 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4829 if(__pFooterUrlField->GetTextLength() == 0)
4831 __pFooterUrlField->SetKeypadActionEnabled(false);
4835 __pFooterUrlField->SetKeypadActionEnabled(true);
4838 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4840 __currentSearchStr = __pFindWordEditField->GetText();
4841 if (__currentSearchStr.GetLength() > 0)
4843 __pFindWordCountLabel->SetShowState(true);
4847 __pFindWordCountLabel->SetShowState(false);
4849 __pFindWordNext->SetEnabled(false);
4850 __pFindWordPrev->SetEnabled(false);
4851 __pFindWordNext->Invalidate(true);
4852 __pFindWordPrev->Invalidate(true);
4853 __pFindWordCountLabel->SetText(L"0/0");
4854 __pFindWordCountLabel->Invalidate(true);
4856 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4858 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4859 if (__currentSearchStr.GetLength() > 0)
4861 __pFindWordCountLabelRightToLeft->SetShowState(true);
4865 __pFindWordCountLabelRightToLeft->SetShowState(false);
4868 __pFindWordNext->SetEnabled(false);
4869 __pFindWordPrev->SetEnabled(false);
4870 __pFindWordNext->Invalidate(true);
4871 __pFindWordPrev->Invalidate(true);
4872 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4873 __pFindWordCountLabelRightToLeft->Invalidate(true);
4875 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4876 if (__currentSearchStr.GetLength() > 0)
4882 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4884 __currentSearchStr = L"";
4885 AppLogDebug("Enter something");
4890 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4897 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4899 if(__pWebViewer != null)
4902 AppLog("MainForm::InitMostVisitedSitesView");
4903 result r = E_SUCCESS;
4906 if (__pWebViewer != null && __pMostVisitedListView != null)
4911 if (__pMostVisitedListView != null)
4913 RemoveControl(__pMostVisitedListView);
4915 if(__pMostVisitedSites != null)
4917 __pMostVisitedSites->RemoveAll(true);
4920 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4922 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4923 __pMostVisitedListView = new(std::nothrow) ListView();
4925 int height = GetClientAreaBounds().height;
4927 if(__pFooterPanel->GetShowState() == true)
4929 height = height - __pFooterPanel->GetHeight();
4931 if(__pAddressbar->GetShowState() == true)
4933 height -= __pAddressbar->GetHeight();
4936 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4940 delete __pMostVisitedListView;
4941 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4944 __pMostVisitedListView->SetItemProvider(*this);
4945 __pMostVisitedListView->AddListViewItemEventListener(*this);
4946 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4947 AddControl(__pMostVisitedListView);
4948 __pMostVisitedListView->UpdateList();
4955 MainForm::GetImagePath(void)
4959 String formattedTime;
4960 DateTime currentTime;
4961 LocaleManager localManager;
4962 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4964 localManager.Construct();
4965 Locale locale = localManager.GetSystemLocale();
4966 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4968 // Get date formatter
4969 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4973 pTimeFormatter->Format(currentTime, formattedTime);
4976 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4977 String delim(L" :");
4978 StringTokenizer strTok(formattedTime, delim);
4981 String str1("GMT+00");
4982 while (strTok.HasMoreTokens())
4984 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4985 if(token.Equals(str1))
4987 AppLog("token is %ls", token.GetPointer());
4988 imageName.Append(token);
4994 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4996 result r = E_FAILURE;
4997 AppLog("Content manager 1");
4998 ContentId contentId;
4999 ContentManager contentManager;
5000 r = contentManager.Construct();
5003 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5006 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5007 Tizen::Io::Directory::Create(contentPath,true);
5008 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5010 AppLog("Already exists");
5012 else if(GetLastResult() == E_SUCCESS)
5014 AppLog("created success");
5016 contentPath.Append(imageName);
5017 contentPath.Append(".jpg");
5018 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5019 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5023 MainForm::SetForwardButtonEnabled(bool isEnabled)
5025 __pGoForwardBtn->SetEnabled(isEnabled);
5026 __pGoForwardBtn->Invalidate(true);
5030 MainForm::SetBackButtonEnabled(bool isEnabled)
5032 __pGoBackBtn->SetEnabled(isEnabled);
5033 __pGoBackBtn->Invalidate(true);
5037 MainForm::UpdateProgress(int percentage)
5039 __progressPercentage = percentage;
5040 if (percentage == 0 || percentage == 100)
5042 __isLoadingData = false;
5043 if (percentage == 100)
5045 __isLoadingCompleted = true;
5046 __progressPercentage = 0;
5050 __isLoadingCompleted = false;
5055 __isLoadingData = true;
5057 UpdateProgressBitmap();
5061 MainForm::GetProgress(void)
5063 return __progressPercentage;
5067 MainForm::UpdateProgressBitmap(void)
5069 result r = E_SUCCESS;
5070 if (__pProgressbarLabel == null)
5072 int w = __pProgressbarLabel->GetWidth();
5073 int h = __pProgressbarLabel->GetHeight();
5075 int progressWidth = 0;
5076 Bitmap* pRetBitmap = null;
5078 if (__progressPercentage == 0 || __progressPercentage == 100)
5080 __pProgressbarLabel->SetShowState(false);
5081 __pProgressbarLabel->Invalidate(false);
5086 __pProgressbarLabel->SetShowState(true);
5087 __pProgressbarLabel->Invalidate(false);
5090 r = canvas.Construct(Rectangle(0, 0, w, h));
5094 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5099 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5103 pBgBmp->Scale(Dimension(w, h));
5104 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5108 progressWidth = (double) (w) * __progressPercentage / 100;
5109 AppLogDebug("progressWidth: %d", progressWidth);
5110 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5112 if (pProgressBmp != null)
5114 pProgressBmp->Scale(Dimension(progressWidth, h));
5115 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5116 delete pProgressBmp;
5119 pRetBitmap = new (std::nothrow) Bitmap();
5121 if (pRetBitmap == null)
5123 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5127 pRetBitmap->Construct(canvas, canvas.GetBounds());
5129 if (__pProgressbarLabel != null && pRetBitmap != null)
5131 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5132 __pProgressbarLabel->Invalidate(false);
5135 if (pRetBitmap != null)
5144 MainForm::ReaderClicked()
5146 result r = E_SUCCESS;
5147 ArrayList* pArgList = new(std::nothrow) ArrayList();
5148 if (pArgList != null)
5150 r = pArgList->Construct();
5157 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5164 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5171 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5179 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5185 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5187 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5189 __currentAddMode = addMode;
5193 case ADDRESSBAR_MODE_INVALID:
5198 case ADDRESSBAR_MODE_READER:
5200 __pStopBtn->SetShowState(false);
5201 __pRefreshBtn->SetShowState(false);
5202 __pClearBtn->SetShowState(false);
5203 __pReaderBtn->SetShowState(false);
5206 case ADDRESSBAR_MODE_LOADING:
5208 __pRefreshBtn->SetShowState(false);
5209 __pStopBtn->SetShowState(true);
5210 __pClearBtn->SetShowState(false);
5211 __pReaderBtn->SetShowState(false);
5214 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5216 // SetUrl(__pAddressbar->GetUrl());
5218 __pRefreshBtn->SetShowState(true);
5219 __pStopBtn->SetShowState(false);
5220 __pClearBtn->SetShowState(false);
5221 __pReaderBtn->SetShowState(false);
5224 case ADDRESSBAR_MODE_EDIT:
5226 __pRefreshBtn->SetShowState(false);
5227 __pStopBtn->SetShowState(false);
5228 __pReaderBtn->SetShowState(false);
5229 __pClearBtn->SetShowState(true);
5236 OnAddressBarModeChanged();
5239 AddressBarMode MainForm::GetAddressbarMode(void)
5241 return __currentAddMode;
5244 void MainForm::SetUrl(const String& url)
5247 if(__displayUrl.GetLength() > 2048)
5248 __displayUrl.SubString(0,2048,__displayUrl);
5250 if (__pFooterUrlField != NULL)
5252 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5253 if (removedHttpUrl.IsEmpty() == false)
5255 __pFooterUrlField->SetText(removedHttpUrl);
5256 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5257 __pAddressbar->SetUrl(__displayUrl);
5261 __pFooterUrlField->SetText(__displayUrl);
5262 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5263 __pAddressbar->SetUrl(__displayUrl);
5265 if(__pFooterUrlField)
5266 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5267 __pFooterUrlField->Invalidate(false);
5268 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5269 __pAddressbar->Invalidate(true);
5270 // __pFooterUrlField->SetCursorPosition(0);
5275 MainForm::RemoveHttpTextFromDisplayURL(void)
5277 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5279 // bool isHttpText = __displayUrl.Contains(L"http://");
5280 String updatedDisplayUrl;
5281 updatedDisplayUrl.Clear();
5282 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5284 __displayUrl.SubString(7,updatedDisplayUrl);
5286 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5288 __displayUrl.SubString(8,updatedDisplayUrl);
5290 return updatedDisplayUrl;
5293 void MainForm::OnSharePopupControlStarted(void)
5295 __pWebViewer->AddTouchEventListener(*this);
5299 MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5301 if (requestId == BACK_GROUND_APP_EVENT)
5303 if(__pWebViewer != null)
5305 __pWebViewer->Pause();
5307 if(__pAddressbar != null)
5309 __pAddressbar->SendUserEvent(BACK_GROUND_APP_EVENT,NULL);
5312 else if(requestId == FORE_GROUND_APP_EVENT)
5314 if(__pWebViewer != null)
5316 __pWebViewer->Resume();
5318 if(__pAddressbar != null)
5320 __pAddressbar->SendUserEvent(FORE_GROUND_APP_EVENT,NULL);
5326 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5328 AppLog("XYZ::MainForm::AddressBarCancelledClicked");
5329 result r = E_SUCCESS;
5332 __pAddressbar->SetShowState(false);
5334 //AppLog("akjshdasd 5");
5335 //__pFooterPanel->SetShowState(true);
5338 __pWebViewer->SetFocus();
5339 else if(__pMostVisitedListView)
5340 __pMostVisitedListView->SetFocus();
5341 else if(__pMultiWindowButton)
5342 __pMultiWindowButton->SetFocus();
5343 else if(__pMoreButton)
5344 __pMoreButton->SetFocus();
5346 __pAddressbar->SetShowState(false);
5348 RelayoutControls(false);
5352 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5354 AppLog("MainForm::OnFormMenuRequested called");
5356 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5358 int bookmarkCount=0;
5361 url=__pWindowInfo->pageUrl;
5362 result r = E_SUCCESS;
5363 Bitmap* pBitmap = null;
5365 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5368 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5373 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5377 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5379 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5381 if (__pOptionMenu->GetItemCount() == 9)
5383 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5387 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5392 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5396 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5397 if (__pOptionMenu->GetItemCount() != 9)
5399 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5400 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5401 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5402 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5403 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5404 __pOptionMenu->SetMaxVisibleItemsCount(6);
5406 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5408 AppLog(" Orientation landscape");
5409 __pOptionMenu->SetMaxVisibleItemsCount(5);
5413 AppLog(" Orientation potrait");
5414 __pOptionMenu->SetMaxVisibleItemsCount(6);
5417 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5420 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5421 __pOptionMenu->SetShowState(true);
5422 __pOptionMenu->Invalidate(true);
5423 __pOptionMenu->Show();