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"
40 : public Tizen::Ui::Controls::Form
41 , public Tizen::Ui::Controls::IListViewItemEventListener
42 , public Tizen::Ui::Controls::IListViewItemProvider
43 , public Tizen::Ui::IActionEventListener
44 , public IAddressbarEventListener
45 , public Tizen::Ui::Controls::IFormBackEventListener
46 , public Tizen::Ui::IKeypadEventListener
47 , public Tizen::Web::Controls::ILoadingListener
48 , public Tizen::Ui::IOrientationEventListener
49 , public Tizen::Ui::ITextEventListener
50 , public Tizen::Ui::ITouchEventListener
51 , public Tizen::Ui::Scenes::ISceneEventListener
52 , public ISettingChangeEventListener
53 , public Tizen::Web::Controls::IWebKeypadEventListener
54 , public Tizen::Web::Controls::IWebUiEventListener
55 , public Tizen::Web::Controls::ITextSearchListener
59 *@brief Default constructor
64 *@brief Default destructor
66 virtual ~MainForm(void);
69 * @brief The method initializes the screen variables and controls to be used by the user.
72 bool Initialize(void);
75 * @brief Initializes this instance of %MainForm.
78 result InitWebControl();
81 * @brief Initializes this instance of Reader Panel.
83 result CreateReaderPanel(void);
85 Tizen::Base::String GetImagePath(void);
87 void LoadUrl(Tizen::Base::String& url);
89 virtual void OnActionPerformed(const Tizen::Ui::Control& source, int actionId);
91 virtual void OnFormBackRequested(Tizen::Ui::Controls::Form& source);
93 //IAddressbarEventListener
94 void OnAddressCancelledClicked(const Addressbar&);
96 void OnAddressBarKeypadClosed(const Addressbar&);
98 void OnAddressBarKeypadOpened(const Addressbar&);
100 void OnAddressBarKeypadWillOpen(const Addressbar&);
102 void OnAddressBarModeChanged(const Addressbar&);
104 void OnBackClicked(const Addressbar&);
106 void OnForwardClicked(const Addressbar&);
108 void OnReaderClicked(const Addressbar&);
110 void OnRefreshClicked(const Addressbar&){}
112 void OnSearchClicked(const Addressbar&){}
114 void OnStopClicked(Addressbar&);
116 void OnUrlSubmitted(Addressbar&);
118 //ILoadingeventListener
119 virtual void OnEstimatedProgress(int progress);
121 virtual bool OnHttpAuthenticationRequestedN(const Tizen::Base::String& host, const Tizen::Base::String& realm, const Tizen::Web::Controls::AuthenticationChallenge& authentication);
123 virtual void OnHttpAuthenticationCanceled(void);
125 virtual result OnInitializing(void);
127 virtual void OnKeypadWillOpen(Tizen::Ui::Control& source);
129 virtual void OnKeypadOpened(Tizen::Ui::Control& source){}
131 virtual void OnKeypadClosed(Tizen::Ui::Control& source);;
133 virtual void OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction){}
135 void OnLoadingErrorOccurred(Tizen::Web::Controls::LoadingErrorType error, const Tizen::Base::String& reason);
137 virtual void OnLoadingStarted(void);
139 virtual void OnLoadingCanceled(void);
141 virtual void OnLoadingCompleted(void);
143 bool OnLoadingRequested(const Tizen::Base::String& url, Tizen::Web::Controls::WebNavigationType type);
145 virtual void OnPageTitleReceived(const Tizen::Base::String& title);
147 virtual Tizen::Web::Controls::DecisionPolicy OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& httpHeader);
149 //IOrientationEventListener
150 virtual void OnOrientationChanged (const Tizen::Ui::Control &source, Tizen::Ui::OrientationStatus orientationStatus);
152 //ISceenEventListener
153 virtual void OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs);
155 virtual void OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId);
157 virtual result OnTerminating(void);
159 void SetImageLoadEnabled(void);
161 void SetJavascriptEnabled(void);
163 // IListViewItemEventListener
165 *Called when the state of an element in the ListContextItem is changed.
167 virtual void OnListViewContextItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListContextItemStatus state);
170 *Called when the state of an element in the ListViewItem in the ListView or GroupedListView is changed.
172 virtual void OnListViewItemStateChanged(Tizen::Ui::Controls::ListView& listView, int index, int elementId, Tizen::Ui::Controls::ListItemStatus status);
175 *Called when the ListItem is swept.
177 virtual void OnListViewItemSwept(Tizen::Ui::Controls::ListView& listView, int index, Tizen::Ui::Controls::SweepDirection direction);
180 *Called when the item or the element is long pressed.
182 virtual void OnListViewItemLongPressed(Tizen::Ui::Controls::ListView& listView, int index, int elementId, bool& invokeListViewItemCallback){};
185 //IListViewItemProvider
186 virtual Tizen::Ui::Controls::ListItemBase * CreateItem (int index, int itemWidth);
187 virtual bool DeleteItem (int index, Tizen::Ui::Controls::ListItemBase *pItem, int itemWidth);
188 virtual int GetItemCount (void);
190 //IWebUiEventListener
191 virtual void OnWebPageBlockSelected(Tizen::Web::Controls::Web& source, Tizen::Graphics::Point& startPoint, Tizen::Graphics::Point& endPoint);
192 virtual void OnWebPageShowRequested(Tizen::Web::Controls::Web& source);
193 virtual Tizen::Web::Controls::Web* OnWebWindowCreateRequested(void);
194 virtual void OnWebWindowCloseRequested(Tizen::Web::Controls::Web& source) {AppLog("acdaqsc");}
196 //IWebKeypadEventListener
197 virtual void OnWebKeypadClosed(Tizen::Web::Controls::Web& source);
198 virtual void OnWebKeypadOpened(Tizen::Web::Controls::Web& source);
199 virtual void OnWebKeypadWillOpen(Tizen::Web::Controls::Web& source);
201 //ITouchEventListener
202 virtual void OnTouchDoublePressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
203 virtual void OnTouchFocusIn(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
204 virtual void OnTouchFocusOut(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo){}
205 virtual void OnTouchLongPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
206 virtual void OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
207 virtual void OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
208 virtual void OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo);
210 virtual void OnTextFound(int totalCount, int currentOrdinal);
212 //ISettingsChangeListener
213 void OnClearCache(void);
214 void OnClearCookie(void);
215 void OnSettingsChange(int settingvalue);
216 void OnSettingsReset(void);
218 virtual void OnTextValueChangeCanceled (const Tizen::Ui::Control &source){}
219 virtual void OnTextValueChanged (const Tizen::Ui::Control &source);
221 void UpdateImageContent(Tizen::Base::ByteBuffer* aBuffer, Tizen::Base::String imageName);
223 double findDistance(int x1,int y1,int x2, int y2);
224 void FindNextWord(bool next = true);
225 result InitAddressbar(void);
226 result InitFooter(void);
227 result InitContextMenu(Tizen::Graphics::Point& p);
228 result InitFindWordPanel(void);
229 result InitImageContextMenu(Tizen::Graphics::Point p);
230 result InitSelectTextContextMenu(Tizen::Graphics::Point p, bool pasteOption, bool onlyPasteOption);
231 result InitMostVisitedSitesPanel(Tizen::Ui::OrientationStatus orientationStatus);
232 result InitMostVisitedSitesView(Tizen::Ui::OrientationStatus orientationStatus);
233 void MoveUiControls(void);
234 void UpdateFavicon(void);
235 void RelayoutControls(bool showAddressbar);
236 void ShowFindWordPanel(bool show = true, bool isTouchPressed = false);
237 void ShowMostVisitedSitesPanel(void);
238 void StartWordSearch();
242 static const int IDA_FORMAT_BITMAP;
243 static const int IDA_FORMAT_DELETE_BITMAP;
244 static const int IDA_FORMAT_TITLE_STRING;
245 static const int IDA_FORMAT_URL_STRING;
246 static const int IDA_CONTEXT_ITEM_DELETE;
248 Tizen::Graphics::Point __adressPanelPosition;
249 AddressBarMode __curAddressBarMode;
250 Tizen::Base::String __currentSearchStr;
251 Tizen::Base::String __currentSelectedStr;
253 int __webControlHeight;
254 float __previousZoomLevel;
255 int __maxOccurrances;
256 int __currentWordIndex;
258 bool __inputEventToBeSupressed;
259 Addressbar* __pAddressbar;
260 Tizen::Ui::Controls::Label* __pArticleReaderLabel;
261 Tizen::Ui::Controls::Panel* __pArticleReaderPanel;
262 Tizen::Ui::Controls::Panel* __pBlankPanel;
263 Tizen::Ui::Controls::Label * __pFindWordBgLabel;
264 Tizen::Ui::Controls::Button* __pFindWordClear;
265 Tizen::Ui::Controls::Label* __pFindWordCountLabel;
266 Tizen::Ui::Controls::Panel* __pFindWordControl;
267 Tizen::Ui::Controls::EditField* __pFindWordEditField;
268 Tizen::Ui::Controls::Button* __pFindWordNext;
269 Tizen::Ui::Controls::Button* __pFindWordPrev;
270 Tizen::Ui::Controls::Panel* __pFindWordPanel;
271 Tizen::Ui::Controls::Panel* __pFooterPanel;
272 Tizen::Web::Controls::HitElementResult* __pHitElementResult;
273 Tizen::Ui::Controls::ContextMenu* __pImageMenu;
274 Tizen::Ui::Controls::ContextMenu* __pMenu;
275 Tizen::Ui::Controls::Button* __pMoreButton;
276 Tizen::Ui::Controls::Button* __pMultiWindowButton;
277 Tizen::Ui::Controls::Button* __pNewWindowButton;
278 SharePopup* __pPopUp;
279 AddressBarMode __prevAddressBarMode;
280 Tizen::Ui::Controls::Button* __pReaderCloseBtn;
281 Tizen::Base::String* __pReaderData;
282 Tizen::Media::Image* __pSaveImage;
283 Tizen::Web::Controls::Web* __pWebReader;
284 Tizen::Web::Controls::Web* __pWebViewer;
285 WindowInfo* __pWindowInfo;
286 Tizen::Ui::Controls::ListView* __pMostVisitedListView;
288 Tizen::Graphics::Point __touchPoint1;
289 Tizen::Graphics::Point __touchPoint2;
290 Tizen::Graphics::Point __webControlPosition;
292 Tizen::Ui::Controls::ListContextItem* __pItemContext;
293 Tizen::Base::Collection::ArrayList* __pMostVisitedSites;
296 #endif //_INT_MAIN_FORM_H_