modify license, permission and remove ^M char
[platform/framework/native/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 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        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          * Sets the margin of the specified item.
178          *
179          * @return              An error code
180          * @param[in]   item    The item for which the margin is set
181          * @param[in]   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.1
185          */
186         result SetMargin(const _ControlImpl& item, float left, float right, float top, float bottom);
187
188         /**
189          * Gets the margin of the specified item.
190          *
191          * @return              An error code
192          * @param[in]   item    The item to get the margin
193          * @param[out]  margin  The margin
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 GetMargin(const _ControlImpl& item, int& left, int& right, int& top, int& bottom) const;
199
200         /*
201          * Gets the margin of the specified item.
202          *
203          * @return              An error code
204          * @param[in]   item    The item to get the margin
205          * @param[out]  margin  The margin
206          * @exception   E_SUCCESS               The method was successful.
207          * @exception   E_INVALID_STATE This instance is in an invalid state.
208          * @since 2.1
209          */
210         result GetMargin(const _ControlImpl& item, float& left, float& right, float& top, float& bottom) const;
211
212         /**
213          * Sets the width of the specified item with the match policy.
214          *
215          * @return              An error code
216          * @param[in]   item            The item for which the width 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 SetHorizontalFitPolicy(const _ControlImpl& item, const FitPolicy policy);
223
224         /**
225          * Gets the width 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 width
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 GetHorizontalFitPolicy(const _ControlImpl& item, FitPolicy& policy) const;
235
236         /**
237          * Sets the height of the specified item with the match policy.
238          *
239          * @return              An error code
240          * @param[in]   item            The item for which the height is set
241          * @patam[in]   matchMode       The match policy
242          * @exception   E_SUCCESS               The method was successful.
243          * @exception   E_INVALID_STATE This instance is in an invalid state.
244          * @since 2.0
245          */
246         result SetVerticalFitPolicy(const _ControlImpl& item, const FitPolicy matchMode);
247
248         /**
249          * Gets the height of the specified item with the match policy.
250          *
251          * @return              An error code
252          * @param[in]   item            The item to get the match policy of the height
253          * @patam[out]  matchMode       The match policy
254          * @exception   E_SUCCESS               The method was successful.
255          * @exception   E_INVALID_STATE This instance is in an invalid state.
256          * @since 2.0
257          */
258         result GetVerticalFitPolicy(const _ControlImpl& item, FitPolicy& matchMode) const;
259
260         /**
261          * Adds the item at the end of the list maintained by the layout
262          *
263          * @return              An error code
264          * @param[in]   addItem
265          * @exception
266          * @since 2.0
267          */
268         result AddItem(_ControlImpl& addItem);
269
270         /**
271          *
272          *
273          * @return              An error code
274          * @param[in]   removeItem
275          * @exception
276          * @since 2.0
277          */
278         result RemoveItem(const _ControlImpl& removeItem);
279
280         /**
281          *
282          *
283          * @return              An error code
284          * @param[in]   viewPosX        The x coordinate
285          * @param[in]   viewPosY        The y coordinate
286          * @exception   E_SUCCESS               The method was successful.
287          * @exception   E_INVALID_STATE The layout have a item instance that is in an invalid state.
288          * @since 2.0
289          */
290         result OnChangeViewPos(int viewPosX, int viewPosY);
291
292         /**
293          * Sets the base location and dimension of the specified item.
294          *
295          * @return              An error code
296          * @param[in]   item            The item for which the base location and dimension are set
297          * @patam[in]   baseRect        The rectangle value with the location and dimension
298          * @exception   E_SUCCESS               The method was successful.
299          * @exception   E_INVALID_STATE This instance is in an invalid state.
300          * @since 2.0
301          */
302         result SetItemBaseRect(const _ControlImpl& item, const _Layout::LayoutRect baseRect);
303
304         /**
305          * Gets the base location and dimension of the specified item.
306          *
307          * @return              An error code
308          * @param[in]   item            The item to get the base location and dimension
309          * @patam[out]  baseRect        The rectangle value with the location and dimension
310          * @exception   E_SUCCESS               The method was successful.
311          * @exception   E_INVALID_STATE This instance is in an invalid state.
312          * @since 2.0
313          */
314         result GetItemBaseRect(const _ControlImpl& item, _Layout::LayoutRect& baseRect) const;
315
316 private:
317         _LayoutImpl& operator =(const _LayoutImpl&);
318         static void AllocateLayoutImpl(Layout* pPublicLayout, _SharedPtr <Tizen::Ui::_LayoutImpl> layoutImpl);
319
320 protected:
321         Layout* _pPublicLayout;
322         _Layout::Layout* _pCoreLayout;
323
324 }; // _LayoutImpl
325
326 struct LayoutImplHolder
327 {
328         _SharedPtr <Tizen::Ui::_LayoutImpl> layoutImpl;
329 };
330
331 }} // Tizen::Ui
332
333 #endif // _FUI_LAYOUT_IMPL_H_