Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_LayoutRelativeLayout.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_LayoutRelativeLayout.h
19  * @brief       This is the header file for RelativeLayout class.
20  *
21  * This header file contains the declaration of RelativeLayout class.
22  */
23
24 #pragma once
25
26 #ifndef _FUI_INTERNAL_LAYOUT_RELATIVE_LAYOUT_H_
27 #define _FUI_INTERNAL_LAYOUT_RELATIVE_LAYOUT_H_
28
29 #include "FUi_LayoutLayout.h"
30
31 namespace Tizen { namespace Ui { namespace _Layout
32 {
33 class RelativeProxyList;
34
35 class _OSP_EXPORT_ RelativeLayout
36         : public Layout
37 {
38 public:
39         /**
40          * This is the default constructor for this class.
41          *
42          * @since 2.0
43          */
44         RelativeLayout(void);
45
46         /**
47          * This is the destructor for this class.
48          *
49          * @since 2.0
50          */
51         virtual ~RelativeLayout(void);
52
53         /**
54          * Creates the instance of RelativeLayout.
55          *
56          * @since 2.0
57          * @return              The instance of RelativeLayout.
58          * @exception   E_SUCCESS               The method was successful.
59          * @exception   E_OUT_OF_MEMORY Insufficient memory.
60          */
61         static RelativeLayout* CreateRelativeLayoutN(void);
62
63         /**
64          * Sets the relation of the specified layout item for the edge with other layout item.
65          *
66          * @since 2.0
67          * @return              An error code
68          * @param[in]   pItem           The layout item for which the relation is set
69          * @param[in]   itemEdge        The edge of pItem.
70          * @param[in]   pTarget         The target layout item.
71          * @param[in]   targetEdge      The edge of targetEdge.
72          * @exception   E_SUCCESS               The method was successful.
73          * @exception   E_INVALID_STATE This instance is in an invalid state.
74          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
75          * @exception   E_SYSTEM                A system error occurred.
76          */
77         result SetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge, LayoutItem* pTarget = null, const RelativeLayoutEdge targetEdge = EDGE_NONE);
78
79         /**
80          * Unsets the relation of the specified layout item for the edge.
81          *
82          * @since 2.0
83          * @return              An error code
84          * @param[in]   pItem           The layout item for which the relation is unset
85          * @param[in]   itemEdge        The edge of pItem.
86          * @exception   E_SUCCESS               The method was successful.
87          * @exception   E_INVALID_STATE This instance is in an invalid state.
88          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
89          * @exception   E_SYSTEM                A system error occurred.
90          */
91         result UnsetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge);
92
93         /**
94          * Gets the layout itme of the specified layout item for the edge.
95          *
96          * @since 2.0
97          * @return              The layout item of specified edge.
98          * @param[in]   pItem           The layout item for which the relation is set
99          * @param[in]   itemEdge        The edge of pItem.
100          * @param[out]  targetEdge      The edge of target layout item.
101          */
102         LayoutItem* GetRelation(LayoutItem& item, const RelativeLayoutEdge itemEdge, RelativeLayoutEdge* pTargetEdge = null);
103
104 protected:
105         /**
106          * Calculates the position and bounds of all chindren, and applies to the control.
107          *
108          * @return              An error code
109          * @param[in]   width
110          * @param[in]   height
111          * @param[in]   layoutUpdating
112          * @exception   E_SUCCESS               The method was successful.
113          * @exception   E_INVALID_STATE This instance is in an invalid state.
114          * @since 2.0
115          */
116         virtual result OnLayout(int width, int height, bool updateLayouting);
117
118 private:
119         /**
120          * This is the copy constructor for this class.
121          *
122          * @since 2.0
123          */
124         RelativeLayout(const RelativeLayout&);
125
126         /**
127          * This is the substitution operator for this class.
128          *
129          * @since 2.0
130          */
131         RelativeLayout& operator =(const RelativeLayout&);
132
133         /**
134          * Increases the reference count.
135          *
136          * @return              An error code
137          * @param[in]   pNode
138          * @exception   E_SUCCESS               The method was successful.
139          * @exception   E_INVALID_STATE This instance is in an invalid state.
140          * @since 2.0
141          */
142         result IncreaseReferenceCount(ProxyListNode& node);
143
144         /**
145          * Decreases the reference count.
146          *
147          * @return              void
148          * @param[in]   pNode
149          * @param[in]   pTargetNode
150          * @since 2.0
151          */
152         void DecreaseReferenceCount(ProxyListNode& node, ProxyListNode& targetNode);
153
154         /**
155          * Reorders the node list
156          *
157          * @return              An error code
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 AlignItemNodeMaxRefMove(void);
163
164         /**
165          * Unsets the all relation of the specified node.
166          *
167          * @return              An error code
168          * @param[in]   pTargetNode
169          * @param[in]   pDeleteNode
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 DeleteTargetInfo(ProxyListNode& targetNode, ProxyListNode& deleteNode);
175
176         /**
177          * Calculates the position of the specified node.
178          *
179          * @return              An error code
180          * @param[in]   pCurNode
181          * @exception   E_SUCCESS               The method was successful.
182          * @exception   E_INVALID_STATE This instance is in an invalid state.
183          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
184          * @exception   E_SYSTEM                A system error occurred.
185          * @since 2.0
186          */
187         result CalculatePosition(ProxyListNode& curNode);
188
189         /**
190          * Calculates the center position of the specified node.
191          *
192          * @return              An error code
193          * @param[in]   pCurNode
194          * @param[out]  calcPosition
195          * @exception   E_SUCCESS               The method was successful.
196          * @exception   E_INVALID_STATE This instance is in an invalid state.
197          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
198          * @exception   E_SYSTEM                A system error occurred.
199          * @since 2.0
200          */
201         result CalculateCenter(ProxyListNode& curNode, bool calcPosition);
202
203         /**
204          * Checks whether the sourceEdge and targetEdge is right.
205          *
206          * @return              @c true, if the sourceEdge and targetEdge is right @n
207                                         @c false, otherwise
208          * @param[in]   sourceEdge
209          * @param[in]   targetEdge
210          * @since 2.0
211          */
212         bool CheckTargetEdge(const RelativeLayoutEdge sourceEdge, const RelativeLayoutEdge targetEdge) const;
213
214         /**
215          * Gets the position of specified item.
216          *
217          * @return              An error code
218          * @param[in]   pTargetProxy
219          * @param[in]   targetEdge
220          * @param[out]  targetPoint
221          * @exception   E_SUCCESS               The method was successful.
222          * @exception   E_INVALID_STATE This instance is in an invalid state.
223          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
224          * @exception   E_SYSTEM                A system error occurred.
225          * @since 2.0
226          */
227         result GetTargetPosition(LayoutItemProxy* pTargetProxy, const RelativeLayoutEdge targetEdge, LayoutPoint& targetPoint) const;
228
229         /**
230          * Sets the relation of the specified node for the edge with pTargetNode.
231          *
232          * @return              An error code
233          * @param[in]   pSourceNode
234          * @param[in]   sourceEdge
235          * @param[in]   pTargetNode
236          * @param[in]   targetEdge
237          * @exception   E_SUCCESS               The method was successful.
238          * @exception   E_INVALID_STATE This instance is in an invalid state.
239          * @exception   E_INVALID_ARG   The specified input parameter is invalid.
240          * @since 2.0
241          */
242         result SetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, ProxyListNode* pTargetNode, const RelativeLayoutEdge targetEdge);
243
244         /**
245          * Unsets the relation of the specified node for the edge.
246          *
247          * @return              An error code
248          * @param[in]   pSourceNode
249          * @param[in]   sourceEdge
250          * @param[out]  ppTargetProxy
251          * @exception   E_SUCCESS               The method was successful.
252          * @exception   E_INVALID_STATE This instance is in an invalid state.
253          * @exception   E_SYSTEM                A system error occurred.
254          * @since 2.0
255          */
256         result UnsetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, LayoutItemProxy** ppTargetProxy);
257
258         /**
259          * Gets the layout itme proxy of the specified node for the edge.
260          *
261          * @return              LayoutItemProxy of pSourceNode for sourceEdge
262          * @param[in]   pSourceNode
263          * @param[in]   sourceEdge
264          * @param[out]  targetEdge
265          * @exception   E_OUT_OF_RANGE  An edge value is invalid.
266          * @since 2.0
267          */
268         LayoutItemProxy* GetAlignment(ProxyListNode& sourceNode, const RelativeLayoutEdge sourceEdge, RelativeLayoutEdge* targetEdge = null);
269
270         /**
271          * The internal methode of IncreaseRefCount.
272          *
273          * @return              An error code
274          * @param[in]   pTargetNode
275          * @param[in]   pBaseNode
276          * @exception   E_SUCCESS               The method was successful.
277          * @exception   E_INVALID_STATE This instance is in an invalid state.
278          * @exception   E_SYSTEM                A system error occurred.
279          * @since 2.0
280          */
281         result IncreaseReference(ProxyListNode& targetNode, ProxyListNode& pBaseNode);
282
283         /**
284          * Gets the node of specified node for edge.
285          *
286          * @return              ProxyListNode of pNode for the edge
287          * @param[in]   pNode
288          * @param[in]   edge
289          * @exception   E_SUCCESS               The method was successful.
290          * @exception   E_INVALID_STATE This instance is in an invalid state.
291          * @exception   E_SYSTEM                A system error occurred.
292          * @since 2.0
293          */
294         ProxyListNode* GetTargetNode(ProxyListNode& node, const RelativeLayoutEdge edge);
295
296         /**
297          * Sets the reference count to zero.
298          *
299          * @return              An error code
300          * @param[in]   pNode
301          * @param[in]   pBaseNode
302          * @exception   E_SUCCESS               The method was successful.
303          * @exception   E_INVALID_STATE This instance is in an invalid state.
304          * @since 2.0
305          */
306         result SetZeroReference(ProxyListNode& node, ProxyListNode& pBaseNode);
307
308         RelativeProxyList* GetRelativeProxyList(void);
309
310 // property
311 private:
312         const LayoutItemProxy* __pTargetParent;
313
314         friend class RelativeProxyList;
315 }; // RelativeLayout
316
317 }}} //Tizen::Ui::_Layout
318
319 #endif // _FUI_INTERNAL_LAYOUT_RELATIVE_LAYOUT_H_