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 "IntNotificationPanel.h"
36 #include "IntSceneRegister.h"
37 #include "IntSettingPresentationModel.h"
39 using namespace Tizen::App;
40 using namespace Tizen::Base;
41 using namespace Tizen::Base::Collection;
42 using namespace Tizen::Base::Runtime;
43 using namespace Tizen::Base::Utility;
44 using namespace Tizen::Graphics;
45 using namespace Tizen::Io;
46 using namespace Tizen::Locales;
47 using namespace Tizen::Media;
48 using namespace Tizen::Ui;
49 using namespace Tizen::Ui::Controls;
50 using namespace Tizen::Content;
51 using namespace Tizen::Ui::Scenes;
52 using namespace Tizen::System;
53 using namespace Tizen::Web;
54 using namespace Tizen::Web::Controls;
56 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
57 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
58 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
59 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
65 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
66 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
67 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
68 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
70 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
71 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
72 static const wchar_t* IDS_APPID = L"AppID";
73 static const wchar_t* IDS_KEY = L"key";
74 static const wchar_t* IDS_VALUE = L"value";
75 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
76 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
77 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
79 const int IDA_BACKBTN_CLICKED = 101;
80 const int IDA_BOOKMARKBTN_CLICKED = 102;
81 const int IDA_MOREBTN_CLICKED = 103;
82 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
83 const int IDA_NEWWINDOWBTN_CLICKED = 105;
84 const int IDA_FORWARD_CLICKED = 106;
85 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
86 const int IDA_SHARE_CLICKED = 108;
87 const int IDA_FINDONPAGE_CLICKED = 109;
88 const int IDA_PRIVATEON_CLICKED = 110;
89 const int IDA_SETTINGS_CLICKED = 111;
90 const int IDA_READER_CLOSE_CLICKED = 112;
91 const int IDA_SMALLFONT_BTN_CLICKED = 113;
92 const int IDA_LARGEFONT_BTN_CLICKED = 114;
93 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
94 const int IDA_HISTORY_CLICKED = 116;
95 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
96 const int IDA_ADD_TO_HOME_CLICKED = 118;
97 const int IDA_SAVED_PAGES_CLICKED = 119;
98 const int IDA_DESKTOP_VIEW_CLICKED = 120;
99 const int IDA_SAVE_CLICKED = 121;
100 const int IDA_PRINT_CLICKED = 122;
102 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
103 const int IDA_FINDWORD_NEXT_CLICKED = 202;
104 const int IDA_FINDWORD_PREV_CLICKED = 203;
105 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
106 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
108 const int IDA_COPY_IMAGE_CLICKED = 206;
109 const int IDA_VIEW_IMAGE_CLICKED = 207;
110 const int IDA_SAVE_IMAGE_CLICKED = 208;
111 const int IDA_SHARE_IMAGE_CLICKED = 209;
113 const int IDA_COPY_TEXT_CLICKED = 210;
114 const int IDA_PASTE_TEXT_CLICKED = 211;
115 const int IDA_FIND_TEXT__CLICKED = 212;
116 const int IDA_SHARE_TEXT_CLICKED = 213;
118 const int IDA_GO_BACK = 214;
119 const int IDA_GO_FORWARD = 215;
120 const int IDA_REFRESH_BTN_CLICKED = 216;
121 const int IDA_STOP_BTN_CLICKED = 217;
122 const int IDA_CLEAR_URL = 218;
123 const int IDA_READER_BTN_CLICKED = 219;
126 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
127 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
128 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
129 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
131 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
133 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
135 const int MainForm::IDA_FORMAT_BITMAP = 500;
136 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
137 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
138 const int MainForm::IDA_FORMAT_URL_STRING = 503;
139 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
141 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
142 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
143 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
145 MainForm::MainForm(void)
147 //__isLongPressedDone = false;
149 __pAddressbar = null;
150 // __pMostVisitedSitesPanel = null;
151 __pMostVisitedListView = null;
152 __pFooterPanel = null;
153 __pHitElementResult = null;
154 __pWindowInfo = null;
158 __pOptionMenu = null;
159 __pFindWordControl = null;
160 __pFindWordPanelLeftToRight = null;
161 __pFindWordPanelRightToLeft = null;
162 __pFindWordBgLabel = null;
163 __pFindWordBgLabelRightToLeft = null;
164 __pFindWordEditField = null;
165 __pFindWordEditFieldRightToLeft = null;
166 __pFindWordClear = null;
167 __pFindWordClearRightToLeft = null;
168 __pFindWordCountLabel = null;
169 __pFindWordClearRightToLeft = null;
170 __pFindWordNext = null;
171 __pFindWordPrev = null;
172 __previousZoomLevel = 1.0;
174 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
177 __currentSearchStr = L"";
178 __currentSelectedStr = L"";
179 __maxOccurrances = 0;
180 __currentWordIndex = 0;
183 //__inputEventToBeSupressed = false;
184 __isLoadingData = false;
185 __isLoadingCompleted = false;
186 __progressPercentage = 0;
187 __touchPoint1 = Point(-1,-1);
188 __touchPoint2 = Point(-1,-1);
189 __longPressPoint = Point(-1,-1);
191 // __pReaderPopup = null;
192 __pReaderData = null;
194 __pReaderCloseBtn = null;
195 //__pNewWindowButton = null;
196 __pMoreButton = null;
197 __pMultiWindowButton = null;
198 __pArticleReaderPanel = null;
199 __pBlankPanel = null;
200 __pArticleReaderLabel = null;
201 __webControlHeight = 0;
202 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
203 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
204 __pMostVisitedSites = null;
205 __pFooterUrlField = null;
207 __pGoForwardBtn = null;
208 __pRefreshBtn = null;
209 __pProgressbarLabel = null;
210 __pFooterLabel = null;
214 __isWebKeypadOpened = false;
216 __isHwKeySupported = false;
219 MainForm::~MainForm(void)
221 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
225 __pAddressbar->SetAddressbarEventListener(null);
228 if(__pHistory != null)
234 if (__pReaderData != null)
236 delete __pReaderData;
237 __pReaderData = null;
240 if (__pPopUp != null)
246 if (__pHitElementResult != null)
248 delete __pHitElementResult;
249 __pHitElementResult = null;
252 String* pSelectedScene = NULL;
253 Object* pValue = NULL;
254 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
255 pSelectedScene = (String*) pValue;
257 /*if (pSelectedScene != null)
259 delete pSelectedScene;
261 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
265 MainForm::Initialize(void)
267 InternetApp* pInternet = static_cast<InternetApp*> (Application::GetInstance());
272 __isHwKeySupported = pInternet->IsHwBackKeyExists();
274 if(__isHwKeySupported)
276 Construct(L"IDL_FORM_HW_KEY");
280 Construct(L"IDL_FORM");
282 // SetFormStyle(FORM_STYLE_NORMAL | FORM_STYLE_INDICATOR | FORM_STYLE_HEADER);
287 MainForm::OnInitializing(void)
289 AppLog("get client area width = %d",GetClientAreaBounds().width);
290 AppLog("get client area height = %d",GetClientAreaBounds().height);
291 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
292 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
294 __fontSize = CommonUtil::GetFontSize();
295 Panel* pFooterPanel = null;
297 __pSaveImage = new Image();
298 __pSaveImage->Construct();
300 // Setup back event listener
301 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
302 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
303 AddOrientationEventListener(*this);
305 AppLogDebug(" MainForm::OnInitializing ended");
306 if (__pMostVisitedSites == null)
308 __pMostVisitedSites = new(std::nothrow) ArrayList();
309 __pMostVisitedSites->Construct();
311 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
313 __pItemContext= new(std::nothrow) ListContextItem();
314 __pItemContext->Construct();
315 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
316 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
318 if (pBitmapNormal != null && pBitmapPressed != null)
320 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
323 if (pBitmapNormal != null)
325 delete pBitmapNormal;
328 if (pBitmapPressed != null)
330 delete pBitmapPressed;
333 __pItemContextLandscape= new(std::nothrow) ListContextItem();
334 __pItemContextLandscape->Construct();
335 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
336 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
338 if (pBitmapNormal != null && pBitmapPressed != null)
340 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
343 if (pBitmapNormal != null)
345 delete pBitmapNormal;
348 if (pBitmapPressed != null)
350 delete pBitmapPressed;
352 SetFormMenuEventListener(this);
357 MainForm::InitAddressbar(void)
359 AppLogDebug("MainForm::InitAddressbar entered");
361 result r = E_SUCCESS;
363 if (__pAddressbar != null)
367 __pAddressbar = new(std::nothrow) Addressbar();
368 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
369 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
372 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
375 __pAddressbar->SetAddressbarEventListener(this);
376 AddControl(__pAddressbar);
377 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
378 SetControlAlwaysOnTop(*__pAddressbar, true);
379 __adressPanelPosition = __pAddressbar->GetPosition();
381 AppLogDebug("MainForm::InitAddressbar exit");
387 MainForm::CreateReaderPanel(void)
389 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
390 result r = E_FAILURE;
392 Button *pSmallFontBtn = null;
393 Button *pLargeFontBtn = null;
395 __pBlankPanel = new (std::nothrow) Panel();
396 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
398 __pArticleReaderPanel = new (std::nothrow) Panel();
399 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
401 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
402 if (__pReaderCloseBtn)
404 AppLogDebug("CreateReaderPanel() 6");
405 __pReaderCloseBtn->AddActionEventListener(*this);
406 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
409 __pWebReader = new (std::nothrow) Web();
410 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
412 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
413 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
415 r = __pWebReader->SetSetting(settings);
417 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
420 __pArticleReaderLabel = new Label();
421 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
423 __pBlankPanel->AddControl(__pArticleReaderLabel);
424 __pBlankPanel->AddControl(__pArticleReaderPanel);
425 AddControl(__pBlankPanel);
427 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
428 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
429 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
431 __pArticleReaderPanel->AddControl(__pWebReader);
432 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
433 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
434 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
436 if (pBitmap != null && pSrcBitmap != null)
438 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
440 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
442 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
445 pSmallFontBtn->AddActionEventListener(*this);
446 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
449 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
452 pLargeFontBtn->AddActionEventListener(*this);
453 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
462 if (pSrcBitmap != null)
468 SetControlAlwaysOnTop(*__pBlankPanel, true);
469 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
476 MainForm::InitWebControl()
478 AppLogDebug("MainForm::InitWebControl enter");
479 result r = E_SUCCESS;
480 AppLogDebug("InitWebControl");
482 if (__pAddressbar == null || __pFooterPanel == null)
485 const int Y_WEBCONTROL_POSITION = 0;
486 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
487 if (__pMostVisitedListView)
489 __pMostVisitedListView->SetShowState(false);
491 if (__pWebViewer != null)
493 AppLogDebug("Already initialized");
496 __pWebViewer = new(std::nothrow) Web();
497 if(__pWebViewer == NULL)
499 AppLogDebug("Initialization failed");
502 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
506 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
513 r = AddControl(__pWebViewer);
519 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
522 __webControlPosition = __pWebViewer->GetPosition();
523 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
526 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
530 __pWebViewer->SetLoadingListener(this);
531 __pWebViewer->SetWebUiEventListener(this);
532 __pWebViewer->SetWebKeypadEventListener(this);
533 __pWebViewer->SetFocus();
534 __pWebViewer->AddTouchEventListener(*this);
536 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
537 __pWebViewer->SetTextSearchListener(this);
540 AppLogDebug("MainForm :before return");
542 AppLogDebug("MainForm::InitWebControl Exit");
548 MainForm::OnFocusGained(const Control& source)
550 AppLog("MainForm::OnFocusGained");
554 MainForm::OnFocusLost(const Control& source)
556 AppLog("MainForm::OnFocusLost");
560 MainForm::SetJavascriptEnabled()
562 WebSetting settings = __pWebViewer->GetSetting();
563 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
564 __pWebViewer->SetSetting(settings);
568 MainForm::SetImageLoadEnabled()
570 WebSetting settings = __pWebViewer->GetSetting();
571 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
572 __pWebViewer->SetSetting(settings);
576 MainForm::InitFooter(void)
578 AppLogDebug("MainForm::InitFooter entered");
579 Button* pBackButton = null;
580 Button* pBookmarkButton = null;
581 Button* pMultiWindowButton = null;
582 Bitmap *pIconBitmap = null;
583 Bitmap *pBGBitmap = null;
584 Label *pBGLabel = null;
586 if (__pFooterPanel == null)
588 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
591 if (__pFooterPanel == null)
596 SetControlAlwaysOnTop(*__pFooterPanel, true);
598 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
599 if ( __pFooterLabel == NULL )
603 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
604 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
607 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
611 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
613 if ( __pMultiWindowButton == NULL )
618 if(__isHwKeySupported == false)
620 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
622 if ( __pMoreButton == NULL )
629 SetFormBackEventListener(this);
632 if (__pMultiWindowButton != null)
634 Bitmap* pBitmap = null;
635 Bitmap* pPressedBitmap = null;
636 String imagePath = "I01_toolbar_icon_windows_manager_0";
637 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
638 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
639 imagePath.Append(totalCount);
640 imagePath.Append(".png");
642 pressedImagePath.Append(totalCount);
643 pressedImagePath.Append("_press.png");
645 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
646 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
647 if ( pBitmap == null )
652 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
655 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
656 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
661 __pMultiWindowButton->AddActionEventListener(*this);
662 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
667 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
668 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
671 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
672 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
673 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
677 __pMoreButton->AddActionEventListener(*this);
678 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
681 //Add the editfield for url
682 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
683 if (__pFooterUrlField == NULL)
685 return E_INVALID_KEY;
688 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
689 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
690 __pFooterUrlField->AddKeypadEventListener(*this);
691 __pFooterUrlField->SetPropagatedTouchEventListener(this);
693 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
695 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
697 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
699 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
703 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
704 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
708 //Add the go Back Button
709 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
710 if (__pGoBackBtn == NULL)
712 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
713 return E_INVALID_KEY;
715 __pGoBackBtn->SetActionId(IDA_GO_BACK);
716 __pGoBackBtn->AddActionEventListener(*this);
718 //Add the go forward Button
719 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
720 if (__pGoForwardBtn == NULL)
722 AppLogDebug("Control not found returning E_INVALID_KEY");
723 return E_INVALID_KEY;
725 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
726 __pGoForwardBtn->AddActionEventListener(*this);
727 if (__pWebViewer && __pWebViewer->CanGoForward())
729 SetForwardButtonEnabled(true);
733 SetForwardButtonEnabled(false);
736 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
737 if (__pRefreshBtn == NULL)
739 AppLogDebug("Control not found returning E_INVALID_KEY");
740 return E_INVALID_KEY;
743 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
744 __pRefreshBtn->AddActionEventListener(*this);
745 __pRefreshBtn->SetShowState(true);
747 //Add the backround label for displaying progressbar
748 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
749 if (__pProgressbarLabel == NULL)
751 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
752 return E_INVALID_KEY;
754 __pProgressbarLabel->SetShowState(false);
756 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
757 if (__pStopBtn == NULL)
759 AppLogDebug("Control not found returning E_INVALID_KEY");
760 return E_INVALID_KEY;
762 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
763 __pStopBtn->AddActionEventListener(*this);
764 __pStopBtn->SetShowState(false);
766 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
767 if (__pClearBtn == NULL)
769 AppLogDebug("Control not found returning E_INVALID_KEY");
770 return E_INVALID_KEY;
772 __pClearBtn->SetActionId(IDA_CLEAR_URL);
773 __pClearBtn->AddActionEventListener(*this);
774 __pClearBtn->SetShowState(false);
776 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
777 if (__pReaderBtn == NULL)
779 AppLogDebug("Control not found returning E_INVALID_KEY");
780 return E_INVALID_KEY;
782 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
783 __pReaderBtn->AddActionEventListener(*this);
784 __pReaderBtn->SetShowState(false);
786 // __pFooterPanel->Invalidate(true);
787 AppLogDebug("MainForm::InitFooter exit");
792 MainForm::InitContextMenu(Point& p)
794 result r = E_SUCCESS;
795 bool isPrivateBrowsing = false;
796 Bitmap* pBitmap = null;
800 __pMenu->SetAnchorPosition(p);
801 __pMenu->Invalidate(true);
805 __pMenu = new(std::nothrow) ContextMenu();
806 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
807 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
809 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
812 if (isPrivateBrowsing == true)
814 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
818 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
821 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
823 if ( pBitmap != NULL)
825 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
828 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
829 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
830 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
833 __pMenu->SetMaxVisibleItemsCount(6);
834 __pMenu->SetShowState(false);
835 __pMenu->AddActionEventListener(*this);
836 SetControlAlwaysOnTop(*__pMenu, true);
843 MainForm::InitOptionMenu()
845 result r = E_SUCCESS;
846 bool isPrivateBrowsing = false;
847 Bitmap* pBitmap = null;
849 if (__pOptionMenu != null)
851 __pOptionMenu->Invalidate(true);
855 __pOptionMenu = new(std::nothrow) OptionMenu();
856 r = __pOptionMenu->Construct();
857 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
859 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
862 if (isPrivateBrowsing == true)
864 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
868 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
871 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
873 if ( pBitmap != NULL)
875 __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
878 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
879 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
880 r = __pOptionMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
883 __pOptionMenu->SetMaxVisibleItemsCount(6);
884 __pOptionMenu->SetShowState(false);
885 __pOptionMenu->AddActionEventListener(*this);
886 SetControlAlwaysOnTop(*__pOptionMenu, true);
892 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
894 result r = E_SUCCESS;
895 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
897 AppLog("MainForm::InitImageContextMenu clicked on image");
898 if (__pImageMenu != null)
904 __pImageMenu = new (std::nothrow) ContextMenu();
905 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
906 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
908 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
909 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
910 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
911 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
912 __pImageMenu->SetMaxVisibleItemsCount(4);
913 __pImageMenu->AddActionEventListener(*this);
914 SetControlAlwaysOnTop(*__pImageMenu, true);
920 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
922 result r = E_SUCCESS;
923 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
925 AppLog("MainForm::InitImageContextMenu clicked on image");
926 if (__pImageMenu != null)
932 if(__pAddressbar->GetShowState() == true)
933 p.y = p.y + __pAddressbar->GetHeight();
935 __pImageMenu = new (std::nothrow) ContextMenu();
936 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
937 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
939 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
940 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
941 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
942 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
944 __pImageMenu->SetMaxVisibleItemsCount(3);
945 __pImageMenu->AddActionEventListener(*this);
946 SetControlAlwaysOnTop(*__pImageMenu, true);
953 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
955 result r = E_SUCCESS;
956 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
958 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
959 if (__pImageMenu != null)
968 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
972 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
974 __pImageMenu = new (std::nothrow) ContextMenu();
975 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
976 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
978 if(onlyPasteOption == false)
980 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
982 if (pasteOption || onlyPasteOption)
984 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
986 if(onlyPasteOption == false)
988 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
989 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
992 __pImageMenu->SetMaxVisibleItemsCount(3);
993 __pImageMenu->AddActionEventListener(*this);
994 SetControlAlwaysOnTop(*__pImageMenu, true);
1001 MainForm::InitFindWordPanel(void)
1003 result r = E_SUCCESS;
1004 Bitmap *pIconBitmap = null;
1006 if (__pFindWordControl != null)
1008 AppLogDebug("Findword panel already initialized");
1009 if (__pFindWordBgLabel != null)
1011 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1012 if (pBitmap != null)
1014 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1018 if (__pFindWordBgLabelRightToLeft != null)
1020 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
1021 if (pBitmap != null)
1023 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1030 __pFindWordControl = new (std::nothrow) Panel();
1031 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
1034 AppLogException("There is some problem in the xml file. Please check.");
1037 AddControl(__pFindWordControl);
1038 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
1039 SetControlAlwaysOnTop(*__pFindWordControl,true);
1040 __pFindWordControl->SetShowState(false);
1041 __pFindWordControl->Invalidate(false);
1043 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1044 __pFindWordPanelLeftToRight->SetShowState(true);
1046 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
1047 __pFindWordPanelRightToLeft->SetShowState(false);
1049 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
1050 if (__pFindWordBgLabel != null)
1052 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1053 Rectangle pRect = pPanel1->GetBounds();
1054 pRect.x = pRect.y = 0;
1055 __pFindWordBgLabel->SetBounds(pRect);
1056 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1057 if (pBitmap != null)
1059 AppLogDebug("InitFindWordPanel: Coming here");
1060 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
1065 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1069 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
1070 if (__pFindWordBgLabelRightToLeft != null)
1072 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
1073 Rectangle pRect = pPanel1->GetBounds();
1074 pRect.x = pRect.y = 0;
1075 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1076 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1077 if (pBitmap != null)
1079 AppLogDebug("InitFindWordPanel: Coming here");
1080 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1085 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1089 Button* pfindWordCancel = null;
1090 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1091 if (pfindWordCancel == null)
1093 AppLogException("There is some problem in the xml file. Please check.");
1096 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1097 pfindWordCancel->AddActionEventListener(*this);
1099 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1100 if (__pFindWordClear == null)
1102 AppLogException("There is some problem in the xml file. Please check.");
1106 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1107 if (__pFindWordClearRightToLeft == null)
1109 AppLogException("There is some problem in the xml file. Please check.");
1113 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1114 __pFindWordClear->AddActionEventListener(*this);
1116 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1117 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1119 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1120 if (__pFindWordNext == null)
1122 AppLogException("There is some problem in the xml file. Please check.");
1126 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1127 __pFindWordNext->AddActionEventListener(*this);
1129 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1130 if (__pFindWordPrev == null)
1132 AppLogException("There is some problem in the xml file. Please check.");
1136 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1137 __pFindWordPrev->AddActionEventListener(*this);
1139 __pFindWordNext->SetEnabled(false);
1140 __pFindWordPrev->SetEnabled(false);
1142 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1143 if (__pFindWordCountLabel == null)
1145 AppLogException("There is some problem in the xml file. Please check.");
1149 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1150 if (__pFindWordCountLabel == null)
1152 AppLogException("There is some problem in the xml file. Please check.");
1156 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1157 if (__pFindWordEditField == null)
1159 AppLogException("There is some problem in the xml file. Please check.");
1162 __pFindWordEditField->AddTextEventListener(*this);
1163 __pFindWordEditField->AddKeypadEventListener(*this);
1164 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1166 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1167 if (__pFindWordEditFieldRightToLeft == null)
1169 AppLogException("There is some problem in the xml file. Please check.");
1172 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1173 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1174 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1180 MainForm::CreateItem (int index, int itemWidth)
1182 Rectangle listImageRect;
1183 Rectangle pagetTitleRect;
1184 Rectangle pageURLRect;
1185 Rectangle deleteImageRect;
1186 String pageTitle(L"");
1187 String pageURL(L"");
1188 result r = E_SUCCESS;
1189 Bitmap* pListIconImage = null;
1192 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1193 if(pHistory == null)
1197 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1198 if ( pAppResource == NULL )
1202 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1204 CustomItem* pItem = new(std::nothrow) CustomItem();
1205 pageTitle = pHistory->GetHistoryTitle();
1206 pageURL = pHistory->GetHistoryUrl();
1208 if (pageURL.GetLength() == 0)
1211 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1212 pageURL = L"<"+ nourl +">";
1216 Rectangle screenBounds = GetBounds();
1219 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1228 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1230 if ( pBitmap != NULL)
1232 pListIconImage = new Bitmap();
1233 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1237 if(pListIconImage == null)
1239 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1242 if ( pListIconImage != NULL)
1244 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1245 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1246 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1249 if (pItem != null && pListIconImage != NULL)
1251 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1255 if (pageTitle.CompareTo(L"") != 0)
1259 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1263 if (pageURL.CompareTo(L"") != 0)
1267 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1272 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1274 if ( __pItemContext!= NULL)
1278 pItem->SetContextItem(__pItemContext);
1284 if ( __pItemContextLandscape!= NULL)
1288 pItem->SetContextItem(__pItemContextLandscape);
1292 if( pListIconImage != NULL)
1294 delete pListIconImage;
1295 pListIconImage = null;
1302 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1309 MainForm::GetItemCount (void)
1311 if(__pMostVisitedSites != null)
1313 __pMostVisitedSites->RemoveAll(true);
1315 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1316 if(__pMostVisitedSites != null)
1318 return __pMostVisitedSites->GetCount();
1325 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1327 if(__pMostVisitedSites != null)
1329 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1330 if (pHistory != null)
1332 String url = pHistory->GetHistoryUrl();
1334 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1335 __pMostVisitedListView->UpdateList();
1341 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1343 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1344 String url = pHistory->GetHistoryUrl();
1352 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1358 MainForm::OnTerminating(void)
1360 result r = E_SUCCESS;
1362 RemoveOrientationEventListener(*this);
1366 __pAddressbar->SetAddressbarEventListener(null);
1371 __pWebViewer->RemoveTouchEventListener(*this);
1376 delete __pItemContext;
1378 if(__pItemContextLandscape)
1380 delete __pItemContextLandscape;
1386 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1388 result r = E_SUCCESS;
1390 AppLogDebug("Clicked : %d", actionId);
1393 case IDA_BACKBTN_CLICKED:
1395 if (__pWebViewer && __pWebViewer->CanGoBack())
1397 __pWebViewer->GoBack();
1399 else if(__pWindowInfo->isJavascriptInitiated == false)
1402 pApp = UiApp::GetInstance();
1405 r = pApp->Terminate();
1408 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1416 WindowInfo* pWindowInfo = null;
1418 SceneManager* pSceneManager = SceneManager::GetInstance();
1419 if (pSceneManager == null)
1423 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1424 if (pAllWindowList == NULL)
1426 pApp = UiApp::GetInstance();
1429 r = pApp->Terminate();
1432 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1437 if (pAllWindowList != null)
1439 totalCount = pAllWindowList->GetCount();
1441 for (int count = 0; count < totalCount; count++)
1443 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1444 if (pWindowInfo == null)
1446 pApp = UiApp::GetInstance();
1449 r = pApp->Terminate();
1452 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1459 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1461 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1464 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1467 r = pAllWindowList->RemoveAt(count, true);
1468 __pWindowInfo = null;
1471 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1476 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1480 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1482 if (pWindowInfo == null)
1484 pApp = UiApp::GetInstance();
1487 r = pApp->Terminate();
1493 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1496 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1508 case IDA_FORWARD_CLICKED:
1509 if (__pWebViewer == null)
1512 if (__pWebViewer->CanGoForward())
1514 __pWebViewer->GoForward();
1516 if(__isHwKeySupported == true)
1518 __pOptionMenu->SetShowState(false);
1519 __pOptionMenu->Invalidate(false);
1523 __pMenu->SetShowState(false);
1524 __pMenu->Invalidate(false);
1528 case IDA_FINDONPAGE_CLICKED:
1530 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1531 __currentSearchStr.Clear();
1533 InitFindWordPanel();
1534 if(__isHwKeySupported == true)
1536 __pOptionMenu->SetShowState(false);
1537 __pOptionMenu->Invalidate(false);
1541 __pMenu->SetShowState(false);
1542 __pMenu->Invalidate(false);
1545 ShowFindWordPanel(true);
1547 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1549 __pFindWordEditField->SetFocus();
1550 __pFindWordCountLabel->SetShowState(false);
1554 __pFindWordEditFieldRightToLeft->SetFocus();
1555 __pFindWordCountLabelRightToLeft->SetShowState(false);
1559 case IDA_PRIVATEON_CLICKED:
1561 result r = E_SUCCESS;
1563 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1564 Bitmap* pBitmap = null;
1565 if (isPrivateBrowsing == true)
1567 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1570 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1574 if (__pWebViewer != NULL)
1576 __pWebViewer->SetPrivateBrowsingEnabled(false);
1579 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1581 if (__pAddressbar != null)
1583 __pAddressbar->UpdateFaviconBitmap(false);
1589 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1592 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1596 if (__pWebViewer != NULL)
1598 __pWebViewer->SetPrivateBrowsingEnabled(true);
1601 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1603 if (__pAddressbar != null)
1605 __pAddressbar->UpdateFaviconBitmap(true);
1608 if(__isHwKeySupported == true)
1610 itemIndex = __pOptionMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1611 r = __pOptionMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1612 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1613 __pOptionMenu->Invalidate(true);
1617 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1618 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1619 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1620 __pMenu->Invalidate(true);
1622 if ( pBitmap != NULL )
1629 case IDA_SETTINGS_CLICKED:
1632 ArrayList* pArgList = new(std::nothrow) ArrayList();
1635 pArgList->Construct();
1636 pArgList->Add(*__pWindowInfo);
1637 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1639 if(__isHwKeySupported)
1641 __pOptionMenu->SetShowState(false);
1642 __pOptionMenu->Invalidate(false);
1646 __pMenu->SetShowState(false);
1647 __pMenu->Invalidate(false);
1649 if (pArgList != null)
1658 case IDA_ADDTOBOOKMARK_CLICKED:
1661 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1663 int bookmarkCount=0;
1666 url=__pWindowInfo->pageUrl;
1667 result r = E_SUCCESS;
1668 Bitmap* pBitmap = null;
1669 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1677 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1678 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1679 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1681 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1682 if (pNotification != null)
1684 pNotification->SetText(message);
1685 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1686 pNotification->ShowNotification();
1691 String title=__pWindowInfo->pageTitle;
1692 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1693 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1695 pBookmark->SetBookmarkTitle(title);
1696 pBookmark->SetUrl(url);
1697 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1699 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1701 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1702 pBookmark->SetFaviconId(id);
1703 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1704 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1707 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1708 if (pNotification != null)
1710 pNotification->SetText(message);
1711 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1712 pNotification->ShowNotification();
1713 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1716 if(__isHwKeySupported == true)
1718 if (pBitmap != null)
1720 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1726 if (pBitmap != null)
1728 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1732 if(__isHwKeySupported == true)
1734 __pOptionMenu->Invalidate(true);
1738 __pMenu->Invalidate(true);
1744 case IDA_PRINT_CLICKED:
1746 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1747 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1749 AppLog("RequestPrint called!");
1750 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1751 result nResult = E_FAILURE;
1754 AppLog("TestPrint if (pAc) == true");
1759 String fileType = L"service_print_files_type";
1760 String typeVal = L"DOC";
1762 String fileCount = L"service_print_files_count";
1763 String countVal = L"1";
1764 String fileFolder= L"service_print_files_folder_name";
1765 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1767 map.Add(&fileCount, &countVal);
1768 map.Add(&fileFolder, &folderVal);
1769 map.Add(&fileType, &typeVal);
1771 String fileName = L"service_print_files_files_name";
1773 ArrayList fileNameList;
1774 fileNameList.Construct();
1775 String file1 = L"test.pdf";
1777 fileNameList.Add(&file1);
1778 map.Add(&fileName, &fileNameList);
1780 nResult = pAc->Start(NULL, NULL, &map, NULL);
1782 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1783 else if (nResult == E_MAX_EXCEEDED)
1784 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1785 else if (nResult == E_OBJ_NOT_FOUND)
1786 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1787 else if (nResult == E_IN_PROGRESS)
1788 AppLog("TestPrint ret == E_IN_PROGRESS");
1789 else if (nResult == E_PRIVILEGE_DENIED)
1790 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1791 else if(nResult == E_SYSTEM)
1792 AppLog("TestPrint ret == E_SYSTEM");
1798 int __modalMsgBoxResult;
1799 MessageBox* pMsgBox = new MessageBox();
1800 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1801 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1804 __modalMsgBoxResult = 0;
1808 case IDA_SHARE_CLICKED:
1810 if(__pPopUp != null)
1815 __pPopUp = new(std::nothrow) SharePopup();
1816 __pPopUp->Initialize();
1817 if (__pWindowInfo != null)
1819 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1820 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1821 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1822 pShareInfo->SetImageAttached(false);
1823 __pPopUp->RemoveAllShareInfo();
1824 __pPopUp->AddShareInfo(pShareInfo);
1826 __pPopUp->SetShowState(true);
1830 case IDA_BOOKMARKBTN_CLICKED:
1832 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1833 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1836 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1841 case IDA_MOREBTN_CLICKED:
1843 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1844 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1845 AppLog("Anchot pos: %d %d", p.x, p.y);
1847 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1849 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1850 int bookmarkCount=0;
1853 url=__pWindowInfo->pageUrl;
1854 result r = E_SUCCESS;
1855 Bitmap* pBitmap = null;
1857 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1860 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1865 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1869 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1871 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1873 if (__pMenu->GetItemCount() == 9)
1875 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1879 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1884 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1888 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1889 if (__pMenu->GetItemCount() != 9)
1891 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1892 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1893 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1894 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1895 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1896 __pMenu->SetMaxVisibleItemsCount(6);
1898 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1900 AppLog(" Orientation landscape");
1901 __pMenu->SetMaxVisibleItemsCount(5);
1905 AppLog(" Orientation potrait");
1906 __pMenu->SetMaxVisibleItemsCount(6);
1909 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1912 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1913 __pMenu->SetShowState(true);
1914 __pMenu->Invalidate(true);
1918 case IDA_HISTORY_CLICKED:
1920 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1921 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1924 case IDA_SAVED_PAGES_CLICKED:
1929 case IDA_DESKTOP_VIEW_CLICKED:
1934 case IDA_SAVE_CLICKED:
1939 case IDA_MULTIWINDOWBTN_CLICKED:
1941 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1942 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1946 case IDA_NEWWINDOWBTN_CLICKED:
1948 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1950 if (pNewWindowInfo == null)
1954 result r = E_SUCCESS;
1955 SceneManager* pSceneManager = SceneManager::GetInstance();
1957 if (pSceneManager == NULL)
1961 ArrayList* pArgList = new(std::nothrow) ArrayList();
1962 if (pArgList == NULL)
1966 r = pArgList->Construct();
1969 pArgList->Add(*pNewWindowInfo);
1970 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1976 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1981 case IDA_SMALLFONT_BTN_CLICKED:
1983 WebSetting setting = __pWebReader->GetSetting();
1984 setting.SetFontSize(15);
1985 __pWebReader->SetSetting(setting);
1988 case IDA_LARGEFONT_BTN_CLICKED:
1990 WebSetting setting = __pWebReader->GetSetting();
1991 setting.SetFontSize(25);
1992 __pWebReader->SetSetting(setting);
1995 case IDA_READER_CLOSE_CLICKED:
1997 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1999 RemoveControl(__pBlankPanel);
2000 __pArticleReaderPanel = null;
2001 __pBlankPanel = null;
2002 __pArticleReaderLabel = null;
2004 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2007 case IDA_FINDWORD_CANCEL_CLICKED:
2009 __currentSearchStr = L"";
2010 __currentWordIndex = 0;
2011 __maxOccurrances = 0;
2012 __pFindWordEditField->SetText(L"");
2013 __pFindWordNext->SetEnabled(false);
2014 __pFindWordPrev->SetEnabled(false);
2015 __pFindWordCountLabel->SetText(L"0/0");
2016 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
2017 AppLog("akjshdasd 1");
2018 __pFooterPanel->SetShowState(true);
2019 ShowFindWordPanel(false);
2022 case IDA_FINDWORD_SEARCH_CLICKED:
2024 __currentSearchStr = __pFindWordEditField->GetText();
2025 if (__currentSearchStr.GetLength() > 0)
2031 AppLogDebug("Enter something");
2035 case IDA_FINDWORD_CLEAR_CLICKED:
2037 __pFindWordCountLabel->SetText(L"0/0");
2038 __pFindWordEditField->SetText(L"");
2039 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2041 __currentSearchStr = L"";
2042 __pFindWordNext->SetEnabled(false);
2043 __pFindWordPrev->SetEnabled(false);
2044 __pFindWordCountLabel->SetShowState(false);
2045 __pFindWordControl->Invalidate(true);
2048 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
2050 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
2051 __pFindWordEditFieldRightToLeft->SetText(L"");
2052 __currentSearchStr = L"aaaaaabbbbbbccccccc";
2054 __currentSearchStr = L"";
2055 __pFindWordNext->SetEnabled(false);
2056 __pFindWordPrev->SetEnabled(false);
2057 __pFindWordCountLabelRightToLeft->SetShowState(false);
2058 __pFindWordControl->Invalidate(true);
2061 case IDA_FINDWORD_NEXT_CLICKED:
2066 case IDA_FINDWORD_PREV_CLICKED:
2068 FindNextWord(false);
2071 case IDA_BRIGHTNESS_BTN_CLICKED:
2073 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
2074 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2077 case IDA_COPY_IMAGE_CLICKED:
2079 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2080 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
2082 const Bitmap* pBitmap = null;
2083 if (__pHitElementResult != null)
2085 pBitmap = __pHitElementResult->GetImage();
2088 String resourcePath = App::GetInstance()->GetAppResourcePath();
2089 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
2091 // copying the item to clipboard
2092 Clipboard* pClipboard = Clipboard::GetInstance();
2093 if (pClipboard != null)
2095 pClipboard->CopyItem(item);
2099 case IDA_VIEW_IMAGE_CLICKED:
2101 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
2102 WindowInfo* pNewWindowInfo = null;
2103 if (__pHitElementResult != null)
2105 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2106 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2112 case IDA_SAVE_IMAGE_CLICKED:
2114 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
2115 const Bitmap* pSaveBitmap = null;
2116 String imageName = GetImagePath();
2117 AppLog("Content manager image name %ls",imageName.GetPointer());
2120 imagePath.Append(imageName);
2121 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2122 AppLog("Content manager image path %ls",imagePath.GetPointer());
2123 if (__pHitElementResult != null)
2125 pSaveBitmap = __pHitElementResult->GetImage();
2127 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2131 UpdateImageContent(pBuffer, imageName);
2133 NotificationPanel *pNotification = new NotificationPanel(*this);
2135 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2136 msg.Append(imagePath);
2137 if (pNotification != null)
2139 pNotification->SetText(msg);
2140 if (__pFooterPanel->GetShowState() == true)
2142 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2146 pNotification->SetPositionDiff(0);
2149 pNotification->ShowNotification();
2154 int __modalMsgBoxResult;
2155 MessageBox* pMsgBox = new MessageBox();
2156 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2157 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2160 __modalMsgBoxResult = 0;
2164 case IDA_SHARE_IMAGE_CLICKED:
2166 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2167 if (__pPopUp != null)
2172 __pPopUp = new(std::nothrow) SharePopup();
2173 __pPopUp->Initialize();
2174 if (__pHitElementResult != null)
2176 const Bitmap* pSaveBitmap = null;
2177 String imageName = GetImagePath();
2178 AppLog("Content manager image name %ls",imageName.GetPointer());
2181 imagePath.Append(imageName);
2182 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2183 AppLog("Content manager image path %ls",imagePath.GetPointer());
2184 if (__pHitElementResult != null)
2186 pSaveBitmap = __pHitElementResult->GetImage();
2188 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2190 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2191 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2193 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2194 pShareInfo->SetPageTitle(L"");
2195 pShareInfo->SetPageUrl(srcUrl);
2196 pShareInfo->SetImageAttached(true);
2197 pShareInfo->SetImagePath(imagePath);
2198 __pPopUp->RemoveAllShareInfo();
2199 __pPopUp->AddShareInfo(pShareInfo);
2200 __pPopUp->SetShowState(true);
2205 case IDA_HYPERLINK_OPEN_CLICKED:
2207 if (__pHitElementResult != null)
2209 String srcUrl = __pHitElementResult->GetUrl();
2211 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2213 if (pNewWindowInfo == null)
2217 result r = E_SUCCESS;
2218 SceneManager* pSceneManager = SceneManager::GetInstance();
2219 if (pSceneManager == NULL)
2223 ArrayList* pArgList = new(std::nothrow) ArrayList();
2224 if (pArgList == NULL)
2228 pArgList->Construct();
2230 pArgList->Add(*pNewWindowInfo);
2231 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2232 if (pArgList != null)
2239 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2245 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2247 if (__pHitElementResult == null)
2252 if(__pPopUp != null)
2257 __pPopUp = new(std::nothrow) SharePopup();
2258 __pPopUp->Initialize();
2260 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2261 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2262 pShareInfo->SetImageAttached(false);
2263 __pPopUp->RemoveAllShareInfo();
2264 __pPopUp->AddShareInfo(pShareInfo);
2266 __pPopUp->SetShowState(true);
2270 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2274 if (__pHitElementResult != null)
2276 url = __pHitElementResult->GetUrl();
2279 String resourcePath = App::GetInstance()->GetAppResourcePath();
2280 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2282 // copying the item to clipboard
2283 Clipboard* pClipboard = Clipboard::GetInstance();
2284 if (pClipboard != null)
2286 pClipboard->CopyItem(item);
2290 case IDA_FIND_TEXT__CLICKED:
2292 // AddressBarCancelledClicked(*__pAddressbar);
2293 RelayoutControls(false);
2294 // __pFooterPanel->SetShowState(false);
2295 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2296 __currentSearchStr.Clear();
2297 __currentSearchStr.Append(__currentSelectedStr);
2298 InitFindWordPanel();
2299 __pFindWordEditField->SetText(__currentSearchStr);
2300 if(__isHwKeySupported)
2302 if(__pOptionMenu != null)
2304 __pOptionMenu->SetShowState(false);
2305 __pOptionMenu->Invalidate(false);
2312 __pMenu->SetShowState(false);
2313 __pMenu->Invalidate(false);
2317 __adressPanelPosition.y = 0;
2319 if (__pAddressbar != null && __pWebViewer != NULL)
2321 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2322 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2324 if (__pFooterPanel->GetShowState() == false)
2325 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2327 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2328 __pWebViewer->Invalidate(true);
2331 ShowFindWordPanel(true);
2332 __pFindWordEditField->SetFocus();
2333 if (__currentSearchStr.GetLength() > 0)
2339 AppLogDebug("Enter something");
2342 if (__pWebViewer != null)
2344 // releasing the set block
2345 __pWebViewer->ReleaseBlock();
2350 case IDA_SHARE_TEXT_CLICKED:
2352 __pWebViewer->ReleaseBlock();
2353 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2354 if(__pPopUp != null)
2359 __pPopUp = new(std::nothrow) SharePopup();
2360 __pPopUp->Initialize();
2361 if (__pHitElementResult != null)
2363 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2364 pShareInfo->SetPageTitle(L"");
2365 pShareInfo->SetPageUrl(__currentSelectedStr);
2366 pShareInfo->SetImageAttached(false);
2367 __pPopUp->RemoveAllShareInfo();
2368 __pPopUp->AddShareInfo(pShareInfo);
2369 __pPopUp->SetShowState(true);
2374 case IDA_COPY_TEXT_CLICKED:
2376 __pWebViewer->ReleaseBlock();
2377 // need to implement
2378 //__currentSelectedStr
2379 // Sets data to a clip board item
2381 String resourcePath = App::GetInstance()->GetAppResourcePath();
2382 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2384 // copying the item to clipboard
2385 Clipboard* pClipboard = Clipboard::GetInstance();
2386 if (pClipboard != null)
2388 pClipboard->CopyItem(item);
2392 case IDA_PASTE_TEXT_CLICKED:
2394 Clipboard* pClipboard = Clipboard::GetInstance();
2396 if(pClipboard == null)
2400 // Retrieves a latest item
2401 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2407 //Gets data from the clipboard item
2408 String* pString = dynamic_cast<String*>(pItem->GetData());
2410 if (pString != null)
2412 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2413 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2414 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2417 if(idElement.GetLength() != 0)
2419 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; } } ";
2420 script.Append("insertAtCursor('");
2421 script.Append(idElement);
2422 script.Append("',");
2423 script.Append("\"");
2424 script.Append(*pString);
2425 script.Append("\");");
2427 else if (nameElement.GetLength() != 0)
2429 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; } } ";
2430 script.Append("insertAtCursor(document.getElementsByName('");
2431 script.Append(nameElement);
2432 script.Append("')[0],");
2433 script.Append("\"");
2434 script.Append(*pString);
2435 script.Append("\");");
2437 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2438 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2449 case IDA_GO_FORWARD:
2454 case IDA_REFRESH_BTN_CLICKED:
2456 __isLoadingCompleted = false;
2457 __isLoadingData = true;
2458 __progressPercentage = 0;
2459 __displayUrl = __pFooterUrlField->GetText();
2461 String url = __pFooterUrlField->GetText();
2462 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2464 __pWebViewer->Reload();
2465 if (__pAddressbar != null)
2467 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2468 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2472 UpdateProgressBitmap();
2475 case IDA_STOP_BTN_CLICKED:
2477 __isLoadingCompleted = false;
2478 __isLoadingData = false;
2479 __progressPercentage = 0;
2480 __pFooterUrlField->HideKeypad();
2481 __displayUrl = __pFooterUrlField->GetText();
2485 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2486 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2487 __pWebViewer->StopLoading();
2488 RequestRedraw(true);
2491 UpdateProgressBitmap();
2496 if (__pFooterUrlField->GetText().IsEmpty() == false)
2498 //__displayUrl = __pUrlField->GetText();
2499 __pFooterUrlField->Clear();
2504 case IDA_READER_BTN_CLICKED:
2515 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2517 result r = E_FAILURE;
2518 if (__pWebViewer && __pWebViewer->CanGoBack())
2520 __pWebViewer->GoBack();
2522 else if(__pWindowInfo->isJavascriptInitiated == false)
2525 pApp = UiApp::GetInstance();
2528 r = pApp->Terminate();
2531 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2539 WindowInfo* pWindowInfo = null;
2541 SceneManager* pSceneManager = SceneManager::GetInstance();
2542 if (pSceneManager == null)
2546 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
2547 if (pAllWindowList == NULL)
2549 pApp = UiApp::GetInstance();
2552 r = pApp->Terminate();
2555 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2560 if (pAllWindowList != null)
2562 totalCount = pAllWindowList->GetCount();
2564 for (int count = 0; count < totalCount; count++)
2566 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
2567 if (pWindowInfo == null)
2569 pApp = UiApp::GetInstance();
2572 r = pApp->Terminate();
2575 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2582 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
2584 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
2587 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2590 r = pAllWindowList->RemoveAt(count, true);
2591 __pWindowInfo = null;
2594 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2599 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
2603 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
2605 if (pWindowInfo == null)
2607 pApp = UiApp::GetInstance();
2610 r = pApp->Terminate();
2616 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
2619 AppLogException("MainForm::OnFormBackRequested failed with %s", GetErrorMessage(r));
2631 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2632 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2634 AppLog("MainForm::OnSceneActivatedN called");
2635 String* pSelectedScene = NULL;
2636 Object* pValue = NULL;
2637 String* pUrl = null;
2638 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2639 pSelectedScene = (String*) pValue;
2641 if (pSelectedScene != null)
2643 delete pSelectedScene;
2645 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2646 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2647 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2648 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2650 // setting the current scene ID
2651 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2653 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2655 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2657 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2658 if(__pWindowInfo == null)
2660 // if(__pWindowInfo == null)
2662 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2665 else if ( pArgs != null && pArgs->GetCount() == 1)
2667 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2673 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2675 // hiding the address bar
2676 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2677 __pAddressbar->SetShowState(false);
2678 // if(__pWebViewer != null)
2680 // __pWebViewer->Resume();
2683 if(pUrl != null && pUrl->GetLength() > 0)
2687 else if(__pWindowInfo != null)
2689 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)
2691 LoadUrl(__pWindowInfo->pageUrl);
2693 else if (__pWindowInfo->isJavascriptInitiated == true)
2697 __pWindowInfo->pCurrentWeb = __pWebViewer;
2701 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2702 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2703 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2705 InitMostVisitedSitesView(GetOrientationStatus());
2707 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2709 if(__pMostVisitedListView != null)
2711 __pMostVisitedListView->SetShowState(false);
2715 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2717 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2719 if (pBookmarkUrl == null)
2721 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2722 //__pAddressbar->SetUrl(*pBookmarkUrl);
2723 SetUrl(*pBookmarkUrl);
2725 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2726 __pWebViewer->LoadUrl(*pBookmarkUrl);
2727 delete pBookmarkUrl;
2730 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2731 Bitmap* pBitmap = null;
2732 if (isPrivateBrowsing == true)
2734 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2736 if (__pWebViewer != null)
2738 __pWebViewer->SetPrivateBrowsingEnabled(true);
2741 if (__pAddressbar != null)
2743 // __pAddressbar->UpdateFaviconBitmap(true);
2749 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2751 if (__pWebViewer != null)
2753 __pWebViewer->SetPrivateBrowsingEnabled(false);
2756 if (__pAddressbar != null)
2758 // __pAddressbar->UpdateFaviconBitmap(false);
2762 if(__isHwKeySupported == true)
2764 if (__pOptionMenu != null && __pOptionMenu->GetItemCount() == 3)
2766 __pOptionMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2768 else if (__pOptionMenu != null )
2770 __pOptionMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2776 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2778 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2780 else if (__pMenu != null )
2782 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2786 if (pBitmap != null)
2791 AppLog("ABC: OnSceneActivatedN started exit");
2796 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2797 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2799 Canvas* pWebCanvas = null;
2800 if (__pWebViewer != null)
2802 pWebCanvas = __pWebViewer->GetCanvasN();
2805 if (pWebCanvas == null)
2809 if (__pWindowInfo != null)
2811 if (__pWindowInfo->pWebCanvasBitmap != null)
2813 delete __pWindowInfo->pWebCanvasBitmap;
2815 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2816 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2817 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2819 Bitmap* pBitmap = GetCapturedBitmapN();
2820 AppLog("Coming here");
2821 Canvas* pCanvas = new(std::nothrow) Canvas();
2822 pCanvas->Construct(GetClientAreaBounds());
2825 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2828 if(__pWebViewer != null && __pWindowInfo != null)
2829 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2831 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2832 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2834 AppLog("Coming here");
2838 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2839 const Tizen::Base::String& realm,
2840 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2846 MainForm::OnHttpAuthenticationCanceled(void)
2851 MainForm::OnLoadingStarted(void)
2853 AppLogDebug("MainForm::OnLoadingStarted entered");
2855 if(__pAddressbar == NULL || __pWebViewer == null)
2860 // this is added in case if menu is opened and user load the page
2861 if(__isHwKeySupported == true)
2863 if(__pOptionMenu != null && __pOptionMenu->GetShowState() == true)
2865 __pOptionMenu->SetShowState(false);
2866 __pOptionMenu->Invalidate(true);
2872 if(__pMenu != null && __pMenu->GetShowState() == true)
2874 __pMenu->SetShowState(false);
2875 __pMenu->Invalidate(true);
2878 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2880 __pImageMenu->SetShowState(false);
2881 __pImageMenu->Invalidate(true);
2883 String url = __pWebViewer->GetUrl();
2884 if(url.Contains(IDS_TIZEN_SERVICE))
2887 String delim(L":;,");
2889 // Creates a StringTokenizer instance
2890 StringTokenizer strTok(url, delim);
2892 int count = strTok.GetTokenCount(); // count == 4
2894 HashMap *pMap = new HashMap();
2899 while (strTok.HasMoreTokens())
2901 AppLog("Token: %ls", token.GetPointer());
2902 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2903 if(token.Contains(IDS_APPID))
2905 token.SubString(6, appId);
2906 AppLog("AppID:%ls", appId.GetPointer());
2908 else if(token.Contains(IDS_KEY))
2910 token.SubString(4, key);
2911 AppLog("key:%ls", key.GetPointer());
2913 else if(token.Contains(IDS_VALUE))
2915 token.SubString(6, value);
2916 AppLog("value:%ls", value.GetPointer());
2919 pMap->Add(key, value);
2923 AppControl *pAppControl = null;
2924 String operationId = L"http://tizen.org/appcontrol/operation/main";
2925 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2928 AppLog("Starting AppControl");
2929 result r = pAppControl->Start(null, null, pMap, null);
2930 AppLog("Result of Start %s", GetErrorMessage(r));
2934 AppLogException("AppControl not found");
2939 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2941 __pAddressbar->SetShowState(false);
2942 AddressBarCancelledClicked(*__pAddressbar);
2943 __pAddressbar->Invalidate(true);
2945 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2948 __pAddressbar->SetFaviconBitmap(*pBitmap);
2951 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2953 // updating the address bar position with respect to web control
2954 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2955 __distanceMoved = 0;
2959 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2960 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2961 if (__pWebViewer != null)
2963 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2964 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2965 SetUrl(__pWebViewer->GetUrl());
2966 if (__pWindowInfo != NULL)
2968 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2969 __pWindowInfo->pageTitle = L"";
2970 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2972 __pAddressbar->Invalidate(true);
2978 MainForm::OnLoadingCanceled(void)
2985 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2987 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2992 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2994 AppLog("XYZ::MainForm::OnKeypadOpened");
2995 __pFooterPanel->SetShowState(false);
3000 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
3002 AppLog("XYZ::MainForm::OnKeypadClosed");
3003 __pFooterPanel->SetShowState(true);
3004 RelayoutControls(true);
3008 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
3010 AppLog("KeypadBoundsChanged");
3011 RelayoutControls(false);
3015 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
3016 const Tizen::Base::String& reason)
3018 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
3022 MainForm::OnLoadingCompleted(void)
3024 AppLog("MainForm::OnLoadingCompleted start");
3026 result r = E_SUCCESS;
3028 if (__pWebViewer == null)
3033 if (__pAddressbar == null)
3037 if (__pWebViewer->CanGoForward())
3039 //__pAddressbar->SetForwardButtonEnabled(true);
3040 SetForwardButtonEnabled(true);
3044 //__pAddressbar->SetForwardButtonEnabled(false);
3045 SetForwardButtonEnabled(false);
3048 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3050 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3052 //__pAddressbar->UpdateProgress(0);
3056 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
3058 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3062 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
3063 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
3064 if (isPrivateBrowsing == false)
3066 if(__pHistory != null)
3072 __pHistory = new(std::nothrow) History;
3073 HistoryPresentationModel::GetCurrentDateTime(date);
3076 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
3077 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
3079 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
3080 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
3082 __pHistory->SetVisitedTime(date);
3084 if (__pWebViewer != null)
3086 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
3088 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
3089 if (pTempBitmap != null)
3091 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
3092 __pHistory->SetFavIconBitmap(*pTempBitmap);
3095 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
3098 Canvas* pCanvas = __pWebViewer->GetCanvasN();
3099 Bitmap* pBitmap = new(std::nothrow) Bitmap();
3100 if ( pCanvas != null && pCanvas != null && pBitmap != null)
3102 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
3103 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
3104 __pHistory->SetThumbnail(pBitmap);
3106 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
3109 __pHistory->SetFavIconBitmap(*pFavIcon);
3113 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
3120 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
3122 // temperary fixed (webpage can be not loaded)
3126 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
3127 if (isReaderEnabled == true)
3131 delete __pReaderData;
3132 __pReaderData = null;
3134 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
3135 filePath.Append(L"data/reader.js");
3141 result r = E_SUCCESS;
3142 FileAttributes attr;
3144 File::GetAttributes(filePath,attr);
3146 r = file.Construct(filePath, L"r+");
3149 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
3152 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
3155 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
3158 // file.Read(pScript,attr.GetFileSize());
3160 // AppLogDebug("scipt length %d",strlen(pScript));
3161 String strScript = L"";
3162 // strScript.Append(pScript);
3163 // for(int i=0; i<25; i++)
3165 file.Read(pScript,attr.GetFileSize());
3166 // AppLog("xyzz tell %d",file.Tell());
3167 // r = strScript.Append(pScript);
3168 // AppLog("xyzz append result %s",GetErrorMessage(r));
3169 // AppLog("xyzz strScript length %d",strScript.GetLength());
3171 // AppLog("xyzz final strScript length %d",strScript.GetLength());
3173 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
3174 if (__pReaderData == null)
3176 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
3177 __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>");
3180 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
3181 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
3183 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3184 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
3190 AppLog("MainForm::OnLoadingCompleted done");
3194 MainForm::OnEstimatedProgress(int progress)
3196 AppLogDebug("MainForm::OnEstimatedProgress entered");
3197 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
3198 progress = DEFAULT_PROGRESS_PERCENTAGE;
3200 // __pAddressbar->UpdateProgress(progress);
3201 UpdateProgress(progress);
3204 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
3206 AppLog("MainForm::OnFaviconReceived");
3207 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
3209 Bitmap* favIcon = __pWebViewer->GetFaviconN();
3212 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
3219 MainForm::OnUrlValueChanged(Addressbar&)
3225 MainForm::OnUrlSubmitted(Addressbar& addBar)
3227 AppLog("MainForm::OnUrlSubmitted");
3228 String url = addBar.GetUrl();
3229 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
3231 if(__pFooterUrlField)
3232 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
3233 AddressBarCancelledClicked(*__pAddressbar);
3238 MainForm::LoadUrl(String& url)
3242 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3243 AppLogDebug("MainForm::LoadUrl enter");
3245 if (__pWebViewer != null)
3247 __pWebViewer->SetShowState(true);
3248 __pWebViewer->Invalidate(true);
3251 if (url.CompareTo(L"") == 0)
3255 if(__pFooterPanel != null)
3257 __pFooterPanel->SetShowState(true);
3258 __pFooterPanel->Invalidate(true);
3265 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
3266 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)
3268 RegularExpression firstRegex;
3269 RegularExpression secondRegex;
3271 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3272 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3275 ret = firstRegex.Match(url, false); // This returns true value
3276 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3278 if (ret == true && __pWebViewer != null)
3281 __pWebViewer->LoadUrl(url);
3283 else if(__pWebViewer != null)
3285 String tempUrl = L"http://";
3286 tempUrl.Append(url);
3290 __pWebViewer->LoadUrl(tempUrl);
3294 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3295 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3298 if (__pAddressbar != null)
3300 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3301 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3304 AppLogDebug("MainForm::LoadUrl exit");
3311 MainForm::OnStopClicked(Addressbar& addBar)
3313 AppLogDebug("MainForm::OnStopClicked called");
3316 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3317 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3318 __pWebViewer->StopLoading();
3319 RequestRedraw(true);
3324 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3326 // AppLog("MainForm::OnBackClicked");
3327 result r = E_FAILURE;
3329 if (__pWebViewer && __pWebViewer->CanGoBack())
3331 __pWebViewer->GoBack();
3333 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3336 pApp = UiApp::GetInstance();
3339 r = pApp->Terminate();
3342 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3350 WindowInfo* pWindowInfo = null;
3352 SceneManager* pSceneManager = SceneManager::GetInstance();
3353 if (pSceneManager == null)
3357 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3358 if (pAllWindowList == NULL)
3360 pApp = UiApp::GetInstance();
3363 r = pApp->Terminate();
3366 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3371 if (pAllWindowList != null)
3373 totalCount = pAllWindowList->GetCount();
3375 for (int count = 0; count < totalCount; count++)
3377 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3378 if (pWindowInfo == null)
3380 pApp = UiApp::GetInstance();
3383 r = pApp->Terminate();
3386 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3391 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3393 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3396 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3399 r = pAllWindowList->RemoveAt(count, true);
3400 __pWindowInfo = null;
3403 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3408 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3412 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3414 if (pWindowInfo == null)
3416 pApp = UiApp::GetInstance();
3419 r = pApp->Terminate();
3425 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3428 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3442 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3444 AppLog("MainForm::OnForwardClicked");
3445 if (__pWebViewer == null)
3448 if (__pWebViewer->CanGoForward())
3450 __pWebViewer->GoForward();
3455 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3457 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3458 if(__pFooterPanel != null)
3460 __pFooterPanel->SetShowState(false);
3463 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3465 __pAddressbar->SetShowState(true);
3466 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3469 RelayoutControls(false);
3473 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3475 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3477 int Height = GetClientAreaBounds().height;
3478 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3481 // __pAddressbar->SetShowState(false);
3483 if (__pFooterPanel != null && addressbarKeyPadState == false)
3485 AppLog("akjshdasd 3");
3486 __pFooterPanel->SetShowState(true);
3489 RelayoutControls(false);
3493 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3495 AddressBarCancelledClicked(addBar);
3499 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3501 __prevAddressBarMode = __curAddressBarMode;
3503 if (__pAddressbar != null)
3505 __curAddressBarMode = GetAddressbarMode();
3508 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3510 __adressPanelPosition.y = 0;
3511 if (__pAddressbar != null)
3513 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3514 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3515 __pAddressbar->Invalidate(true);
3517 if (__pWebViewer != null)
3519 __pWebViewer->StopLoading();
3522 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3524 __adressPanelPosition.y = 0;
3525 if (__pAddressbar != null)
3527 __webControlPosition.y = 0;
3528 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3529 __pAddressbar->Invalidate(true);
3535 MainForm::OnClipboardClosed(const Addressbar& addBar)
3537 RelayoutControls(false);
3541 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3543 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3545 AppLog("akjshdasd 3");
3546 __pFooterPanel->SetShowState(true);
3549 RelayoutControls(false,footerState);
3553 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3555 RelayoutControls(false);
3559 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3561 __pFooterPanel->SetShowState(false);
3565 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3567 AppLog("KeypadBoundsChanged");
3568 RelayoutControls(false);
3572 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3574 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3577 __pWindowInfo->pageTitle = title;
3578 if (__pWebViewer != null)
3580 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3583 if (__pAddressbar != null && __pWebViewer != null)
3585 SetUrl(__pWebViewer->GetUrl());
3586 __pAddressbar->Invalidate(true);
3591 MainForm::UpdateFavicon(void)
3593 bool urlImageType = false;
3594 String *tempPath = null;
3596 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();");
3597 Bitmap* pBitmap = null;
3599 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3601 if (__pWindowInfo != null)
3604 url.SetUri(*tempPath);
3605 if (url.GetHost().GetLength() == 0)
3608 webUrl.SetUri(__pWebViewer->GetUrl());
3609 result r = url.SetHost(webUrl.GetHost());
3616 if (url.GetScheme().GetLength() == 0)
3619 webUrl.SetUri(__pWebViewer->GetUrl());
3620 url.SetScheme(webUrl.GetScheme());
3622 __pWindowInfo->faviconUrl = url.ToString();
3624 pBitmap = __pWebViewer->GetFaviconN();
3626 if (pBitmap != null)
3628 if (__pWindowInfo->pFavicon != NULL)
3630 __pWindowInfo->pFavicon = null;
3632 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3633 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3635 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3637 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3639 else if(__pWindowInfo->pFavicon != null)
3641 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3645 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3646 if(pDefaultBmp != null)
3648 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3657 if(tempPath != null)
3661 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3668 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3669 Tizen::Web::Controls::WebNavigationType type)
3671 // when load new page if find word panel is open its show state is false
3672 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3674 __currentSearchStr = L"";
3675 __currentWordIndex = 0;
3676 __maxOccurrances = 0;
3677 __pFindWordEditField->SetText(L"");
3678 __pFindWordNext->SetEnabled(false);
3679 __pFindWordPrev->SetEnabled(false);
3680 __pFindWordCountLabel->SetText(L"0/0");
3681 __pFindWordControl->SetShowState(false);
3682 __pFindWordEditField->HideKeypad();
3683 RelayoutControls(false);
3688 __pFooterPanel->Invalidate(true);
3691 uriInfo.SetUri(url);
3693 if(url.Contains(IDS_TIZEN_SERVICE))
3696 String delim(L":;,");
3698 // Creates a StringTokenizer instance
3699 StringTokenizer strTok(url, delim);
3701 int count = strTok.GetTokenCount(); // count == 4
3703 HashMap *pMap = new HashMap();
3709 while (strTok.HasMoreTokens())
3711 AppLog("Token: %ls", token.GetPointer());
3712 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3713 if(token.Contains(IDS_APPID))
3715 token.SubString(6, appId);
3716 AppLog("AppID:%ls", appId.GetPointer());
3718 else if(token.Contains(IDS_KEY))
3720 token.SubString(4, key);
3721 AppLog("key:%ls", key.GetPointer());
3723 else if(token.Contains(IDS_VALUE))
3725 token.SubString(6, value);
3726 AppLog("value:%ls", value.GetPointer());
3729 pMap->Add(key, value);
3733 AppControl *pAppControl = null;
3734 String operationId = L"http://tizen.org/appcontrol/operation/main";
3735 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3738 result r = pAppControl->Start(null, null, pMap, null);
3742 AppLogException("AppControl not found");
3752 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3753 const Tizen::Net::Http::HttpHeader& httpHeader)
3755 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3760 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3762 AppLog("MainForm::OnWebPageBlockSelected");
3763 if (__pHitElementResult != null)
3765 delete __pHitElementResult;
3766 __pHitElementResult = null;
3769 if (__pWebViewer != null)
3771 AppLog("MainForm::OnWebPageBlockSelected web not null");
3772 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3774 if(GetLastResult() == E_INVALID_ARG)
3776 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3777 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3778 if(GetLastResult() == E_INVALID_ARG)
3780 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3782 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3786 if (__pHitElementResult == null)
3791 if (__pHitElementResult->HasImage() != true)
3793 String tagName = __pHitElementResult->GetTagName();
3794 String type = __pHitElementResult->GetAttributeValue("type");
3797 __currentSelectedStr.Clear();
3798 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3799 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3800 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3802 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3804 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3806 InitSelectTextContextMenu(endPoint,true);
3807 __pImageMenu->SetShowState(true);
3808 __pImageMenu->Show();
3809 __pImageMenu->Invalidate(true);
3811 else /*if(__isLongPressedDone == true)*/
3813 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3815 if(__pHitElementResult->GetUrl().GetLength() > 0)
3817 __currentSelectedStr.Clear();
3818 __currentSelectedStr = __pHitElementResult->GetUrl();
3820 InitSelectTextContextMenu(endPoint,false);
3821 __pImageMenu->SetShowState(true);
3822 __pImageMenu->Show();
3823 __pImageMenu->Invalidate(true);
3826 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3827 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3828 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3834 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3840 MainForm::OnWebWindowCreateRequested(void)
3842 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3844 if (pNewWindowInfo == null)
3848 result r = E_SUCCESS;
3849 SceneManager* pSceneManager = SceneManager::GetInstance();
3850 if (pSceneManager == NULL)
3854 ArrayList* pArgList = new(std::nothrow) ArrayList();
3855 if (pArgList == NULL)
3859 r = pArgList->Construct();
3862 pNewWindowInfo->isJavascriptInitiated = true;
3863 pArgList->Add(*pNewWindowInfo);
3864 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3868 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3875 return pNewWindowInfo->pCurrentWeb;
3879 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3881 __webControlPosition.y = 0;
3882 __webControlHeight = GetClientAreaBounds().height;
3883 AppLog("Client area height: %d", __webControlHeight);
3885 AppLog("Client area height: %d", __webControlHeight);
3886 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3888 __webControlPosition.y += __pAddressbar->GetHeight();
3889 __webControlHeight -= __pAddressbar->GetHeight();
3890 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3892 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3894 __webControlPosition.y += __pFindWordControl->GetHeight();
3895 __webControlHeight -= __pFindWordControl->GetHeight();
3896 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3899 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3901 __webControlHeight -= __pFooterPanel->GetHeight();
3903 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3905 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3907 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3908 __pWebViewer->Invalidate(false);
3910 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3912 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3919 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3921 if (__pFindWordControl == null)
3926 Tizen::Locales::LocaleManager localeManager;
3927 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3929 String languageCode;
3930 result r = SettingInfo::GetValue(L"Language", languageCode);
3931 // int languagecode = local.GetLanguageCode();
3932 AppLog("rahul language is %S", languageCode.GetPointer());
3936 InitFindWordPanel();
3938 if (languageCode.CompareTo("ara") == 0)
3940 AppLog("rahul language is arabic");
3942 __pFindWordPanelLeftToRight->SetShowState(false);
3943 __pFindWordPanelRightToLeft->SetShowState(true);
3945 __pFindWordClear->SetShowState(false);
3946 __pFindWordCountLabel->SetShowState(false);
3947 __pFindWordEditField->SetShowState(false);
3949 __pFindWordClearRightToLeft->SetShowState(true);
3950 __pFindWordCountLabelRightToLeft->SetShowState(true);
3951 __pFindWordEditFieldRightToLeft->SetShowState(true);
3955 AppLog("rahul language is not arabic");
3958 __pFindWordPanelLeftToRight->SetShowState(true);
3959 __pFindWordPanelRightToLeft->SetShowState(false);
3961 __pFindWordClear->SetShowState(true);
3962 __pFindWordCountLabel->SetShowState(true);
3963 __pFindWordEditField->SetShowState(true);
3965 __pFindWordClearRightToLeft->SetShowState(false);
3966 __pFindWordCountLabelRightToLeft->SetShowState(false);
3967 __pFindWordEditFieldRightToLeft->SetShowState(false);
3969 __pFindWordControl->SetShowState(true);
3973 if(__pFindWordControl != null)
3975 __pFindWordControl->SetShowState(false);
3979 AppLog("MainForm::ShowFindWordPanel %d",show);
3980 if (show && !isTouchPressed)
3982 if (languageCode.CompareTo("ara") == 0)
3984 if (__pFindWordEditFieldRightToLeft)
3986 __pFindWordEditFieldRightToLeft->SetFocus();
3987 __pFindWordEditFieldRightToLeft->ShowKeypad();
3992 if (__pFindWordEditField)
3994 __pFindWordEditField->SetFocus();
3995 __pFindWordEditField->ShowKeypad();
4001 if (languageCode.CompareTo("ara") == 0)
4003 if (__pFindWordEditFieldRightToLeft)
4004 __pFindWordEditFieldRightToLeft->HideKeypad();
4008 if (__pFindWordEditField)
4009 __pFindWordEditField->HideKeypad();
4013 RelayoutControls(false);
4017 MainForm::StartWordSearch()
4019 //Get the count of occurances of the word in the current page
4020 __maxOccurrances = 0;
4021 __currentWordIndex = 0;
4023 __pFindWordPrev->SetEnabled(false);
4024 String *pCountStr = null;
4025 result r = __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
4026 AppLog("Search Result %s",GetErrorMessage(r));
4027 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
4028 if (pCountStr != null)
4030 Integer::Parse(*pCountStr, 10, __maxOccurrances);
4034 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
4039 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
4041 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
4042 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
4044 if(totalCount == -1 || totalCount == 0)
4046 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
4047 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
4050 else if(totalCount > 100)
4052 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4053 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4057 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
4058 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
4061 __maxOccurrances = totalCount;
4062 __currentWordIndex = currentOrdinal;
4064 //Reset the UI controls as per the maxOccurrance value
4065 if (totalCount <= 0)
4067 AppLog("Word not found");
4068 //Show error notification to user
4069 __pFindWordNext->SetEnabled(false);
4070 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4072 __pFindWordCountLabel->SetText(L"0/0");
4073 __pFindWordCountLabel->Invalidate(false);
4075 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4077 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4078 __pFindWordCountLabelRightToLeft->Invalidate(false);
4080 __pFindWordNext->Invalidate(false);
4081 __pFindWordPrev->Invalidate(false);
4086 if (totalCount == 1)
4088 __pFindWordNext->SetEnabled(false);
4092 __pFindWordNext->SetEnabled(true);
4095 String countStr = L"";
4096 countStr.Append(__currentWordIndex);
4097 countStr.Append(L"/");
4098 countStr.Append(__maxOccurrances);
4099 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4101 __pFindWordCountLabel->SetText(countStr);
4102 __pFindWordCountLabel->Invalidate(false);
4103 __pFindWordCountLabel->Invalidate(false);
4105 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4107 __pFindWordCountLabelRightToLeft->SetText(countStr);
4108 __pFindWordCountLabelRightToLeft->Invalidate(false);
4109 __pFindWordCountLabelRightToLeft->Invalidate(false);
4111 //FindNextWord(true);
4112 //Update the controls
4113 __pFindWordNext->Invalidate(false);
4114 __pFindWordPrev->Invalidate(false);
4119 MainForm::FindNextWord(bool next)
4123 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
4124 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
4126 if (__currentWordIndex < __maxOccurrances)
4128 __currentWordIndex++;
4134 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
4135 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
4137 if(__currentWordIndex > 1)
4139 __currentWordIndex--;
4144 String countStr = L"";
4145 countStr.Append(__currentWordIndex);
4146 countStr.Append(L"/");
4147 countStr.Append(__maxOccurrances);
4149 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
4151 __pFindWordCountLabel->SetText(countStr);
4152 __pFindWordCountLabel->Invalidate(false);
4154 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
4156 __pFindWordCountLabelRightToLeft->SetText(countStr);
4157 __pFindWordCountLabelRightToLeft->Invalidate(false);
4160 if (__currentWordIndex >= __maxOccurrances)
4162 __pFindWordNext->SetEnabled(false);
4166 __pFindWordNext->SetEnabled(true);
4168 if (__currentWordIndex <= 1)
4170 __pFindWordPrev->SetEnabled(false);
4174 __pFindWordPrev->SetEnabled(true);
4176 __pFindWordPrev->Invalidate(false);
4177 __pFindWordNext->Invalidate(false);
4179 __pFindWordControl->Invalidate(true);
4183 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
4185 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
4186 __isWebKeypadOpened = true;
4187 __pFooterPanel->SetShowState(false);
4188 // OnAddressBarKeypadOpened(*__pAddressbar);
4192 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
4194 AppLog("xyz::MainForm::OnWebKeypadOpened");
4196 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4198 __currentSearchStr = L"";
4199 __currentWordIndex = 0;
4200 __maxOccurrances = 0;
4201 __pFindWordEditField->SetText(L"");
4202 __pFindWordNext->SetEnabled(false);
4203 __pFindWordPrev->SetEnabled(false);
4204 __pFindWordCountLabel->SetText(L"0/0");
4205 __pWebViewer->SearchTextAllAsync(L"",false);
4206 __pFindWordControl->SetShowState(false);
4207 __pFindWordEditField->HideKeypad();
4211 if (__pWebViewer != null && __pFooterPanel != null)
4213 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
4214 if(__pAddressbar != null)
4216 __pAddressbar->SetShowState(false);
4218 if(__pFindWordControl != null)
4220 __pFindWordControl->SetShowState(false);
4222 __pFooterPanel->SetShowState(false);
4223 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
4225 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
4227 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
4228 // AppLog("omgomgomg");
4234 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
4236 AppLog("xyz::MainForm::OnWebKeypadClosed");
4237 AppLog("akjshdasd 4");
4238 __pFooterPanel->SetShowState(true);
4239 // OnAddressBarKeypadClosed(*__pAddressbar);
4240 RelayoutControls(false);
4241 __isWebKeypadOpened = false;
4245 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
4247 // RelativeLayout(false);
4251 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
4253 Control* temp = const_cast< Control* >(&source);
4254 Header* pHeader = dynamic_cast< Header* >(temp);
4255 if (pHeader != null)
4257 //Header double - clicked
4258 AppLog("Header double clicked");
4260 if(__pFindWordControl)
4262 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4263 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4267 AppLog("MainScene::OnTouchDoublePressed");
4271 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4273 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4274 __longPressPoint = currentPosition;
4276 if (__pHitElementResult != null)
4278 delete __pHitElementResult;
4279 __pHitElementResult = null;
4282 if (__pWebViewer != null)
4284 AppLog("MainForm::OnTouchLongPressed web not null");
4285 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4288 if (__pHitElementResult == null)
4293 if (__pHitElementResult->HasImage() == true)
4295 InitImageContextMenu(currentPosition);
4296 __pImageMenu->SetShowState(true);
4297 __pImageMenu->Show();
4298 __pImageMenu->Invalidate(true);
4300 else if(__pHitElementResult->HasUrl() == true)
4302 String tempURl = __pHitElementResult->GetUrl();
4303 AppLog("tempURl is %ls", tempURl.GetPointer());
4304 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4305 if (pBitmap != null)
4313 InitImageLinkContextMenu(currentPosition);
4314 __pImageMenu->SetShowState(true);
4315 __pImageMenu->Show();
4316 __pImageMenu->Invalidate(true);
4320 String tagName = __pHitElementResult->GetTagName();
4321 String type = __pHitElementResult->GetAttributeValue("type");
4322 String value = __pHitElementResult->GetAttributeValue(L"value");
4323 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4325 __currentSelectedStr.Clear();
4326 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4328 AppLog("tag name is %ls", tagName.GetPointer());
4329 AppLog("type is %ls", type.GetPointer());
4333 //__isLongPressedDone = true;
4334 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4335 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4337 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4339 InitSelectTextContextMenu(currentPosition,true, true);
4342 __pImageMenu->SetShowState(true);
4343 __pImageMenu->Show();
4344 __pImageMenu->Invalidate(true);
4347 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4350 // __inputEventToBeSupressed = true;
4354 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4356 AppLog("MainForm::OnTouchReleased");
4359 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4360 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4362 __pWebViewer->ConsumeInputEvent();
4364 if(pHitElement != null)
4368 __inputEventToBeSupressed = false;*/
4372 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4379 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4381 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4383 __currentSearchStr = L"";
4384 __currentWordIndex = 0;
4385 __maxOccurrances = 0;
4387 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4389 __pFindWordEditField->SetText(L"");
4390 __pFindWordEditField->HideKeypad();
4391 __pFindWordControl->SetShowState(false);
4392 __pFindWordCountLabel->SetText(L"0/0");
4394 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4396 __pFindWordEditFieldRightToLeft->SetText(L"");
4397 __pFindWordEditFieldRightToLeft->HideKeypad();
4398 __pFindWordControl->SetShowState(false);
4399 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4402 __pFindWordNext->SetEnabled(false);
4403 __pFindWordPrev->SetEnabled(false);
4405 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4406 __pFindWordControl->SetShowState(false);
4408 if(__pAddressbar->GetShowState() == false)
4410 __pAddressbar->SetAddressbarURLFocus();
4411 __pFooterPanel->SetShowState(false);
4418 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4424 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4430 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4436 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4442 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4448 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4450 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4451 int widthContextItem = 0;
4453 // As per the platform engineer comment removed this line
4454 /*if(__pWebViewer != null)
4456 // 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
4457 __pWebViewer->ReleaseBlock();
4460 // if(__pFindWordControl != null)
4461 // ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4462 if ( __pFooterLabel != null)
4464 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4467 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4473 if (__pFindWordBgLabel != null)
4475 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4476 if (pBitmap != null)
4478 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4483 if (__pFindWordBgLabelRightToLeft != null)
4485 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4486 if (pBitmap != null)
4488 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4493 if(__isHwKeySupported == true)
4495 if(__pOptionMenu != null)
4496 __pOptionMenu->SetShowState(false);
4501 __pMenu->SetShowState(false);
4503 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4505 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4509 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4514 AppLog("__pFooterPanel->GetShowState() is true");
4516 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4517 __pFooterPanel->Invalidate(true);
4521 if(__pMoreButton && __pMenu)
4523 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4524 __pMenu->SetAnchorPosition(p);
4525 __pMenu->Invalidate(true);
4528 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4529 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4531 InitMostVisitedSitesView(orientationStatus);
4534 RelayoutControls(false);
4535 if (__pArticleReaderPanel != null)
4537 if (__pArticleReaderPanel->GetShowState() == true)
4539 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4541 if (__pBlankPanel != null)
4542 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4544 if (__pWebReader != null)
4546 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4548 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4549 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4551 if ( pBitmap != null && pSrcBitmap != null)
4553 AppLog("CreateReaderPanel ninepatchbitmap found");
4554 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4557 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4558 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4559 if (pBitmap != null)
4564 if (pSrcBitmap != null)
4573 if (__pAddressbar != null)
4575 int width = GetClientAreaBounds().width;
4576 __pAddressbar->OrientationChanged(width);
4581 MainForm::OnSettingsChange(int settingvalue)
4583 AppLogDebug("MainForm::OnSettingsChange entered");
4585 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4587 __pAddressbar->ResetGuideText();
4589 if (__pWebViewer == null)
4591 AppLogDebug("Webviewer is not initialized yet.");
4595 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4597 WebSetting settings = __pWebViewer->GetSetting();
4598 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4600 settings.SetAutoFittingEnabled(true);
4602 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4604 settings.SetAutoFittingEnabled(false);
4606 __pWebViewer->SetSetting(settings);
4608 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4610 WebSetting settings = __pWebViewer->GetSetting();
4611 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4612 __pWebViewer->SetSetting(settings);
4614 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4616 WebSetting settings = __pWebViewer->GetSetting();
4617 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4618 __pWebViewer->SetSetting(settings);
4619 __pWebViewer->Reload();
4621 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4623 WebSetting settings = __pWebViewer->GetSetting();
4624 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4625 __pWebViewer->SetSetting(settings);
4627 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4631 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4634 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4638 WebSetting settings = __pWebViewer->GetSetting();
4639 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4640 __pWebViewer->SetSetting(settings);
4643 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4647 WebSetting settings = __pWebViewer->GetSetting();
4648 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4649 __pWebViewer->SetSetting(settings);
4652 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4654 WebSetting settings = __pWebViewer->GetSetting();
4655 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4657 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4661 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4663 __pWebViewer->SetSetting(settings);
4665 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4669 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4670 WebSetting settings = __pWebReader->GetSetting();
4671 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4672 __pWebReader->SetSetting(settings);
4678 MainForm::OnSettingsReset()
4682 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4683 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4688 MainForm::OnClearCache()
4690 result r = E_SUCCESS;
4692 if (__pWebViewer != NULL)
4694 r = __pWebViewer->ClearCache();
4697 AppLogDebug("Cache cleared success");
4701 AppLogDebug("Cache cleared fail");
4707 MainForm::OnClearCookie()
4709 result r = E_SUCCESS;
4711 if (__pWebViewer != NULL)
4713 __pWebViewer->ClearCookie();
4717 AppLogDebug("Cookie cleared success");
4721 AppLogDebug("Cache cleared fail");
4726 MainForm::OnClearFormData()
4728 result r = E_SUCCESS;
4730 if (__pWebViewer != NULL)
4732 __pWebViewer->ClearFormData();
4736 AppLogDebug("Cookie cleared success");
4740 AppLogDebug("Cache cleared fail");
4745 MainForm::OnClearPasswords()
4747 result r = E_SUCCESS;
4749 if (__pWebViewer != NULL)
4751 __pWebViewer->ClearLoginFormData();
4755 AppLogDebug("Cookie cleared success");
4759 AppLogDebug("Cache cleared fail");
4765 MainForm::findDistance(int x1,int y1,int x2, int y2)
4767 int deltaX = Math::Abs(x2 - x1);
4768 int deltaY = Math::Abs(y2 - y1);
4769 double num = deltaX*deltaX + deltaY*deltaY;
4775 for (i = 0; i < 20; i++)
4777 x = (((x*x)+ num)/(2*x));
4788 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4790 if(__pFindWordControl)
4792 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4793 // ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4795 //__isLongPressedDone = false;
4797 __pAddressbar->SetShowState(false);
4800 IList* pList = null;
4801 pList = touch.GetTouchInfoListN(source);
4805 int count = pList->GetCount();
4808 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4809 __touchPoint1 = pTouchInfo->position;
4811 /*if (__pAddressbar != null)
4813 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4815 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4817 __pAddressbar->SaveAddressbarEditText();
4819 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4822 __pAddressbar->Invalidate(true);
4824 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4826 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4828 //__pAddressbar->SaveAddressbarEditText();
4830 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4833 else if (count == 2)
4835 AppLogDebug("MainForm::OnTouchPressed count is two");
4836 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4837 __touchPoint1 = pTouchInfo->position;
4839 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4840 __touchPoint2 = pTouchInfo->position;
4845 pList->RemoveAll(true);
4848 // RelayoutControls(false);
4853 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4855 // __currentWordIndex = 0;
4856 //__isLongPressedDone = false;
4861 MainForm::MoveUiControls()
4866 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4868 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4870 if(__pFooterUrlField->GetTextLength() == 0)
4872 __pFooterUrlField->SetKeypadActionEnabled(false);
4876 __pFooterUrlField->SetKeypadActionEnabled(true);
4879 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4881 __currentSearchStr = __pFindWordEditField->GetText();
4882 if (__currentSearchStr.GetLength() > 0)
4884 __pFindWordCountLabel->SetShowState(true);
4888 __pFindWordCountLabel->SetShowState(false);
4890 __pFindWordNext->SetEnabled(false);
4891 __pFindWordPrev->SetEnabled(false);
4892 __pFindWordNext->Invalidate(true);
4893 __pFindWordPrev->Invalidate(true);
4894 __pFindWordCountLabel->SetText(L"0/0");
4895 __pFindWordCountLabel->Invalidate(true);
4897 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4899 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4900 if (__currentSearchStr.GetLength() > 0)
4902 __pFindWordCountLabelRightToLeft->SetShowState(true);
4906 __pFindWordCountLabelRightToLeft->SetShowState(false);
4909 __pFindWordNext->SetEnabled(false);
4910 __pFindWordPrev->SetEnabled(false);
4911 __pFindWordNext->Invalidate(true);
4912 __pFindWordPrev->Invalidate(true);
4913 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4914 __pFindWordCountLabelRightToLeft->Invalidate(true);
4916 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4917 if (__currentSearchStr.GetLength() > 0)
4923 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4925 __currentSearchStr = L"";
4926 AppLogDebug("Enter something");
4931 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4938 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4940 if(__pWebViewer != null)
4943 AppLog("MainForm::InitMostVisitedSitesView");
4944 result r = E_SUCCESS;
4947 if (__pWebViewer != null && __pMostVisitedListView != null)
4952 if (__pMostVisitedListView != null)
4954 RemoveControl(__pMostVisitedListView);
4956 if(__pMostVisitedSites != null)
4958 __pMostVisitedSites->RemoveAll(true);
4961 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4963 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4964 __pMostVisitedListView = new(std::nothrow) ListView();
4966 int height = GetClientAreaBounds().height;
4968 if(__pFooterPanel->GetShowState() == true)
4970 height = height - __pFooterPanel->GetHeight();
4972 if(__pAddressbar->GetShowState() == true)
4974 height -= __pAddressbar->GetHeight();
4977 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4981 delete __pMostVisitedListView;
4982 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4985 __pMostVisitedListView->SetItemProvider(*this);
4986 __pMostVisitedListView->AddListViewItemEventListener(*this);
4987 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4988 AddControl(__pMostVisitedListView);
4989 __pMostVisitedListView->UpdateList();
4996 MainForm::GetImagePath(void)
5000 String formattedTime;
5001 DateTime currentTime;
5002 LocaleManager localManager;
5003 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
5005 localManager.Construct();
5006 Locale locale = localManager.GetSystemLocale();
5007 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
5009 // Get date formatter
5010 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
5014 pTimeFormatter->Format(currentTime, formattedTime);
5017 AppLog("current time stamp is %ls", formattedTime.GetPointer());
5018 String delim(L" :");
5019 StringTokenizer strTok(formattedTime, delim);
5022 String str1("GMT+00");
5023 while (strTok.HasMoreTokens())
5025 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
5026 if(token.Equals(str1))
5028 AppLog("token is %ls", token.GetPointer());
5029 imageName.Append(token);
5035 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
5037 result r = E_FAILURE;
5038 AppLog("Content manager 1");
5039 ContentId contentId;
5040 ContentManager contentManager;
5041 r = contentManager.Construct();
5044 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
5047 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
5048 Tizen::Io::Directory::Create(contentPath,true);
5049 if(GetLastResult() == E_FILE_ALREADY_EXIST)
5051 AppLog("Already exists");
5053 else if(GetLastResult() == E_SUCCESS)
5055 AppLog("created success");
5057 contentPath.Append(imageName);
5058 contentPath.Append(".jpg");
5059 contentId = contentManager.CreateContent(*aBuffer, contentPath);
5060 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
5064 MainForm::SetForwardButtonEnabled(bool isEnabled)
5066 __pGoForwardBtn->SetEnabled(isEnabled);
5067 __pGoForwardBtn->Invalidate(true);
5071 MainForm::SetBackButtonEnabled(bool isEnabled)
5073 __pGoBackBtn->SetEnabled(isEnabled);
5074 __pGoBackBtn->Invalidate(true);
5078 MainForm::UpdateProgress(int percentage)
5080 __progressPercentage = percentage;
5081 if (percentage == 0 || percentage == 100)
5083 __isLoadingData = false;
5084 if (percentage == 100)
5086 __isLoadingCompleted = true;
5087 __progressPercentage = 0;
5091 __isLoadingCompleted = false;
5096 __isLoadingData = true;
5098 UpdateProgressBitmap();
5102 MainForm::GetProgress(void)
5104 return __progressPercentage;
5108 MainForm::UpdateProgressBitmap(void)
5110 result r = E_SUCCESS;
5111 if (__pProgressbarLabel == null)
5113 int w = __pProgressbarLabel->GetWidth();
5114 int h = __pProgressbarLabel->GetHeight();
5116 int progressWidth = 0;
5117 Bitmap* pRetBitmap = null;
5119 if (__progressPercentage == 0 || __progressPercentage == 100)
5121 __pProgressbarLabel->SetShowState(false);
5122 __pProgressbarLabel->Invalidate(false);
5127 __pProgressbarLabel->SetShowState(true);
5128 __pProgressbarLabel->Invalidate(false);
5131 r = canvas.Construct(Rectangle(0, 0, w, h));
5135 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
5140 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
5144 pBgBmp->Scale(Dimension(w, h));
5145 canvas.DrawBitmap(Point(0,0), *pBgBmp);
5149 progressWidth = (double) (w) * __progressPercentage / 100;
5150 AppLogDebug("progressWidth: %d", progressWidth);
5151 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
5153 if (pProgressBmp != null)
5155 pProgressBmp->Scale(Dimension(progressWidth, h));
5156 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
5157 delete pProgressBmp;
5160 pRetBitmap = new (std::nothrow) Bitmap();
5162 if (pRetBitmap == null)
5164 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
5168 pRetBitmap->Construct(canvas, canvas.GetBounds());
5170 if (__pProgressbarLabel != null && pRetBitmap != null)
5172 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
5173 __pProgressbarLabel->Invalidate(false);
5176 if (pRetBitmap != null)
5185 MainForm::ReaderClicked()
5187 result r = E_SUCCESS;
5188 ArrayList* pArgList = new(std::nothrow) ArrayList();
5189 if (pArgList != null)
5191 r = pArgList->Construct();
5198 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
5205 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
5212 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
5220 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
5224 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
5226 CreateReaderPanel();
5227 AppLogDebug("MainScene::ReaderClicked entered");
5230 /*if (__pArticleReaderPanel)
5232 AppLogDebug("showstate true for reader panel");
5233 __pArticleReaderPanel->SetShowState(true);
5234 __pArticleReaderPanel->Show();
5236 int xPos = __pArticleReaderPanel->GetX();
5237 int yPos = __pArticleReaderPanel->GetY();
5238 AppLog("ReaderClicked() xPos = %d",xPos);
5239 AppLog("ReaderClicked() yPos = %d",yPos);
5241 if (__pReaderData == null)
5246 String loadData = L"<html>\
5248 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
5253 background-color: transparent;\
5272 <body style='width:'";
5273 loadData.Append(bodyWidth);
5274 loadData.Append(L"px'>");
5275 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5276 loadData.Append(*__pReaderData);
5277 loadData.Append(L"</body></html>");
5280 buf.Construct(loadData.GetLength());
5281 AppLogDebug("data->GetLength %d",loadData.GetLength());
5282 for (int z=0;z<loadData.GetLength();z++)
5285 loadData.GetCharAt(z,b);
5286 buf.SetByte((byte)b);
5290 if (__pWebReader != null)
5292 __pWebReader->LoadData(L"",buf,L"text/html");
5293 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5297 AppLogDebug("cannot LoadData __pWebReader is null");
5302 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5304 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5306 __currentAddMode = addMode;
5310 case ADDRESSBAR_MODE_INVALID:
5315 case ADDRESSBAR_MODE_READER:
5317 __pStopBtn->SetShowState(false);
5318 __pRefreshBtn->SetShowState(false);
5319 __pClearBtn->SetShowState(false);
5320 __pReaderBtn->SetShowState(false);
5323 case ADDRESSBAR_MODE_LOADING:
5325 __pRefreshBtn->SetShowState(false);
5326 __pStopBtn->SetShowState(true);
5327 __pClearBtn->SetShowState(false);
5328 __pReaderBtn->SetShowState(false);
5331 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5333 // SetUrl(__pAddressbar->GetUrl());
5335 __pRefreshBtn->SetShowState(true);
5336 __pStopBtn->SetShowState(false);
5337 __pClearBtn->SetShowState(false);
5338 __pReaderBtn->SetShowState(false);
5341 case ADDRESSBAR_MODE_EDIT:
5343 __pRefreshBtn->SetShowState(false);
5344 __pStopBtn->SetShowState(false);
5345 __pReaderBtn->SetShowState(false);
5346 __pClearBtn->SetShowState(true);
5353 OnAddressBarModeChanged();
5356 AddressBarMode MainForm::GetAddressbarMode(void)
5358 return __currentAddMode;
5361 void MainForm::SetUrl(const String& url)
5364 if(__displayUrl.GetLength() > 2048)
5365 __displayUrl.SubString(0,2048,__displayUrl);
5367 if (__pFooterUrlField != NULL)
5369 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5370 if (removedHttpUrl.IsEmpty() == false)
5372 __pFooterUrlField->SetText(removedHttpUrl);
5373 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5374 __pAddressbar->SetUrl(__displayUrl);
5378 __pFooterUrlField->SetText(__displayUrl);
5379 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5380 __pAddressbar->SetUrl(__displayUrl);
5382 if(__pFooterUrlField)
5383 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5384 __pFooterUrlField->Invalidate(false);
5385 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5386 __pAddressbar->Invalidate(true);
5387 // __pFooterUrlField->SetCursorPosition(0);
5392 MainForm::RemoveHttpTextFromDisplayURL(void)
5394 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5396 // bool isHttpText = __displayUrl.Contains(L"http://");
5397 String updatedDisplayUrl;
5398 updatedDisplayUrl.Clear();
5399 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5401 __displayUrl.SubString(7,updatedDisplayUrl);
5403 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5405 __displayUrl.SubString(8,updatedDisplayUrl);
5407 return updatedDisplayUrl;
5410 void MainForm::OnSharePopupControlStarted(void)
5412 __pWebViewer->AddTouchEventListener(*this);
5415 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5417 if (requestId == BACK_GROUND_APP_EVENT)
5419 if(__pWebViewer != null)
5421 __pWebViewer->Pause();
5424 else if(requestId == FORE_GROUND_APP_EVENT)
5426 if(__pWebViewer != null)
5428 __pWebViewer->Resume();
5434 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5436 result r = E_SUCCESS;
5439 __pAddressbar->SetShowState(false);
5441 //AppLog("akjshdasd 5");
5442 //__pFooterPanel->SetShowState(true);
5445 __pWebViewer->SetFocus();
5446 else if(__pMostVisitedListView)
5447 __pMostVisitedListView->SetFocus();
5448 else if(__pMultiWindowButton)
5449 __pMultiWindowButton->SetFocus();
5450 else if(__pMoreButton)
5451 __pMoreButton->SetFocus();
5453 __pAddressbar->SetShowState(false);
5455 RelayoutControls(false);
5459 MainForm::OnFormMenuRequested (Tizen::Ui::Controls::Form &source)
5461 AppLog("MainForm::OnFormMenuRequested called");
5478 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
5480 int bookmarkCount=0;
5483 url=__pWindowInfo->pageUrl;
5484 result r = E_SUCCESS;
5485 Bitmap* pBitmap = null;
5487 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
5490 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
5495 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
5499 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
5501 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
5503 if (__pOptionMenu->GetItemCount() == 9)
5505 r = __pOptionMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5509 r = __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
5514 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
5518 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
5519 if (__pOptionMenu->GetItemCount() != 9)
5521 __pOptionMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
5522 __pOptionMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
5523 // __pOptionMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
5524 __pOptionMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
5525 __pOptionMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
5526 __pOptionMenu->SetMaxVisibleItemsCount(6);
5528 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
5530 AppLog(" Orientation landscape");
5531 __pOptionMenu->SetMaxVisibleItemsCount(5);
5535 AppLog(" Orientation potrait");
5536 __pOptionMenu->SetMaxVisibleItemsCount(6);
5539 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
5542 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
5543 __pOptionMenu->SetShowState(true);
5544 __pOptionMenu->Invalidate(true);
5545 __pOptionMenu->Show();