Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / FUi_LayoutImpl.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        FUi_LayoutImpl.h
19  * @brief       This is the header file for _LayoutImpl class.
20  *
21  * This header file contains the declaration of _LayoutImpl class.
22  */
23
24 #ifndef _FUI_LAYOUT_IMPL_H_
25 #define _FUI_LAYOUT_IMPL_H_
26
27 #include <FUiLayoutTypes.h>
28 #include <FBaseSysLog.h>
29 #include "FUi_ControlImpl.h"
30 #include "FUi_LayoutLayout.h"
31 #include "FUi_SharedPtr.h"
32
33 namespace Tizen { namespace Ui
34 {
35
36 class Layout;
37
38 class _LayoutImpl
39         : public Tizen::Base::Object
40 {
41 public:
42         /**
43          * This is the default constructor for this class.
44          *
45          * @since               2.0
46          */
47         _LayoutImpl(const _LayoutImpl&);
48
49         /**
50          * This is the destructor for this class.
51          *
52          * @since               2.0
53          */
54         virtual ~_LayoutImpl(void);
55
56         /**
57          * Gets the name of public class.
58          *
59          * @since 2.0
60          * @return              The name of public class.
61          */
62         virtual const char* GetPublicClassName(void) const;
63
64         /**
65          * Gets the public class.
66          *
67          * @since 2.0
68          * @return              The public class.
69          */
70         virtual const Layout& GetPublic(void) const;
71
72         /**
73          * Gets the public class.
74          *
75          * @since 2.0
76          * @return              The public class.
77          */
78         virtual Layout& GetPublic(void);
79
80         /**
81          * Gets the core class.
82          *
83          * @since 2.0
84          * @return              The core class.
85          */
86         virtual const _Layout::Layout& GetCore(void) const;
87
88         /**
89          * Gets the core class.
90          *
91          * @since 2.0
92          * @return              The core class.
93          */
94         virtual _Layout::Layout& GetCore(void);
95
96         /**
97          * Gets the _LayoutImpl instance for the Layout.
98          *
99          * @since 2.0
100          * @return              The _LayoutImpl instance.
101          * @param[in]   pLayout         The Layout instance.
102          */
103         static const _LayoutImpl* GetInstance(const Layout& layout);
104
105         /**
106          * Gets the _LayoutImpl instance for the Layout.
107          *
108          * @since 2.0
109          * @return              The _LayoutImpl instance.
110          * @param[in]   pLayout         The Layout instance.
111          */
112         static _LayoutImpl* GetInstance(Layout& layout);
113
114         /**
115          * Gets the type of the layout.
116          *
117          * @since       2.0
118          * @return      The layout type
119          */
120         virtual LayoutType GetLayoutType(void) const = 0;
121
122         /**
123          *
124          *
125          * @return              An error code
126          * @exception
127          * @since 2.0
128          */
129         result UpdateLayout(void);
130
131         static _SharedPtr <_LayoutImpl> GetLayoutImpl(Layout* pLayout);
132         static Layout* CreatePublicLayoutN(_SharedPtr <_LayoutImpl> layoutImpl);
133         static void SetLayoutImpl(Layout* pPublicLayout, _LayoutImpl* pImplLayout);
134
135 protected:
136         _LayoutImpl(Layout* pPublicLayout, _Layout::Layout* _pCoreLayout);
137         static result CheckConstruction(_Layout::Layout* pCoreLayout, _LayoutImpl* pImplLayout);
138
139         /**
140          * Sets the alignment of the specified item.
141          *
142          * @return              An error code
143          * @param[in]   item    The item for which the alignment is set
144          * @param[in]   align   The alignment
145          * @exception   E_SUCCESS               The method was successful.
146          * @exception   E_INVALID_STATE This instance is in an invalid state.
147          * @exception   E_INVALID_ARG   The alignment parameter is invalid.
148          * @since 2.0
149          */
150         result SetAlignment(const _ControlImpl& item, const LayoutHorizontalAlignment horizontalAlign, const LayoutVerticalAlignment verticalAlign);
151
152         /**
153          * Gets the alignment of the specified item.
154          *
155          * @return              An error code
156          * @param[in]   item    The item to get the alignment
157          * @param[out]  align   The alignment
158          * @exception   E_SUCCESS               The method was successful.
159          * @exception   E_INVALID_STATE This instance is in an invalid state.
160          * @since 2.0
161          */
162         result GetAlignment(const _ControlImpl& item, LayoutHorizontalAlignment& horizontalAlign, LayoutVerticalAlignment& verticalAlign) const;
163
164         /**
165          * Sets the margin of the specified item.
166          *
167          * @return              An error code
168          * @param[in]   item    The item for which the margin is set
169          * @param[in]   margin  The margin
170          * @exception   E_SUCCESS               The method was successful.
171          * @exception   E_INVALID_STATE This instance is in an invalid state.
172          * @since 2.0
173          */
174         result SetMargin(const _ControlImpl& item, int left, int right, int top, int bottom);
175
176         /**
177          * Gets the margin of the specified item.
178          *
179          * @return              An error code
180          * @param[in]   item    The item to get the margin
181          * @param[out]  margin  The margin
182          * @exception   E_SUCCESS               The method was successful.
183          * @exception   E_INVALID_STATE This instance is in an invalid state.
184          * @since 2.0
185          */
186         result GetMargin(const _ControlImpl& item, int& left, int& right, int& top, int& bottom) const;
187
188         /**
189          * Sets the width of the specified item with the match policy.
190          *
191          * @return              An error code
192          * @param[in]   item            The item for which the width is set
193          * @patam[in]   matchMode       The match policy
194          * @exception   E_SUCCESS               The method was successful.
195          * @exception   E_INVALID_STATE This instance is in an invalid state.
196          * @since 2.0
197          */
198         result SetHorizontalFitPolicy(const _ControlImpl& item, const FitPolicy policy);
199
200         /**
201          * Gets the width of the specified item with the match policy.
202          *
203          * @return              An error code
204          * @param[in]   item            The item to get the match policy of the width
205          * @patam[out]  matchMode       The match policy
206          * @exception   E_SUCCESS               The method was successful.
207          * @exception   E_INVALID_STATE This instance is in an invalid state.
208          * @since 2.0
209          */
210         result GetHorizontalFitPolicy(const _ControlImpl& item, FitPolicy& policy) const;
211
212         /**
213          * Sets the height of the specified item with the match policy.
214          *
215          * @return              An error code
216          * @param[in]   item            The item for which the height is set
217          * @patam[in]   matchMode       The match policy
218          * @exception   E_SUCCESS               The method was successful.
219          * @exception   E_INVALID_STATE This instance is in an invalid state.
220          * @since 2.0
221          */
222         result SetVerticalFitPolicy(const _ControlImpl& item, const FitPolicy matchMode);
223
224         /**
225          * Gets the height of the specified item with the match policy.
226          *
227          * @return              An error code
228          * @param[in]   item            The item to get the match policy of the height
229          * @patam[out]  matchMode       The match policy
230          * @exception   E_SUCCESS               The method was successful.
231          * @exception   E_INVALID_STATE This instance is in an invalid state.
232          * @since 2.0
233          */
234         result GetVerticalFitPolicy(const _ControlImpl& item, FitPolicy& matchMode) const;
235
236         /**
237          * Adds the item at the end of the list maintained by the layout
238          *
239          * @return              An error code
240          * @param[in]   addItem
241          * @exception
242          * @since 2.0
243          */
244         result AddItem(_ControlImpl& addItem);
245
246         /**
247          *
248          *
249          * @return              An error code
250          * @param[in]   removeItem
251          * @exception
252          * @since 2.0
253          */
254         result RemoveItem(const _ControlImpl& removeItem);
255
256         /**
257          *
258          *
259          * @return              An error code
260          * @param[in]   viewPosX        The x coordinate
261          * @param[in]   viewPosY        The y coordinate
262          * @exception   E_SUCCESS               The method was successful.
263          * @exception   E_INVALID_STATE The layout have a item instance that is in an invalid state.
264          * @since 2.0
265          */
266         result OnChangeViewPos(int viewPosX, int viewPosY);
267
268         /**
269          * Sets the base location and dimension of the specified item.
270          *
271          * @return              An error code
272          * @param[in]   item            The item for which the base location and dimension are set
273          * @patam[in]   baseRect        The rectangle value with the location and dimension
274          * @exception   E_SUCCESS               The method was successful.
275          * @exception   E_INVALID_STATE This instance is in an invalid state.
276          * @since 2.0
277          */
278         result SetItemBaseRect(const _ControlImpl& item, const _Layout::LayoutRect baseRect);
279
280         /**
281          * Gets the base location and dimension of the specified item.
282          *
283          * @return              An error code
284          * @param[in]   item            The item to get the base location and dimension
285          * @patam[out]  baseRect        The rectangle value with the location and dimension
286          * @exception   E_SUCCESS               The method was successful.
287          * @exception   E_INVALID_STATE This instance is in an invalid state.
288          * @since 2.0
289          */
290         result GetItemBaseRect(const _ControlImpl& item, _Layout::LayoutRect& baseRect) const;
291
292 private:
293         _LayoutImpl& operator =(const _LayoutImpl&);
294         static void AllocateLayoutImpl(Layout* pPublicLayout, _SharedPtr <Tizen::Ui::_LayoutImpl> layoutImpl);
295
296 protected:
297         Layout* _pPublicLayout;
298         _Layout::Layout* _pCoreLayout;
299
300 }; // _LayoutImpl
301
302 struct LayoutImplHolder
303 {
304         _SharedPtr <Tizen::Ui::_LayoutImpl> layoutImpl;
305 };
306
307 }} // Tizen::Ui
308
309 #endif // _FUI_LAYOUT_IMPL_H_