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::Controls::IFormBackEventListener
55 , public Tizen::Ui::IKeypadEventListener
56 , public Tizen::Web::Controls::ILoadingListener
57 , public Tizen::Ui::IOrientationEventListener
58 , public Tizen::Ui::ITextEventListener
59 , public Tizen::Ui::ITouchEventListener
60 , public Tizen::Ui::Scenes::ISceneEventListener
61 , public ISettingChangeEventListener
62 , public Tizen::Web::Controls::IWebKeypadEventListener
63 , public Tizen::Web::Controls::IWebUiEventListener
64 , public Tizen::Web::Controls::ITextSearchListener
68 *@brief Default constructor
73 *@brief Default destructor
75 virtual ~MainForm(void);
78 * @brief The method initializes the screen variables and controls to be used by the user.
81 bool Initialize(void);
84 * @brief Initializes this instance of %MainForm.
87 result InitWebControl();
90 * @brief Initializes this instance of Reader Panel.
92 result CreateReaderPanel(void);
94 Tizen::Base::String GetImagePath(void);
96 void LoadUrl(Tizen::Base::String& url);
98 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
100 virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
102 //IAddressbarEventListener
103 void OnAddressCancelledClicked(const Addressbar&);
105 void OnAddressBarKeypadClosed(const Addressbar&, bool footerState = true);
107 void OnAddressBarKeypadOpened(const Addressbar&);
109 void OnAddressBarKeypadWillOpen(const Addressbar&);
111 void OnAddressBarModeChanged(/*const Addressbar&*/);
113 void OnBackClicked(/*const Addressbar&*/);
115 void OnForwardClicked(/*const Addressbar&*/);
117 void OnReaderClicked(const Addressbar&);
119 void OnRefreshClicked(const Addressbar&){}
121 void OnSearchClicked(const Addressbar&){}
123 void OnStopClicked(Addressbar&);
125 void OnUrlSubmitted(Addressbar&);
127 //ILoadingeventListener
128 virtual void OnEstimatedProgress(int progress);
129 virtual void OnFaviconReceived(const Tizen::Graphics::Bitmap& favicon);
131 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
133 virtual void OnHttpAuthenticationCanceled(void);
135 virtual result OnInitializing(void);
137 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
139 virtual void OnKeypadOpened(Tizen::Ui::Control& source);
141 virtual void OnKeypadClosed(Tizen::Ui::Control& source);
143 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
145 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
147 virtual void OnLoadingStarted(void);
149 virtual void OnLoadingCanceled(void);
151 virtual void OnLoadingCompleted(void);
153 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
155 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
157 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
159 //IOrientationEventListener
160 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
162 //ISceenEventListener
163 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
165 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
167 virtual result OnTerminating(void);
169 void SetImageLoadEnabled(void);
171 void SetJavascriptEnabled(void);
173 // IListViewItemEventListener
175 *Called when the state of an element in the ListContextItem is changed.
177 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
180 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
182 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
185 *Called when the ListItem is swept.
187 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
190 *Called when the item or the element is long pressed.
192 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
195 //IListViewItemProvider
196 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
197 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
198 virtual int GetItemCount (void);
200 //IWebUiEventListener
201 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint);
202 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
203 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
204 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
206 //IWebKeypadEventListener
207 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
208 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
209 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
211 //ITouchEventListener
212 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
213 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
214 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
215 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
216 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
217 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
218 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
220 virtual void OnTextFound(int totalCount, int currentOrdinal);
222 //ISettingsChangeListener
223 void OnClearCache(void);
224 void OnClearCookie(void);
225 void OnSettingsChange(int settingvalue);
226 void OnSettingsReset(void);
228 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
229 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
231 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
233 void SetForwardButtonEnabled(bool isEnabled);
234 void SetBackButtonEnabled(bool isEnabled);
236 void UpdateProgress(int percentage);
237 int GetProgress(void);
238 void UpdateProgressBitmap(void);
241 * @brief Sets the current addressbar Mode.
243 void SetAddressbarMode(AddressBarMode addMode);
245 void SetUrl(const Tizen::Base::String& url);
248 double findDistance(int x1,int y1,int x2, int y2);
249 void FindNextWord(bool next = true);
250 result InitAddressbar(void);
251 result InitFooter(void);
252 result InitContextMenu(Tizen::Graphics::Point& p);
253 result InitFindWordPanel(void);
254 result InitImageContextMenu(Tizen::Graphics::Point p);
255 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
256 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
257 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
258 void MoveUiControls(void);
259 void UpdateFavicon(void);
260 void RelayoutControls(bool showAddressbar);
261 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
262 void ShowMostVisitedSitesPanel(void);
263 void StartWordSearch();
264 AddressBarMode GetAddressbarMode(void);
265 Tizen::Base::String RemoveHttpTextFromDisplayURL(void);
269 static const int IDA_FORMAT_BITMAP;
270 static const int IDA_FORMAT_DELETE_BITMAP;
271 static const int IDA_FORMAT_TITLE_STRING;
272 static const int IDA_FORMAT_URL_STRING;
273 static const int IDA_CONTEXT_ITEM_DELETE;
275 Tizen::Graphics::Point __adressPanelPosition;
276 AddressBarMode __curAddressBarMode;
277 Tizen::Base::String __currentSearchStr;
278 Tizen::Base::String __currentSelectedStr;
280 int __webControlHeight;
281 float __previousZoomLevel;
282 int __maxOccurrances;
283 int __currentWordIndex;
285 bool __inputEventToBeSupressed;
287 bool __isLoadingData;
288 bool __isLoadingCompleted;
289 int __progressPercentage;
291 AddressBarMode __currentAddMode;
292 Tizen::Base::String __displayUrl;
293 Tizen::Base::String __editTextUrl;
295 Addressbar* __pAddressbar;
296 Tizen::Graphics::Point __contextMenuPosition;
297 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
298 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
299 Tizen::Ui::Controls::Panel* __pBlankPanel;
300 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
301 Tizen::Ui::Controls::Button* __pFindWordClear;
302 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
303 Tizen::Ui::Controls::Panel* __pFindWordControl;
304 Tizen::Ui::Controls::EditField* __pFindWordEditField;
305 Tizen::Ui::Controls::Button* __pFindWordNext;
306 Tizen::Ui::Controls::Button* __pFindWordPrev;
307 Tizen::Ui::Controls::Panel* __pFindWordPanel;
308 Tizen::Ui::Controls::Panel* __pFooterPanel;
309 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
310 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
311 Tizen::Ui::Controls::ContextMenu* __pMenu;
312 Tizen::Ui::Controls::Button* __pMoreButton;
313 Tizen::Ui::Controls::Button* __pMultiWindowButton;
314 // Tizen::Ui::Controls::Button* __pNewWindowButton;
315 SharePopup* __pPopUp;
316 AddressBarMode __prevAddressBarMode;
317 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
318 Tizen::Base::String* __pReaderData;
319 Tizen::Media::Image* __pSaveImage;
320 Tizen::Web::Controls::Web* __pWebReader;
321 Tizen::Web::Controls::Web* __pWebViewer;
322 WindowInfo* __pWindowInfo;
323 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
325 Tizen::Graphics::Point __touchPoint1;
326 Tizen::Graphics::Point __touchPoint2;
327 Tizen::Graphics::Point __webControlPosition;
329 Tizen::Ui::Controls::ListContextItem* __pItemContext;
330 Tizen::Ui::Controls::ListContextItem* __pItemContextLandscape;
331 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
332 Tizen::Ui::Controls::EditField* __pFooterUrlField;
333 Tizen::Ui::Controls::Button* __pGoBackBtn;
334 Tizen::Ui::Controls::Button* __pGoForwardBtn;
335 Tizen::Ui::Controls::Button* __pRefreshBtn;
336 Tizen::Ui::Controls::Label* __pProgressbarLabel;
337 Tizen::Ui::Controls::Label* __pFooterLabel;
338 Tizen::Ui::Controls::Button* __pStopBtn;
339 Tizen::Ui::Controls::Button* __pClearBtn;
343 #endif //_INT_MAIN_FORM_H_