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 OnAddressCancelledClicked(const Addressbar&);
108 void OnAddressBarKeypadClosed(const Addressbar&, bool footerState = true);
110 void OnAddressBarKeypadOpened(const Addressbar&);
112 void OnAddressBarKeypadWillOpen(const Addressbar&);
114 void OnAddressBarKeypadBoundsChanged(const Addressbar& addBar);
116 void OnAddressBarModeChanged(/*const Addressbar&*/);
118 virtual void OnClipboardClosed(const Addressbar&);
120 void OnBackClicked(/*const Addressbar&*/);
122 void OnForwardClicked(/*const Addressbar&*/);
124 void OnReaderClicked(const Addressbar&);
126 void OnRefreshClicked(const Addressbar&){}
128 void OnSearchClicked(const Addressbar&){}
130 void OnStopClicked(Addressbar&);
132 void OnUrlValueChanged(Addressbar&);
134 void OnUrlSubmitted(Addressbar&);
136 //ILoadingeventListener
137 virtual void OnEstimatedProgress(int progress);
138 virtual void OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon);
140 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
142 virtual void OnHttpAuthenticationCanceled(void);
144 virtual result OnInitializing(void);
146 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
148 virtual void OnKeypadOpened(Tizen::Ui::Control& source);
150 virtual void OnKeypadClosed(Tizen::Ui::Control& source);
152 virtual void OnKeypadBoundsChanged (Tizen::Ui::Control &source);
154 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
156 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
158 virtual void OnLoadingStarted(void);
160 virtual void OnLoadingCanceled(void);
162 virtual void OnLoadingCompleted(void);
164 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
166 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
168 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
170 //IOrientationEventListener
171 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
173 //ISceenEventListener
174 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
176 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
178 virtual result OnTerminating(void);
180 void SetImageLoadEnabled(void);
182 void SetJavascriptEnabled(void);
184 void OnFocusGained(const Tizen::Ui::Control& source);
185 void OnFocusLost(const Tizen::Ui::Control& source);
187 // IListViewItemEventListener
189 *Called when the state of an element in the ListContextItem is changed.
191 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
194 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
196 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
199 *Called when the ListItem is swept.
201 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
204 *Called when the item or the element is long pressed.
206 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
209 //IListViewItemProvider
210 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
211 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
212 virtual int GetItemCount (void);
214 //IWebUiEventListener
215 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint);
216 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
217 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
218 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
220 //IWebKeypadEventListener
221 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
222 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
223 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
225 //ITouchEventListener
226 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
227 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
228 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
229 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
230 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
231 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
232 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
234 //IPropagatedTouchEventListener
235 virtual bool OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
236 virtual bool OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
237 virtual bool OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
238 virtual bool OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
239 virtual bool OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
240 virtual bool OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
241 virtual bool OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
243 virtual void OnTextFound(int totalCount, int currentOrdinal);
245 //ISettingsChangeListener
246 void OnClearCache(void);
247 void OnClearCookie(void);
248 void OnClearFormData(void);
249 void OnClearPasswords(void);
250 void OnSettingsChange(int settingvalue);
251 void OnSettingsReset(void);
253 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
254 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
256 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
258 void SetForwardButtonEnabled(bool isEnabled);
259 void SetBackButtonEnabled(bool isEnabled);
261 void UpdateProgress(int percentage);
262 int GetProgress(void);
263 void UpdateProgressBitmap(void);
266 * @brief Sets the current addressbar Mode.
268 void SetAddressbarMode(AddressBarMode addMode);
270 void SetUrl(const Tizen::Base::String& url);
272 void OnSharePopupControlStarted(void);
274 virtual void OnUserEventReceivedN (RequestId requestId, Tizen::Base::Collection::IList *pArgs);
277 double findDistance(int x1,int y1,int x2, int y2);
278 void FindNextWord(bool next = true);
279 result InitAddressbar(void);
280 result InitFooter(void);
281 result InitContextMenu(Tizen::Graphics::Point& p);
282 result InitFindWordPanel(void);
283 result InitImageContextMenu(Tizen::Graphics::Point p);
284 result InitImageLinkContextMenu(Tizen::Graphics::Point p);
285 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
286 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
287 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
288 void MoveUiControls(void);
289 void UpdateFavicon(void);
290 void RelayoutControls(bool showAddressbar,bool relayoutFooter = true);
291 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
292 void ShowMostVisitedSitesPanel(void);
293 void StartWordSearch();
294 AddressBarMode GetAddressbarMode(void);
295 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
299 static const int IDA_FORMAT_BITMAP;
300 static const int IDA_FORMAT_DELETE_BITMAP;
301 static const int IDA_FORMAT_TITLE_STRING;
302 static const int IDA_FORMAT_URL_STRING;
303 static const int IDA_CONTEXT_ITEM_DELETE;
305 Tizen::Graphics::Point __adressPanelPosition;
306 AddressBarMode __curAddressBarMode;
307 Tizen::Base::String __currentSearchStr;
308 Tizen::Base::String __currentSelectedStr;
310 int __webControlHeight;
311 float __previousZoomLevel;
312 int __maxOccurrances;
313 int __currentWordIndex;
315 bool __inputEventToBeSupressed;
317 bool __isLoadingData;
318 bool __isLoadingCompleted;
319 bool __isLongPressedDone;
320 bool __isWebKeypadOpened;
321 int __progressPercentage;
323 AddressBarMode __currentAddMode;
324 Tizen::Base::String __displayUrl;
325 Tizen::Base::String __editTextUrl;
327 Addressbar* __pAddressbar;
329 Tizen::Graphics::Point __contextMenuPosition;
330 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
331 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
332 Tizen::Ui::Controls::Panel* __pBlankPanel;
333 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
334 Tizen::Ui::Controls::Button* __pFindWordClear;
335 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
336 Tizen::Ui::Controls::Panel* __pFindWordControl;
337 Tizen::Ui::Controls::EditField* __pFindWordEditField;
338 Tizen::Ui::Controls::Button* __pFindWordNext;
339 Tizen::Ui::Controls::Button* __pFindWordPrev;
340 // Tizen::Ui::Controls::Panel* __pFindWordPanel;
341 Tizen::Ui::Controls::Panel* __pFooterPanel;
342 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
343 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
344 Tizen::Ui::Controls::ContextMenu* __pMenu;
345 Tizen::Ui::Controls::Button* __pMoreButton;
346 Tizen::Ui::Controls::Button* __pMultiWindowButton;
347 // Tizen::Ui::Controls::Button* __pNewWindowButton;
348 SharePopup* __pPopUp;
349 AddressBarMode __prevAddressBarMode;
350 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
351 Tizen::Base::String* __pReaderData;
352 Tizen::Media::Image* __pSaveImage;
353 Tizen::Web::Controls::Web* __pWebReader;
354 Tizen::Web::Controls::Web* __pWebViewer;
355 WindowInfo* __pWindowInfo;
356 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
358 Tizen::Graphics::Point __touchPoint1;
359 Tizen::Graphics::Point __touchPoint2;
360 Tizen::Graphics::Point __webControlPosition;
362 Tizen::Ui::Controls::ListContextItem* __pItemContext;
363 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
364 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
365 Tizen::Ui::Controls::EditField* __pFooterUrlField;
366 Tizen::Ui::Controls::Button* __pGoBackBtn;
367 Tizen::Ui::Controls::Button* __pGoForwardBtn;
368 Tizen::Ui::Controls::Button* __pRefreshBtn;
369 Tizen::Ui::Controls::Label* __pProgressbarLabel;
370 Tizen::Ui::Controls::Label* __pFooterLabel;
371 Tizen::Ui::Controls::Button* __pStopBtn;
372 Tizen::Ui::Controls::Button* __pClearBtn;
376 #endif //_INT_MAIN_FORM_H_