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 "IntSharePopup.h"
42 ADDRESSBAR_MODE_INVALID = -1,
43 ADDRESSBAR_MODE_READER = 0,
44 ADDRESSBAR_MODE_LOADING,
45 ADDRESSBAR_MODE_LOADING_COMPLETE,
50 : public Tizen::Ui::Controls::Form
51 , public Tizen::Ui::Controls::IListViewItemEventListener
52 , public Tizen::Ui::Controls::IListViewItemProvider
53 , public Tizen::Ui::IActionEventListener
54 , public IAddressbarEventListener
55 , public Tizen::Ui::IFocusEventListener
56 , public Tizen::Ui::Controls::IFormBackEventListener
57 , public Tizen::Ui::IKeypadEventListener
58 , public Tizen::Web::Controls::ILoadingListener
59 , public Tizen::Ui::IOrientationEventListener
60 , public Tizen::Ui::ITextEventListener
61 , public Tizen::Ui::IPropagatedTouchEventListener
62 , public Tizen::Ui::ITouchEventListener
63 , public Tizen::Ui::Scenes::ISceneEventListener
64 , public ISettingChangeEventListener
65 , public Tizen::Web::Controls::IWebKeypadEventListener
66 , public Tizen::Web::Controls::IWebUiEventListener
67 , public Tizen::Web::Controls::ITextSearchListener
71 *@brief Default constructor
76 *@brief Default destructor
78 virtual ~MainForm(void);
81 * @brief The method initializes the screen variables and controls to be used by the user.
84 bool Initialize(void);
87 * @brief Initializes this instance of %MainForm.
90 result InitWebControl();
93 * @brief Initializes this instance of Reader Panel.
95 result CreateReaderPanel(void);
97 Tizen::Base::String GetImagePath(void);
99 void LoadUrl(Tizen::Base::String& url);
101 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
103 virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
105 //IAddressbarEventListener
106 void OnAddressBarFocusGained(const Addressbar& addBar);
108 void OnAddressBarFocusLost(const Addressbar& addBar);
110 void OnAddressCancelledClicked(const Addressbar&);
112 void OnAddressBarKeypadClosed(const Addressbar&, bool footerState = true);
114 void OnAddressBarKeypadOpened(const Addressbar&);
116 void OnAddressBarKeypadWillOpen(const Addressbar&);
118 void OnAddressBarKeypadBoundsChanged(const Addressbar& addBar);
120 void OnAddressBarModeChanged(/*const Addressbar&*/);
122 virtual void OnClipboardClosed(const Addressbar&);
124 void OnBackClicked(/*const Addressbar&*/);
126 void OnForwardClicked(/*const Addressbar&*/);
128 void OnRefreshClicked(const Addressbar&){}
130 void OnSearchClicked(const Addressbar&){}
132 void OnStopClicked(Addressbar&);
134 void OnUrlValueChanged(Addressbar&);
136 void OnUrlSubmitted(Addressbar&);
138 //ILoadingeventListener
139 virtual void OnEstimatedProgress(int progress);
140 virtual void OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon);
142 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
144 virtual void OnHttpAuthenticationCanceled(void);
146 virtual result OnInitializing(void);
148 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
150 virtual void OnKeypadOpened(Tizen::Ui::Control& source);
152 virtual void OnKeypadClosed(Tizen::Ui::Control& source);
154 virtual void OnKeypadBoundsChanged (Tizen::Ui::Control &source);
156 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
158 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
160 virtual void OnLoadingStarted(void);
162 virtual void OnLoadingCanceled(void);
164 virtual void OnLoadingCompleted(void);
166 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
168 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
170 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
172 //IOrientationEventListener
173 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
175 //ISceenEventListener
176 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
178 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
180 virtual result OnTerminating(void);
182 void SetImageLoadEnabled(void);
184 void SetJavascriptEnabled(void);
186 void OnFocusGained(const Tizen::Ui::Control& source);
187 void OnFocusLost(const Tizen::Ui::Control& source);
189 // IListViewItemEventListener
191 *Called when the state of an element in the ListContextItem is changed.
193 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
196 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
198 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
201 *Called when the ListItem is swept.
203 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
206 *Called when the item or the element is long pressed.
208 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
211 //IListViewItemProvider
212 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
213 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
214 virtual int GetItemCount (void);
216 //IWebUiEventListener
217 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint);
218 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
219 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
220 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
222 //IWebKeypadEventListener
223 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
224 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
225 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
227 //ITouchEventListener
228 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
229 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
230 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
231 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
232 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
233 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
234 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
236 //IPropagatedTouchEventListener
237 virtual bool OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
238 virtual bool OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
239 virtual bool OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
240 virtual bool OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
241 virtual bool OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
242 virtual bool OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
243 virtual bool OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
245 virtual void OnTextFound(int totalCount, int currentOrdinal);
247 //ISettingsChangeListener
248 void OnClearCache(void);
249 void OnClearCookie(void);
250 void OnClearFormData(void);
251 void OnClearPasswords(void);
252 void OnSettingsChange(int settingvalue);
253 void OnSettingsReset(void);
255 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
256 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
258 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
260 void SetForwardButtonEnabled(bool isEnabled);
261 void SetBackButtonEnabled(bool isEnabled);
263 void UpdateProgress(int percentage);
264 int GetProgress(void);
265 void UpdateProgressBitmap(void);
266 void ReaderClicked();
269 * @brief Sets the current addressbar Mode.
271 void SetAddressbarMode(AddressBarMode addMode);
273 void SetUrl(const Tizen::Base::String& url);
275 void OnSharePopupControlStarted(void);
277 virtual void OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs);
279 void AddressBarCancelledClicked(const Addressbar& addBar);
281 double findDistance(int x1,int y1,int x2, int y2);
282 void FindNextWord(bool next = true);
283 result InitAddressbar(void);
284 result InitFooter(void);
285 result InitContextMenu(Tizen::Graphics::Point& p);
286 result InitFindWordPanel(void);
287 result InitImageContextMenu(Tizen::Graphics::Point p);
288 result InitImageLinkContextMenu(Tizen::Graphics::Point p);
289 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
290 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
291 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
292 void MoveUiControls(void);
293 void UpdateFavicon(void);
294 void RelayoutControls(bool showAddressbar,bool relayoutFooter = true);
295 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
296 void ShowMostVisitedSitesPanel(void);
297 void StartWordSearch();
298 AddressBarMode GetAddressbarMode(void);
299 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
303 static const int IDA_FORMAT_BITMAP;
304 static const int IDA_FORMAT_DELETE_BITMAP;
305 static const int IDA_FORMAT_TITLE_STRING;
306 static const int IDA_FORMAT_URL_STRING;
307 static const int IDA_CONTEXT_ITEM_DELETE;
309 Tizen::Graphics::Point __adressPanelPosition;
310 AddressBarMode __curAddressBarMode;
311 Tizen::Base::String __currentSearchStr;
312 Tizen::Base::String __currentSelectedStr;
314 int __webControlHeight;
315 float __previousZoomLevel;
316 int __maxOccurrances;
317 int __currentWordIndex;
319 //bool __inputEventToBeSupressed;
321 bool __isLoadingData;
322 bool __isLoadingCompleted;
323 bool __isLongPressedDone;
324 bool __isWebKeypadOpened;
325 int __progressPercentage;
327 AddressBarMode __currentAddMode;
328 Tizen::Base::String __displayUrl;
329 Tizen::Base::String __editTextUrl;
331 Addressbar* __pAddressbar;
333 Tizen::Graphics::Point __contextMenuPosition;
334 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
335 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
336 Tizen::Ui::Controls::Panel* __pBlankPanel;
337 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
338 Tizen::Ui::Controls::Button* __pFindWordClear;
339 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
340 Tizen::Ui::Controls::Panel* __pFindWordControl;
341 Tizen::Ui::Controls::EditField* __pFindWordEditField;
342 Tizen::Ui::Controls::Button* __pFindWordNext;
343 Tizen::Ui::Controls::Button* __pFindWordPrev;
344 // Tizen::Ui::Controls::Panel* __pFindWordPanel;
345 Tizen::Ui::Controls::Panel* __pFooterPanel;
346 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
347 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
348 Tizen::Ui::Controls::ContextMenu* __pMenu;
349 Tizen::Ui::Controls::Button* __pMoreButton;
350 Tizen::Ui::Controls::Button* __pMultiWindowButton;
351 // Tizen::Ui::Controls::Button* __pNewWindowButton;
352 SharePopup* __pPopUp;
353 AddressBarMode __prevAddressBarMode;
354 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
355 Tizen::Base::String* __pReaderData;
356 Tizen::Media::Image* __pSaveImage;
357 Tizen::Web::Controls::Web* __pWebReader;
358 Tizen::Web::Controls::Web* __pWebViewer;
359 WindowInfo* __pWindowInfo;
360 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
362 Tizen::Graphics::Point __touchPoint1;
363 Tizen::Graphics::Point __touchPoint2;
364 Tizen::Graphics::Point __webControlPosition;
366 Tizen::Ui::Controls::ListContextItem* __pItemContext;
367 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
368 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
369 Tizen::Ui::Controls::EditField* __pFooterUrlField;
370 Tizen::Ui::Controls::Button* __pGoBackBtn;
371 Tizen::Ui::Controls::Button* __pGoForwardBtn;
372 Tizen::Ui::Controls::Button* __pRefreshBtn;
373 Tizen::Ui::Controls::Label* __pProgressbarLabel;
374 Tizen::Ui::Controls::Label* __pFooterLabel;
375 Tizen::Ui::Controls::Button* __pStopBtn;
376 Tizen::Ui::Controls::Button* __pClearBtn;
377 Tizen::Ui::Controls::Button* __pReaderBtn;
381 #endif //_INT_MAIN_FORM_H_