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 "IntMainForm.h"
34 #include "IntNotificationPanel.h"
35 #include "IntSceneRegister.h"
36 #include "IntSettingPresentationModel.h"
38 using namespace Tizen::App;
39 using namespace Tizen::Base;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Base::Runtime;
42 using namespace Tizen::Base::Utility;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Io;
45 using namespace Tizen::Locales;
46 using namespace Tizen::Media;
47 using namespace Tizen::Ui;
48 using namespace Tizen::Ui::Controls;
49 using namespace Tizen::Content;
50 using namespace Tizen::Ui::Scenes;
51 using namespace Tizen::System;
52 using namespace Tizen::Web;
53 using namespace Tizen::Web::Controls;
55 static const wchar_t* IDB_SEARCH_INPUT_FIELD_BG = L"I01_toolbar_input_field.9.png";
56 static const wchar_t* IDB_FINDWORD_INPUT_FIELD_BG = L"I01_toolbar_input_field_findword.9.png";
57 static const wchar_t* IDB_BTN_BACK = L"I01_icon_Back.png";
58 static const wchar_t* IDB_BTN_BACK_PRESS = L"I01_icon_Back_press.png";
59 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK = L"I01_search_list_icon_favorite.png";
60 static const wchar_t* IDB_CONTRLBAR_ICON_BOOKMARK_PRESS = L"I01_search_list_icon_favorite_press.png";
61 static const wchar_t* IDB_CONTRLBAR_ICON_MORE = L"I01_icon_more.png";
62 static const wchar_t* IDB_CONTRLBAR_ICON_MORE_PRESS = L"I01_icon_more_press.png";
63 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW = L"I01_icon_plus.png";
64 static const wchar_t* IDB_CONTRLBAR_ICON_NEW_WINDOW_PRESS = L"I01_icon_plus_press.png";
65 static const wchar_t* IDB_CONTROLBAR_ICON_CREATE_DISABLE = L"I01_controlbar_icon_create_disable.png";
66 static const wchar_t* IDB_BUTTON_ON = L"00_button_on.png";
67 static const wchar_t* IDB_BUTTON_OFF = L"00_button_off.png";
68 static const wchar_t* IDB_ICON_BOOKMARK_OFF_TEMP = L"I01_icon_bookmark_off_temp.png";
69 static const wchar_t* IDB_ICON_BOOKMARK_ON_TEMP = L"I01_icon_bookmark_on_temp.png";
70 static const wchar_t* IDS_TIZEN_SERVICE = L"tizen-service";
71 static const wchar_t* IDS_APPID = L"AppID";
72 static const wchar_t* IDS_KEY = L"key";
73 static const wchar_t* IDS_VALUE = L"value";
74 static const wchar_t* IDB_TITLE_PROGRESS_BAR_BG = L"I01_title_progress_bar_bg.png";
75 static const wchar_t* IDB_TITLE_PROGRESS_BAR = L"I01_title_progress_bar.png";
76 //static const wchar_t* IDB_ADDRESS_BAR_BACKGROUND = L"I01_toolbar_bg_02.9.png";
78 const int IDA_BACKBTN_CLICKED = 101;
79 const int IDA_BOOKMARKBTN_CLICKED = 102;
80 const int IDA_MOREBTN_CLICKED = 103;
81 const int IDA_MULTIWINDOWBTN_CLICKED = 104;
82 const int IDA_NEWWINDOWBTN_CLICKED = 105;
83 const int IDA_FORWARD_CLICKED = 106;
84 const int IDA_ADDTOBOOKMARK_CLICKED = 107;
85 const int IDA_SHARE_CLICKED = 108;
86 const int IDA_FINDONPAGE_CLICKED = 109;
87 const int IDA_PRIVATEON_CLICKED = 110;
88 const int IDA_SETTINGS_CLICKED = 111;
89 const int IDA_READER_CLOSE_CLICKED = 112;
90 const int IDA_SMALLFONT_BTN_CLICKED = 113;
91 const int IDA_LARGEFONT_BTN_CLICKED = 114;
92 const int IDA_BRIGHTNESS_BTN_CLICKED = 115;
93 const int IDA_HISTORY_CLICKED = 116;
94 const int IDA_ADD_TO_BOOKMARKBTN_CLICKED = 117;
95 const int IDA_ADD_TO_HOME_CLICKED = 118;
96 const int IDA_SAVED_PAGES_CLICKED = 119;
97 const int IDA_DESKTOP_VIEW_CLICKED = 120;
98 const int IDA_SAVE_CLICKED = 121;
99 const int IDA_PRINT_CLICKED = 122;
101 const int IDA_FINDWORD_SEARCH_CLICKED = 201;
102 const int IDA_FINDWORD_NEXT_CLICKED = 202;
103 const int IDA_FINDWORD_PREV_CLICKED = 203;
104 const int IDA_FINDWORD_CLEAR_CLICKED = 204;
105 const int IDA_FINDWORD_CANCEL_CLICKED = 205;
107 const int IDA_COPY_IMAGE_CLICKED = 206;
108 const int IDA_VIEW_IMAGE_CLICKED = 207;
109 const int IDA_SAVE_IMAGE_CLICKED = 208;
110 const int IDA_SHARE_IMAGE_CLICKED = 209;
112 const int IDA_COPY_TEXT_CLICKED = 210;
113 const int IDA_PASTE_TEXT_CLICKED = 211;
114 const int IDA_FIND_TEXT__CLICKED = 212;
115 const int IDA_SHARE_TEXT_CLICKED = 213;
117 const int IDA_GO_BACK = 214;
118 const int IDA_GO_FORWARD = 215;
119 const int IDA_REFRESH_BTN_CLICKED = 216;
120 const int IDA_STOP_BTN_CLICKED = 217;
121 const int IDA_CLEAR_URL = 218;
122 const int IDA_READER_BTN_CLICKED = 219;
125 const int IDA_HYPERLINK_OPEN_CLICKED = 220;
126 const int IDA_HYPERLINK_COPY_LINK_CLICKED = 221;
127 const int IDA_HYPERLINK_SAVE_IMAGE_CLICKED = 222;
128 const int IDA_HYPERLINK_SHARE_IMAGE_CLICKED = 223;
130 const int IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED = 224;
132 const int DEFAULT_PROGRESS_PERCENTAGE = 10;
134 const int MainForm::IDA_FORMAT_BITMAP = 500;
135 const int MainForm::IDA_FORMAT_DELETE_BITMAP = 501;
136 const int MainForm::IDA_FORMAT_TITLE_STRING = 502;
137 const int MainForm::IDA_FORMAT_URL_STRING = 503;
138 const int MainForm::IDA_CONTEXT_ITEM_DELETE = 504;
140 static const int WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT = 336;
141 static const int WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE = 800;
142 static const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
144 MainForm::MainForm(void)
146 //__isLongPressedDone = false;
148 __pAddressbar = null;
149 // __pMostVisitedSitesPanel = null;
150 __pMostVisitedListView = null;
151 __pFooterPanel = null;
152 __pHitElementResult = null;
153 __pWindowInfo = null;
157 __pFindWordControl = null;
158 __pFindWordPanelLeftToRight = null;
159 __pFindWordPanelRightToLeft = null;
160 __pFindWordBgLabel = null;
161 __pFindWordBgLabelRightToLeft = null;
162 __pFindWordEditField = null;
163 __pFindWordEditFieldRightToLeft = null;
164 __pFindWordClear = null;
165 __pFindWordClearRightToLeft = null;
166 __pFindWordCountLabel = null;
167 __pFindWordClearRightToLeft = null;
168 __pFindWordNext = null;
169 __pFindWordPrev = null;
170 __previousZoomLevel = 1.0;
172 __currentAddMode = ADDRESSBAR_MODE_LOADING_COMPLETE;
175 __currentSearchStr = L"";
176 __currentSelectedStr = L"";
177 __maxOccurrances = 0;
178 __currentWordIndex = 0;
181 //__inputEventToBeSupressed = false;
182 __isLoadingData = false;
183 __isLoadingCompleted = false;
184 __progressPercentage = 0;
185 __touchPoint1 = Point(-1,-1);
186 __touchPoint2 = Point(-1,-1);
187 __longPressPoint = Point(-1,-1);
189 // __pReaderPopup = null;
190 __pReaderData = null;
192 __pReaderCloseBtn = null;
193 //__pNewWindowButton = null;
194 __pMoreButton = null;
195 __pMultiWindowButton = null;
196 __pArticleReaderPanel = null;
197 __pBlankPanel = null;
198 __pArticleReaderLabel = null;
199 __webControlHeight = 0;
200 __prevAddressBarMode = ADDRESSBAR_MODE_INVALID;
201 __curAddressBarMode = ADDRESSBAR_MODE_INVALID;
202 __pMostVisitedSites = null;
203 __pFooterUrlField = null;
205 __pGoForwardBtn = null;
206 __pRefreshBtn = null;
207 __pProgressbarLabel = null;
208 __pFooterLabel = null;
212 __isWebKeypadOpened = false;
216 MainForm::~MainForm(void)
218 SettingPresentationModel::GetInstance()->RemoveSettingsEventListener(*this);
222 __pAddressbar->SetAddressbarEventListener(null);
225 if(__pHistory != null)
231 if (__pReaderData != null)
233 delete __pReaderData;
234 __pReaderData = null;
237 if (__pPopUp != null)
243 if (__pHitElementResult != null)
245 delete __pHitElementResult;
246 __pHitElementResult = null;
249 String* pSelectedScene = NULL;
250 Object* pValue = NULL;
251 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
252 pSelectedScene = (String*) pValue;
254 /*if (pSelectedScene != null)
256 delete pSelectedScene;
258 MultiWindowPresentationModel::SetValue(SELECTED_SCENE_ID, null);*/
262 MainForm::Initialize(void)
264 Construct(L"IDL_FORM");
269 MainForm::OnInitializing(void)
271 AppLog("get client area width = %d",GetClientAreaBounds().width);
272 AppLog("get client area height = %d",GetClientAreaBounds().height);
273 const int WIDTH_CONTEXT_MENU_BUTTON = 336;
274 const int HEIGHT_CONTEXT_MENU_BUTTON = 72;
276 __fontSize = CommonUtil::GetFontSize();
277 Panel* pFooterPanel = null;
279 __pSaveImage = new Image();
280 __pSaveImage->Construct();
282 // Setup back event listener
283 SettingPresentationModel::GetInstance()->AddSettingsEventListener(*this);
284 SceneManager::GetInstance()->AddSceneEventListener(IDSCN_MAIN_VIEW, *this);
285 AddOrientationEventListener(*this);
286 AppLogDebug(" MainForm::OnInitializing ended");
287 if (__pMostVisitedSites == null)
289 __pMostVisitedSites = new(std::nothrow) ArrayList();
290 __pMostVisitedSites->Construct();
292 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
294 __pItemContext= new(std::nothrow) ListContextItem();
295 __pItemContext->Construct();
296 Bitmap* pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON,HEIGHT_CONTEXT_MENU_BUTTON);
297 Bitmap* pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON, HEIGHT_CONTEXT_MENU_BUTTON);
299 if (pBitmapNormal != null && pBitmapPressed != null)
301 __pItemContext->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
304 if (pBitmapNormal != null)
306 delete pBitmapNormal;
309 if (pBitmapPressed != null)
311 delete pBitmapPressed;
314 __pItemContextLandscape= new(std::nothrow) ListContextItem();
315 __pItemContextLandscape->Construct();
316 pBitmapNormal = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE,HEIGHT_CONTEXT_MENU_BUTTON);
317 pBitmapPressed = CommonUtil::GetNinepatchedBitmapN(L"00_button_sweep_delete_press.9.png", WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE, HEIGHT_CONTEXT_MENU_BUTTON);
319 if (pBitmapNormal != null && pBitmapPressed != null)
321 __pItemContextLandscape->AddElement(IDA_CONTEXT_ITEM_DELETE, CommonUtil::GetString(L"IDS_BR_SK_DELETE_ABB"), *pBitmapNormal, *pBitmapPressed, pBitmapPressed);
324 if (pBitmapNormal != null)
326 delete pBitmapNormal;
329 if (pBitmapPressed != null)
331 delete pBitmapPressed;
338 MainForm::InitAddressbar(void)
340 AppLogDebug("MainForm::InitAddressbar entered");
342 result r = E_SUCCESS;
344 if (__pAddressbar != null)
348 __pAddressbar = new(std::nothrow) Addressbar();
349 AppLog("MainForm::InitAddressbar GetClientAreaBounds().width %d",GetClientAreaBounds().width);
350 r = __pAddressbar->Initialize(Tizen::Graphics::Rectangle(0, 0, GetClientAreaBounds().width, 82));
353 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
356 __pAddressbar->SetAddressbarEventListener(this);
357 AddControl(__pAddressbar);
358 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
359 SetControlAlwaysOnTop(*__pAddressbar, true);
360 __adressPanelPosition = __pAddressbar->GetPosition();
362 AppLogDebug("MainForm::InitAddressbar exit");
368 MainForm::CreateReaderPanel(void)
370 AppLogDebug("CreateReaderPanel() width %d",GetClientAreaBounds().width);
371 result r = E_FAILURE;
373 Button *pSmallFontBtn = null;
374 Button *pLargeFontBtn = null;
376 __pBlankPanel = new (std::nothrow) Panel();
377 __pBlankPanel->Construct(L"IDL_BLANK_PANEL");
379 __pArticleReaderPanel = new (std::nothrow) Panel();
380 __pArticleReaderPanel->Construct(L"IDL_ARTICLE_READER");
382 __pReaderCloseBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_CLOSE_READER",true));
383 if (__pReaderCloseBtn)
385 AppLogDebug("CreateReaderPanel() 6");
386 __pReaderCloseBtn->AddActionEventListener(*this);
387 __pReaderCloseBtn->SetActionId(IDA_READER_CLOSE_CLICKED);
390 __pWebReader = new (std::nothrow) Web();
391 __pWebReader->Construct(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
393 settings.SetInputStyle(INPUT_STYLE_OVERLAY);
394 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
396 r = __pWebReader->SetSetting(settings);
398 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
401 __pArticleReaderLabel = new Label();
402 __pArticleReaderLabel->Construct(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()),L"");
404 __pBlankPanel->AddControl(__pArticleReaderLabel);
405 __pBlankPanel->AddControl(__pArticleReaderPanel);
406 AddControl(__pBlankPanel);
408 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
409 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
410 __pArticleReaderLabel->SetBounds(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
412 __pArticleReaderPanel->AddControl(__pWebReader);
413 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth()-2,__pArticleReaderPanel->GetHeight() - 96 -2));
414 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
415 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
417 if (pBitmap != null && pSrcBitmap != null)
419 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
421 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
423 pSmallFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_SMALL_FONT",true));
426 pSmallFontBtn->AddActionEventListener(*this);
427 pSmallFontBtn->SetActionId(IDA_SMALLFONT_BTN_CLICKED);
430 pLargeFontBtn = static_cast<Button*>(__pArticleReaderPanel->GetControl(L"IDC_LARGE_FONT",true));
433 pLargeFontBtn->AddActionEventListener(*this);
434 pLargeFontBtn->SetActionId(IDA_LARGEFONT_BTN_CLICKED);
443 if (pSrcBitmap != null)
449 SetControlAlwaysOnTop(*__pBlankPanel, true);
450 //__pBlankPanel->SetControlAlwaysAtBottom(*__pArticleReaderPanel, true);
457 MainForm::InitWebControl()
459 AppLogDebug("MainForm::InitWebControl enter");
460 result r = E_SUCCESS;
461 AppLogDebug("InitWebControl");
463 if (__pAddressbar == null || __pFooterPanel == null)
466 const int Y_WEBCONTROL_POSITION = 0;
467 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
468 if (__pMostVisitedListView)
470 __pMostVisitedListView->SetShowState(false);
472 if (__pWebViewer != null)
474 AppLogDebug("Already initialized");
477 __pWebViewer = new(std::nothrow) Web();
478 if(__pWebViewer == NULL)
480 AppLogDebug("Initialization failed");
483 r = __pWebViewer->Construct(Rectangle(0, Y_WEBCONTROL_POSITION, GetClientAreaBounds().width,__webControlHeight + 12));
487 AppLogDebug("Web construct failed with %s", GetErrorMessage(r));
494 r = AddControl(__pWebViewer);
500 AppLogDebug("Web addcontrol failed with %s", GetErrorMessage(r));
503 __webControlPosition = __pWebViewer->GetPosition();
504 r = __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
507 AppLogDebug("Web setting add failed with %s", GetErrorMessage(r));
511 __pWebViewer->SetLoadingListener(this);
512 __pWebViewer->SetWebUiEventListener(this);
513 __pWebViewer->SetWebKeypadEventListener(this);
514 __pWebViewer->SetFocus();
515 __pWebViewer->AddTouchEventListener(*this);
517 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
518 __pWebViewer->SetTextSearchListener(this);
521 AppLogDebug("MainForm :before return");
523 AppLogDebug("MainForm::InitWebControl Exit");
529 MainForm::OnFocusGained(const Control& source)
531 AppLog("MainForm::OnFocusGained");
535 MainForm::OnFocusLost(const Control& source)
537 AppLog("MainForm::OnFocusLost");
541 MainForm::SetJavascriptEnabled()
543 WebSetting settings = __pWebViewer->GetSetting();
544 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
545 __pWebViewer->SetSetting(settings);
549 MainForm::SetImageLoadEnabled()
551 WebSetting settings = __pWebViewer->GetSetting();
552 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
553 __pWebViewer->SetSetting(settings);
557 MainForm::InitFooter(void)
559 AppLogDebug("MainForm::InitFooter entered");
560 Button* pBackButton = null;
561 Button* pBookmarkButton = null;
562 Button* pMultiWindowButton = null;
563 Bitmap *pIconBitmap = null;
564 Bitmap *pBGBitmap = null;
565 Label *pBGLabel = null;
567 if (__pFooterPanel == null)
569 __pFooterPanel = static_cast< Panel* >(GetControl(L"IDC_FOOTER_PANEL", true));
572 if (__pFooterPanel == null)
577 SetControlAlwaysOnTop(*__pFooterPanel, true);
579 __pFooterLabel = static_cast< Label* >(GetControl(L"IDC_FOOTER_LABEL", true));
580 if ( __pFooterLabel == NULL )
584 //__pFooterPanel->SetBackgroundColor(CUSTOM_COLOR_TRANSPARENT);
585 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
588 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
592 __pMultiWindowButton = static_cast< Button* >(GetControl(L"IDC_MULTIWINDOW_BUTTON", true));
594 if ( __pMultiWindowButton == NULL )
599 __pMoreButton = static_cast<Button*>(GetControl(L"IDC_MORE_BUTTON",true));
601 if ( __pMoreButton == NULL )
606 if (__pMultiWindowButton != null)
608 Bitmap* pBitmap = null;
609 Bitmap* pPressedBitmap = null;
610 String imagePath = "I01_toolbar_icon_windows_manager_0";
611 String pressedImagePath = "I01_toolbar_icon_windows_manager_0";
612 int totalCount = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList()->GetCount();
613 imagePath.Append(totalCount);
614 imagePath.Append(".png");
616 pressedImagePath.Append(totalCount);
617 pressedImagePath.Append("_press.png");
619 pBitmap = AppResource::GetInstance()->GetBitmapN(imagePath);
620 pPressedBitmap = AppResource::GetInstance()->GetBitmapN(pressedImagePath);
621 if ( pBitmap == null )
626 Point startPoint = Point((__pMultiWindowButton->GetWidth() - pBitmap->GetWidth())/2,(__pMultiWindowButton->GetHeight() - pBitmap->GetHeight())/2);
629 __pMultiWindowButton->SetNormalBitmap(startPoint, *pBitmap);
630 __pMultiWindowButton->SetPressedBitmap(startPoint, *pPressedBitmap);
635 __pMultiWindowButton->AddActionEventListener(*this);
636 __pMultiWindowButton->SetActionId(IDA_MULTIWINDOWBTN_CLICKED);
641 Bitmap* pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE);
642 Bitmap* pPressedBitmap = AppResource::GetInstance()->GetBitmapN(IDB_CONTRLBAR_ICON_MORE_PRESS);
645 Point startPoint((__pMoreButton->GetWidth() - pBitmap->GetWidth())/2,(__pMoreButton->GetHeight() - pBitmap->GetHeight())/2 );
646 __pMoreButton->SetNormalBitmap(startPoint, *pBitmap);
647 __pMoreButton->SetPressedBitmap(startPoint, *pPressedBitmap);
651 __pMoreButton->AddActionEventListener(*this);
652 __pMoreButton->SetActionId(IDA_MOREBTN_CLICKED);
655 //Add the editfield for url
656 __pFooterUrlField = static_cast<EditField*> (GetControl(L"IDC_URL_EDIT_FIELD",true));
657 if (__pFooterUrlField == NULL)
659 return E_INVALID_KEY;
662 __pFooterUrlField->SetOverlayKeypadCommandButtonVisible(false);
663 __pFooterUrlField->SetKeypadAction(KEYPAD_ACTION_GO);
664 __pFooterUrlField->AddKeypadEventListener(*this);
665 __pFooterUrlField->SetPropagatedTouchEventListener(this);
667 if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
669 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
671 else if (SettingPresentationModel::GetInstance()->GetHomepage().CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
673 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_ABOUT_C_BLANK"));
677 //__pUrlField->SetText(SettingPresentationModel::GetInstance()->GetFavoriteURL());
678 __pFooterUrlField->SetGuideText(CommonUtil::GetString(L"IDS_BR_BODY_SEARCH_OR_ENTER_URL"));
682 //Add the go Back Button
683 __pGoBackBtn = static_cast<Button*> (GetControl(L"IDC_PAGEBACK_BUTTON",true));
684 if (__pGoBackBtn == NULL)
686 AppLogDebug("__pGoBackBtn Control not found returning E_INVALID_KEY");
687 return E_INVALID_KEY;
689 __pGoBackBtn->SetActionId(IDA_GO_BACK);
690 __pGoBackBtn->AddActionEventListener(*this);
692 //Add the go forward Button
693 __pGoForwardBtn = static_cast<Button*> (GetControl(L"IDC_PAGEFORWARD_BUTTON",true));
694 if (__pGoForwardBtn == NULL)
696 AppLogDebug("Control not found returning E_INVALID_KEY");
697 return E_INVALID_KEY;
699 __pGoForwardBtn->SetActionId(IDA_GO_FORWARD);
700 __pGoForwardBtn->AddActionEventListener(*this);
701 if (__pWebViewer && __pWebViewer->CanGoForward())
703 SetForwardButtonEnabled(true);
707 SetForwardButtonEnabled(false);
710 __pRefreshBtn = static_cast<Button*> (GetControl(L"IDC_REFRESH_BUTTON",true));
711 if (__pRefreshBtn == NULL)
713 AppLogDebug("Control not found returning E_INVALID_KEY");
714 return E_INVALID_KEY;
717 __pRefreshBtn->SetActionId(IDA_REFRESH_BTN_CLICKED);
718 __pRefreshBtn->AddActionEventListener(*this);
719 __pRefreshBtn->SetShowState(true);
721 //Add the backround label for displaying progressbar
722 __pProgressbarLabel = static_cast<Label*> (GetControl(L"IDC_PROGRESS_BAR_LABEL",true));
723 if (__pProgressbarLabel == NULL)
725 AppLogDebug("__pProgressbarLabel Control not found returning E_INVALID_KEY");
726 return E_INVALID_KEY;
728 __pProgressbarLabel->SetShowState(false);
730 __pStopBtn = static_cast<Button*> (GetControl(L"IDC_STOP_BUTTON",true));
731 if (__pStopBtn == NULL)
733 AppLogDebug("Control not found returning E_INVALID_KEY");
734 return E_INVALID_KEY;
736 __pStopBtn->SetActionId(IDA_STOP_BTN_CLICKED);
737 __pStopBtn->AddActionEventListener(*this);
738 __pStopBtn->SetShowState(false);
740 __pClearBtn = static_cast<Button*> (GetControl(L"IDC_CLEAR_BUTTON",true));
741 if (__pClearBtn == NULL)
743 AppLogDebug("Control not found returning E_INVALID_KEY");
744 return E_INVALID_KEY;
746 __pClearBtn->SetActionId(IDA_CLEAR_URL);
747 __pClearBtn->AddActionEventListener(*this);
748 __pClearBtn->SetShowState(false);
750 __pReaderBtn = static_cast<Button*> (GetControl(L"IDC_READER_BUTTON",true));
751 if (__pReaderBtn == NULL)
753 AppLogDebug("Control not found returning E_INVALID_KEY");
754 return E_INVALID_KEY;
756 __pReaderBtn->SetActionId(IDA_READER_BTN_CLICKED);
757 __pReaderBtn->AddActionEventListener(*this);
758 __pReaderBtn->SetShowState(false);
760 // __pFooterPanel->Invalidate(true);
761 AppLogDebug("MainForm::InitFooter exit");
767 MainForm::InitContextMenu(Point& p)
769 result r = E_SUCCESS;
770 bool isPrivateBrowsing = false;
771 Bitmap* pBitmap = null;
775 __pMenu->SetAnchorPosition(p);
776 __pMenu->Invalidate(true);
780 __pMenu = new(std::nothrow) ContextMenu();
781 r = __pMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD);
782 TryCatch(!IsFailed(r),,"Contextmenu creation failed with%s",GetErrorMessage(r));
784 isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
787 if (isPrivateBrowsing == true)
789 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
793 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
796 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_BOOKMARK"), IDA_BOOKMARKBTN_CLICKED);
798 if ( pBitmap != NULL)
800 __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"), IDA_PRIVATEON_CLICKED,*pBitmap);
803 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_BR_TAB_HISTORY"), IDA_HISTORY_CLICKED);
804 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_BRIGHTNESS"), IDA_BRIGHTNESS_BTN_CLICKED);
805 r = __pMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_SETTINGS_CLICKED);
808 __pMenu->SetMaxVisibleItemsCount(6);
809 __pMenu->SetShowState(false);
810 __pMenu->AddActionEventListener(*this);
811 SetControlAlwaysOnTop(*__pMenu, true);
817 result MainForm::InitImageContextMenu(Tizen::Graphics::Point p)
819 result r = E_SUCCESS;
820 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
822 AppLog("MainForm::InitImageContextMenu clicked on image");
823 if (__pImageMenu != null)
829 __pImageMenu = new (std::nothrow) ContextMenu();
830 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
831 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
833 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE"),IDA_COPY_IMAGE_CLICKED);
834 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_VIEW_IMAGE"),IDA_VIEW_IMAGE_CLICKED);
835 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_SAVE_IMAGE_CLICKED);
836 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_IMAGE_CLICKED);
837 __pImageMenu->SetMaxVisibleItemsCount(4);
838 __pImageMenu->AddActionEventListener(*this);
839 SetControlAlwaysOnTop(*__pImageMenu, true);
845 MainForm::InitImageLinkContextMenu(Tizen::Graphics::Point p)
847 result r = E_SUCCESS;
848 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
850 AppLog("MainForm::InitImageContextMenu clicked on image");
851 if (__pImageMenu != null)
857 if(__pAddressbar->GetShowState() == true)
858 p.y = p.y + __pAddressbar->GetHeight();
860 __pImageMenu = new (std::nothrow) ContextMenu();
861 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_LIST, direction);
862 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
864 r = __pImageMenu->AddItem("Open in new window"/*CommonUtil::GetString(L"IDS_BR_OPT_COPY_IMAGE")*/,IDA_HYPERLINK_OPEN_CLICKED);
865 r = __pImageMenu->AddItem("Copy link URL"/*CommonUtil::GetString(L"IDS_DLNA_BODY_SHARE_IMAGE_ABB")*/,IDA_HYPERLINK_COPY_LINK_CLICKED);
866 //r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SAVE_IMAGE"),IDA_HYPERLINK_SAVE_IMAGE_CLICKED);
867 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_HYPERLINK_SHARE_IMAGE_CLICKED);
869 __pImageMenu->SetMaxVisibleItemsCount(3);
870 __pImageMenu->AddActionEventListener(*this);
871 SetControlAlwaysOnTop(*__pImageMenu, true);
878 MainForm::InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption = false)
880 result r = E_SUCCESS;
881 ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_AUTO;
883 AppLog("MainForm::InitSelectTextContextMenu clicked on text");
884 if (__pImageMenu != null)
893 direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
897 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
899 __pImageMenu = new (std::nothrow) ContextMenu();
900 r = __pImageMenu->Construct(p, CONTEXT_MENU_STYLE_GRID, direction);
901 TryCatch(!IsFailed(r),, "Context image menu creation failed with%s",GetErrorMessage(r));
903 if(onlyPasteOption == false)
905 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_OPT_COPY"),IDA_COPY_TEXT_CLICKED);
907 if (pasteOption || onlyPasteOption)
909 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_COM_BODY_PASTE"),IDA_PASTE_TEXT_CLICKED);
911 if(onlyPasteOption == false)
913 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"),IDA_FIND_TEXT__CLICKED);
914 r = __pImageMenu->AddItem(CommonUtil::GetString(L"IDS_BR_OPT_SHARE"),IDA_SHARE_TEXT_CLICKED);
917 __pImageMenu->SetMaxVisibleItemsCount(3);
918 __pImageMenu->AddActionEventListener(*this);
919 SetControlAlwaysOnTop(*__pImageMenu, true);
926 MainForm::InitFindWordPanel(void)
928 result r = E_SUCCESS;
929 Bitmap *pIconBitmap = null;
931 if (__pFindWordControl != null)
933 AppLogDebug("Findword panel already initialized");
934 if (__pFindWordBgLabel != null)
936 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
939 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
943 if (__pFindWordBgLabelRightToLeft != null)
945 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
948 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
955 __pFindWordControl = new (std::nothrow) Panel();
956 r = __pFindWordControl->Construct(L"IDL_FIND_ON_PAGE");
959 AppLogException("There is some problem in the xml file. Please check.");
962 AddControl(__pFindWordControl);
963 __pFindWordControl->SetBounds(0,0, __pFindWordControl->GetWidth(), __pFindWordControl->GetHeight());
964 SetControlAlwaysOnTop(*__pFindWordControl,true);
965 __pFindWordControl->SetShowState(false);
966 __pFindWordControl->Invalidate(false);
968 __pFindWordPanelLeftToRight = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
969 __pFindWordPanelLeftToRight->SetShowState(true);
971 __pFindWordPanelRightToLeft = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL2", true));
972 __pFindWordPanelRightToLeft->SetShowState(false);
974 __pFindWordBgLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL1", true));
975 if (__pFindWordBgLabel != null)
977 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
978 Rectangle pRect = pPanel1->GetBounds();
979 pRect.x = pRect.y = 0;
980 __pFindWordBgLabel->SetBounds(pRect);
981 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
984 AppLogDebug("InitFindWordPanel: Coming here");
985 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
990 AppLogDebug("InitFindWordPanel: shouldn't Come here");
994 __pFindWordBgLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_LABEL2", true));
995 if (__pFindWordBgLabelRightToLeft != null)
997 Panel* pPanel1 = static_cast<Panel*>(__pFindWordControl->GetControl(L"IDC_PANEL1", true));
998 Rectangle pRect = pPanel1->GetBounds();
999 pRect.x = pRect.y = 0;
1000 __pFindWordBgLabelRightToLeft->SetBounds(pRect);
1001 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_search_input_field_bg.9.png", __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
1002 if (pBitmap != null)
1004 AppLogDebug("InitFindWordPanel: Coming here");
1005 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
1010 AppLogDebug("InitFindWordPanel: shouldn't Come here");
1014 Button* pfindWordCancel = null;
1015 pfindWordCancel = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CANCEL", true));
1016 if (pfindWordCancel == null)
1018 AppLogException("There is some problem in the xml file. Please check.");
1021 pfindWordCancel->SetActionId(IDA_FINDWORD_CANCEL_CLICKED);
1022 pfindWordCancel->AddActionEventListener(*this);
1024 __pFindWordClear = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR", true));
1025 if (__pFindWordClear == null)
1027 AppLogException("There is some problem in the xml file. Please check.");
1031 __pFindWordClearRightToLeft = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_CLEAR2", true));
1032 if (__pFindWordClearRightToLeft == null)
1034 AppLogException("There is some problem in the xml file. Please check.");
1038 __pFindWordClear->SetActionId(IDA_FINDWORD_CLEAR_CLICKED);
1039 __pFindWordClear->AddActionEventListener(*this);
1041 __pFindWordClearRightToLeft->SetActionId(IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED);
1042 __pFindWordClearRightToLeft->AddActionEventListener(*this);
1044 __pFindWordNext = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_NEXT", true));
1045 if (__pFindWordNext == null)
1047 AppLogException("There is some problem in the xml file. Please check.");
1051 __pFindWordNext->SetActionId(IDA_FINDWORD_NEXT_CLICKED);
1052 __pFindWordNext->AddActionEventListener(*this);
1054 __pFindWordPrev = static_cast<Button*>(__pFindWordControl->GetControl(L"IDC_FIND_PREV", true));
1055 if (__pFindWordPrev == null)
1057 AppLogException("There is some problem in the xml file. Please check.");
1061 __pFindWordPrev->SetActionId(IDA_FINDWORD_PREV_CLICKED);
1062 __pFindWordPrev->AddActionEventListener(*this);
1064 __pFindWordNext->SetEnabled(false);
1065 __pFindWordPrev->SetEnabled(false);
1067 __pFindWordCountLabel = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL", true));
1068 if (__pFindWordCountLabel == null)
1070 AppLogException("There is some problem in the xml file. Please check.");
1074 __pFindWordCountLabelRightToLeft = static_cast<Label*>(__pFindWordControl->GetControl(L"IDC_FIND_COUNT_LABEL2", true));
1075 if (__pFindWordCountLabel == null)
1077 AppLogException("There is some problem in the xml file. Please check.");
1081 __pFindWordEditField = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD", true));
1082 if (__pFindWordEditField == null)
1084 AppLogException("There is some problem in the xml file. Please check.");
1087 __pFindWordEditField->AddTextEventListener(*this);
1088 __pFindWordEditField->AddKeypadEventListener(*this);
1089 __pFindWordEditField->SetOverlayKeypadCommandButtonVisible(false);
1091 __pFindWordEditFieldRightToLeft = static_cast<EditField*>(__pFindWordControl->GetControl(L"IDC_FIND_WORD_EDITFIELD2", true));
1092 if (__pFindWordEditFieldRightToLeft == null)
1094 AppLogException("There is some problem in the xml file. Please check.");
1097 __pFindWordEditFieldRightToLeft->AddTextEventListener(*this);
1098 __pFindWordEditFieldRightToLeft->AddKeypadEventListener(*this);
1099 __pFindWordEditFieldRightToLeft->SetOverlayKeypadCommandButtonVisible(false);
1105 MainForm::CreateItem (int index, int itemWidth)
1107 Rectangle listImageRect;
1108 Rectangle pagetTitleRect;
1109 Rectangle pageURLRect;
1110 Rectangle deleteImageRect;
1111 String pageTitle(L"");
1112 String pageURL(L"");
1113 result r = E_SUCCESS;
1114 Bitmap* pListIconImage = null;
1117 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1118 if(pHistory == null)
1122 AppResource* pAppResource = Application::GetInstance()->GetAppResource();
1123 if ( pAppResource == NULL )
1127 ListAnnexStyle style = LIST_ANNEX_STYLE_NORMAL;
1129 CustomItem* pItem = new(std::nothrow) CustomItem();
1130 pageTitle = pHistory->GetHistoryTitle();
1131 pageURL = pHistory->GetHistoryUrl();
1133 if (pageURL.GetLength() == 0)
1136 pAppResource->GetString(L"IDS_BR_BODY_ABOUT_C_BLANK", nourl);
1137 pageURL = L"<"+ nourl +">";
1141 Rectangle screenBounds = GetBounds();
1144 r = pItem->Construct(Dimension(itemWidth, 128 + (__fontSize - 44)), style);
1153 Bitmap* pBitmap = pHistory->GetFavIconBitmap();
1155 if ( pBitmap != NULL)
1157 pListIconImage = new Bitmap();
1158 pListIconImage->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
1162 if(pListIconImage == null)
1164 pListIconImage = pAppResource->GetBitmapN(L"I01_icon_default_favicon.png");
1167 if ( pListIconImage != NULL)
1169 listImageRect.SetBounds(screenBounds.x + 16, screenBounds.y + 28 + (__fontSize - 44)/2 , 72, 72);
1170 pagetTitleRect.SetBounds(listImageRect.x + 72 + 16,10, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 60 + (__fontSize - 44));
1171 pageURLRect.SetBounds(pagetTitleRect.x, pagetTitleRect.y + pagetTitleRect.height, screenBounds.width - 2 * pListIconImage->GetWidth() - 120, 48);
1174 if (pItem != null && pListIconImage != NULL)
1176 pItem->AddElement(listImageRect, IDA_FORMAT_BITMAP, *pListIconImage, null, null);
1180 if (pageTitle.CompareTo(L"") != 0)
1184 pItem->AddElement(pagetTitleRect, IDA_FORMAT_TITLE_STRING, pageTitle, __fontSize, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, CUSTOM_COLOR_TRANSPARENT, true);
1188 if (pageURL.CompareTo(L"") != 0)
1192 pItem->AddElement(pageURLRect, IDA_FORMAT_URL_STRING, pageURL, 32, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, CUSTOM_COLOR_GREY, true);
1197 if(GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT || GetOrientationStatus() == ORIENTATION_STATUS_PORTRAIT_REVERSE)
1199 if ( __pItemContext!= NULL)
1203 pItem->SetContextItem(__pItemContext);
1209 if ( __pItemContextLandscape!= NULL)
1213 pItem->SetContextItem(__pItemContextLandscape);
1217 if( pListIconImage != NULL)
1219 delete pListIconImage;
1220 pListIconImage = null;
1227 MainForm::DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth)
1234 MainForm::GetItemCount (void)
1236 if(__pMostVisitedSites != null)
1238 __pMostVisitedSites->RemoveAll(true);
1240 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
1241 if(__pMostVisitedSites != null)
1243 return __pMostVisitedSites->GetCount();
1250 MainForm::OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state)
1252 if(__pMostVisitedSites != null)
1254 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1255 if (pHistory != null)
1257 String url = pHistory->GetHistoryUrl();
1259 HistoryPresentationModel::GetInstance()->DeleteHistory(url);
1260 __pMostVisitedListView->UpdateList();
1266 MainForm::OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status)
1268 History* pHistory = static_cast < History* >(__pMostVisitedSites->GetAt(index));
1269 String url = pHistory->GetHistoryUrl();
1277 MainForm::OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction)
1283 MainForm::OnTerminating(void)
1285 result r = E_SUCCESS;
1287 RemoveOrientationEventListener(*this);
1291 __pAddressbar->SetAddressbarEventListener(null);
1296 __pWebViewer->RemoveTouchEventListener(*this);
1301 delete __pItemContext;
1303 if(__pItemContextLandscape)
1305 delete __pItemContextLandscape;
1311 MainForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
1313 result r = E_SUCCESS;
1315 AppLogDebug("Clicked : %d", actionId);
1318 case IDA_BACKBTN_CLICKED:
1320 if (__pWebViewer && __pWebViewer->CanGoBack())
1322 __pWebViewer->GoBack();
1324 else if(__pWindowInfo->isJavascriptInitiated == false)
1327 pApp = UiApp::GetInstance();
1330 r = pApp->Terminate();
1333 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1341 WindowInfo* pWindowInfo = null;
1343 SceneManager* pSceneManager = SceneManager::GetInstance();
1344 if (pSceneManager == null)
1348 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
1349 if (pAllWindowList == NULL)
1351 pApp = UiApp::GetInstance();
1354 r = pApp->Terminate();
1357 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1362 if (pAllWindowList != null)
1364 totalCount = pAllWindowList->GetCount();
1366 for (int count = 0; count < totalCount; count++)
1368 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
1369 if (pWindowInfo == null)
1371 pApp = UiApp::GetInstance();
1374 r = pApp->Terminate();
1377 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1384 if (pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
1386 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
1389 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1392 r = pAllWindowList->RemoveAt(count, true);
1393 __pWindowInfo = null;
1396 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1401 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
1405 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
1407 if (pWindowInfo == null)
1409 pApp = UiApp::GetInstance();
1412 r = pApp->Terminate();
1418 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1421 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
1433 case IDA_FORWARD_CLICKED:
1434 if (__pWebViewer == null)
1437 if (__pWebViewer->CanGoForward())
1439 __pWebViewer->GoForward();
1441 __pMenu->SetShowState(false);
1442 __pMenu->Invalidate(false);
1445 case IDA_FINDONPAGE_CLICKED:
1447 AppLogDebug("MainForm::OnActionPerformed findword clicked");
1448 __currentSearchStr.Clear();
1450 InitFindWordPanel();
1451 __pMenu->SetShowState(false);
1452 __pMenu->Invalidate(false);
1454 ShowFindWordPanel(true);
1456 if(__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
1458 __pFindWordEditField->SetFocus();
1459 __pFindWordCountLabel->SetShowState(false);
1463 __pFindWordEditFieldRightToLeft->SetFocus();
1464 __pFindWordCountLabelRightToLeft->SetShowState(false);
1468 case IDA_PRIVATEON_CLICKED:
1470 result r = E_SUCCESS;
1472 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
1473 Bitmap* pBitmap = null;
1474 if (isPrivateBrowsing == true)
1476 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
1479 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1483 if (__pWebViewer != NULL)
1485 __pWebViewer->SetPrivateBrowsingEnabled(false);
1488 SettingPresentationModel::GetInstance()->SetPrivateOn(false);
1490 if (__pAddressbar != null)
1492 __pAddressbar->UpdateFaviconBitmap(false);
1498 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
1501 AppLogException("Contextmenu additem:Find on page failed with %s", GetErrorMessage(r));
1505 if (__pWebViewer != NULL)
1507 __pWebViewer->SetPrivateBrowsingEnabled(true);
1510 SettingPresentationModel::GetInstance()->SetPrivateOn(true);
1512 if (__pAddressbar != null)
1514 __pAddressbar->UpdateFaviconBitmap(true);
1519 itemIndex = __pMenu->GetItemIndexFromActionId(IDA_PRIVATEON_CLICKED);
1520 r = __pMenu->SetItemAt(itemIndex,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
1521 AppLog("Result:: %s for index = %d", GetErrorMessage(r),itemIndex);
1522 __pMenu->Invalidate(true);
1524 if ( pBitmap != NULL )
1531 case IDA_SETTINGS_CLICKED:
1534 ArrayList* pArgList = new(std::nothrow) ArrayList();
1537 pArgList->Construct();
1538 pArgList->Add(*__pWindowInfo);
1539 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_SETTINGS), pArgList);
1541 __pMenu->SetShowState(false);
1542 __pMenu->Invalidate(false);
1543 if (pArgList != null)
1552 case IDA_ADDTOBOOKMARK_CLICKED:
1555 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL)
1557 int bookmarkCount=0;
1560 url=__pWindowInfo->pageUrl;
1561 result r = E_SUCCESS;
1562 Bitmap* pBitmap = null;
1563 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1571 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_REMOVED");
1572 BookmarkPresentationModel::GetInstance()->DeleteBookmark(url);
1573 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1575 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1576 if (pNotification != null)
1578 pNotification->SetText(message);
1579 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1580 pNotification->ShowNotification();
1585 String title=__pWindowInfo->pageTitle;
1586 String message = CommonUtil::GetString(L"IDS_BR_POP_BOOKMARK_ADDED");
1587 BookmarkData* pBookmark=new (std::nothrow) BookmarkData();
1589 pBookmark->SetBookmarkTitle(title);
1590 pBookmark->SetUrl(url);
1591 if (__pWebViewer != null && __pWebViewer->GetFaviconN() != null)
1593 pBookmark->SetFavIconBitmap(*(__pWebViewer->GetFaviconN()));
1595 String id = FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
1596 pBookmark->SetFaviconId(id);
1597 //r = BookmarkPresentationModel::GetInstance()->SaveBookmark(*pBookmark);
1598 r = BookmarkPresentationModel::GetInstance()->SaveTempBookmark(*pBookmark);
1601 NotificationPanel* pNotification = new (std::nothrow) NotificationPanel(*this);
1602 if (pNotification != null)
1604 pNotification->SetText(message);
1605 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
1606 pNotification->ShowNotification();
1607 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1610 if (pBitmap != null)
1612 r = __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1616 __pMenu->Invalidate(true);
1620 case IDA_PRINT_CLICKED:
1622 r = __pWebViewer->SavePageAsPdf(UiApp::GetInstance()->GetAppRootPath()+"//data//test.pdf");
1623 AppLog("SavePageAsPdf result %s",GetErrorMessage(r));
1625 AppLog("RequestPrint called!");
1626 AppControl* pAc = Tizen::App::AppManager::FindAppControlN(L"org.tizen.mobileprint", L"http://tizen.org/appcontrol/operation/print");
1627 result nResult = E_FAILURE;
1630 AppLog("TestPrint if (pAc) == true");
1635 String fileType = L"service_print_files_type";
1636 String typeVal = L"DOC";
1638 String fileCount = L"service_print_files_count";
1639 String countVal = L"1";
1640 String fileFolder= L"service_print_files_folder_name";
1641 String folderVal = UiApp::GetInstance()->GetAppRootPath()+"//data";
1643 map.Add(&fileCount, &countVal);
1644 map.Add(&fileFolder, &folderVal);
1645 map.Add(&fileType, &typeVal);
1647 String fileName = L"service_print_files_files_name";
1649 ArrayList fileNameList;
1650 fileNameList.Construct();
1651 String file1 = L"test.pdf";
1653 fileNameList.Add(&file1);
1654 map.Add(&fileName, &fileNameList);
1656 nResult = pAc->Start(NULL, NULL, &map, NULL);
1658 if (nResult == E_SUCCESS) AppLog("TestPrint ret == E_SUCCESS");
1659 else if (nResult == E_MAX_EXCEEDED)
1660 AppLog("TestPrint ret == E_MAX_EXCEEDED");
1661 else if (nResult == E_OBJ_NOT_FOUND)
1662 AppLog("TestPrint ret == E_OBJ_NOT_FOUND");
1663 else if (nResult == E_IN_PROGRESS)
1664 AppLog("TestPrint ret == E_IN_PROGRESS");
1665 else if (nResult == E_PRIVILEGE_DENIED)
1666 AppLog("TestPrint ret == E_PRIVILEGE_DENIED");
1667 else if(nResult == E_SYSTEM)
1668 AppLog("TestPrint ret == E_SYSTEM");
1674 int __modalMsgBoxResult;
1675 MessageBox* pMsgBox = new MessageBox();
1676 pMsgBox->Construct("Not Supported","Not Supported",MSGBOX_STYLE_OK,3000);
1677 pMsgBox->ShowAndWait(__modalMsgBoxResult);
1680 __modalMsgBoxResult = 0;
1684 case IDA_SHARE_CLICKED:
1686 if(__pPopUp != null)
1691 __pPopUp = new(std::nothrow) SharePopup();
1692 __pPopUp->Initialize();
1693 if (__pWindowInfo != null)
1695 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
1696 pShareInfo->SetPageTitle(__pWindowInfo->pageTitle);
1697 pShareInfo->SetPageUrl(__pWindowInfo->pageUrl);
1698 pShareInfo->SetImageAttached(false);
1699 __pPopUp->RemoveAllShareInfo();
1700 __pPopUp->AddShareInfo(pShareInfo);
1702 __pPopUp->SetShowState(true);
1706 case IDA_BOOKMARKBTN_CLICKED:
1708 AppLogDebug("ONACTION_PERFORMED:IDA_BOOKMARKBTN_CLICKED");
1709 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BOOKMARK_VIEW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1712 case IDA_ADD_TO_BOOKMARKBTN_CLICKED:
1717 case IDA_MOREBTN_CLICKED:
1719 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 1");
1720 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetClientAreaBounds().y + GetClientAreaBounds().height - __pMoreButton->GetHeight());
1721 AppLog("Anchot pos: %d %d", p.x, p.y);
1723 if (__pWindowInfo != NULL && __pWindowInfo->pageUrl != NULL && __pWebViewer->GetShowState() == true)
1725 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 2");
1726 int bookmarkCount=0;
1729 url=__pWindowInfo->pageUrl;
1730 result r = E_SUCCESS;
1731 Bitmap* pBitmap = null;
1733 r=BookmarkPresentationModel::GetInstance()->DoesBookmarkExist(url,exist);
1736 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED failed");
1741 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_ON_TEMP);
1745 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_ICON_BOOKMARK_OFF_TEMP);
1747 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 3");
1749 if (__pMenu->GetItemCount() == 9)
1751 r = __pMenu->SetItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1755 r = __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED,*pBitmap);
1760 AppLogException("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED Add to Bookmark failed with %s", GetErrorMessage(r));
1764 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 4");
1765 if (__pMenu->GetItemCount() != 9)
1767 __pMenu->InsertItemAt(1,CommonUtil::GetString(L"IDS_BR_OPT_ADDTOBOOKMARKS"), IDA_ADDTOBOOKMARK_CLICKED);
1768 __pMenu->InsertItemAt(2,CommonUtil::GetString(L"IDS_BR_BODY_PRINT"), IDA_PRINT_CLICKED);
1769 // __pMenu->InsertItemAt(2,L"Add to Home"/*CommonUtil::GetString(L"IDS_BR_OPT_SHARE")*/, IDA_ADD_TO_HOME_CLICKED);
1770 __pMenu->InsertItemAt(3,CommonUtil::GetString(L"IDS_BR_OPT_SHARE"), IDA_SHARE_CLICKED);
1771 __pMenu->InsertItemAt(4,CommonUtil::GetString(L"IDS_BR_OPT_FIND_ON_PAGE_ABB"), IDA_FINDONPAGE_CLICKED);
1772 __pMenu->SetMaxVisibleItemsCount(6);
1774 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE)
1776 AppLog(" Orientation landscape");
1777 __pMenu->SetMaxVisibleItemsCount(5);
1781 AppLog(" Orientation potrait");
1782 __pMenu->SetMaxVisibleItemsCount(6);
1785 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED 5");
1788 AppLogDebug("ONACTION_PERFORMED:IDA_MOREBTN_CLICKED end");
1789 __pMenu->SetShowState(true);
1790 __pMenu->Invalidate(true);
1794 case IDA_HISTORY_CLICKED:
1796 AppLogDebug("ONACTION_PERFORMED:IDA_HISTORYBTN_CLICKED");
1797 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_HISTORY_LIST, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1800 case IDA_SAVED_PAGES_CLICKED:
1805 case IDA_DESKTOP_VIEW_CLICKED:
1810 case IDA_SAVE_CLICKED:
1815 case IDA_MULTIWINDOWBTN_CLICKED:
1817 result r = SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_MULTIPLE_WINDOW, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1818 AppLog("IDA_MULTIWINDOWBTN_CLICKED result %s",GetErrorMessage(r));
1822 case IDA_NEWWINDOWBTN_CLICKED:
1824 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
1826 if (pNewWindowInfo == null)
1830 result r = E_SUCCESS;
1831 SceneManager* pSceneManager = SceneManager::GetInstance();
1833 if (pSceneManager == NULL)
1837 ArrayList* pArgList = new(std::nothrow) ArrayList();
1838 if (pArgList == NULL)
1842 r = pArgList->Construct();
1845 pArgList->Add(*pNewWindowInfo);
1846 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
1852 AppLogDebug("MainForm::OnActionPerformed Failed to GoBackward %s",GetErrorMessage(r));
1857 case IDA_SMALLFONT_BTN_CLICKED:
1859 WebSetting setting = __pWebReader->GetSetting();
1860 setting.SetFontSize(15);
1861 __pWebReader->SetSetting(setting);
1864 case IDA_LARGEFONT_BTN_CLICKED:
1866 WebSetting setting = __pWebReader->GetSetting();
1867 setting.SetFontSize(25);
1868 __pWebReader->SetSetting(setting);
1871 case IDA_READER_CLOSE_CLICKED:
1873 if (__pArticleReaderPanel != null && __pBlankPanel != null)
1875 RemoveControl(__pBlankPanel);
1876 __pArticleReaderPanel = null;
1877 __pBlankPanel = null;
1878 __pArticleReaderLabel = null;
1880 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
1883 case IDA_FINDWORD_CANCEL_CLICKED:
1885 __currentSearchStr = L"";
1886 __currentWordIndex = 0;
1887 __maxOccurrances = 0;
1888 __pFindWordEditField->SetText(L"");
1889 __pFindWordNext->SetEnabled(false);
1890 __pFindWordPrev->SetEnabled(false);
1891 __pFindWordCountLabel->SetText(L"0/0");
1892 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
1893 AppLog("akjshdasd 1");
1894 __pFooterPanel->SetShowState(true);
1895 ShowFindWordPanel(false);
1898 case IDA_FINDWORD_SEARCH_CLICKED:
1900 __currentSearchStr = __pFindWordEditField->GetText();
1901 if (__currentSearchStr.GetLength() > 0)
1907 AppLogDebug("Enter something");
1911 case IDA_FINDWORD_CLEAR_CLICKED:
1913 __pFindWordCountLabel->SetText(L"0/0");
1914 __pFindWordEditField->SetText(L"");
1915 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1917 __currentSearchStr = L"";
1918 __pFindWordNext->SetEnabled(false);
1919 __pFindWordPrev->SetEnabled(false);
1920 __pFindWordCountLabel->SetShowState(false);
1921 __pFindWordControl->Invalidate(true);
1924 case IDA_FINDWORD_CLEAR_RIGHT_TO_LEFT_CLICKED:
1926 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
1927 __pFindWordEditFieldRightToLeft->SetText(L"");
1928 __currentSearchStr = L"aaaaaabbbbbbccccccc";
1930 __currentSearchStr = L"";
1931 __pFindWordNext->SetEnabled(false);
1932 __pFindWordPrev->SetEnabled(false);
1933 __pFindWordCountLabelRightToLeft->SetShowState(false);
1934 __pFindWordControl->Invalidate(true);
1937 case IDA_FINDWORD_NEXT_CLICKED:
1942 case IDA_FINDWORD_PREV_CLICKED:
1944 FindNextWord(false);
1947 case IDA_BRIGHTNESS_BTN_CLICKED:
1949 AppLogDebug("IDA_BRIGHTNESS_BTN_CLICKED");
1950 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_BRIGHTNESS, SCENE_TRANSITION_ANIMATION_TYPE_NONE));
1953 case IDA_COPY_IMAGE_CLICKED:
1955 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1956 AppLogDebug("IDA_COPY_IMAGE_CLICKED");
1958 const Bitmap* pBitmap = null;
1959 if (__pHitElementResult != null)
1961 pBitmap = __pHitElementResult->GetImage();
1964 String resourcePath = App::GetInstance()->GetAppResourcePath();
1965 item.Construct(CLIPBOARD_DATA_TYPE_IMAGE , *pBitmap);
1967 // copying the item to clipboard
1968 Clipboard* pClipboard = Clipboard::GetInstance();
1969 if (pClipboard != null)
1971 pClipboard->CopyItem(item);
1975 case IDA_VIEW_IMAGE_CLICKED:
1977 AppLogDebug("IDA_VIEW_IMAGE_CLICKED");
1978 WindowInfo* pNewWindowInfo = null;
1979 if (__pHitElementResult != null)
1981 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
1982 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
1988 case IDA_SAVE_IMAGE_CLICKED:
1990 AppLogDebug("IDA_SAVE_IMAGE_CLICKED");
1991 const Bitmap* pSaveBitmap = null;
1992 String imageName = GetImagePath();
1993 AppLog("Content manager image name %ls",imageName.GetPointer());
1996 imagePath.Append(imageName);
1997 imagePath.Format(100, L"%ls/Downloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
1998 AppLog("Content manager image path %ls",imagePath.GetPointer());
1999 if (__pHitElementResult != null)
2001 pSaveBitmap = __pHitElementResult->GetImage();
2003 ByteBuffer* pBuffer = __pSaveImage->EncodeToBufferN(*pSaveBitmap, IMG_FORMAT_JPG);
2007 UpdateImageContent(pBuffer, imageName);
2009 NotificationPanel *pNotification = new NotificationPanel(*this);
2011 AppResource::GetInstance()->GetString("IDS_COM_SK_SAVE", msg);
2012 msg.Append(imagePath);
2013 if (pNotification != null)
2015 pNotification->SetText(msg);
2016 if (__pFooterPanel->GetShowState() == true)
2018 pNotification->SetPositionDiff(__pFooterPanel->GetHeight());
2022 pNotification->SetPositionDiff(0);
2025 pNotification->ShowNotification();
2030 int __modalMsgBoxResult;
2031 MessageBox* pMsgBox = new MessageBox();
2032 pMsgBox->Construct(CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),CommonUtil::GetString(L"IDS_COM_FAILED_TO_SAVE_IMAGE"),MSGBOX_STYLE_OK,3000);
2033 pMsgBox->ShowAndWait(__modalMsgBoxResult);
2036 __modalMsgBoxResult = 0;
2040 case IDA_SHARE_IMAGE_CLICKED:
2042 AppLogDebug("IDA_SHARE_IMAGE_CLICKED");
2043 if (__pPopUp != null)
2048 __pPopUp = new(std::nothrow) SharePopup();
2049 __pPopUp->Initialize();
2050 if (__pHitElementResult != null)
2052 const Bitmap* pSaveBitmap = null;
2053 String imageName = GetImagePath();
2054 AppLog("Content manager image name %ls",imageName.GetPointer());
2057 imagePath.Append(imageName);
2058 imagePath.Format(100, L"%lsDownloads/%ls.jpg",Tizen::System::Environment::GetMediaPath().GetPointer(), imageName.GetPointer());
2059 AppLog("Content manager image path %ls",imagePath.GetPointer());
2060 if (__pHitElementResult != null)
2062 pSaveBitmap = __pHitElementResult->GetImage();
2064 __pSaveImage->EncodeToFile(*pSaveBitmap, IMG_FORMAT_JPG, imagePath, true);
2066 String srcUrl = __pHitElementResult->GetAttributeValue(L"src");
2067 AppLog("MainForm::OnTouchLongPressed srcUrl is %ls",srcUrl.GetPointer());
2069 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2070 pShareInfo->SetPageTitle(L"");
2071 pShareInfo->SetPageUrl(srcUrl);
2072 pShareInfo->SetImageAttached(true);
2073 pShareInfo->SetImagePath(imagePath);
2074 __pPopUp->RemoveAllShareInfo();
2075 __pPopUp->AddShareInfo(pShareInfo);
2076 __pPopUp->SetShowState(true);
2081 case IDA_HYPERLINK_OPEN_CLICKED:
2083 if (__pHitElementResult != null)
2085 String srcUrl = __pHitElementResult->GetUrl();
2087 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN(srcUrl);
2089 if (pNewWindowInfo == null)
2093 result r = E_SUCCESS;
2094 SceneManager* pSceneManager = SceneManager::GetInstance();
2095 if (pSceneManager == NULL)
2099 ArrayList* pArgList = new(std::nothrow) ArrayList();
2100 if (pArgList == NULL)
2104 pArgList->Construct();
2106 pArgList->Add(*pNewWindowInfo);
2107 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
2108 if (pArgList != null)
2115 AppLogDebug("MultipleWindowForm::OnActionPerformed GoForward failed %s",GetErrorMessage(r));
2121 case IDA_HYPERLINK_SHARE_IMAGE_CLICKED:
2123 if (__pHitElementResult == null)
2128 if(__pPopUp != null)
2133 __pPopUp = new(std::nothrow) SharePopup();
2134 __pPopUp->Initialize();
2136 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2137 pShareInfo->SetPageUrl(__pHitElementResult->GetUrl());
2138 pShareInfo->SetImageAttached(false);
2139 __pPopUp->RemoveAllShareInfo();
2140 __pPopUp->AddShareInfo(pShareInfo);
2142 __pPopUp->SetShowState(true);
2146 case IDA_HYPERLINK_COPY_LINK_CLICKED:
2150 if (__pHitElementResult != null)
2152 url = __pHitElementResult->GetUrl();
2155 String resourcePath = App::GetInstance()->GetAppResourcePath();
2156 item.Construct(CLIPBOARD_DATA_TYPE_TEXT , url);
2158 // copying the item to clipboard
2159 Clipboard* pClipboard = Clipboard::GetInstance();
2160 if (pClipboard != null)
2162 pClipboard->CopyItem(item);
2166 case IDA_FIND_TEXT__CLICKED:
2168 // AddressBarCancelledClicked(*__pAddressbar);
2169 RelayoutControls(false);
2170 // __pFooterPanel->SetShowState(false);
2171 AppLogDebug("MainForm::OnActionPerformed find word clicked");
2172 __currentSearchStr.Clear();
2173 __currentSearchStr.Append(__currentSelectedStr);
2174 InitFindWordPanel();
2175 __pFindWordEditField->SetText(__currentSearchStr);
2178 __pMenu->SetShowState(false);
2179 __pMenu->Invalidate(false);
2182 __adressPanelPosition.y = 0;
2184 if (__pAddressbar != null && __pWebViewer != NULL)
2186 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
2187 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight() - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12);
2189 if (__pFooterPanel->GetShowState() == false)
2190 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, GetClientAreaBounds().height - ( /*__pAddressbar->GetY() +*/ __pAddressbar->GetHeight() - 12)));
2192 __pWebViewer->SetBounds(Rectangle(0,__webControlPosition.y,GetClientAreaBounds().width, __webControlHeight));
2193 __pWebViewer->Invalidate(true);
2196 ShowFindWordPanel(true);
2197 __pFindWordEditField->SetFocus();
2198 if (__currentSearchStr.GetLength() > 0)
2204 AppLogDebug("Enter something");
2207 if (__pWebViewer != null)
2209 // releasing the set block
2210 __pWebViewer->ReleaseBlock();
2215 case IDA_SHARE_TEXT_CLICKED:
2217 __pWebViewer->ReleaseBlock();
2218 AppLogDebug("IDA_SHARE_TEXT_CLICKED");
2219 if(__pPopUp != null)
2224 __pPopUp = new(std::nothrow) SharePopup();
2225 __pPopUp->Initialize();
2226 if (__pHitElementResult != null)
2228 ShareInfo* pShareInfo = new(std::nothrow) ShareInfo();
2229 pShareInfo->SetPageTitle(L"");
2230 pShareInfo->SetPageUrl(__currentSelectedStr);
2231 pShareInfo->SetImageAttached(false);
2232 __pPopUp->RemoveAllShareInfo();
2233 __pPopUp->AddShareInfo(pShareInfo);
2234 __pPopUp->SetShowState(true);
2239 case IDA_COPY_TEXT_CLICKED:
2241 __pWebViewer->ReleaseBlock();
2242 // need to implement
2243 //__currentSelectedStr
2244 // Sets data to a clip board item
2246 String resourcePath = App::GetInstance()->GetAppResourcePath();
2247 item.Construct(CLIPBOARD_DATA_TYPE_TEXT, __currentSelectedStr);
2249 // copying the item to clipboard
2250 Clipboard* pClipboard = Clipboard::GetInstance();
2251 if (pClipboard != null)
2253 pClipboard->CopyItem(item);
2257 case IDA_PASTE_TEXT_CLICKED:
2259 Clipboard* pClipboard = Clipboard::GetInstance();
2261 if(pClipboard == null)
2265 // Retrieves a latest item
2266 ClipboardItem* pItem = pClipboard->RetrieveLatestItemN(CLIPBOARD_DATA_TYPE_TEXT | CLIPBOARD_DATA_TYPE_HTML);
2272 //Gets data from the clipboard item
2273 String* pString = dynamic_cast<String*>(pItem->GetData());
2275 if (pString != null)
2277 String idElement = __pHitElementResult->GetAttributeValue(L"id");
2278 String nameElement = __pHitElementResult->GetAttributeValue(L"name");
2279 AppLog("MainForm::IDA_PASTE_TEXT_CLICKED id is %ls",idElement.GetPointer());
2282 if(idElement.GetLength() != 0)
2284 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; } } ";
2285 script.Append("insertAtCursor('");
2286 script.Append(idElement);
2287 script.Append("',");
2288 script.Append("\"");
2289 script.Append(*pString);
2290 script.Append("\");");
2292 else if (nameElement.GetLength() != 0)
2294 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; } } ";
2295 script.Append("insertAtCursor(document.getElementsByName('");
2296 script.Append(nameElement);
2297 script.Append("')[0],");
2298 script.Append("\"");
2299 script.Append(*pString);
2300 script.Append("\");");
2302 AppLog("MainForm::OnTouchLongPressed script is %ls",script.GetPointer());
2303 String* pStr = __pWebViewer->EvaluateJavascriptN(script);
2314 case IDA_GO_FORWARD:
2319 case IDA_REFRESH_BTN_CLICKED:
2321 __isLoadingCompleted = false;
2322 __isLoadingData = true;
2323 __progressPercentage = 0;
2324 __displayUrl = __pFooterUrlField->GetText();
2326 String url = __pFooterUrlField->GetText();
2327 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2329 __pWebViewer->Reload();
2330 if (__pAddressbar != null)
2332 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2333 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2337 UpdateProgressBitmap();
2340 case IDA_STOP_BTN_CLICKED:
2342 __isLoadingCompleted = false;
2343 __isLoadingData = false;
2344 __progressPercentage = 0;
2345 __pFooterUrlField->HideKeypad();
2346 __displayUrl = __pFooterUrlField->GetText();
2350 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2351 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2352 __pWebViewer->StopLoading();
2353 RequestRedraw(true);
2356 UpdateProgressBitmap();
2361 if (__pFooterUrlField->GetText().IsEmpty() == false)
2363 //__displayUrl = __pUrlField->GetText();
2364 __pFooterUrlField->Clear();
2369 case IDA_READER_BTN_CLICKED:
2380 MainForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
2383 UiApp* pApp = UiApp::GetInstance();
2392 MainForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
2393 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
2395 AppLog("MainForm::OnSceneActivatedN called");
2396 String* pSelectedScene = NULL;
2397 Object* pValue = NULL;
2398 String* pUrl = null;
2399 MultipleWindowPresentationModel::GetInstance()->GetValue(SELECTED_SCENE_ID, &pValue);
2400 pSelectedScene = (String*) pValue;
2402 if (pSelectedScene != null)
2404 delete pSelectedScene;
2406 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, null);
2407 String* selectedSceneID = new(std::nothrow) String(currentSceneId);
2408 AppLogDebug("current scene id is %ls", currentSceneId.GetPointer());
2409 AppLogDebug("selected scene id is %ls", currentSceneId.GetPointer());
2411 // setting the current scene ID
2412 MultipleWindowPresentationModel::GetInstance()->SetCurrentSceneID(currentSceneId);
2414 MultipleWindowPresentationModel::GetInstance()->SetValue(SELECTED_SCENE_ID, (Object*) selectedSceneID);
2416 if(pArgs != null && pArgs->GetCount() > 0 && pArgs->GetCount() == 2)
2418 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2419 if(__pWindowInfo == null)
2421 // if(__pWindowInfo == null)
2423 pUrl = dynamic_cast< String* >(pArgs->GetAt(1));
2426 else if ( pArgs != null && pArgs->GetCount() == 1)
2428 __pWindowInfo = dynamic_cast< WindowInfo* >(pArgs->GetAt(0));
2434 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), GetClientAreaBounds().width, __pFooterPanel->GetHeight());
2436 // hiding the address bar
2437 // __pAddressbar->SetBounds(__pAddressbar->GetX(), __pAddressbar->GetY() - __pAddressbar->GetHeight(), __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
2438 __pAddressbar->SetShowState(false);
2439 // if(__pWebViewer != null)
2441 // __pWebViewer->Resume();
2444 if(pUrl != null && pUrl->GetLength() > 0)
2448 else if(__pWindowInfo != null)
2450 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)
2452 LoadUrl(__pWindowInfo->pageUrl);
2454 else if (__pWindowInfo->isJavascriptInitiated == true)
2458 __pWindowInfo->pCurrentWeb = __pWebViewer;
2462 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
2463 AppLog("Homepage Value in Onsceneactivated is %ls",homePage.GetPointer());
2464 if(homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
2466 InitMostVisitedSitesView(GetOrientationStatus());
2468 else if (homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) == 0)
2470 if(__pMostVisitedListView != null)
2472 __pMostVisitedListView->SetShowState(false);
2476 if (__pAddressbar != null && pArgs != null && (previousSceneId == IDSCN_BOOKMARK_VIEW || previousSceneId == IDSCN_HISTORY_LIST))
2478 String* pBookmarkUrl = dynamic_cast< String* >(pArgs->GetAt(0));
2480 if (pBookmarkUrl == null)
2482 AppLogDebug("bookmarkUrl = %ls",pBookmarkUrl->GetPointer());
2483 //__pAddressbar->SetUrl(*pBookmarkUrl);
2484 SetUrl(*pBookmarkUrl);
2486 if (__pWebViewer != null && homePage.CompareTo((L"IDS_BR_BODY_BLANK_PAGE")) != 0)
2487 __pWebViewer->LoadUrl(*pBookmarkUrl);
2488 delete pBookmarkUrl;
2491 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2492 Bitmap* pBitmap = null;
2493 if (isPrivateBrowsing == true)
2495 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_ON);
2497 if (__pWebViewer != null)
2499 __pWebViewer->SetPrivateBrowsingEnabled(true);
2502 if (__pAddressbar != null)
2504 // __pAddressbar->UpdateFaviconBitmap(true);
2510 pBitmap = AppResource::GetInstance()->GetBitmapN(IDB_BUTTON_OFF);
2512 if (__pWebViewer != null)
2514 __pWebViewer->SetPrivateBrowsingEnabled(false);
2517 if (__pAddressbar != null)
2519 // __pAddressbar->UpdateFaviconBitmap(false);
2523 if (__pMenu != null && __pMenu->GetItemCount() == 3)
2525 __pMenu->SetItemAt(0,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2527 else if (__pMenu != null )
2529 __pMenu->SetItemAt(3,CommonUtil::GetString(L"IDS_BR_BODY_PRIVACY_AND_SECURITY_ABB"),IDA_PRIVATEON_CLICKED,*pBitmap);
2532 if (pBitmap != null)
2537 AppLog("ABC: OnSceneActivatedN started exit");
2542 MainForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
2543 const Tizen::Ui::Scenes::SceneId& nextSceneId)
2545 Canvas* pWebCanvas = null;
2546 if (__pWebViewer != null)
2548 pWebCanvas = __pWebViewer->GetCanvasN();
2551 if (pWebCanvas == null)
2555 if (__pWindowInfo != null)
2557 if (__pWindowInfo->pWebCanvasBitmap != null)
2559 delete __pWindowInfo->pWebCanvasBitmap;
2561 __pWindowInfo->pWebCanvasBitmap = new(std::nothrow) Bitmap();
2562 result r = __pWindowInfo->pWebCanvasBitmap->Construct(*pWebCanvas,Rectangle(0,0,pWebCanvas->GetBounds().width,pWebCanvas->GetBounds().height));
2563 AppLog("Bitmap Construction result %s",GetErrorMessage(r));
2565 Bitmap* pBitmap = GetCapturedBitmapN();
2566 AppLog("Coming here");
2567 Canvas* pCanvas = new(std::nothrow) Canvas();
2568 pCanvas->Construct(GetClientAreaBounds());
2571 pCanvas->DrawBitmap(Point(0,0),*pBitmap);
2574 if(__pWebViewer != null && __pWindowInfo != null)
2575 pCanvas->DrawBitmap(__pWebViewer->GetPosition(),*__pWindowInfo->pWebCanvasBitmap);
2577 WindowInfo::pFormCanvasBitmap = new(std::nothrow) Bitmap();
2578 WindowInfo::pFormCanvasBitmap->Construct(*pCanvas,Rectangle(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height - __pFooterPanel->GetHeight()));
2580 AppLog("Coming here");
2584 MainForm::OnHttpAuthenticationRequestedN(const Tizen::Base::String& host,
2585 const Tizen::Base::String& realm,
2586 const Tizen::Web::Controls::AuthenticationChallenge& authentication)
2592 MainForm::OnHttpAuthenticationCanceled(void)
2597 MainForm::OnLoadingStarted(void)
2599 AppLogDebug("MainForm::OnLoadingStarted entered");
2601 if(__pAddressbar == NULL || __pWebViewer == null)
2605 // this is added in case if menu is opened and user load the page
2606 if(__pMenu != null && __pMenu->GetShowState() == true)
2608 __pMenu->SetShowState(false);
2609 __pMenu->Invalidate(true);
2611 if(__pImageMenu != null && __pImageMenu->GetShowState() == true)
2613 __pImageMenu->SetShowState(false);
2614 __pImageMenu->Invalidate(true);
2616 String url = __pWebViewer->GetUrl();
2617 if(url.Contains(IDS_TIZEN_SERVICE))
2620 String delim(L":;,");
2622 // Creates a StringTokenizer instance
2623 StringTokenizer strTok(url, delim);
2625 int count = strTok.GetTokenCount(); // count == 4
2627 HashMap *pMap = new HashMap();
2632 while (strTok.HasMoreTokens())
2634 AppLog("Token: %ls", token.GetPointer());
2635 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
2636 if(token.Contains(IDS_APPID))
2638 token.SubString(6, appId);
2639 AppLog("AppID:%ls", appId.GetPointer());
2641 else if(token.Contains(IDS_KEY))
2643 token.SubString(4, key);
2644 AppLog("key:%ls", key.GetPointer());
2646 else if(token.Contains(IDS_VALUE))
2648 token.SubString(6, value);
2649 AppLog("value:%ls", value.GetPointer());
2652 pMap->Add(key, value);
2656 AppControl *pAppControl = null;
2657 String operationId = L"http://tizen.org/appcontrol/operation/main";
2658 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
2661 AppLog("Starting AppControl");
2662 result r = pAppControl->Start(null, null, pMap, null);
2663 AppLog("Result of Start %s", GetErrorMessage(r));
2667 AppLogException("AppControl not found");
2672 if ( __pAddressbar != null && __pAddressbar->GetShowState() == true)
2674 __pAddressbar->SetShowState(false);
2675 AddressBarCancelledClicked(*__pAddressbar);
2676 __pAddressbar->Invalidate(true);
2678 Bitmap* pBitmap = FaviconManager::GetInstance()->GetDefaultFaviconN();
2681 __pAddressbar->SetFaviconBitmap(*pBitmap);
2684 if (__adressPanelPosition.y < (0 - __pAddressbar->GetHeight() + 12))
2686 // updating the address bar position with respect to web control
2687 __adressPanelPosition.y = 0 - __pAddressbar->GetHeight() + 12; //-12 is for the progress label
2688 __distanceMoved = 0;
2692 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2693 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
2694 if (__pWebViewer != null)
2696 AppLog("MainForm::OnLoadingStarted __pWebViewer->GetUrl() %ls",__pWebViewer->GetUrl().GetPointer());
2697 //__pAddressbar->SetUrl(__pWebViewer->GetUrl());
2698 SetUrl(__pWebViewer->GetUrl());
2699 if (__pWindowInfo != NULL)
2701 // resetting the page title to blank, it will be received in OnPageTitleReceived()
2702 __pWindowInfo->pageTitle = L"";
2703 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
2705 __pAddressbar->Invalidate(true);
2711 MainForm::OnLoadingCanceled(void)
2718 MainForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
2720 AppLog("XYZ::MainForm::OnKeypadWillOpen");
2725 MainForm::OnKeypadOpened(Tizen::Ui::Control& source)
2727 AppLog("XYZ::MainForm::OnKeypadOpened");
2728 __pFooterPanel->SetShowState(false);
2733 MainForm::OnKeypadClosed(Tizen::Ui::Control& source)
2735 AppLog("XYZ::MainForm::OnKeypadClosed");
2736 __pFooterPanel->SetShowState(true);
2737 RelayoutControls(true);
2741 MainForm::OnKeypadBoundsChanged(Tizen::Ui::Control &source)
2743 AppLog("KeypadBoundsChanged");
2744 RelayoutControls(false);
2748 MainForm::OnLoadingErrorOccurred(LoadingErrorType error,
2749 const Tizen::Base::String& reason)
2751 AppLogDebug("Error: %d, %ls", error, reason.GetPointer());
2755 MainForm::OnLoadingCompleted(void)
2757 AppLog("MainForm::OnLoadingCompleted start");
2759 result r = E_SUCCESS;
2761 if (__pWebViewer == null)
2766 if (__pAddressbar == null)
2770 if (__pWebViewer->CanGoForward())
2772 //__pAddressbar->SetForwardButtonEnabled(true);
2773 SetForwardButtonEnabled(true);
2777 //__pAddressbar->SetForwardButtonEnabled(false);
2778 SetForwardButtonEnabled(false);
2781 /*if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2783 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2785 //__pAddressbar->UpdateProgress(0);
2789 if(GetAddressbarMode() != ADDRESSBAR_MODE_EDIT)
2791 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
2795 AppLog("PrivateBrowsing %d",__pWebViewer->IsPrivateBrowsingEnabled());
2796 bool isPrivateBrowsing = SettingPresentationModel::GetInstance()->GetPrivateOn();
2797 if (isPrivateBrowsing == false)
2799 if(__pHistory != null)
2805 __pHistory = new(std::nothrow) History;
2806 HistoryPresentationModel::GetCurrentDateTime(date);
2809 __pHistory->SetHistoryTitle(__pWindowInfo->pageTitle);
2810 AppLogDebug("MainForm::OnLoadingCompleted pagetitle = %ls", __pWindowInfo->pageTitle.GetPointer());
2812 __pHistory->SetHistoryUrl(__pWindowInfo->pageUrl);
2813 AppLogDebug("MainForm::OnLoadingCompleted pageUrl = %ls", __pWindowInfo->pageUrl.GetPointer());
2815 __pHistory->SetVisitedTime(date);
2817 if (__pWebViewer != null)
2819 AppLog("MainForm::OnLoadingCompleted setting the fav icon 0");
2821 Bitmap* pTempBitmap = __pWebViewer->GetFaviconN();
2822 if (pTempBitmap != null)
2824 AppLog("MainForm::OnLoadingCompleted setting the fav icon 1");
2825 __pHistory->SetFavIconBitmap(*pTempBitmap);
2828 AppLog("MainForm::OnLoadingCompleted setting the fav icon 2");
2831 Canvas* pCanvas = __pWebViewer->GetCanvasN();
2832 Bitmap* pBitmap = new(std::nothrow) Bitmap();
2833 if ( pCanvas != null && pCanvas != null && pBitmap != null)
2835 pBitmap->Construct(*pCanvas, pCanvas->GetBounds());
2836 pBitmap->Scale(Dimension(pBitmap->GetWidth()/4, pBitmap->GetHeight()/4));
2837 __pHistory->SetThumbnail(pBitmap);
2839 Bitmap *pFavIcon = __pWebViewer->GetFaviconN();
2842 __pHistory->SetFavIconBitmap(*pFavIcon);
2846 HistoryPresentationModel::GetInstance()->SaveTempHistory(*__pHistory);
2853 // if (__pWindowInfo && __pWindowInfo->faviconUrl == "")
2855 // temperary fixed (webpage can be not loaded)
2859 bool isReaderEnabled = SettingPresentationModel::GetInstance()->IsRunReaderEnabled();
2860 if (isReaderEnabled == true)
2864 delete __pReaderData;
2865 __pReaderData = null;
2867 String filePath = Tizen::App::UiApp::GetInstance()->GetAppRootPath();
2868 filePath.Append(L"data/reader.js");
2874 result r = E_SUCCESS;
2875 FileAttributes attr;
2877 File::GetAttributes(filePath,attr);
2879 r = file.Construct(filePath, L"r+");
2882 AppLogDebug("File construct failed with %s", GetErrorMessage(r));
2885 char* pScript = new(std::nothrow) char[attr.GetFileSize()+1];
2888 AppLogDebug("Memory allocation for file failed %s", GetErrorMessage(r));
2891 // file.Read(pScript,attr.GetFileSize());
2893 // AppLogDebug("scipt length %d",strlen(pScript));
2894 String strScript = L"";
2895 // strScript.Append(pScript);
2896 // for(int i=0; i<25; i++)
2898 file.Read(pScript,attr.GetFileSize());
2899 // AppLog("xyzz tell %d",file.Tell());
2900 // r = strScript.Append(pScript);
2901 // AppLog("xyzz append result %s",GetErrorMessage(r));
2902 // AppLog("xyzz strScript length %d",strScript.GetLength());
2904 // AppLog("xyzz final strScript length %d",strScript.GetLength());
2906 __pReaderData = __pWebViewer->EvaluateJavascriptN(pScript);
2907 if (__pReaderData == null)
2909 AppLog("MainScene::data is null Error :%s",GetErrorMessage(GetLastResult()));
2910 __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>");
2913 AppLogDebug("evaluateJavascript result %s , __pReaderData %ls",GetErrorMessage(GetLastResult()),__pReaderData->GetPointer());
2914 if (__pReaderData->CompareTo(L"undefined") != 0 && __pReaderData->CompareTo(L"") != 0)
2916 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2917 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_READER);
2923 AppLog("MainForm::OnLoadingCompleted done");
2927 MainForm::OnEstimatedProgress(int progress)
2929 AppLogDebug("MainForm::OnEstimatedProgress entered");
2930 if (progress < DEFAULT_PROGRESS_PERCENTAGE)
2931 progress = DEFAULT_PROGRESS_PERCENTAGE;
2933 // __pAddressbar->UpdateProgress(progress);
2934 UpdateProgress(progress);
2937 void MainForm::OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon)
2939 AppLog("MainForm::OnFaviconReceived");
2940 if (__pWebViewer != null && __pHistory != null && __pWindowInfo != null && (__pWindowInfo->pageUrl.CompareTo(__pHistory->GetHistoryUrl()) == 0))
2942 Bitmap* favIcon = __pWebViewer->GetFaviconN();
2945 HistoryPresentationModel::GetInstance()->UpdateHistoryFavIcon(*__pHistory, *favIcon);
2952 MainForm::OnUrlValueChanged(Addressbar&)
2958 MainForm::OnUrlSubmitted(Addressbar& addBar)
2960 AppLog("MainForm::OnUrlSubmitted");
2961 String url = addBar.GetUrl();
2962 AppLog("MainForm::OnUrlSubmitted url is %ls", url.GetPointer());
2964 if(__pFooterUrlField)
2965 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
2966 AddressBarCancelledClicked(*__pAddressbar);
2971 MainForm::LoadUrl(String& url)
2975 // UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
2976 AppLogDebug("MainForm::LoadUrl enter");
2978 if (__pWebViewer != null)
2980 __pWebViewer->SetShowState(true);
2981 __pWebViewer->Invalidate(true);
2984 if (url.CompareTo(L"") == 0)
2988 if(__pFooterPanel != null)
2990 __pFooterPanel->SetShowState(true);
2991 __pFooterPanel->Invalidate(true);
2998 String firstPattern(L"((https?|ftp|gopher|telnet|file|notes|ms-help):((//)|(\\\\))+[\w\d:#@%/;$()~_?\+-=\\\.&]*)");
2999 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)
3001 RegularExpression firstRegex;
3002 RegularExpression secondRegex;
3004 firstRegex.Construct(firstPattern, REGEX_CASELESS);
3005 secondRegex.Construct(secondPattern, REGEX_CASELESS);
3008 ret = firstRegex.Match(url, false); // This returns true value
3009 flag = secondRegex.Match(url, false); // Checks whether URL typed is of type abc.com (i.e without protocol in front of it)
3011 if (ret == true && __pWebViewer != null)
3014 __pWebViewer->LoadUrl(url);
3016 else if(__pWebViewer != null)
3018 String tempUrl = L"http://";
3019 tempUrl.Append(url);
3023 __pWebViewer->LoadUrl(tempUrl);
3027 UrlEncoder::Encode(url, L"UTF-8", encodedUrl);
3028 __pWebViewer->LoadUrl(SettingPresentationModel::GetInstance()->GetSearchUrl(encodedUrl));
3031 if (__pAddressbar != null)
3033 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3034 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING);
3037 AppLogDebug("MainForm::LoadUrl exit");
3044 MainForm::OnStopClicked(Addressbar& addBar)
3046 AppLogDebug("MainForm::OnStopClicked called");
3049 //__pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3050 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
3051 __pWebViewer->StopLoading();
3052 RequestRedraw(true);
3057 MainForm::OnBackClicked(/*const Addressbar& addBar*/)
3059 // AppLog("MainForm::OnBackClicked");
3060 result r = E_FAILURE;
3062 if (__pWebViewer && __pWebViewer->CanGoBack())
3064 __pWebViewer->GoBack();
3066 else if(__pWindowInfo && __pWindowInfo->isJavascriptInitiated == false)
3069 pApp = UiApp::GetInstance();
3072 r = pApp->Terminate();
3075 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3083 WindowInfo* pWindowInfo = null;
3085 SceneManager* pSceneManager = SceneManager::GetInstance();
3086 if (pSceneManager == null)
3090 ArrayList* pAllWindowList = MultipleWindowPresentationModel::GetInstance()->GetAllWindowArrayList();
3091 if (pAllWindowList == NULL)
3093 pApp = UiApp::GetInstance();
3096 r = pApp->Terminate();
3099 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3104 if (pAllWindowList != null)
3106 totalCount = pAllWindowList->GetCount();
3108 for (int count = 0; count < totalCount; count++)
3110 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count));
3111 if (pWindowInfo == null)
3113 pApp = UiApp::GetInstance();
3116 r = pApp->Terminate();
3119 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3124 if (pSceneManager != null && pWindowInfo != null && pSceneManager->GetCurrentSceneId() == pWindowInfo->sceneID && pWindowInfo->isJavascriptInitiated == true)
3126 r = SceneRegister::DestroyAndUnRegisterScene(pWindowInfo->sceneID);
3129 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3132 r = pAllWindowList->RemoveAt(count, true);
3133 __pWindowInfo = null;
3136 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3141 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(count - 1));
3145 pWindowInfo = dynamic_cast< WindowInfo* >(pAllWindowList->GetAt(pAllWindowList->GetCount() - 1));
3147 if (pWindowInfo == null)
3149 pApp = UiApp::GetInstance();
3152 r = pApp->Terminate();
3158 r = pSceneManager->GoBackward(BackwardSceneTransition(pWindowInfo->sceneID ,SCENE_TRANSITION_ANIMATION_TYPE_NONE));
3161 AppLogException("OnActionPerformed failed with %s", GetErrorMessage(r));
3175 MainForm::OnForwardClicked(/*const Addressbar& addBar*/)
3177 AppLog("MainForm::OnForwardClicked");
3178 if (__pWebViewer == null)
3181 if (__pWebViewer->CanGoForward())
3183 __pWebViewer->GoForward();
3188 MainForm::OnAddressBarFocusGained(const Addressbar& addBar)
3190 AppLog("XYZ::MainForm::OnAddressBarFocusGained");
3191 if(__pFooterPanel != null)
3193 __pFooterPanel->SetShowState(false);
3196 if (__pAddressbar != null && __pAddressbar->GetShowState() == false)
3198 __pAddressbar->SetShowState(true);
3199 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3202 RelayoutControls(false);
3206 MainForm::OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState)
3208 AppLog("XYZ::MainForm::OnAddressBarFocusLost");
3210 int Height = GetClientAreaBounds().height;
3211 AppLog("MainForm::OnAddressBarFocusLost height is %d",Height);
3214 // __pAddressbar->SetShowState(false);
3216 if (__pFooterPanel != null && addressbarKeyPadState == false)
3218 AppLog("akjshdasd 3");
3219 __pFooterPanel->SetShowState(true);
3222 RelayoutControls(false);
3226 MainForm::OnAddressCancelledClicked(const Addressbar& addBar)
3228 AddressBarCancelledClicked(addBar);
3232 MainForm::OnAddressBarModeChanged(/*const Addressbar& addBar*/)
3234 __prevAddressBarMode = __curAddressBarMode;
3236 if (__pAddressbar != null)
3238 __curAddressBarMode = GetAddressbarMode();
3241 if (__curAddressBarMode == ADDRESSBAR_MODE_EDIT)
3243 __adressPanelPosition.y = 0;
3244 if (__pAddressbar != null)
3246 __webControlPosition.y = __pAddressbar->GetHeight() - 12;
3247 __pAddressbar->SetBounds(Rectangle(0,0,GetClientAreaBounds().width,__pAddressbar->GetHeight()));
3248 __pAddressbar->Invalidate(true);
3250 if (__pWebViewer != null)
3252 __pWebViewer->StopLoading();
3255 else if(__curAddressBarMode == ADDRESSBAR_MODE_LOADING)
3257 __adressPanelPosition.y = 0;
3258 if (__pAddressbar != null)
3260 __webControlPosition.y = 0;
3261 __pAddressbar->SetBounds(Rectangle(0, __pAddressbar->GetY() - __pAddressbar->GetHeight(), GetClientAreaBounds().width, __pAddressbar->GetHeight()));
3262 __pAddressbar->Invalidate(true);
3268 MainForm::OnClipboardClosed(const Addressbar& addBar)
3270 RelayoutControls(false);
3274 MainForm::OnAddressBarKeypadClosed(const Addressbar& addBar, bool footerState)
3276 if (__pFooterPanel && __pAddressbar->GetShowState() == false)
3278 AppLog("akjshdasd 3");
3279 __pFooterPanel->SetShowState(true);
3282 RelayoutControls(false,footerState);
3286 MainForm::OnAddressBarKeypadOpened(const Addressbar& addBar)
3288 RelayoutControls(false);
3292 MainForm::OnAddressBarKeypadWillOpen(const Addressbar& addBar)
3294 __pFooterPanel->SetShowState(false);
3298 MainForm::OnAddressBarKeypadBoundsChanged(const Addressbar& addBar)
3300 AppLog("KeypadBoundsChanged");
3301 RelayoutControls(false);
3305 MainForm::OnPageTitleReceived(const Tizen::Base::String& title)
3307 AppLog("MainForm::OnPageTitleReceived %ls",title.GetPointer());
3310 __pWindowInfo->pageTitle = title;
3311 if (__pWebViewer != null)
3313 __pWindowInfo->pageUrl = __pWebViewer->GetUrl();
3316 if (__pAddressbar != null && __pWebViewer != null)
3318 SetUrl(__pWebViewer->GetUrl());
3319 __pAddressbar->Invalidate(true);
3324 MainForm::UpdateFavicon(void)
3326 bool urlImageType = false;
3327 String *tempPath = null;
3329 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();");
3330 Bitmap* pBitmap = null;
3332 if (tempPath && tempPath->GetLength() > 0 && tempPath->CompareTo(L"undefined") != 0)
3334 if (__pWindowInfo != null)
3337 url.SetUri(*tempPath);
3338 if (url.GetHost().GetLength() == 0)
3341 webUrl.SetUri(__pWebViewer->GetUrl());
3342 result r = url.SetHost(webUrl.GetHost());
3349 if (url.GetScheme().GetLength() == 0)
3352 webUrl.SetUri(__pWebViewer->GetUrl());
3353 url.SetScheme(webUrl.GetScheme());
3355 __pWindowInfo->faviconUrl = url.ToString();
3357 pBitmap = __pWebViewer->GetFaviconN();
3359 if (pBitmap != null)
3361 if (__pWindowInfo->pFavicon != NULL)
3363 __pWindowInfo->pFavicon = null;
3365 __pWindowInfo->pFavicon = new(std::nothrow) Bitmap();
3366 __pWindowInfo->pFavicon->Construct(*pBitmap,Rectangle(0,0,pBitmap->GetWidth(),pBitmap->GetHeight()));
3368 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3370 FaviconManager::GetInstance()->SaveFavicon(*__pWindowInfo->pFavicon, __pWindowInfo->faviconUrl);
3372 else if(__pWindowInfo->pFavicon != null)
3374 __pAddressbar->SetFaviconBitmap(*__pWindowInfo->pFavicon);
3378 Bitmap *pDefaultBmp = FaviconManager::GetInstance()->GetDefaultFaviconN();
3379 if(pDefaultBmp != null)
3381 __pAddressbar->SetFaviconBitmap(*pDefaultBmp);
3390 if(tempPath != null)
3394 AppLogDebug("Error occured: %s", GetErrorMessage(GetLastResult()));
3401 MainForm::OnLoadingRequested(const Tizen::Base::String& url,
3402 Tizen::Web::Controls::WebNavigationType type)
3404 // when load new page if find word panel is open its show state is false
3405 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3407 __currentSearchStr = L"";
3408 __currentWordIndex = 0;
3409 __maxOccurrances = 0;
3410 __pFindWordEditField->SetText(L"");
3411 __pFindWordNext->SetEnabled(false);
3412 __pFindWordPrev->SetEnabled(false);
3413 __pFindWordCountLabel->SetText(L"0/0");
3414 __pFindWordControl->SetShowState(false);
3415 __pFindWordEditField->HideKeypad();
3416 RelayoutControls(false);
3421 __pFooterPanel->Invalidate(true);
3424 uriInfo.SetUri(url);
3426 if(url.Contains(IDS_TIZEN_SERVICE))
3429 String delim(L":;,");
3431 // Creates a StringTokenizer instance
3432 StringTokenizer strTok(url, delim);
3434 int count = strTok.GetTokenCount(); // count == 4
3436 HashMap *pMap = new HashMap();
3442 while (strTok.HasMoreTokens())
3444 AppLog("Token: %ls", token.GetPointer());
3445 strTok.GetNextToken(token); // Tizen, StringTokenizer, Sample, code
3446 if(token.Contains(IDS_APPID))
3448 token.SubString(6, appId);
3449 AppLog("AppID:%ls", appId.GetPointer());
3451 else if(token.Contains(IDS_KEY))
3453 token.SubString(4, key);
3454 AppLog("key:%ls", key.GetPointer());
3456 else if(token.Contains(IDS_VALUE))
3458 token.SubString(6, value);
3459 AppLog("value:%ls", value.GetPointer());
3462 pMap->Add(key, value);
3466 AppControl *pAppControl = null;
3467 String operationId = L"http://tizen.org/appcontrol/operation/main";
3468 pAppControl = dynamic_cast<AppControl*>(AppManager::FindAppControlN(appId, operationId));
3471 result r = pAppControl->Start(null, null, pMap, null);
3475 AppLogException("AppControl not found");
3485 MainForm::OnWebDataReceived(const Tizen::Base::String& mime,
3486 const Tizen::Net::Http::HttpHeader& httpHeader)
3488 return Tizen::Web::Controls::WEB_DECISION_CONTINUE;
3493 MainForm::OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint)
3495 AppLog("MainForm::OnWebPageBlockSelected");
3496 if (__pHitElementResult != null)
3498 delete __pHitElementResult;
3499 __pHitElementResult = null;
3502 if (__pWebViewer != null)
3504 AppLog("MainForm::OnWebPageBlockSelected web not null");
3505 __pHitElementResult = __pWebViewer->GetElementByPointN(startPoint);
3507 if(GetLastResult() == E_INVALID_ARG)
3509 AppLog("datafirst startpoint error %s",GetErrorMessage(GetLastResult()));
3510 __pHitElementResult = __pWebViewer->GetElementByPointN(endPoint);
3511 if(GetLastResult() == E_INVALID_ARG)
3513 __pHitElementResult = __pWebViewer->GetElementByPointN(__longPressPoint);
3515 AppLog("datafirst endpoint error %s",GetErrorMessage(GetLastResult()));
3519 if (__pHitElementResult == null)
3524 if (__pHitElementResult->HasImage() != true)
3526 String tagName = __pHitElementResult->GetTagName();
3527 String type = __pHitElementResult->GetAttributeValue("type");
3530 __currentSelectedStr.Clear();
3531 AppLog("__currentSelectedStr after clear %ls",__currentSelectedStr.GetPointer());
3532 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
3533 AppLog("__currentSelectedStr after GetTextFromBlock %ls",__currentSelectedStr.GetPointer());
3535 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) /*&& __isLongPressedDone == true*/ && __currentSelectedStr.CompareTo(L"") !=0)
3537 AppLog("MainForm::OnWebPageBlockSelected show paste option");
3539 InitSelectTextContextMenu(endPoint,true);
3540 __pImageMenu->SetShowState(true);
3541 __pImageMenu->Show();
3542 __pImageMenu->Invalidate(true);
3544 else /*if(__isLongPressedDone == true)*/
3546 AppLog("MainForm::OnWebPageBlockSelected no paste option");
3548 if(__pHitElementResult->GetUrl().GetLength() > 0)
3550 __currentSelectedStr.Clear();
3551 __currentSelectedStr = __pHitElementResult->GetUrl();
3553 InitSelectTextContextMenu(endPoint,false);
3554 __pImageMenu->SetShowState(true);
3555 __pImageMenu->Show();
3556 __pImageMenu->Invalidate(true);
3559 AppLog("MainForm::OnWebPageBlockSelected block text is %ls",__currentSelectedStr.GetPointer());
3560 AppLog("MainForm::OnWebPageBlockSelected tag name is %ls",tagName.GetPointer());
3561 AppLog("MainForm::OnWebPageBlockSelected type name is %ls",type.GetPointer());
3567 MainForm::OnWebPageShowRequested(Tizen::Web::Controls::Web& source)
3573 MainForm::OnWebWindowCreateRequested(void)
3575 WindowInfo* pNewWindowInfo = MultipleWindowPresentationModel::GetInstance()->CreateNewMainViewSceneN();
3577 if (pNewWindowInfo == null)
3581 result r = E_SUCCESS;
3582 SceneManager* pSceneManager = SceneManager::GetInstance();
3583 if (pSceneManager == NULL)
3587 ArrayList* pArgList = new(std::nothrow) ArrayList();
3588 if (pArgList == NULL)
3592 r = pArgList->Construct();
3595 pNewWindowInfo->isJavascriptInitiated = true;
3596 pArgList->Add(*pNewWindowInfo);
3597 r = pSceneManager->GoForward(ForwardSceneTransition(pNewWindowInfo->sceneID, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
3601 AppLogDebug("EditHistoryListForm::OnFormBackRequested Failed to GoBackward %s",GetErrorMessage(r));
3608 return pNewWindowInfo->pCurrentWeb;
3612 MainForm::RelayoutControls(bool showAddressbar,bool relayoutFooter)
3614 __webControlPosition.y = 0;
3615 __webControlHeight = GetClientAreaBounds().height;
3616 AppLog("Client area height: %d", __webControlHeight);
3618 AppLog("Client area height: %d", __webControlHeight);
3619 if(__pAddressbar != null && __pAddressbar->GetShowState() == true)
3621 __webControlPosition.y += __pAddressbar->GetHeight();
3622 __webControlHeight -= __pAddressbar->GetHeight();
3623 __pAddressbar->SetBounds(0, 0, __pAddressbar->GetWidth(), __pAddressbar->GetHeight());
3625 else if(__pFindWordControl != null && __pFindWordControl->GetShowState() == true)
3627 __webControlPosition.y += __pFindWordControl->GetHeight();
3628 __webControlHeight -= __pFindWordControl->GetHeight();
3629 __pFindWordControl->SetBounds(0, 0, GetClientAreaBounds().width, __pFindWordControl->GetHeight());
3632 if(__pFooterPanel != null && __pFooterPanel->GetShowState() == true && relayoutFooter == true)
3634 __webControlHeight -= __pFooterPanel->GetHeight();
3636 __pFooterPanel->SetBounds(0, __webControlPosition.y + __webControlHeight, GetClientAreaBounds().width, __pFooterPanel->GetHeight());
3638 if (__pWebViewer != null && __pWebViewer->GetShowState() == true)
3640 __pWebViewer->SetBounds(0, __webControlPosition.y, GetClientAreaBounds().width, __webControlHeight + 12);
3641 __pWebViewer->Invalidate(false);
3643 if(__pMostVisitedListView != null && __pAddressbar != null && __pFooterPanel != null)
3645 __pMostVisitedListView->SetBounds(Tizen::Graphics::Rectangle(0,__webControlPosition.y , GetClientAreaBounds().width, __webControlHeight));
3652 MainForm::ShowFindWordPanel(bool show , bool isTouchPressed)
3654 if (__pFindWordControl == null)
3659 Tizen::Locales::LocaleManager localeManager;
3660 Tizen::Locales::Locale local = localeManager.GetSystemLocale();
3662 String languageCode;
3663 result r = SettingInfo::GetValue(L"Language", languageCode);
3664 // int languagecode = local.GetLanguageCode();
3665 AppLog("rahul language is %S", languageCode.GetPointer());
3669 InitFindWordPanel();
3671 if (languageCode.CompareTo("ara") == 0)
3673 AppLog("rahul language is arabic");
3675 __pFindWordPanelLeftToRight->SetShowState(false);
3676 __pFindWordPanelRightToLeft->SetShowState(true);
3678 __pFindWordClear->SetShowState(false);
3679 __pFindWordCountLabel->SetShowState(false);
3680 __pFindWordEditField->SetShowState(false);
3682 __pFindWordClearRightToLeft->SetShowState(true);
3683 __pFindWordCountLabelRightToLeft->SetShowState(true);
3684 __pFindWordEditFieldRightToLeft->SetShowState(true);
3688 AppLog("rahul language is not arabic");
3691 __pFindWordPanelLeftToRight->SetShowState(true);
3692 __pFindWordPanelRightToLeft->SetShowState(false);
3694 __pFindWordClear->SetShowState(true);
3695 __pFindWordCountLabel->SetShowState(true);
3696 __pFindWordEditField->SetShowState(true);
3698 __pFindWordClearRightToLeft->SetShowState(false);
3699 __pFindWordCountLabelRightToLeft->SetShowState(false);
3700 __pFindWordEditFieldRightToLeft->SetShowState(false);
3702 __pFindWordControl->SetShowState(true);
3706 if(__pFindWordControl != null)
3708 __pFindWordControl->SetShowState(false);
3712 AppLog("MainForm::ShowFindWordPanel %d",show);
3713 if (show && !isTouchPressed)
3715 if (languageCode.CompareTo("ara") == 0)
3717 if (__pFindWordEditFieldRightToLeft)
3719 __pFindWordEditFieldRightToLeft->SetFocus();
3720 __pFindWordEditFieldRightToLeft->ShowKeypad();
3725 if (__pFindWordEditField)
3727 __pFindWordEditField->SetFocus();
3728 __pFindWordEditField->ShowKeypad();
3734 if (languageCode.CompareTo("ara") == 0)
3736 if (__pFindWordEditFieldRightToLeft)
3737 __pFindWordEditFieldRightToLeft->HideKeypad();
3741 if (__pFindWordEditField)
3742 __pFindWordEditField->HideKeypad();
3746 RelayoutControls(false);
3750 MainForm::StartWordSearch()
3752 //Get the count of occurances of the word in the current page
3753 __maxOccurrances = 0;
3754 __currentWordIndex = 0;
3756 __pFindWordPrev->SetEnabled(false);
3757 String *pCountStr = null;
3758 __pWebViewer->SearchTextAllAsync(__currentSearchStr, false);
3759 /*__pWebViewer->EvaluateJavascriptN(L"document.body.textContent.match(/" + __currentSearchStr + "/gi).length;");
3760 if (pCountStr != null)
3762 Integer::Parse(*pCountStr, 10, __maxOccurrances);
3766 AppLogDebug("'%ls' is found %d times", __currentSearchStr.GetPointer(), __maxOccurrances);
3771 void MainForm::OnTextFound(int totalCount, int currentOrdinal)
3773 AppLog("MainForm::OnTextFound totalCount %d",totalCount);
3774 AppLog("MainForm::OnTextFound currentOrdinal %d",currentOrdinal);
3776 if(totalCount == -1 || totalCount == 0)
3778 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),84,__pFindWordCountLabel->GetHeight());
3779 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),214+80,__pFindWordEditField->GetHeight());
3782 else if(totalCount > 100)
3784 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3785 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3789 __pFindWordCountLabel->SetBounds(__pFindWordCountLabel->GetX(),__pFindWordCountLabel->GetY(),124,__pFindWordCountLabel->GetHeight());
3790 __pFindWordEditField->SetBounds(__pFindWordEditField->GetX(),__pFindWordEditField->GetY(),174,__pFindWordEditField->GetHeight());
3793 __maxOccurrances = totalCount;
3794 __currentWordIndex = currentOrdinal;
3796 //Reset the UI controls as per the maxOccurrance value
3797 if (totalCount <= 0)
3799 AppLog("Word not found");
3800 //Show error notification to user
3801 __pFindWordNext->SetEnabled(false);
3802 if(__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3804 __pFindWordCountLabel->SetText(L"0/0");
3805 __pFindWordCountLabel->Invalidate(false);
3807 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3809 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
3810 __pFindWordCountLabelRightToLeft->Invalidate(false);
3812 __pFindWordNext->Invalidate(false);
3813 __pFindWordPrev->Invalidate(false);
3818 if (totalCount == 1)
3820 __pFindWordNext->SetEnabled(false);
3824 __pFindWordNext->SetEnabled(true);
3827 String countStr = L"";
3828 countStr.Append(__currentWordIndex);
3829 countStr.Append(L"/");
3830 countStr.Append(__maxOccurrances);
3831 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3833 __pFindWordCountLabel->SetText(countStr);
3834 __pFindWordCountLabel->Invalidate(false);
3835 __pFindWordCountLabel->Invalidate(false);
3837 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3839 __pFindWordCountLabelRightToLeft->SetText(countStr);
3840 __pFindWordCountLabelRightToLeft->Invalidate(false);
3841 __pFindWordCountLabelRightToLeft->Invalidate(false);
3843 //FindNextWord(true);
3844 //Update the controls
3845 __pFindWordNext->Invalidate(false);
3846 __pFindWordPrev->Invalidate(false);
3851 MainForm::FindNextWord(bool next)
3855 //if (__pWebViewer->SearchText(__currentSearchStr, true) == true)
3856 if (__pWebViewer->SearchNextAsync(true) == E_SUCCESS)
3858 if (__currentWordIndex < __maxOccurrances)
3860 __currentWordIndex++;
3866 //if (__pWebViewer->SearchText(__currentSearchStr, false) == true)
3867 if (__pWebViewer->SearchNextAsync(false) == E_SUCCESS)
3869 if(__currentWordIndex > 1)
3871 __currentWordIndex--;
3876 String countStr = L"";
3877 countStr.Append(__currentWordIndex);
3878 countStr.Append(L"/");
3879 countStr.Append(__maxOccurrances);
3881 if (__pFindWordCountLabel && __pFindWordCountLabel->GetShowState() == true)
3883 __pFindWordCountLabel->SetText(countStr);
3884 __pFindWordCountLabel->Invalidate(false);
3886 else if(__pFindWordCountLabelRightToLeft && __pFindWordCountLabelRightToLeft->GetShowState() == true)
3888 __pFindWordCountLabelRightToLeft->SetText(countStr);
3889 __pFindWordCountLabelRightToLeft->Invalidate(false);
3892 if (__currentWordIndex >= __maxOccurrances)
3894 __pFindWordNext->SetEnabled(false);
3898 __pFindWordNext->SetEnabled(true);
3900 if (__currentWordIndex <= 1)
3902 __pFindWordPrev->SetEnabled(false);
3906 __pFindWordPrev->SetEnabled(true);
3908 __pFindWordPrev->Invalidate(false);
3909 __pFindWordNext->Invalidate(false);
3911 __pFindWordControl->Invalidate(true);
3915 MainForm::OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source)
3917 AppLog("xyz::MainForm::OnWebKeypadWillOpen");
3918 __isWebKeypadOpened = true;
3919 __pFooterPanel->SetShowState(false);
3920 // OnAddressBarKeypadOpened(*__pAddressbar);
3924 MainForm::OnWebKeypadOpened(Tizen::Web::Controls::Web& source)
3926 AppLog("xyz::MainForm::OnWebKeypadOpened");
3928 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
3930 __currentSearchStr = L"";
3931 __currentWordIndex = 0;
3932 __maxOccurrances = 0;
3933 __pFindWordEditField->SetText(L"");
3934 __pFindWordNext->SetEnabled(false);
3935 __pFindWordPrev->SetEnabled(false);
3936 __pFindWordCountLabel->SetText(L"0/0");
3937 __pWebViewer->SearchTextAllAsync(L"",false);
3938 __pFindWordControl->SetShowState(false);
3939 __pFindWordEditField->HideKeypad();
3943 if (__pWebViewer != null && __pFooterPanel != null)
3945 AppLog("MainForm::OnWebKeypadOpened GetClientAreaBounds().height %d ", GetClientAreaBounds().height);
3946 if(__pAddressbar != null)
3948 __pAddressbar->SetShowState(false);
3950 if(__pFindWordControl != null)
3952 __pFindWordControl->SetShowState(false);
3954 __pFooterPanel->SetShowState(false);
3955 __pWebViewer->SetBounds(Rectangle(0, 0,GetClientAreaBounds().width, GetClientAreaBounds().height));
3957 // if(__pImageMenu && __pImageMenu->GetShowState() == true)
3959 // __pImageMenu->SetAnchorPosition(Point(__pImageMenu->GetAnchorPosition().x/2,__pImageMenu->GetAnchorPosition().y/2));
3960 // AppLog("omgomgomg");
3966 MainForm::OnWebKeypadClosed(Tizen::Web::Controls::Web& source)
3968 AppLog("xyz::MainForm::OnWebKeypadClosed");
3969 AppLog("akjshdasd 4");
3970 __pFooterPanel->SetShowState(true);
3971 // OnAddressBarKeypadClosed(*__pAddressbar);
3972 RelayoutControls(false);
3973 __isWebKeypadOpened = false;
3977 MainForm::OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source)
3979 // RelativeLayout(false);
3983 MainForm::OnTouchDoublePressed(const Control& source, const Point& currentPosition, const TouchEventInfo& touchInfo)
3985 Control* temp = const_cast< Control* >(&source);
3986 Header* pHeader = dynamic_cast< Header* >(temp);
3987 if (pHeader != null)
3989 //Header double - clicked
3990 AppLog("Header double clicked");
3992 if(__pFindWordControl)
3994 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
3995 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
3999 AppLog("MainScene::OnTouchDoublePressed");
4003 void MainForm::OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4005 AppLog("abcde::MainForm::OnTouchLongPressed %d, %d" ,currentPosition.x,currentPosition.y);
4006 __longPressPoint = currentPosition;
4008 if (__pHitElementResult != null)
4010 delete __pHitElementResult;
4011 __pHitElementResult = null;
4014 if (__pWebViewer != null)
4016 AppLog("MainForm::OnTouchLongPressed web not null");
4017 __pHitElementResult = __pWebViewer->GetElementByPointN(currentPosition);
4020 if (__pHitElementResult == null)
4025 if (__pHitElementResult->HasImage() == true)
4027 InitImageContextMenu(currentPosition);
4028 __pImageMenu->SetShowState(true);
4029 __pImageMenu->Show();
4030 __pImageMenu->Invalidate(true);
4032 else if(__pHitElementResult->HasUrl() == true)
4034 String tempURl = __pHitElementResult->GetUrl();
4035 AppLog("tempURl is %ls", tempURl.GetPointer());
4036 const Bitmap* pBitmap = __pHitElementResult->GetImage();
4037 if (pBitmap != null)
4045 InitImageLinkContextMenu(currentPosition);
4046 __pImageMenu->SetShowState(true);
4047 __pImageMenu->Show();
4048 __pImageMenu->Invalidate(true);
4052 String tagName = __pHitElementResult->GetTagName();
4053 String type = __pHitElementResult->GetAttributeValue("type");
4054 String value = __pHitElementResult->GetAttributeValue(L"value");
4055 String innerHtml = __pHitElementResult->GetAttributeValue(L"innerHTML");
4057 __currentSelectedStr.Clear();
4058 __currentSelectedStr = __pWebViewer->GetTextFromBlock();
4060 AppLog("tag name is %ls", tagName.GetPointer());
4061 AppLog("type is %ls", type.GetPointer());
4065 //__isLongPressedDone = true;
4066 result r =__pWebViewer->SetBlockSelectionPosition(currentPosition);
4067 if (((tagName.CompareTo(L"INPUT") == 0) || tagName.CompareTo(L"TEXTAREA") == 0) && innerHtml.GetLength() == 0 /*&& __isWebKeypadOpened == true*/ && __currentSelectedStr.CompareTo(L"") == 0 && r == E_INVALID_ARG)
4069 AppLog("MainForm::OnWebPageBlockSelected show paste option");
4071 InitSelectTextContextMenu(currentPosition,true, true);
4074 __pImageMenu->SetShowState(true);
4075 __pImageMenu->Show();
4076 __pImageMenu->Invalidate(true);
4079 AppLog("setselectionselectedornot %s",GetErrorMessage(r));
4082 // __inputEventToBeSupressed = true;
4086 MainForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4088 AppLog("MainForm::OnTouchReleased");
4091 /*HitElementResult* pHitElement = __pWebViewer->GetElementByPointN(currentPosition);
4092 if(pHitElement != null && pHitElement->HasUrl() == true && __inputEventToBeSupressed == true)
4094 __pWebViewer->ConsumeInputEvent();
4096 if(pHitElement != null)
4100 __inputEventToBeSupressed = false;*/
4104 MainForm::OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4111 MainForm::OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4113 if(__pFindWordControl && __pFindWordControl->GetShowState() == true)
4115 __currentSearchStr = L"";
4116 __currentWordIndex = 0;
4117 __maxOccurrances = 0;
4119 if (__pFindWordPanelLeftToRight && __pFindWordPanelLeftToRight->GetShowState() == true)
4121 __pFindWordEditField->SetText(L"");
4122 __pFindWordEditField->HideKeypad();
4123 __pFindWordControl->SetShowState(false);
4124 __pFindWordCountLabel->SetText(L"0/0");
4126 else if(__pFindWordPanelRightToLeft && __pFindWordPanelRightToLeft->GetShowState() == true)
4128 __pFindWordEditFieldRightToLeft->SetText(L"");
4129 __pFindWordEditFieldRightToLeft->HideKeypad();
4130 __pFindWordControl->SetShowState(false);
4131 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4134 __pFindWordNext->SetEnabled(false);
4135 __pFindWordPrev->SetEnabled(false);
4137 __pWebViewer->SearchText(L"aaaabbbbcccc",true);
4138 __pFindWordControl->SetShowState(false);
4140 if(__pAddressbar->GetShowState() == false)
4142 __pAddressbar->SetAddressbarURLFocus();
4143 __pFooterPanel->SetShowState(false);
4150 MainForm::OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4156 MainForm::OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4162 MainForm::OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4168 MainForm::OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4174 MainForm::OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo)
4180 MainForm::OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus)
4182 AppLog("MainForm::OnOrientationChanged GetClientAreaBounds %d, %d",GetClientAreaBounds().width,GetClientAreaBounds().height);
4183 int widthContextItem = 0;
4185 // As per the platform engineer comment removed this line
4186 /*if(__pWebViewer != null)
4188 // 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
4189 __pWebViewer->ReleaseBlock();
4192 if(__pFindWordControl != null)
4193 ShowFindWordPanel(__pFindWordControl->GetShowState(), false);
4194 if ( __pFooterLabel != null)
4196 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_SEARCH_INPUT_FIELD_BG, __pFooterLabel->GetWidth(), __pFooterLabel->GetHeight());
4199 __pFooterLabel->SetBackgroundBitmap(*pBitmap);
4205 if (__pFindWordBgLabel != null)
4207 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabel->GetWidth(), __pFindWordBgLabel->GetHeight());
4208 if (pBitmap != null)
4210 __pFindWordBgLabel->SetBackgroundBitmap(*pBitmap);
4215 if (__pFindWordBgLabelRightToLeft != null)
4217 Bitmap *pBitmap = CommonUtil::GetNinepatchedBitmapN(IDB_FINDWORD_INPUT_FIELD_BG, __pFindWordBgLabelRightToLeft->GetWidth(), __pFindWordBgLabelRightToLeft->GetHeight());
4218 if (pBitmap != null)
4220 __pFindWordBgLabelRightToLeft->SetBackgroundBitmap(*pBitmap);
4226 __pMenu->SetShowState(false);
4227 if( GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
4229 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_LANDSCAPE;
4233 widthContextItem = WIDTH_CONTEXT_MENU_BUTTON_PORTRAIT;
4238 AppLog("__pFooterPanel->GetShowState() is true");
4240 __pFooterPanel->SetBounds(0, GetClientAreaBounds().height - __pFooterPanel->GetHeight(), __pFooterPanel->GetWidth(), __pFooterPanel->GetHeight());
4241 __pFooterPanel->Invalidate(true);
4245 if(__pMoreButton && __pMenu)
4247 Point p = Point(__pMoreButton->GetX() + __pMoreButton->GetWidth() / 2, GetBounds().height - __pMoreButton->GetHeight());
4248 __pMenu->SetAnchorPosition(p);
4249 __pMenu->Invalidate(true);
4252 String homePage = SettingPresentationModel::GetInstance()->GetHomepage();
4253 if (homePage.CompareTo((L"IDS_BR_BODY_MOST_VISITED_SITES")) == 0)
4255 InitMostVisitedSitesView(orientationStatus);
4258 RelayoutControls(false);
4259 if (__pArticleReaderPanel != null)
4261 if (__pArticleReaderPanel->GetShowState() == true)
4263 __pArticleReaderPanel->SetBounds((GetClientAreaBounds().width - __pArticleReaderPanel->GetWidth())/2,(GetClientAreaBounds().height - __pArticleReaderPanel->GetHeight())/2, __pArticleReaderPanel->GetWidth(), __pArticleReaderPanel->GetHeight());
4265 if (__pBlankPanel != null)
4266 __pBlankPanel->SetBounds(0,0,GetClientAreaBounds().width,GetClientAreaBounds().height);
4268 if (__pWebReader != null)
4270 __pWebReader->SetBounds(Rectangle(2,2, __pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight() - 96));
4272 Bitmap* pBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4273 Bitmap* pSrcBitmap = CommonUtil::GetNinepatchedBitmapN(L"I01_popup_bottom_bg.9.png",__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight());
4275 if ( pBitmap != null && pSrcBitmap != null)
4277 AppLog("CreateReaderPanel ninepatchbitmap found");
4278 pBitmap->Merge(Point(0,__pArticleReaderPanel->GetHeight() - 96),*pSrcBitmap,Rectangle(0,0,pSrcBitmap->GetWidth(),pSrcBitmap->GetHeight()));
4281 __pArticleReaderLabel->SetBounds(Rectangle(__pArticleReaderPanel->GetX(),__pArticleReaderPanel->GetY(),__pArticleReaderPanel->GetWidth(),__pArticleReaderPanel->GetHeight()));
4282 __pArticleReaderLabel->SetBackgroundBitmap(*pBitmap);
4283 if (pBitmap != null)
4288 if (pSrcBitmap != null)
4297 if (__pAddressbar != null)
4299 int width = GetClientAreaBounds().width;
4300 __pAddressbar->OrientationChanged(width);
4305 MainForm::OnSettingsChange(int settingvalue)
4307 AppLogDebug("MainForm::OnSettingsChange entered");
4309 if(settingvalue == (int)REGISTRY_SETTING_HOMEPAGE)
4311 __pAddressbar->ResetGuideText();
4313 if (__pWebViewer == null)
4315 AppLogDebug("Webviewer is not initialized yet.");
4319 if (settingvalue == (int) REGISTRY_SETTING_DEFAULT_VIEW)
4321 WebSetting settings = __pWebViewer->GetSetting();
4322 if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_FIT_TO_WIDTH")) == 0)
4324 settings.SetAutoFittingEnabled(true);
4326 else if (SettingPresentationModel::GetInstance()->GetDefaultView().CompareTo((L"IDS_BR_BODY_READABLE")) == 0)
4328 settings.SetAutoFittingEnabled(false);
4330 __pWebViewer->SetSetting(settings);
4332 else if (settingvalue == (int) REGISTRY_SETTING_RUN_JAVASCRIPT)
4334 WebSetting settings = __pWebViewer->GetSetting();
4335 settings.SetJavascriptEnabled(SettingPresentationModel::GetInstance()->IsRunJavascriptEnabled());
4336 __pWebViewer->SetSetting(settings);
4338 else if (settingvalue == (int) REGISTRY_SETTING_DISPLAY_IMAGES)
4340 WebSetting settings = __pWebViewer->GetSetting();
4341 settings.SetAutoImageLoadEnabled(SettingPresentationModel::GetInstance()->IsDisplayImagesEnabled());
4342 __pWebViewer->SetSetting(settings);
4343 __pWebViewer->Reload();
4345 else if (settingvalue == (int) REGISTRY_SETTING_BLOCK_POPUP)
4347 WebSetting settings = __pWebViewer->GetSetting();
4348 settings.SetJavaScriptPopupEnabled(SettingPresentationModel::GetInstance()->IsBlockPopUp());
4349 __pWebViewer->SetSetting(settings);
4351 else if (settingvalue == (int) REGISTRY_SETTING_ACCEPT_COOKIES)
4355 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4358 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_FORM_DATA)
4362 WebSetting settings = __pWebViewer->GetSetting();
4363 settings.SetAutoFormDataShowEnabled(SettingPresentationModel::GetInstance()->IsRememberFormData());
4364 __pWebViewer->SetSetting(settings);
4367 else if(settingvalue == (int) REGISTRY_SETTING_REMEMBER_PASSWORD)
4371 WebSetting settings = __pWebViewer->GetSetting();
4372 settings.SetAutoLoginFormFillEnabled(SettingPresentationModel::GetInstance()->IsRememberPassword());
4373 __pWebViewer->SetSetting(settings);
4376 else if (settingvalue == (int) REGISTRY_SETTING_SHOW_SECURITY_WARNINGS)
4378 WebSetting settings = __pWebViewer->GetSetting();
4379 if (SettingPresentationModel::GetInstance()->IsSecurityWarningsEnabled() == true)
4381 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_USER_CONFIRM);
4385 settings.SetCertificateErrorHandlingMode(WEB_CERTIFICATE_ERROR_HANDLING_MODE_CONTINUE);
4387 __pWebViewer->SetSetting(settings);
4389 else if (settingvalue == (int) REGISTRY_SETTING_READER_FONT_SIZE)
4393 AppLogDebug("IntMainForm fontsize Changed to %d",SettingPresentationModel::GetInstance()->GetReaderFontSize());
4394 WebSetting settings = __pWebReader->GetSetting();
4395 settings.SetFontSize(SettingPresentationModel::GetInstance()->GetReaderFontSize());
4396 __pWebReader->SetSetting(settings);
4402 MainForm::OnSettingsReset()
4406 __pWebViewer->SetCookieEnabled(SettingPresentationModel::GetInstance()->IsCookiesEnabled());
4407 __pWebViewer->SetSetting(SettingPresentationModel::GetInstance()->GetWebSettings());
4412 MainForm::OnClearCache()
4414 result r = E_SUCCESS;
4416 if (__pWebViewer != NULL)
4418 r = __pWebViewer->ClearCache();
4421 AppLogDebug("Cache cleared success");
4425 AppLogDebug("Cache cleared fail");
4431 MainForm::OnClearCookie()
4433 result r = E_SUCCESS;
4435 if (__pWebViewer != NULL)
4437 __pWebViewer->ClearCookie();
4441 AppLogDebug("Cookie cleared success");
4445 AppLogDebug("Cache cleared fail");
4450 MainForm::OnClearFormData()
4452 result r = E_SUCCESS;
4454 if (__pWebViewer != NULL)
4456 __pWebViewer->ClearFormData();
4460 AppLogDebug("Cookie cleared success");
4464 AppLogDebug("Cache cleared fail");
4469 MainForm::OnClearPasswords()
4471 result r = E_SUCCESS;
4473 if (__pWebViewer != NULL)
4475 __pWebViewer->ClearLoginFormData();
4479 AppLogDebug("Cookie cleared success");
4483 AppLogDebug("Cache cleared fail");
4489 MainForm::findDistance(int x1,int y1,int x2, int y2)
4491 int deltaX = Math::Abs(x2 - x1);
4492 int deltaY = Math::Abs(y2 - y1);
4493 double num = deltaX*deltaX + deltaY*deltaY;
4499 for (i = 0; i < 20; i++)
4501 x = (((x*x)+ num)/(2*x));
4512 MainForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4514 if(__pFindWordControl)
4516 AppLog("MainForm::OnTouchPressed %d",__pFindWordControl->GetShowState());
4517 ShowFindWordPanel(__pFindWordControl->GetShowState(), true);
4519 //__isLongPressedDone = false;
4521 __pAddressbar->SetShowState(false);
4524 IList* pList = null;
4525 pList = touch.GetTouchInfoListN(source);
4529 int count = pList->GetCount();
4532 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4533 __touchPoint1 = pTouchInfo->position;
4535 /*if (__pAddressbar != null)
4537 if (__pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && __pAddressbar->GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4539 if (__pAddressbar->GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4541 __pAddressbar->SaveAddressbarEditText();
4543 __pAddressbar->SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4546 __pAddressbar->Invalidate(true);
4548 if (GetAddressbarMode() != ADDRESSBAR_MODE_LOADING_COMPLETE && GetAddressbarMode() != ADDRESSBAR_MODE_LOADING)
4550 if (GetAddressbarMode() == ADDRESSBAR_MODE_EDIT)
4552 //__pAddressbar->SaveAddressbarEditText();
4554 SetAddressbarMode((AddressBarMode)ADDRESSBAR_MODE_LOADING_COMPLETE);
4557 else if (count == 2)
4559 AppLogDebug("MainForm::OnTouchPressed count is two");
4560 TouchInfo* pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(0));
4561 __touchPoint1 = pTouchInfo->position;
4563 pTouchInfo = static_cast<TouchInfo*>(pList->GetAt(1));
4564 __touchPoint2 = pTouchInfo->position;
4570 pList->RemoveAll(true);
4577 MainForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
4579 // __currentWordIndex = 0;
4580 //__isLongPressedDone = false;
4585 MainForm::MoveUiControls()
4590 MainForm::OnTextValueChanged (const Tizen::Ui::Control &source)
4592 if(&source == dynamic_cast<Control*>(__pFooterUrlField) && __pFooterUrlField != null)
4594 if(__pFooterUrlField->GetTextLength() == 0)
4596 __pFooterUrlField->SetKeypadActionEnabled(false);
4600 __pFooterUrlField->SetKeypadActionEnabled(true);
4603 if (__pFindWordEditField != null && __pFindWordEditField->GetShowState() == true)
4605 __currentSearchStr = __pFindWordEditField->GetText();
4606 if (__currentSearchStr.GetLength() > 0)
4608 __pFindWordCountLabel->SetShowState(true);
4612 __pFindWordCountLabel->SetShowState(false);
4614 __pFindWordNext->SetEnabled(false);
4615 __pFindWordPrev->SetEnabled(false);
4616 __pFindWordNext->Invalidate(true);
4617 __pFindWordPrev->Invalidate(true);
4618 __pFindWordCountLabel->SetText(L"0/0");
4619 __pFindWordCountLabel->Invalidate(true);
4621 else if (__pFindWordEditFieldRightToLeft != null && __pFindWordEditFieldRightToLeft->GetShowState() == true)
4623 __currentSearchStr = __pFindWordEditFieldRightToLeft->GetText();
4624 if (__currentSearchStr.GetLength() > 0)
4626 __pFindWordCountLabelRightToLeft->SetShowState(true);
4630 __pFindWordCountLabelRightToLeft->SetShowState(false);
4633 __pFindWordNext->SetEnabled(false);
4634 __pFindWordPrev->SetEnabled(false);
4635 __pFindWordNext->Invalidate(true);
4636 __pFindWordPrev->Invalidate(true);
4637 __pFindWordCountLabelRightToLeft->SetText(L"0/0");
4638 __pFindWordCountLabelRightToLeft->Invalidate(true);
4640 AppLog("__currentSearchStr %ls",__currentSearchStr.GetPointer());
4641 if (__currentSearchStr.GetLength() > 0)
4647 __currentSearchStr = L"aaaaaaaabbbbbbbccccccc";
4649 __currentSearchStr = L"";
4650 AppLogDebug("Enter something");
4655 MainForm::InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus)
4662 MainForm::InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus)
4664 if(__pWebViewer != null)
4667 AppLog("MainForm::InitMostVisitedSitesView");
4668 result r = E_SUCCESS;
4671 if (__pWebViewer != null && __pMostVisitedListView != null)
4676 if (__pMostVisitedListView != null)
4678 RemoveControl(__pMostVisitedListView);
4680 if(__pMostVisitedSites != null)
4682 __pMostVisitedSites->RemoveAll(true);
4685 HistoryPresentationModel::GetInstance()->GetMostVisitedSites(*__pMostVisitedSites);
4687 __webControlHeight = GetClientAreaBounds().height - __pFooterPanel->GetHeight();
4688 __pMostVisitedListView = new(std::nothrow) ListView();
4690 int height = GetClientAreaBounds().height;
4692 if(__pFooterPanel->GetShowState() == true)
4694 height = height - __pFooterPanel->GetHeight();
4696 if(__pAddressbar->GetShowState() == true)
4698 height -= __pAddressbar->GetHeight();
4701 r = __pMostVisitedListView->Construct(Tizen::Graphics::Rectangle(0,0 , GetClientAreaBounds().width, height),true,false);
4705 delete __pMostVisitedListView;
4706 AppLogDebug("Addressbar init failed with %s", GetErrorMessage(r));
4709 __pMostVisitedListView->SetItemProvider(*this);
4710 __pMostVisitedListView->AddListViewItemEventListener(*this);
4711 __pMostVisitedListView->SetTextOfEmptyList(CommonUtil::GetString(L"IDS_BR_BODY_NO_RECENTLY_VISITED_SITES"));
4712 AddControl(__pMostVisitedListView);
4713 __pMostVisitedListView->UpdateList();
4720 MainForm::GetImagePath(void)
4724 String formattedTime;
4725 DateTime currentTime;
4726 LocaleManager localManager;
4727 SystemTime::GetCurrentTime(TIME_MODE_WALL, currentTime);
4729 localManager.Construct();
4730 Locale locale = localManager.GetSystemLocale();
4731 //Locale locale(LANGUAGE_ENG, COUNTRY_US);
4733 // Get date formatter
4734 DateTimeFormatter* pTimeFormatter = DateTimeFormatter::CreateDateTimeFormatterN(locale, DATE_TIME_STYLE_DEFAULT);
4738 pTimeFormatter->Format(currentTime, formattedTime);
4741 AppLog("current time stamp is %ls", formattedTime.GetPointer());
4742 String delim(L" :");
4743 StringTokenizer strTok(formattedTime, delim);
4746 String str1("GMT+00");
4747 while (strTok.HasMoreTokens())
4749 strTok.GetNextToken(token); // Osp, StringTokenizer, Sample, code
4750 if(token.Equals(str1))
4752 AppLog("token is %ls", token.GetPointer());
4753 imageName.Append(token);
4759 void MainForm::UpdateImageContent(ByteBuffer* aBuffer, String imageName)
4761 result r = E_FAILURE;
4762 AppLog("Content manager 1");
4763 ContentId contentId;
4764 ContentManager contentManager;
4765 r = contentManager.Construct();
4768 AppLog("Content manager update content result %s" ,GetErrorMessage(r));
4771 Tizen::Base::String contentPath = Tizen::System::Environment::GetMediaPath() + L"Downloads/";
4772 Tizen::Io::Directory::Create(contentPath,true);
4773 if(GetLastResult() == E_FILE_ALREADY_EXIST)
4775 AppLog("Already exists");
4777 else if(GetLastResult() == E_SUCCESS)
4779 AppLog("created success");
4781 contentPath.Append(imageName);
4782 contentPath.Append(".jpg");
4783 contentId = contentManager.CreateContent(*aBuffer, contentPath);
4784 AppLog("Content manager update content result %s" ,GetErrorMessage(GetLastResult()));
4788 MainForm::SetForwardButtonEnabled(bool isEnabled)
4790 __pGoForwardBtn->SetEnabled(isEnabled);
4791 __pGoForwardBtn->Invalidate(true);
4795 MainForm::SetBackButtonEnabled(bool isEnabled)
4797 __pGoBackBtn->SetEnabled(isEnabled);
4798 __pGoBackBtn->Invalidate(true);
4802 MainForm::UpdateProgress(int percentage)
4804 __progressPercentage = percentage;
4805 if (percentage == 0 || percentage == 100)
4807 __isLoadingData = false;
4808 if (percentage == 100)
4810 __isLoadingCompleted = true;
4811 __progressPercentage = 0;
4815 __isLoadingCompleted = false;
4820 __isLoadingData = true;
4822 UpdateProgressBitmap();
4826 MainForm::GetProgress(void)
4828 return __progressPercentage;
4832 MainForm::UpdateProgressBitmap(void)
4834 result r = E_SUCCESS;
4835 if (__pProgressbarLabel == null)
4837 int w = __pProgressbarLabel->GetWidth();
4838 int h = __pProgressbarLabel->GetHeight();
4840 int progressWidth = 0;
4841 Bitmap* pRetBitmap = null;
4843 if (__progressPercentage == 0 || __progressPercentage == 100)
4845 __pProgressbarLabel->SetShowState(false);
4846 __pProgressbarLabel->Invalidate(false);
4851 __pProgressbarLabel->SetShowState(true);
4852 __pProgressbarLabel->Invalidate(false);
4855 r = canvas.Construct(Rectangle(0, 0, w, h));
4859 AppLogException("Canvas construction failed with %s", GetErrorMessage(r));
4864 Bitmap *pBgBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR_BG);
4868 pBgBmp->Scale(Dimension(w, h));
4869 canvas.DrawBitmap(Point(0,0), *pBgBmp);
4873 progressWidth = (double) (w) * __progressPercentage / 100;
4874 AppLogDebug("progressWidth: %d", progressWidth);
4875 Bitmap *pProgressBmp = AppResource::GetInstance()->GetBitmapN(IDB_TITLE_PROGRESS_BAR);
4877 if (pProgressBmp != null)
4879 pProgressBmp->Scale(Dimension(progressWidth, h));
4880 canvas.DrawBitmap(Point(0,0), *pProgressBmp);
4881 delete pProgressBmp;
4884 pRetBitmap = new (std::nothrow) Bitmap();
4886 if (pRetBitmap == null)
4888 AppLogException("Bitmap creation failed with %s", GetErrorMessage(r));
4892 pRetBitmap->Construct(canvas, canvas.GetBounds());
4894 if (__pProgressbarLabel != null && pRetBitmap != null)
4896 __pProgressbarLabel->SetBackgroundBitmap(*pRetBitmap);
4897 __pProgressbarLabel->Invalidate(false);
4900 if (pRetBitmap != null)
4909 MainForm::ReaderClicked()
4911 result r = E_SUCCESS;
4912 ArrayList* pArgList = new(std::nothrow) ArrayList();
4913 if (pArgList != null)
4915 r = pArgList->Construct();
4922 r = pArgList->Add(*new(std::nothrow) String(*__pReaderData));
4929 r = pArgList->Add(*new(std::nothrow) String(__pWebViewer->GetUrl()));
4936 r = pArgList->Add(*new(std::nothrow) String(__pWindowInfo->pageTitle));
4944 SceneManager::GetInstance()->GoForward(ForwardSceneTransition(IDSCN_ARTICLE_READER, SCENE_TRANSITION_ANIMATION_TYPE_NONE),pArgList);
4948 int bodyWidth = ((double)(GetClientAreaBounds().width))*0.73;
4950 CreateReaderPanel();
4951 AppLogDebug("MainScene::ReaderClicked entered");
4954 /*if (__pArticleReaderPanel)
4956 AppLogDebug("showstate true for reader panel");
4957 __pArticleReaderPanel->SetShowState(true);
4958 __pArticleReaderPanel->Show();
4960 int xPos = __pArticleReaderPanel->GetX();
4961 int yPos = __pArticleReaderPanel->GetY();
4962 AppLog("ReaderClicked() xPos = %d",xPos);
4963 AppLog("ReaderClicked() yPos = %d",yPos);
4965 if (__pReaderData == null)
4970 String loadData = L"<html>\
4972 <meta name='viewport' content='width=device-width*0.73,minimum-scale=1.0, maximum-scale=1.0, user-scalable=no'>\
4977 background-color: transparent;\
4996 <body style='width:'";
4997 loadData.Append(bodyWidth);
4998 loadData.Append(L"px'>");
4999 AppLogDebug("data->GetLength %d",__pReaderData->GetLength());
5000 loadData.Append(*__pReaderData);
5001 loadData.Append(L"</body></html>");
5004 buf.Construct(loadData.GetLength());
5005 AppLogDebug("data->GetLength %d",loadData.GetLength());
5006 for (int z=0;z<loadData.GetLength();z++)
5009 loadData.GetCharAt(z,b);
5010 buf.SetByte((byte)b);
5014 if (__pWebReader != null)
5016 __pWebReader->LoadData(L"",buf,L"text/html");
5017 AppLogDebug("LoadData result %s",GetErrorMessage(GetLastResult()));
5021 AppLogDebug("cannot LoadData __pWebReader is null");
5026 void MainForm::SetAddressbarMode(AddressBarMode addMode)
5028 AppLogDebug("AddressBar::setAddressbarMode to %d",addMode);
5030 __currentAddMode = addMode;
5034 case ADDRESSBAR_MODE_INVALID:
5039 case ADDRESSBAR_MODE_READER:
5041 __pStopBtn->SetShowState(false);
5042 __pRefreshBtn->SetShowState(false);
5043 __pClearBtn->SetShowState(false);
5044 __pReaderBtn->SetShowState(false);
5047 case ADDRESSBAR_MODE_LOADING:
5049 __pRefreshBtn->SetShowState(false);
5050 __pStopBtn->SetShowState(true);
5051 __pClearBtn->SetShowState(false);
5052 __pReaderBtn->SetShowState(false);
5055 case ADDRESSBAR_MODE_LOADING_COMPLETE:
5057 // SetUrl(__pAddressbar->GetUrl());
5059 __pRefreshBtn->SetShowState(true);
5060 __pStopBtn->SetShowState(false);
5061 __pClearBtn->SetShowState(false);
5062 __pReaderBtn->SetShowState(false);
5065 case ADDRESSBAR_MODE_EDIT:
5067 __pRefreshBtn->SetShowState(false);
5068 __pStopBtn->SetShowState(false);
5069 __pReaderBtn->SetShowState(false);
5070 __pClearBtn->SetShowState(true);
5077 OnAddressBarModeChanged();
5080 AddressBarMode MainForm::GetAddressbarMode(void)
5082 return __currentAddMode;
5085 void MainForm::SetUrl(const String& url)
5088 if(__displayUrl.GetLength() > 2048)
5089 __displayUrl.SubString(0,2048,__displayUrl);
5091 if (__pFooterUrlField != NULL)
5093 String removedHttpUrl = RemoveHttpTextFromDisplayURL();
5094 if (removedHttpUrl.IsEmpty() == false)
5096 __pFooterUrlField->SetText(removedHttpUrl);
5097 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5098 __pAddressbar->SetUrl(__displayUrl);
5102 __pFooterUrlField->SetText(__displayUrl);
5103 if(__pAddressbar != NULL && __pAddressbar->HasCurrentFocus() == false)
5104 __pAddressbar->SetUrl(__displayUrl);
5106 if(__pFooterUrlField)
5107 __pFooterUrlField->SetCursorPosition(__pFooterUrlField->GetTextLength());
5108 __pFooterUrlField->Invalidate(false);
5109 if(__pAddressbar != NULL && __pAddressbar->HasFocus())
5110 __pAddressbar->Invalidate(true);
5111 // __pFooterUrlField->SetCursorPosition(0);
5116 MainForm::RemoveHttpTextFromDisplayURL(void)
5118 AppLog("MainForm::RemoveHttpTextFromDisplayURL __displayUrl %ls",__displayUrl.GetPointer());
5120 // bool isHttpText = __displayUrl.Contains(L"http://");
5121 String updatedDisplayUrl;
5122 updatedDisplayUrl.Clear();
5123 if(__displayUrl.IndexOf(L"http://",0,index) == E_SUCCESS && index == 0)
5125 __displayUrl.SubString(7,updatedDisplayUrl);
5127 else if(__displayUrl.IndexOf(L"https://",0,index) == E_SUCCESS && index == 0)
5129 __displayUrl.SubString(8,updatedDisplayUrl);
5131 return updatedDisplayUrl;
5134 void MainForm::OnSharePopupControlStarted(void)
5136 __pWebViewer->AddTouchEventListener(*this);
5139 void MainForm::OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs)
5141 if (requestId == BACK_GROUND_APP_EVENT)
5143 if(__pWebViewer != null)
5145 __pWebViewer->Pause();
5148 else if(requestId == FORE_GROUND_APP_EVENT)
5150 if(__pWebViewer != null)
5152 __pWebViewer->Resume();
5158 MainForm::AddressBarCancelledClicked(const Addressbar& addBar)
5160 result r = E_SUCCESS;
5163 __pAddressbar->SetShowState(false);
5165 //AppLog("akjshdasd 5");
5166 //__pFooterPanel->SetShowState(true);
5169 __pWebViewer->SetFocus();
5170 else if(__pMostVisitedListView)
5171 __pMostVisitedListView->SetFocus();
5172 else if(__pMultiWindowButton)
5173 __pMultiWindowButton->SetFocus();
5174 __pMoreButton->SetFocus();
5176 __pAddressbar->SetShowState(false);
5178 RelayoutControls(false);