17a95fa92f6245b4724e87a2be776824f9e43bda
[platform/framework/native/uifw.git] / src / ui / inc / FUiCtrl_Form.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17 /**
18  * @file                FUiCtrl_Form.h
19  * @brief               This is the header file for the %_Form class.
20  *
21  * This header file contains the declarations of the %_Form class.
22  */
23 #ifndef _FUI_CTRL_INTERNAL_FORM_H_
24 #define _FUI_CTRL_INTERNAL_FORM_H_
25
26 #include <unique_ptr.h>
27 #include <FUiIOrientationEventListener.h>
28 #include <FUiCtrlControlsTypes.h>
29 #include <FUiCtrlOverlayRegion.h>
30 #include "FUi_Control.h"
31 #include "FUiCtrl_IActionEventListener.h"
32 #include "FUi_EcoreEvas.h"
33
34
35 namespace Tizen { namespace Ui { namespace Controls
36 {
37
38 class _FormPresenter;
39 class _Toolbar;
40 class _Tab;
41 class _Indicator;
42 class _ActionEvent;
43 class _OverlayRegionImpl;
44 class _IFormBackEventListener;
45 class _IFormMenuEventListener;
46
47 enum _FormStyle
48 {
49         _FORM_STYLE_NORMAL = 0x00000000,     /**< The basic form style */
50         _FORM_STYLE_TITLE = 0x00000001,      /**< @deprecated This enumeration field is deprecated because the use of the Title control is no longer recommended.*/
51         _FORM_STYLE_INDICATOR = 0x00000002,  /**< The form with the indicator area */
52         _FORM_STYLE_SOFTKEY_0 = 0x00000010,  /**< @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.*/
53         _FORM_STYLE_SOFTKEY_1 = 0x00000020,  /**< @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.*/
54         _FORM_STYLE_OPTIONKEY = 0x00000040,  /**< @deprecated This enumeration field is deprecated because the use of the Optionkey control is no longer recommended.*/
55         _FORM_STYLE_TEXT_TAB = 0x00000100,   /**< @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended.*/
56         _FORM_STYLE_ICON_TAB = 0x00000200,   /**< @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended.*/
57         _FORM_STYLE_HEADER = 0x00001000,     /**< The form with a header @b Since: @b 2.0 */
58         _FORM_STYLE_FOOTER = 0x00002000,      /**< The form with a footer @b Since: @b 2.0 */
59         _FORM_STYLE_INDICATOR_AUTO_HIDE = 0x00010000,      /**< The form with a indicator which is hidden. @b Since: @b 2.1 */
60         _FORM_STYLE_PORTRAIT_INDICATOR_AUTO_HIDE = _FORM_STYLE_INDICATOR_AUTO_HIDE,   /**< The form with a indicator which is hidden. @b Since: @b 2.2 */
61         _FORM_STYLE_LANDSCAPE_INDICATOR_AUTO_HIDE = 0x00020000   /**< The form with a indicator which is hidden. @b Since: @b 2.2 */
62 };
63
64 enum _Softkey
65 {
66         _SOFTKEY_0,      /**< The left softkey */
67         _SOFTKEY_1,      /**< The right softkey */
68         _SOFTKEY_COUNT   /**< This is internal. If used in an application, the application can get rejected during the certification process. Define the softkey count */
69 };
70
71 class _IFormOrientationStatusEventListener
72         : virtual public Tizen::Base::Runtime::IEventListener
73 {
74         // Lifecycle
75         public:
76                 virtual ~_IFormOrientationStatusEventListener(void) {}
77
78         // Operation
79         public:
80                 virtual Tizen::Ui::OrientationStatus OnFormOrientationStatusRequested(void) = 0;
81 };
82
83 /**
84  * @class _Form
85  * @brief
86  * @since       2.0
87  */
88
89 class _OSP_EXPORT_ _Form
90         : public _Control
91         , public _IActionEventListener
92 {
93 // Lifecycle
94 public:
95         _Form(void);
96         virtual ~_Form(void);
97
98 // Operations
99 public:
100         static _Form* CreateFormN(void);
101
102         void SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener);
103         void SetFormMenuEventListener(_IFormMenuEventListener* pFormMenuEventListener);
104
105         unsigned long GetFormStyle(void) const;
106         _Toolbar* GetFooter(void) const;
107         _Toolbar* GetHeader(void) const;
108         _Tab* GetTab(void) const;
109         _Indicator* GetIndicator(void) const;
110         Tizen::Base::String GetTitleText(void) const;
111         HorizontalAlignment GetTitleTextHorizontalAlignment(void) const;
112         OverlayRegion* GetOverlayRegionN(const Tizen::Graphics::Rectangle& rect, OverlayRegionType regionType);
113         OverlayRegion* GetOverlayRegionN(const Tizen::Graphics::FloatRectangle& rect, OverlayRegionType regionType);
114         int     GetOverlayRegionCount(void) const;
115         Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const;
116         int GetSoftkeyActionId(_Softkey softkey) const;
117         int GetOptionkeyActionId(void) const;
118         Tizen::Base::String GetSoftkeyText(_Softkey softkey) const;
119
120         void SetFormStyle(unsigned long formStyle);
121         result SetActionBarsTranslucent(unsigned long actionBars, bool translucent);
122         result SetActionBarsVisible(unsigned long actionBars, bool visible);
123         result SetTitleIcon(const Tizen::Graphics::Bitmap* pTitleBitmap);
124         result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment);
125         result SetSoftkeyEnabled(_Softkey softkey, bool enable);
126         result SetOptionkeyActionId(int actionId);
127         result SetSoftkeyActionId(_Softkey softkey, int actionId);
128         result SetSoftkeyText(_Softkey softkey, const Tizen::Base::String& text);
129         result SetSoftkeyIcon(_Softkey softkey, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap);
130
131         bool HasFooter(void) const;
132         bool HasHeader(void) const;
133         bool HasIndicator(void) const;
134         bool HasTitle(void) const;
135         bool HasTab(void) const;
136         bool IsIndicatorVisible(void) const;
137         bool IsHeaderVisible(void) const;
138         bool IsFooterVisible(void) const;
139         bool IsIndicatorTranslucent(void) const;
140         bool IsIndicatorAutoHide(void) const;
141         bool IsHeaderTranslucent(void) const;
142         bool IsFooterTranslucent(void) const;
143         bool IsTabTranslucent(void) const;
144         bool HasOptionkey(void) const;
145         bool HasSoftkey(_Softkey softkey) const;
146         bool IsSoftkeyEnabled(_Softkey softkey) const;
147         bool CheckSoftkey(_Softkey softkey) const;
148         virtual bool IsOrientationRoot(void) const;
149
150         Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position)    const;
151         Tizen::Graphics::FloatPoint TranslateToClientAreaPosition(const Tizen::Graphics::FloatPoint& position)  const;
152         Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition)    const;
153         Tizen::Graphics::FloatPoint TranslateFromClientAreaPosition(const Tizen::Graphics::FloatPoint& clientPosition)  const;
154
155         bool IsDeflated(void);
156         bool DeflateClientRectHeight(int height);
157         bool DeflateClientRectHeight(float height);
158
159         static _Toolbar* CreateHeaderN(void);
160         static _Toolbar* CreateFooterN(void);
161         static _Tab* CreateTabN(void);
162         static _Indicator* CreateIndicatorN(void);
163
164         int GetToolbarHeight(bool header) const;
165         float GetToolbarHeightF(bool header) const;
166         int GetTabHeight(void) const;
167         float GetTabHeightF(void) const;
168         bool RemoveHeader(void);
169         bool RemoveFooter(void);
170         bool RemoveTab(void);
171         bool RemoveIndicator(void);
172         result SetHeaderBounds(Tizen::Graphics::Rectangle& bounds);
173         result SetHeaderBounds(Tizen::Graphics::FloatRectangle& bounds);
174         result SetFooterBounds(Tizen::Graphics::Rectangle& bounds);
175         result SetFooterBounds(Tizen::Graphics::FloatRectangle& bounds);
176         result SetTabBounds(Tizen::Graphics::Rectangle& bounds);
177         result SetTabBounds(Tizen::Graphics::FloatRectangle& bounds);
178         Tizen::Graphics::Rectangle GetIndicatorBounds(void) const;
179         Tizen::Graphics::FloatRectangle GetIndicatorBoundsF(void) const;
180
181         void SetHeader(_Toolbar* pToolbar);
182         void SetFooter(_Toolbar* pToolbar);
183         void SetTab(_Tab* pTab);
184         void CreateSoftkey(unsigned long formStyle);
185         void SetTabStyle(int style);
186
187         result SetIndicatorShowState(bool state);
188         void SetIndicatorAutoHide(bool portrait, bool landscape);
189         result SetIndicatorOpacity(_IndicatorOpacity opacity);
190
191         virtual bool OnMousePressed(const _Control& source, const _MouseInfo& mouseinfo);
192         virtual bool OnMouseReleased(const _Control& source, const _MouseInfo& mouseinfo);
193
194         virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
195         virtual bool OnKeyReleased(const _Control& source, const _KeyInfo& keyInfo);
196
197         result AdjustClientBounds(void);
198
199         result AddActionEventListener(Tizen::Ui::Controls::_IActionEventListener& listener);
200         void AddOptionkeyActionListener(Tizen::Ui::Controls::_IActionEventListener& listener);
201         void AddSoftkeyActionListener(_Softkey softkey, Tizen::Ui::Controls::_IActionEventListener& listener);
202         result RemoveActionEventListener(Tizen::Ui::Controls::_IActionEventListener& listener);
203         void RemoveOptionkeyActionListener(Tizen::Ui::Controls::_IActionEventListener& listener);
204         void RemoveSoftkeyActionListener(_Softkey softkey, Tizen::Ui::Controls::_IActionEventListener& listener);
205
206         result AttachedToMainTree(void);
207         result DetachingFromMainTree(void);
208
209         result AddIndicatorObject(void);
210         result DeleteIndicatorObject(void);
211
212         void SetKeypadShowState(bool state);
213         void SetClipboardShowState(bool state);
214
215         Tizen::Graphics::FloatDimension TranslateSize(Tizen::Graphics::FloatDimension size) const;
216
217         result SetNotificationTrayOpenEnabled(bool enable);
218         bool IsNotificationTrayOpenEnabled(void) const;
219
220         void SetFormOrientationStatusEventListener(Tizen::Ui::Controls::_IFormOrientationStatusEventListener* pFormOrientationstatusEventListener);
221         Tizen::Ui::OrientationStatus GetFormOrientationStatus(void) const;
222
223 //callback
224         virtual void OnDraw(void);
225         virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
226         virtual void OnChildVisibleStateChanged(const _Control& child);
227         virtual void OnBoundsChanged(void);
228         virtual void UpdateClientBounds(const Tizen::Graphics::FloatDimension& size, Tizen::Graphics::FloatRectangle& clientBounds);
229         virtual void OnVisibleStateChanged(void);
230
231 // Focus UI
232         Tizen::Base::Collection::IListT<_Control*>* GetFocusList(void) const;
233         void ResetFocusList(void);
234         _Control* GetFocusTraversalControl(void) const;
235         void SetFocusTraversalControl(_Control* pControl);
236
237 // Focus
238         _Control* GetFocusControl(void) const;
239         void SetFocusControl(const _Control* pControl);
240
241 // Accessor
242 protected:
243         result SetPresenter(const _FormPresenter& formPresenter);
244
245 private:
246         _Form(const _Form& value);
247         _Form& operator =(const _Form& value);
248
249         void MoveOverlayRegion(bool top);
250         void UpdateSoftkey(unsigned long formStyle);
251
252         virtual Tizen::Base::String GetDescription(void) const;
253
254         // Attribute
255 private:
256         _FormPresenter* __pFormPresenter;
257         _IFormBackEventListener* __pFormBackEventListener;
258         _IFormMenuEventListener* __pFormMenuEventListener;
259
260         unsigned long __formStyle;
261         _ActionEvent* __pActionEvent;
262
263         _Toolbar* __pHeader;
264         _Toolbar* __pFooter;
265         _Tab* __pTab;
266         _Indicator* __pIndicator;
267
268         bool __transparentIndicator;
269         bool __transparentHeader;
270         bool __transparentFooter;
271         bool __transparentTab;
272
273         bool __indicatorShowState;
274
275         bool __deflated;
276         float __deflatedHeight;
277
278         int __overlayRegionCount;
279         _OverlayRegionImpl** __pOverlayerRegionImplArray;
280
281         int __softkeyCount;
282         int __updatedSoftkeyCount;
283         int __actionId[_SOFTKEY_COUNT + 1];
284         bool __enableSoftkey[_SOFTKEY_COUNT + 1];
285         bool __showSoftkey[_SOFTKEY_COUNT + 1];
286         bool __keypadShowstate;
287         bool __clipboardShowstate;
288         bool __alreadyStopKeySent;
289
290         Tizen::Base::String __softkeyText[_SOFTKEY_COUNT + 1];
291
292         Tizen::Graphics::Bitmap* __pSoftkeyNormalBitmap[_SOFTKEY_COUNT+1];
293         Tizen::Graphics::Bitmap* __pSoftkeyDisabledBitmap[_SOFTKEY_COUNT+1];
294         Tizen::Graphics::Bitmap* __pSoftkeyPressedBitmap[_SOFTKEY_COUNT+1];
295         Tizen::Graphics::Bitmap* __pSoftkeyHighlightedBitmap[_SOFTKEY_COUNT+1];
296
297         Tizen::Graphics::Bitmap* __pSoftkeyNormalEffectBitmap[_SOFTKEY_COUNT+1];
298         Tizen::Graphics::Bitmap* __pSoftkeyPressedEffectBitmap[_SOFTKEY_COUNT+1];
299
300         Tizen::Graphics::Bitmap* __pTextSoftkeyNormalBitmap[_SOFTKEY_COUNT+1];
301         Tizen::Graphics::Bitmap* __pTextSoftkeyDisabledBitmap[_SOFTKEY_COUNT+1];
302         Tizen::Graphics::Bitmap* __pTextSoftkeyPressedBitmap[_SOFTKEY_COUNT+1];
303         Tizen::Graphics::Bitmap* __pTextSoftkeyHighlightedBitmap[_SOFTKEY_COUNT+1];
304
305         Tizen::Graphics::Bitmap* __pTextSoftkeyNormalEffectBitmap[_SOFTKEY_COUNT+1];
306         Tizen::Graphics::Bitmap* __pTextSoftkeyPressedEffectBitmap[_SOFTKEY_COUNT+1];
307
308         Tizen::Graphics::Bitmap* __pSoftkeyNormalIcon[_SOFTKEY_COUNT+1];
309         Tizen::Graphics::Bitmap* __pSoftkeyDisabledIcon[_SOFTKEY_COUNT+1];
310         Tizen::Graphics::Bitmap* __pSoftkeyPressedIcon[_SOFTKEY_COUNT+1];
311         Tizen::Graphics::Bitmap* __pSoftkeyHighlightedIcon[_SOFTKEY_COUNT+1];
312
313         Tizen::Ui::Controls::_IFormOrientationStatusEventListener* __pFormOrientationstatusEventListener;
314
315         //Back button action ID
316         static const int ID_BACK_BUTTON = -10;
317         static const int ID_MENU_BUTTON = -20;
318
319         //For Focus UI
320         mutable std::unique_ptr<Tizen::Base::Collection::IListT<_Control*> > __pFocusControlList;
321         _Control* __pFocusControl;
322         _Control* __pFocusTraversalControl;
323         friend class _Frame;
324         friend class _OverlayRegionImpl;
325 }; // _Form
326
327 }}} // Tizen::Ui::Controls
328
329 #endif // _FUI_CTRL_INTERNAL_FORM_H_