Tizen 2.1 base
[framework/osp/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 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
8 //
9 //     http://floralicense.org/license/
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 <FUiCtrlControlsTypes.h>
27 #include <FUiCtrlOverlayRegion.h>
28 #include "FUi_Control.h"
29 #include "FUiCtrl_IActionEventListener.h"
30 #include "FUi_EcoreEvas.h"
31
32
33 namespace Tizen { namespace Ui { namespace Controls
34 {
35
36 class _FormPresenter;
37 class _Toolbar;
38 class _Tab;
39 class _Indicator;
40 class _ActionEvent;
41 class _OverlayRegionImpl;
42 class _IFormBackEventListener;
43
44 enum _FormStyle
45 {
46         _FORM_STYLE_NORMAL = 0x00000000,     /**< The basic form style */
47         _FORM_STYLE_TITLE = 0x00000001,      /**< @deprecated This enumeration field is deprecated because the use of the Title control is no longer recommended.*/
48         _FORM_STYLE_INDICATOR = 0x00000002,  /**< The form with the indicator area */
49         _FORM_STYLE_SOFTKEY_0 = 0x00000010,  /**< @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.*/
50         _FORM_STYLE_SOFTKEY_1 = 0x00000020,  /**< @deprecated This enumeration field is deprecated because the use of the Softkey control is no longer recommended.*/
51         _FORM_STYLE_OPTIONKEY = 0x00000040,  /**< @deprecated This enumeration field is deprecated because the use of the Optionkey control is no longer recommended.*/
52         _FORM_STYLE_TEXT_TAB = 0x00000100,   /**< @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended.*/
53         _FORM_STYLE_ICON_TAB = 0x00000200,   /**< @deprecated This enumeration field is deprecated because the use of the Tab control is no longer recommended.*/
54         _FORM_STYLE_HEADER = 0x00001000,     /**< The form with a header @b Since: @b 2.0 */
55         _FORM_STYLE_FOOTER = 0x00002000      /**< The form with a footer @b Since: @b 2.0 */
56 };
57
58 enum _Softkey
59 {
60         _SOFTKEY_0,      /**< The left softkey */
61         _SOFTKEY_1,      /**< The right softkey */
62         _SOFTKEY_COUNT   /**< This is internal. If used in an application, the application can get rejected during the certification process. Define the softkey count */
63 };
64
65 /**
66  * @class _Form
67  * @brief
68  * @since       1.0
69  */
70
71 class _OSP_EXPORT_ _Form
72         : public _Control
73         , public _IActionEventListener
74         , virtual public Tizen::Base::Runtime::IEventListener
75         , virtual public Tizen::Ui::_IUiEventListener
76         , virtual public Tizen::Ui::_IUiEventPreviewer
77 {
78 // Lifecycle
79 public:
80         _Form(void);
81         virtual ~_Form(void);
82
83 // Operations
84 public:
85         static _Form* CreateFormN(void);
86
87         void SetFormBackEventListener(_IFormBackEventListener* pFormBackEventListener);
88
89         unsigned long GetFormStyle(void) const;
90         _Toolbar* GetFooter(void) const;
91         _Toolbar* GetHeader(void) const;
92         _Tab* GetTab(void) const;
93         _Indicator* GetIndicator(void) const;
94         Tizen::Base::String GetTitleText(void) const;
95         HorizontalAlignment GetTitleTextHorizontalAlignment(void) const;
96         OverlayRegion* GetOverlayRegionN(const Tizen::Graphics::Rectangle& rect, OverlayRegionType regionType);
97         int     GetOverlayRegionCount(void) const;
98         Tizen::Graphics::Canvas* GetClientAreaCanvasN(void) const;
99         int GetSoftkeyActionId(_Softkey softkey) const;
100         int GetOptionkeyActionId(void) const;
101         Tizen::Base::String GetSoftkeyText(_Softkey softkey) const;
102
103         void SetFormStyle(unsigned long formStyle);
104         result SetActionBarsTranslucent(unsigned long actionBars, bool translucent);
105         result SetActionBarsVisible(unsigned long actionBars, bool visible);
106         result SetTitleIcon(const Tizen::Graphics::Bitmap* pTitleBitmap);
107         result SetTitleText(const Tizen::Base::String& title, HorizontalAlignment alignment);
108         result SetSoftkeyEnabled(_Softkey softkey, bool enable);
109         result SetOptionkeyActionId(int actionId);
110         result SetSoftkeyActionId(_Softkey softkey, int actionId);
111         result SetSoftkeyText(_Softkey softkey, const Tizen::Base::String& text);
112         result SetSoftkeyIcon(_Softkey softkey, const Tizen::Graphics::Bitmap& normalBitmap, const Tizen::Graphics::Bitmap* pPressedBitmap);
113
114         bool HasFooter(void) const;
115         bool HasHeader(void) const;
116         bool HasIndicator(void) const;
117         bool HasTitle(void) const;
118         bool HasTab(void) const;
119         bool IsIndicatorVisible(void) const;
120         bool IsHeaderVisible(void) const;
121         bool IsFooterVisible(void) const;
122         bool IsIndicatorTranslucent(void) const;
123         bool IsHeaderTranslucent(void) const;
124         bool IsFooterTranslucent(void) const;
125         bool IsTabTranslucent(void) const;
126         bool HasOptionkey(void) const;
127         bool HasSoftkey(_Softkey softkey) const;
128         bool IsSoftkeyEnabled(_Softkey softkey) const;
129         bool CheckSoftkey(_Softkey softkey) const;
130         virtual bool IsOrientationRoot(void) const;
131
132         Tizen::Graphics::Point TranslateToClientAreaPosition(const Tizen::Graphics::Point& position)    const;
133         Tizen::Graphics::Point TranslateFromClientAreaPosition(const Tizen::Graphics::Point& clientPosition)    const;
134
135         bool DeflateClientRectHeight(int height);
136
137         static _Toolbar* CreateHeaderN(void);
138         static _Toolbar* CreateFooterN(void);
139         static _Tab* CreateTabN(void);
140         static _Indicator* CreateIndicatorN(void);
141
142         int GetToolbarHeight(bool header) const;
143         int GetTabHeight(void) const;
144         bool RemoveHeader(void);
145         bool RemoveFooter(void);
146         bool RemoveTab(void);
147         bool RemoveIndicator(void);
148         result SetHeaderBounds(Tizen::Graphics::Rectangle& bounds);
149         result SetHeaderFloatBounds(Tizen::Graphics::FloatRectangle& bounds);
150         result SetFooterBounds(Tizen::Graphics::Rectangle& bounds);
151         result SetTabBounds(Tizen::Graphics::Rectangle& bounds);
152         Tizen::Graphics::Rectangle GetIndicatorBounds(void) const;
153         Tizen::Graphics::FloatRectangle GetIndicatorFloatBounds(void) const;
154
155         void SetHeader(_Toolbar* pToolbar);
156         void SetFooter(_Toolbar* pToolbar);
157         void SetTab(_Tab* pTab);
158         void CreateSoftkey(unsigned long formStyle);
159         void SetTabStyle(int style);
160
161         result SetIndicatorShowState(bool state);
162         result SetIndicatorOpacity(_IndicatorOpacity opacity);
163
164         result AdjustClientBounds(void);
165
166         result AddActionEventListener(Tizen::Ui::Controls::_IActionEventListener& listener);
167         void AddOptionkeyActionListener(Tizen::Ui::Controls::_IActionEventListener& listener);
168         void AddSoftkeyActionListener(_Softkey softkey, Tizen::Ui::Controls::_IActionEventListener& listener);
169         result RemoveActionEventListener(Tizen::Ui::Controls::_IActionEventListener& listener);
170         void RemoveOptionkeyActionListener(Tizen::Ui::Controls::_IActionEventListener& listener);
171         void RemoveSoftkeyActionListener(_Softkey softkey, Tizen::Ui::Controls::_IActionEventListener& listener);
172
173         result AttachedToMainTree(void);
174         result DetachingFromMainTree(void);
175
176         result AddIndicatorObject(void);
177         result DeleteIndicatorObject(void);
178
179 //callback
180         virtual void OnDraw(void);
181         virtual void OnActionPerformed(const Tizen::Ui::_Control& source, int actionId);
182         virtual void OnChildVisibleStateChanged(const _Control& child);
183         virtual void OnBoundsChanged(void);
184
185 // Accessor
186 protected:
187         result SetPresenter(const _FormPresenter& formPresenter);
188
189 private:
190         _Form(const _Form& value);
191         _Form& operator =(const _Form& value);
192
193         void MoveOverlayRegion(bool top);
194         void UpdateSoftkey(unsigned long formStyle);
195
196         virtual Tizen::Base::String GetDescription(void) const;
197
198         // Attribute
199 private:
200         _FormPresenter* __pFormPresenter;
201         _IFormBackEventListener* __pFormBackEventListener;
202
203         unsigned long __formStyle;
204         _ActionEvent* __pActionEvent;
205
206         _Toolbar* __pHeader;
207         _Toolbar* __pFooter;
208         _Tab* __pTab;
209         _Indicator* __pIndicator;
210
211         bool __transparentIndicator;
212         bool __transparentHeader;
213         bool __transparentFooter;
214         bool __transparentTab;
215
216         bool __indicatorShowState;
217
218         bool __deflated;
219         int __deflatedHeight;
220
221         int __overlayRegionCount;
222         _OverlayRegionImpl** __ppOverlayerRegionImplArray;
223
224         int __softkeyCount;
225         int __updatedSoftkeyCount;
226         int __actionId[_SOFTKEY_COUNT + 1];
227         bool __enableSoftkey[_SOFTKEY_COUNT + 1];
228         bool __showSoftkey[_SOFTKEY_COUNT + 1];
229
230         Tizen::Base::String __softkeyText[_SOFTKEY_COUNT + 1];
231
232         Tizen::Graphics::Bitmap* __pSoftkeyNormalBitmap[_SOFTKEY_COUNT+1];
233         Tizen::Graphics::Bitmap* __pSoftkeyNormalEffectBitmap[_SOFTKEY_COUNT+1];
234         Tizen::Graphics::Bitmap* __pSoftkeyPressedBitmap[_SOFTKEY_COUNT+1];
235         Tizen::Graphics::Bitmap* __pSoftkeyPressedEffectBitmap[_SOFTKEY_COUNT+1];
236
237         Tizen::Graphics::Bitmap* __pSoftkeyNormalIcon[_SOFTKEY_COUNT];
238         Tizen::Graphics::Bitmap* __pSoftkeyPressedIcon[_SOFTKEY_COUNT];
239
240         //Back button action ID
241         static const int ID_BACK_BUTTON = -10;
242
243         friend class _Frame;
244         friend class _OverlayRegionImpl;
245 }; // _Form
246
247 }}} // Tizen::Ui::Controls
248
249 #endif // _FUI_CTRL_INTERNAL_FORM_H_