3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (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"
41 ADDRESSBAR_MODE_INVALID = -1,
42 ADDRESSBAR_MODE_READER = 0,
43 ADDRESSBAR_MODE_LOADING,
44 ADDRESSBAR_MODE_LOADING_COMPLETE,
49 : public Tizen::Ui::Controls::Form
50 , public Tizen::Ui::Controls::IListViewItemEventListener
51 , public Tizen::Ui::Controls::IListViewItemProvider
52 , public Tizen::Ui::IActionEventListener
53 , public IAddressbarEventListener
54 , public Tizen::Ui::IFocusEventListener
55 , public Tizen::Ui::Controls::IFormBackEventListener
56 , public Tizen::Ui::IKeypadEventListener
57 , public Tizen::Web::Controls::ILoadingListener
58 , public Tizen::Ui::IOrientationEventListener
59 , public Tizen::Ui::ITextEventListener
60 , public Tizen::Ui::IPropagatedTouchEventListener
61 , public Tizen::Ui::ITouchEventListener
62 , public Tizen::Ui::Scenes::ISceneEventListener
63 , public ISettingChangeEventListener
64 , public Tizen::Web::Controls::IWebKeypadEventListener
65 , public Tizen::Web::Controls::IWebUiEventListener
66 , public Tizen::Web::Controls::ITextSearchListener
70 *@brief Default constructor
75 *@brief Default destructor
77 virtual ~MainForm(void);
80 * @brief The method initializes the screen variables and controls to be used by the user.
83 bool Initialize(void);
86 * @brief Initializes this instance of %MainForm.
89 result InitWebControl();
92 * @brief Initializes this instance of Reader Panel.
94 result CreateReaderPanel(void);
96 Tizen::Base::String GetImagePath(void);
98 void LoadUrl(Tizen::Base::String& url);
100 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
102 virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
104 //IAddressbarEventListener
105 void OnAddressCancelledClicked(const Addressbar&);
107 void OnAddressBarKeypadClosed(const Addressbar&, bool footerState = true);
109 void OnAddressBarKeypadOpened(const Addressbar&);
111 void OnAddressBarKeypadWillOpen(const Addressbar&);
113 void OnAddressBarKeypadBoundsChanged(const Addressbar& addBar);
115 void OnAddressBarModeChanged(/*const Addressbar&*/);
117 void OnBackClicked(/*const Addressbar&*/);
119 void OnForwardClicked(/*const Addressbar&*/);
121 void OnReaderClicked(const Addressbar&);
123 void OnRefreshClicked(const Addressbar&){}
125 void OnSearchClicked(const Addressbar&){}
127 void OnStopClicked(Addressbar&);
129 void OnUrlValueChanged(Addressbar&);
131 void OnUrlSubmitted(Addressbar&);
133 //ILoadingeventListener
134 virtual void OnEstimatedProgress(int progress);
135 virtual void OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon);
137 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
139 virtual void OnHttpAuthenticationCanceled(void);
141 virtual result OnInitializing(void);
143 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
145 virtual void OnKeypadOpened(Tizen::Ui::Control& source);
147 virtual void OnKeypadClosed(Tizen::Ui::Control& source);
149 virtual void OnKeypadBoundsChanged (Tizen::Ui::Control &source);
151 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
153 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
155 virtual void OnLoadingStarted(void);
157 virtual void OnLoadingCanceled(void);
159 virtual void OnLoadingCompleted(void);
161 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
163 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
165 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
167 //IOrientationEventListener
168 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
170 //ISceenEventListener
171 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
173 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
175 virtual result OnTerminating(void);
177 void SetImageLoadEnabled(void);
179 void SetJavascriptEnabled(void);
181 void OnFocusGained(const Tizen::Ui::Control& source);
182 void OnFocusLost(const Tizen::Ui::Control& source);
184 // IListViewItemEventListener
186 *Called when the state of an element in the ListContextItem is changed.
188 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
191 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
193 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
196 *Called when the ListItem is swept.
198 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
201 *Called when the item or the element is long pressed.
203 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
206 //IListViewItemProvider
207 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
208 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
209 virtual int GetItemCount (void);
211 //IWebUiEventListener
212 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint);
213 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
214 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
215 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
217 //IWebKeypadEventListener
218 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
219 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
220 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
222 //ITouchEventListener
223 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
224 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
225 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
226 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
227 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
228 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
229 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
231 //IPropagatedTouchEventListener
232 virtual bool OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
233 virtual bool OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
234 virtual bool OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
235 virtual bool OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
236 virtual bool OnPreviewTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
237 virtual bool OnPreviewTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
238 virtual bool OnPreviewTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchEventInfo);
240 virtual void OnTextFound(int totalCount, int currentOrdinal);
242 //ISettingsChangeListener
243 void OnClearCache(void);
244 void OnClearCookie(void);
245 void OnSettingsChange(int settingvalue);
246 void OnSettingsReset(void);
248 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
249 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
251 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
253 void SetForwardButtonEnabled(bool isEnabled);
254 void SetBackButtonEnabled(bool isEnabled);
256 void UpdateProgress(int percentage);
257 int GetProgress(void);
258 void UpdateProgressBitmap(void);
261 * @brief Sets the current addressbar Mode.
263 void SetAddressbarMode(AddressBarMode addMode);
265 void SetUrl(const Tizen::Base::String& url);
268 double findDistance(int x1,int y1,int x2, int y2);
269 void FindNextWord(bool next = true);
270 result InitAddressbar(void);
271 result InitFooter(void);
272 result InitContextMenu(Tizen::Graphics::Point& p);
273 result InitFindWordPanel(void);
274 result InitImageContextMenu(Tizen::Graphics::Point p);
275 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
276 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
277 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
278 void MoveUiControls(void);
279 void UpdateFavicon(void);
280 void RelayoutControls(bool showAddressbar);
281 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
282 void ShowMostVisitedSitesPanel(void);
283 void StartWordSearch();
284 AddressBarMode GetAddressbarMode(void);
285 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
289 static const int IDA_FORMAT_BITMAP;
290 static const int IDA_FORMAT_DELETE_BITMAP;
291 static const int IDA_FORMAT_TITLE_STRING;
292 static const int IDA_FORMAT_URL_STRING;
293 static const int IDA_CONTEXT_ITEM_DELETE;
295 Tizen::Graphics::Point __adressPanelPosition;
296 AddressBarMode __curAddressBarMode;
297 Tizen::Base::String __currentSearchStr;
298 Tizen::Base::String __currentSelectedStr;
300 int __webControlHeight;
301 float __previousZoomLevel;
302 int __maxOccurrances;
303 int __currentWordIndex;
305 bool __inputEventToBeSupressed;
307 bool __isLoadingData;
308 bool __isLoadingCompleted;
309 bool __isLongPressedDone;
310 bool __isWebKeypadOpened;
311 int __progressPercentage;
313 AddressBarMode __currentAddMode;
314 Tizen::Base::String __displayUrl;
315 Tizen::Base::String __editTextUrl;
317 Addressbar* __pAddressbar;
318 Tizen::Graphics::Point __contextMenuPosition;
319 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
320 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
321 Tizen::Ui::Controls::Panel* __pBlankPanel;
322 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
323 Tizen::Ui::Controls::Button* __pFindWordClear;
324 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
325 Tizen::Ui::Controls::Panel* __pFindWordControl;
326 Tizen::Ui::Controls::EditField* __pFindWordEditField;
327 Tizen::Ui::Controls::Button* __pFindWordNext;
328 Tizen::Ui::Controls::Button* __pFindWordPrev;
329 // Tizen::Ui::Controls::Panel* __pFindWordPanel;
330 Tizen::Ui::Controls::Panel* __pFooterPanel;
331 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
332 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
333 Tizen::Ui::Controls::ContextMenu* __pMenu;
334 Tizen::Ui::Controls::Button* __pMoreButton;
335 Tizen::Ui::Controls::Button* __pMultiWindowButton;
336 // Tizen::Ui::Controls::Button* __pNewWindowButton;
337 SharePopup* __pPopUp;
338 AddressBarMode __prevAddressBarMode;
339 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
340 Tizen::Base::String* __pReaderData;
341 Tizen::Media::Image* __pSaveImage;
342 Tizen::Web::Controls::Web* __pWebReader;
343 Tizen::Web::Controls::Web* __pWebViewer;
344 WindowInfo* __pWindowInfo;
345 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
347 Tizen::Graphics::Point __touchPoint1;
348 Tizen::Graphics::Point __touchPoint2;
349 Tizen::Graphics::Point __webControlPosition;
351 Tizen::Ui::Controls::ListContextItem* __pItemContext;
352 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
353 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
354 Tizen::Ui::Controls::EditField* __pFooterUrlField;
355 Tizen::Ui::Controls::Button* __pGoBackBtn;
356 Tizen::Ui::Controls::Button* __pGoForwardBtn;
357 Tizen::Ui::Controls::Button* __pRefreshBtn;
358 Tizen::Ui::Controls::Label* __pProgressbarLabel;
359 Tizen::Ui::Controls::Label* __pFooterLabel;
360 Tizen::Ui::Controls::Button* __pStopBtn;
361 Tizen::Ui::Controls::Button* __pClearBtn;
365 #endif //_INT_MAIN_FORM_H_