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::IFocusEventListener
53 , public Tizen::Ui::Controls::IFormMenuEventListener
54 , public Tizen::Ui::Controls::IListViewItemEventListener
55 , public Tizen::Ui::Controls::IListViewItemProvider
56 , public Tizen::Ui::IActionEventListener
57 , public IAddressbarEventListener
58 , public Tizen::Ui::Controls::IFormBackEventListener
59 , public Tizen::Ui::IKeypadEventListener
60 , public Tizen::Web::Controls::ILoadingListener
61 , public Tizen::Ui::IOrientationEventListener
62 , public Tizen::Ui::ITextEventListener
63 , public Tizen::Ui::IPropagatedTouchEventListener
64 , public Tizen::Ui::ITouchEventListener
65 , public Tizen::Ui::Scenes::ISceneEventListener
66 , public ISettingChangeEventListener
67 , public Tizen::Web::Controls::IWebKeypadEventListener
68 , public Tizen::Web::Controls::IWebUiEventListenerF
69 , public Tizen::Web::Controls::ITextSearchListener
74 *@brief Default constructor
79 *@brief Default destructor
81 virtual ~MainForm(void);
84 * @brief The method initializes the screen variables and controls to be used by the user.
87 bool Initialize(void);
90 * @brief Initializes this instance of %MainForm.
93 result InitWebControl();
96 * @brief Initializes this instance of Reader Panel.
98 result CreateReaderPanel(void);
100 Tizen::Base::String GetImagePath(void);
102 void LoadUrl(Tizen::Base::String& url);
104 //IFocusEventListener
105 void OnFocusGained(const Tizen::Ui::Control& source);
106 void OnFocusLost(const Tizen::Ui::Control& source);
108 //IFormMenuEventListener
109 virtual void OnFormMenuRequested (Tizen::Ui::Controls::Form &source);
111 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
113 virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
115 //IAddressbarEventListener
116 void OnAddressBarFocusGained(const Addressbar& addBar);
118 void OnAddressBarFocusLost(const Addressbar& addBar, bool addressbarKeyPadState);
120 void OnAddressCancelledClicked(const Addressbar&);
122 void OnAddressBarKeypadClosed(const Addressbar&, bool footerState = true);
124 void OnAddressBarKeypadOpened(const Addressbar&);
126 void OnAddressBarKeypadWillOpen(const Addressbar&);
128 void OnAddressBarKeypadBoundsChanged(const Addressbar& addBar);
130 void OnAddressBarModeChanged(/*const Addressbar&*/);
132 virtual void OnClipboardClosed(const Addressbar&);
134 void OnBackClicked(/*const Addressbar&*/);
136 void OnForwardClicked(/*const Addressbar&*/);
138 void OnRefreshClicked(const Addressbar&){}
140 void OnSearchClicked(const Addressbar&){}
142 void OnStopClicked(Addressbar&);
144 void OnUrlValueChanged(Addressbar&);
146 void OnUrlSubmitted(Addressbar&);
148 //ILoadingeventListener
149 virtual void OnEstimatedProgress(int progress);
150 virtual void OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon);
152 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
154 virtual void OnHttpAuthenticationCanceled(void);
156 virtual result OnInitializing(void);
158 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
160 virtual void OnKeypadOpened(Tizen::Ui::Control& source);
162 virtual void OnKeypadClosed(Tizen::Ui::Control& source);
164 virtual void OnKeypadBoundsChanged (Tizen::Ui::Control &source);
166 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
168 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
170 virtual void OnLoadingStarted(void);
172 virtual void OnLoadingCanceled(void);
174 virtual void OnLoadingCompleted(void);
176 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
178 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
180 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
182 //IOrientationEventListener
183 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
185 //ISceenEventListener
186 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
188 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
190 virtual result OnTerminating(void);
192 void SetImageLoadEnabled(void);
194 void SetJavascriptEnabled(void);
196 // IListViewItemEventListener
198 *Called when the state of an element in the ListContextItem is changed.
200 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
203 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
205 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
208 *Called when the ListItem is swept.
210 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
213 *Called when the item or the element is long pressed.
215 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
218 //IListViewItemProvider
219 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
220 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
221 virtual int GetItemCount (void);
223 //IWebUiEventListener
224 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::FloatPoint& startPoint, Tizen::Graphics::FloatPoint& endPoint);
225 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
226 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
227 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
229 //IWebKeypadEventListener
230 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
231 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
232 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
233 virtual void OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source);
235 //ITouchEventListener
236 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
237 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
238 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
239 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
240 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
241 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
242 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
244 //IPropagatedTouchEventListener
245 virtual bool OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
246 virtual bool OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
247 virtual bool OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
248 virtual bool OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
249 virtual bool OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
250 virtual bool OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
251 virtual bool OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
253 virtual void OnTextFound(int totalCount, int currentOrdinal);
255 //ISettingsChangeListener
256 void OnClearCache(void);
257 void OnClearCookie(void);
258 void OnClearFormData(void);
259 void OnClearPasswords(void);
260 void OnSettingsChange(int settingvalue);
261 void OnSettingsReset(void);
263 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
264 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
266 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
267 void ShowIndicatorNotification(const Tizen::Base::String& messageText, const Tizen::Base::String& contentPath);
269 void SetForwardButtonEnabled(bool isEnabled);
270 void SetBackButtonEnabled(bool isEnabled);
272 void UpdateProgress(int percentage);
273 int GetProgress(void);
274 void UpdateProgressBitmap(void);
275 void ReaderClicked();
278 * @brief Sets the current addressbar Mode.
280 void SetAddressbarMode(AddressBarMode addMode);
282 void SetUrl(const Tizen::Base::String& url);
284 void OnSharePopupControlStarted(void);
286 virtual void OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs);
288 void AddressBarCancelledClicked(const Addressbar& addBar);
290 double findDistance(int x1,int y1,int x2, int y2);
291 void FindNextWord(bool next = true);
292 result InitAddressbar(void);
293 result InitFooter(void);
294 result InitOptionMenu(void);
295 result InitFindWordPanel(void);
296 result InitImageContextMenu(Tizen::Graphics::Point p);
297 result InitImageLinkContextMenu(Tizen::Graphics::Point p);
298 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
299 result InitSelectTextContextMenuF(Tizen::Graphics::FloatPoint p, bool pasteOption, bool onlyPasteOption);
300 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
301 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
302 void MoveUiControls(void);
303 void UpdateFavicon(void);
304 void RelayoutControls(bool showAddressbar,bool relayoutFooter = true);
305 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
306 void ShowMostVisitedSitesPanel(void);
307 void StartWordSearch();
308 AddressBarMode GetAddressbarMode(void);
309 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
313 static const int IDA_FORMAT_BITMAP;
314 static const int IDA_FORMAT_DELETE_BITMAP;
315 static const int IDA_FORMAT_TITLE_STRING;
316 static const int IDA_FORMAT_URL_STRING;
317 static const int IDA_CONTEXT_ITEM_DELETE;
319 Tizen::Graphics::Point __adressPanelPosition;
320 AddressBarMode __curAddressBarMode;
321 Tizen::Base::String __currentSearchStr;
322 Tizen::Base::String __currentSelectedStr;
324 int __webControlHeight;
325 float __previousZoomLevel;
326 int __maxOccurrances;
327 int __currentWordIndex;
329 //bool __inputEventToBeSupressed;
331 bool __isLoadingData;
332 bool __isLoadingCompleted;
333 bool __isLongPressedDone;
334 bool __isKeypadOpened;
335 int __progressPercentage;
337 AddressBarMode __currentAddMode;
338 Tizen::Base::String __displayUrl;
339 Tizen::Base::String __editTextUrl;
341 Addressbar* __pAddressbar;
343 Tizen::Graphics::Point __contextMenuPosition;
344 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
345 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
346 Tizen::Ui::Controls::Panel* __pBlankPanel;
347 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
348 Tizen::Ui::Controls::Label * __pFindWordBgLabelRightToLeft;
349 Tizen::Ui::Controls::Button* __pFindWordClear;
350 Tizen::Ui::Controls::Button* __pFindWordClearRightToLeft;
351 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
352 Tizen::Ui::Controls::Label* __pFindWordCountLabelRightToLeft;
353 Tizen::Ui::Controls::Panel* __pFindWordControl;
355 Tizen::Ui::Controls::Panel* __pFindWordPanelLeftToRight;
356 Tizen::Ui::Controls::Panel* __pFindWordPanelRightToLeft;
358 Tizen::Ui::Controls::EditField* __pFindWordEditField;
359 Tizen::Ui::Controls::EditField* __pFindWordEditFieldRightToLeft;
360 Tizen::Ui::Controls::Button* __pFindWordNext;
361 Tizen::Ui::Controls::Button* __pFindWordPrev;
362 // Tizen::Ui::Controls::Panel* __pFindWordPanel;
363 Tizen::Ui::Controls::Panel* __pFooterPanel;
364 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
365 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
366 // Tizen::Ui::Controls::ContextMenu* __pMenu;
368 Tizen::Ui::Controls::OptionMenu* __pOptionMenu;
369 Tizen::Ui::Controls::Button* __pMoreButton;
370 Tizen::Ui::Controls::Button* __pMultiWindowButton;
371 // Tizen::Ui::Controls::Button* __pNewWindowButton;
372 SharePopup* __pPopUp;
373 Tizen::Ui::Controls::Label* __pCheckLabel;
374 AddressBarMode __prevAddressBarMode;
375 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
376 Tizen::Base::String* __pReaderData;
377 Tizen::Media::Image* __pSaveImage;
378 Tizen::Web::Controls::Web* __pWebReader;
379 Tizen::Web::Controls::Web* __pWebViewer;
381 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
383 Tizen::Graphics::Point __touchPoint1;
384 Tizen::Graphics::Point __touchPoint2;
385 Tizen::Graphics::Point __webControlPosition;
387 Tizen::Ui::Controls::ListContextItem* __pItemContext;
388 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
389 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
390 Tizen::Ui::Controls::EditField* __pFooterUrlField;
391 Tizen::Ui::Controls::Button* __pGoBackBtn;
392 Tizen::Ui::Controls::Button* __pGoForwardBtn;
393 Tizen::Ui::Controls::Button* __pRefreshBtn;
394 Tizen::Ui::Controls::Label* __pProgressbarLabel;
395 Tizen::Ui::Controls::Label* __pFooterLabel;
396 Tizen::Ui::Controls::Button* __pStopBtn;
397 Tizen::Ui::Controls::Button* __pClearBtn;
398 Tizen::Ui::Controls::Button* __pReaderBtn;
399 Tizen::Graphics::Point __longPressPoint;
400 NotificationPanel* __pNotification;
402 WindowInfo* __pWindowInfo;
403 // bool __isHwKeySupported;
406 #endif //_INT_MAIN_FORM_H_