2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
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
9 // http://floralicense.org/license/
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.
18 * @file FUi_LayoutLinearLayout.h
19 * @brief This is the header file for LinearLayout class.
21 * This header file contains the declaration of LinearLayout class.
26 #ifndef _FUI_INTERNAL_LAYOUT_LINEAR_LAYOUT_H_
27 #define _FUI_INTERNAL_LAYOUT_LINEAR_LAYOUT_H_
29 #include "FUi_LayoutLayout.h"
31 namespace Tizen { namespace Ui { namespace _Layout
41 class _OSP_EXPORT_ LinearLayout
46 * This is the default constructor for this class.
53 * This is the destructor for this class.
57 virtual ~LinearLayout(void);
60 * Creates the instance of LinearLayout.
63 * @return The instance of LinearLayout.
64 * @exception E_SUCCESS The method was successful.
65 * @exception E_OUT_OF_MEMORY Insufficient memory.
67 static LinearLayout* CreateLinearLayoutN(void);
70 * Checks whether the arguments are valid, and sets the arguments.
73 * @return An error code
74 * @param[in] orientation The orientation of the linear layout.
75 * @param[in] direction The direction in which the children are attached.
76 * @exception E_SUCCESS The method was successful.
77 * @exception E_INVALID_ARG The specified input parameter is invalid.
79 result Initialize(const LinearLayoutOrientation orientation, const LinearLayoutDirection direction);
82 * Adds the item to the list according to the index.
85 * @return An error code
86 * @param[in] addItem The added item.
87 * @param[in] index The index of list.
88 * @exception E_SUCCESS The method was successful.
89 * @exception E_INVALID_ARG The specified input parameter is invalid.
90 * @exception E_INVALID_STATE This instance is in an invalid state.
92 result AddItemToIndex(LayoutItem& addItem, int index);
95 * Moves the item according to the index.
98 * @return An error code
99 * @param[in] item The item of list.
100 * @param[in] index The index of list.
101 * @exception E_SUCCESS The method was successful.
102 * @exception E_INVALID_ARG The specified input parameter is invalid.
103 * @exception E_INVALID_STATE This instance is in an invalid state.
105 result MoveItem(LayoutItem& item, int index);
108 * Swaps the targetItem and the destItem.
111 * @return An error code
112 * @param[in] targetItem The target item.
113 * @param[in] destItem The destination item.
114 * @exception E_SUCCESS The method was successful.
115 * @exception E_INVALID_ARG The specified input parameter is invalid.
117 result SwapItem(LayoutItem& targetItem, LayoutItem& destItem);
120 * Gets the item count of layout.
123 * @return The item count of layout.
124 * @exception E_INVALID_STATE This instance is in an invalid state.
126 int GetItemCount(void) const;
129 * Gets the index of the specified item.
132 * @return An error code
133 * @param[in] item The layout item.
134 * @param[out] index The index of item.
135 * @exception E_SUCCESS The method was successful.
136 * @exception E_INVALID_ARG The specified input parameter is invalid.
138 result GetItemIndex(LayoutItem& item, int& index) const;
141 * Sets the orientation.
144 * @return An error code
145 * @param[in] orientation The orientation of linear layout.
146 * @exception E_SUCCESS The method was successful.
147 * @exception E_INVALID_ARG The specified input parameter is invalid.
149 result SetOrientation(const LinearLayoutOrientation orientation);
152 * Gets the orientation.
155 * @return An error code
156 * @param[out] orientation The orientation of linear layout.
157 * @exception E_SUCCESS The method was successful.
158 * @exception E_INVALID_STATE This instance is in an invalid state.
160 result GetOrientation(LinearLayoutOrientation& orientation) const;
163 * Sets the direction.
166 * @return An error code
167 * @param[in] direction The direction in which the children are attached.
168 * @exception E_SUCCESS The method was successful.
169 * @exception E_INVALID_ARG The specified input parameter is invalid.
171 result SetDirection(const LinearLayoutDirection direction);
174 * Gets the direction.
177 * @return An error code
178 * @param[out] direction The direction in which the children are attached.
179 * @exception E_SUCCESS The method was successful.
180 * @exception E_INVALID_STATE This instance is in an invalid state.
182 result GetDirection(LinearLayoutDirection& direction) const;
185 * Sets the weight for specified item.
188 * @return An error code
189 * @param[in] item The target item.
190 * @param[in] weight The weight that indicates how much extra space the control occupies in proportion to it.
191 * @exception E_SUCCESS The method was successful.
192 * @exception E_INVALID_ARG The specified input parameter is invalid.
193 * @exception E_INVALID_STATE This instance is in an invalid state.
195 result SetItemWeight(LayoutItem& item, const float weight);
198 * Gets the weight for specified item.
201 * @return An error code
202 * @param[out] item The target item.
203 * @param[out] weight The weight of target item.
204 * @exception E_SUCCESS The method was successful.
205 * @exception E_INVALID_ARG The specified input parameter is invalid.
206 * @exception E_INVALID_STATE This instance is in an invalid state.
208 result GetItemWeight(const LayoutItem& item, float& weight) const;
211 * Sets the spacing for specified item.
214 * @return An error code
215 * @param[in] item The target item.
216 * @param[in] spacing The space.
217 * @exception E_SUCCESS The method was successful.
218 * @exception E_INVALID_ARG The specified input parameter is invalid.
219 * @exception E_INVALID_STATE This instance is in an invalid state.
221 result SetItemSpacing(LayoutItem& item, int spacing);
224 * Gets the spacing for specified item.
227 * @return An error code
228 * @param[in] item The target item.
229 * @param[out] spacing The space of target item.
230 * @exception E_SUCCESS The method was successful.
231 * @exception E_INVALID_ARG The specified input parameter is invalid.
232 * @exception E_INVALID_STATE This instance is in an invalid state.
234 result GetItemSpacing(const LayoutItem& item, int& spacing) const;
238 * Calculates the position and bounds of all chindren, and applies to the control.
240 * @return An error code
243 * @param[in] layoutUpdating
244 * @exception E_SUCCESS The method was successful.
245 * @exception E_INVALID_STATE This instance is in an invalid state.
248 virtual result OnLayout(int width, int height, bool layoutUpdating);
252 * This is the copy constructor for this class.
256 LinearLayout(const LinearLayout&);
259 * This is the substitution operator for this class.
263 LinearLayout& operator =(const LinearLayout&);
266 * Calculates the size & position of all children. @n
267 * Wrapper method of CalcHorizontalPosSize and CalcVerticalPosSize. @n
271 * @return An error code
272 * @param[out] rightBound
273 * @param[out] bottomBounds
274 * @exception E_SUCCESS The method was successful.
275 * @exception E_INVALID_STATE This instance is in an invalid state.
277 result CalculatePositionSize(int& rightBound, int& bottomBound);
280 * If orientation is horizontal, Calculates the size & position of all children. @n
281 * Used by CalcPosSize.
284 * @return An error code
285 * @param[out] rightBound
286 * @param[out] bottomBound
287 * @exception E_SUCCESS The method was successful.
288 * @exception E_INVALID_STATE This instance is in an invalid state.
290 result CalculateHorizontalPositionSize(int& rightBound, int& bottomBound);
293 * If orientation is vertical, Calculates the size & position of all children. @n
294 * Used by CalcPosSize.
297 * @return An error code
298 * @param[out] rightBound
299 * @param[out] bottomBound
300 * @exception E_SUCCESS The method was successful.
301 * @exception E_INVALID_STATE This instance is in an invalid state.
303 result CalculateVerticalPositonSize(int& rightBound, int& bottomBound);
306 * Calculates the bound in empty space according to weight. @n
310 * @return An error code
311 * @param[out] rightBound
312 * @param[out] bottomBound
313 * @exception E_SUCCESS The method was successful.
314 * @exception E_INVALID_STATE This instance is in an invalid state.
316 result CalculateWeight(int& rightBound, int& bottomBound);
319 * If orientation is horizontal, Calculates the bound in empty space according to weight. @n
320 * Used by CalcWeight.
322 * @return An error code
323 * @param[out] emptySpace
324 * @exception E_SUCCESS The method was successful.
325 * @exception E_INVALID_STATE This instance is in an invalid state.
327 result CalculateHorizontalWeight(int& emptySpace);
330 * If orientation is vertical, Calculates the bound in empty space according to weight. @n
331 * Used by CalcWeight.
333 * @return An error code
334 * @param[in] emptySpace
335 * @exception E_SUCCESS The method was successful.
336 * @exception E_INVALID_STATE This instance is in an invalid state.
338 result CalculateVerticalWeight(int& emptySpace);
341 * Checks whether container is wrap content mode, and calculate size. @n
344 * @return An error code
345 * @param[in] rightBound
346 * @param[in] bottomBound
347 * @param[in] layoutUpdating
348 * @exception E_SUCCESS The method was successful.
349 * @exception E_INVALID_STATE This instance is in an invalid state.
351 result CalculateWrapContent(LayoutItemProxy& containerProxy, int rightBound, int bottomBound, bool layoutUpdating);
354 * Checks whether container is match parent mode, and calculate size. @n
357 * @return An error code
358 * @exception E_SUCCESS The method was successful.
359 * @exception E_INVALID_STATE This instance is in an invalid state.
361 result CalculateMatchParent(void);
364 * Corrects the bounds according to orientation. @n
367 * @return An error code
368 * @exception E_SUCCESS The method was successful.
369 * @exception E_INVALID_STATE This instance is in an invalid state.
371 result CalculateCorrectedAlignment(void);
374 LinearLayoutOrientation __orientation;
375 LinearLayoutDirection __direction;
379 }}} // Tizen::Ui::_Layout
381 #endif //_FUI_INTERNAL_LAYOUT_LINEAR_LAYOUT_H_