3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.1 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
18 //!Internet MainForm class
20 *@brief: The %MainForm provides the common functionalities for the Main View of the Browser including the addressbar,
21 * loading,handling events etc.
24 #ifndef _INT_MAIN_FORM_H_
25 #define _INT_MAIN_FORM_H_
31 #include "IntAddressbar.h"
32 #include "IntHistoryData.h"
33 #include "IntHistoryPresentationModel.h"
34 #include "IntIAddressbarEventListener.h"
35 #include "IntISettingChangeListener.h"
36 #include "IntMultipleWindowPresentationModel.h"
37 #include "IntNotificationPanel.h"
38 #include "IntSharePopup.h"
43 ADDRESSBAR_MODE_INVALID = -1,
44 ADDRESSBAR_MODE_READER = 0,
45 ADDRESSBAR_MODE_LOADING,
46 ADDRESSBAR_MODE_LOADING_COMPLETE,
51 : public Tizen::Ui::Controls::Form
52 , public Tizen::Ui::Controls::IFormMenuEventListener
53 , public Tizen::Ui::Controls::IListViewItemEventListener
54 , public Tizen::Ui::Controls::IListViewItemProvider
55 , public Tizen::Ui::IActionEventListener
56 , public IAddressbarEventListener
57 , public Tizen::Ui::Controls::IFormBackEventListener
58 , public Tizen::Ui::IKeypadEventListener
59 , public Tizen::Web::Controls::ILoadingListener
60 , public Tizen::Ui::IOrientationEventListener
61 , public Tizen::Ui::ITextEventListener
62 , public Tizen::Ui::IPropagatedTouchEventListener
63 , public Tizen::Ui::ITouchEventListener
64 , public Tizen::Ui::Scenes::ISceneEventListener
65 , public ISettingChangeEventListener
66 , public Tizen::Web::Controls::IWebKeypadEventListener
67 , public Tizen::Web::Controls::IWebUiEventListenerF
68 , public Tizen::Web::Controls::ITextSearchListener
72 *@brief Default constructor
77 *@brief Default destructor
79 virtual ~MainForm(void);
82 * @brief The method initializes the screen variables and controls to be used by the user.
85 bool Initialize(void);
88 * @brief Initializes this instance of %MainForm.
91 result InitWebControl();
94 * @brief Initializes this instance of Reader Panel.
96 result CreateReaderPanel(void);
98 Tizen::Base::String GetImagePath(void);
100 void LoadUrl(Tizen::Base::String& url);
102 //IFormMenuEventListener
103 virtual void OnFormMenuRequested (Tizen::Ui::Controls::Form &source);
105 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
107 virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
109 //IAddressbarEventListener
110 void OnAddressBarFocusGained(const Addressbar& addBar);
112 void OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState);
114 void OnAddressCancelledClicked(const Addressbar&);
116 void OnAddressBarKeypadClosed(const Addressbar&, bool footerState = true);
118 void OnAddressBarKeypadOpened(const Addressbar&);
120 void OnAddressBarKeypadWillOpen(const Addressbar&);
122 void OnAddressBarKeypadBoundsChanged(const Addressbar& addBar);
124 void OnAddressBarModeChanged(/*const Addressbar&*/);
126 virtual void OnClipboardClosed(const Addressbar&);
128 void OnBackClicked(/*const Addressbar&*/);
130 void OnForwardClicked(/*const Addressbar&*/);
132 void OnRefreshClicked(const Addressbar&){}
134 void OnSearchClicked(const Addressbar&){}
136 void OnStopClicked(Addressbar&);
138 void OnUrlValueChanged(Addressbar&);
140 void OnUrlSubmitted(Addressbar&);
142 //ILoadingeventListener
143 virtual void OnEstimatedProgress(int progress);
144 virtual void OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon);
146 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
148 virtual void OnHttpAuthenticationCanceled(void);
150 virtual result OnInitializing(void);
152 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
154 virtual void OnKeypadOpened(Tizen::Ui::Control& source);
156 virtual void OnKeypadClosed(Tizen::Ui::Control& source);
158 virtual void OnKeypadBoundsChanged (Tizen::Ui::Control &source);
160 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
162 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
164 virtual void OnLoadingStarted(void);
166 virtual void OnLoadingCanceled(void);
168 virtual void OnLoadingCompleted(void);
170 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
172 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
174 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
176 //IOrientationEventListener
177 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
179 //ISceenEventListener
180 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
182 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
184 virtual result OnTerminating(void);
186 void SetImageLoadEnabled(void);
188 void SetJavascriptEnabled(void);
190 // IListViewItemEventListener
192 *Called when the state of an element in the ListContextItem is changed.
194 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
197 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
199 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
202 *Called when the ListItem is swept.
204 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
207 *Called when the item or the element is long pressed.
209 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
212 //IListViewItemProvider
213 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
214 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
215 virtual int GetItemCount (void);
217 //IWebUiEventListener
218 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::FloatPoint& startPoint, Tizen::Graphics::FloatPoint& endPoint);
219 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
220 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
221 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
223 //IWebKeypadEventListener
224 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
225 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
226 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
227 virtual void OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source);
229 //ITouchEventListener
230 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
231 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
232 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
233 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
234 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
235 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
236 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
238 //IPropagatedTouchEventListener
239 virtual bool OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
240 virtual bool OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
241 virtual bool OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
242 virtual bool OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
243 virtual bool OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
244 virtual bool OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
245 virtual bool OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
247 virtual void OnTextFound(int totalCount, int currentOrdinal);
249 //ISettingsChangeListener
250 void OnClearCache(void);
251 void OnClearCookie(void);
252 void OnClearFormData(void);
253 void OnClearPasswords(void);
254 void OnSettingsChange(int settingvalue);
255 void OnSettingsReset(void);
257 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
258 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
260 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
262 void SetForwardButtonEnabled(bool isEnabled);
263 void SetBackButtonEnabled(bool isEnabled);
265 void UpdateProgress(int percentage);
266 int GetProgress(void);
267 void UpdateProgressBitmap(void);
268 void ReaderClicked();
271 * @brief Sets the current addressbar Mode.
273 void SetAddressbarMode(AddressBarMode addMode);
275 void SetUrl(const Tizen::Base::String& url);
277 void OnSharePopupControlStarted(void);
279 virtual void OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs);
281 void AddressBarCancelledClicked(const Addressbar& addBar);
283 double findDistance(int x1,int y1,int x2, int y2);
284 void FindNextWord(bool next = true);
285 result InitAddressbar(void);
286 result InitFooter(void);
287 result InitOptionMenu(void);
288 result InitFindWordPanel(void);
289 result InitImageContextMenu(Tizen::Graphics::Point p);
290 result InitImageLinkContextMenu(Tizen::Graphics::Point p);
291 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
292 result InitSelectTextContextMenuF(Tizen::Graphics::FloatPoint p, bool pasteOption, bool onlyPasteOption);
293 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
294 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
295 void MoveUiControls(void);
296 void UpdateFavicon(void);
297 void RelayoutControls(bool showAddressbar,bool relayoutFooter = true);
298 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
299 void ShowMostVisitedSitesPanel(void);
300 void StartWordSearch();
301 AddressBarMode GetAddressbarMode(void);
302 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
306 static const int IDA_FORMAT_BITMAP;
307 static const int IDA_FORMAT_DELETE_BITMAP;
308 static const int IDA_FORMAT_TITLE_STRING;
309 static const int IDA_FORMAT_URL_STRING;
310 static const int IDA_CONTEXT_ITEM_DELETE;
312 Tizen::Graphics::Point __adressPanelPosition;
313 AddressBarMode __curAddressBarMode;
314 Tizen::Base::String __currentSearchStr;
315 Tizen::Base::String __currentSelectedStr;
317 int __webControlHeight;
318 float __previousZoomLevel;
319 int __maxOccurrances;
320 int __currentWordIndex;
322 //bool __inputEventToBeSupressed;
324 bool __isLoadingData;
325 bool __isLoadingCompleted;
326 //bool __isLongPressedDone;
327 bool __isWebKeypadOpened;
328 int __progressPercentage;
330 AddressBarMode __currentAddMode;
331 Tizen::Base::String __displayUrl;
332 Tizen::Base::String __editTextUrl;
334 Addressbar* __pAddressbar;
336 Tizen::Graphics::Point __contextMenuPosition;
337 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
338 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
339 Tizen::Ui::Controls::Panel* __pBlankPanel;
340 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
341 Tizen::Ui::Controls::Label * __pFindWordBgLabelRightToLeft;
342 Tizen::Ui::Controls::Button* __pFindWordClear;
343 Tizen::Ui::Controls::Button* __pFindWordClearRightToLeft;
344 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
345 Tizen::Ui::Controls::Label* __pFindWordCountLabelRightToLeft;
346 Tizen::Ui::Controls::Panel* __pFindWordControl;
348 Tizen::Ui::Controls::Panel* __pFindWordPanelLeftToRight;
349 Tizen::Ui::Controls::Panel* __pFindWordPanelRightToLeft;
351 Tizen::Ui::Controls::EditField* __pFindWordEditField;
352 Tizen::Ui::Controls::EditField* __pFindWordEditFieldRightToLeft;
353 Tizen::Ui::Controls::Button* __pFindWordNext;
354 Tizen::Ui::Controls::Button* __pFindWordPrev;
355 // Tizen::Ui::Controls::Panel* __pFindWordPanel;
356 Tizen::Ui::Controls::Panel* __pFooterPanel;
357 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
358 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
359 // Tizen::Ui::Controls::ContextMenu* __pMenu;
361 Tizen::Ui::Controls::OptionMenu* __pOptionMenu;
362 Tizen::Ui::Controls::Button* __pMoreButton;
363 Tizen::Ui::Controls::Button* __pMultiWindowButton;
364 // Tizen::Ui::Controls::Button* __pNewWindowButton;
365 SharePopup* __pPopUp;
366 Tizen::Ui::Controls::Label* __pCheckLabel;
367 AddressBarMode __prevAddressBarMode;
368 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
369 Tizen::Base::String* __pReaderData;
370 Tizen::Media::Image* __pSaveImage;
371 Tizen::Web::Controls::Web* __pWebReader;
372 Tizen::Web::Controls::Web* __pWebViewer;
373 WindowInfo* __pWindowInfo;
374 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
376 Tizen::Graphics::Point __touchPoint1;
377 Tizen::Graphics::Point __touchPoint2;
378 Tizen::Graphics::Point __webControlPosition;
380 Tizen::Ui::Controls::ListContextItem* __pItemContext;
381 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
382 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
383 Tizen::Ui::Controls::EditField* __pFooterUrlField;
384 Tizen::Ui::Controls::Button* __pGoBackBtn;
385 Tizen::Ui::Controls::Button* __pGoForwardBtn;
386 Tizen::Ui::Controls::Button* __pRefreshBtn;
387 Tizen::Ui::Controls::Label* __pProgressbarLabel;
388 Tizen::Ui::Controls::Label* __pFooterLabel;
389 Tizen::Ui::Controls::Button* __pStopBtn;
390 Tizen::Ui::Controls::Button* __pClearBtn;
391 Tizen::Ui::Controls::Button* __pReaderBtn;
392 Tizen::Graphics::Point __longPressPoint;
393 NotificationPanel* __pNotification;
395 bool __isHwKeySupported;
398 #endif //_INT_MAIN_FORM_H_