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, bool addressbarKeyPadState);
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);
226 virtual void OnWebKeypadBoundsChanged(Tizen::Web::Controls::Web& source);
228 //ITouchEventListener
229 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
230 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
231 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
232 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
233 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
234 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
235 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
237 //IPropagatedTouchEventListener
238 virtual bool OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
239 virtual bool OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
240 virtual bool OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
241 virtual bool OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
242 virtual bool OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
243 virtual bool OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
244 virtual bool OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
246 virtual void OnTextFound(int totalCount, int currentOrdinal);
248 //ISettingsChangeListener
249 void OnClearCache(void);
250 void OnClearCookie(void);
251 void OnClearFormData(void);
252 void OnClearPasswords(void);
253 void OnSettingsChange(int settingvalue);
254 void OnSettingsReset(void);
256 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
257 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
259 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
261 void SetForwardButtonEnabled(bool isEnabled);
262 void SetBackButtonEnabled(bool isEnabled);
264 void UpdateProgress(int percentage);
265 int GetProgress(void);
266 void UpdateProgressBitmap(void);
267 void ReaderClicked();
270 * @brief Sets the current addressbar Mode.
272 void SetAddressbarMode(AddressBarMode addMode);
274 void SetUrl(const Tizen::Base::String& url);
276 void OnSharePopupControlStarted(void);
278 virtual void OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs);
280 void AddressBarCancelledClicked(const Addressbar& addBar);
282 double findDistance(int x1,int y1,int x2, int y2);
283 void FindNextWord(bool next = true);
284 result InitAddressbar(void);
285 result InitFooter(void);
286 result InitContextMenu(Tizen::Graphics::Point& p);
287 result InitFindWordPanel(void);
288 result InitImageContextMenu(Tizen::Graphics::Point p);
289 result InitImageLinkContextMenu(Tizen::Graphics::Point p);
290 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
291 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
292 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
293 void MoveUiControls(void);
294 void UpdateFavicon(void);
295 void RelayoutControls(bool showAddressbar,bool relayoutFooter = true);
296 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
297 void ShowMostVisitedSitesPanel(void);
298 void StartWordSearch();
299 AddressBarMode GetAddressbarMode(void);
300 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
304 static const int IDA_FORMAT_BITMAP;
305 static const int IDA_FORMAT_DELETE_BITMAP;
306 static const int IDA_FORMAT_TITLE_STRING;
307 static const int IDA_FORMAT_URL_STRING;
308 static const int IDA_CONTEXT_ITEM_DELETE;
310 Tizen::Graphics::Point __adressPanelPosition;
311 AddressBarMode __curAddressBarMode;
312 Tizen::Base::String __currentSearchStr;
313 Tizen::Base::String __currentSelectedStr;
315 int __webControlHeight;
316 float __previousZoomLevel;
317 int __maxOccurrances;
318 int __currentWordIndex;
320 //bool __inputEventToBeSupressed;
322 bool __isLoadingData;
323 bool __isLoadingCompleted;
324 //bool __isLongPressedDone;
325 bool __isWebKeypadOpened;
326 int __progressPercentage;
328 AddressBarMode __currentAddMode;
329 Tizen::Base::String __displayUrl;
330 Tizen::Base::String __editTextUrl;
332 Addressbar* __pAddressbar;
334 Tizen::Graphics::Point __contextMenuPosition;
335 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
336 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
337 Tizen::Ui::Controls::Panel* __pBlankPanel;
338 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
339 Tizen::Ui::Controls::Label * __pFindWordBgLabelRightToLeft;
340 Tizen::Ui::Controls::Button* __pFindWordClear;
341 Tizen::Ui::Controls::Button* __pFindWordClearRightToLeft;
342 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
343 Tizen::Ui::Controls::Label* __pFindWordCountLabelRightToLeft;
344 Tizen::Ui::Controls::Panel* __pFindWordControl;
346 Tizen::Ui::Controls::Panel* __pFindWordPanelLeftToRight;
347 Tizen::Ui::Controls::Panel* __pFindWordPanelRightToLeft;
349 Tizen::Ui::Controls::EditField* __pFindWordEditField;
350 Tizen::Ui::Controls::EditField* __pFindWordEditFieldRightToLeft;
351 Tizen::Ui::Controls::Button* __pFindWordNext;
352 Tizen::Ui::Controls::Button* __pFindWordPrev;
353 // Tizen::Ui::Controls::Panel* __pFindWordPanel;
354 Tizen::Ui::Controls::Panel* __pFooterPanel;
355 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
356 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
357 Tizen::Ui::Controls::ContextMenu* __pMenu;
358 Tizen::Ui::Controls::Button* __pMoreButton;
359 Tizen::Ui::Controls::Button* __pMultiWindowButton;
360 // Tizen::Ui::Controls::Button* __pNewWindowButton;
361 SharePopup* __pPopUp;
362 Tizen::Ui::Controls::Label* __pCheckLabel;
363 AddressBarMode __prevAddressBarMode;
364 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
365 Tizen::Base::String* __pReaderData;
366 Tizen::Media::Image* __pSaveImage;
367 Tizen::Web::Controls::Web* __pWebReader;
368 Tizen::Web::Controls::Web* __pWebViewer;
369 WindowInfo* __pWindowInfo;
370 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
372 Tizen::Graphics::Point __touchPoint1;
373 Tizen::Graphics::Point __touchPoint2;
374 Tizen::Graphics::Point __webControlPosition;
376 Tizen::Ui::Controls::ListContextItem* __pItemContext;
377 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
378 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
379 Tizen::Ui::Controls::EditField* __pFooterUrlField;
380 Tizen::Ui::Controls::Button* __pGoBackBtn;
381 Tizen::Ui::Controls::Button* __pGoForwardBtn;
382 Tizen::Ui::Controls::Button* __pRefreshBtn;
383 Tizen::Ui::Controls::Label* __pProgressbarLabel;
384 Tizen::Ui::Controls::Label* __pFooterLabel;
385 Tizen::Ui::Controls::Button* __pStopBtn;
386 Tizen::Ui::Controls::Button* __pClearBtn;
387 Tizen::Ui::Controls::Button* __pReaderBtn;
388 Tizen::Graphics::Point __longPressPoint;
392 #endif //_INT_MAIN_FORM_H_