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_LayoutLayout.h
19 * @brief This is the header file for Layout class.
21 * This header file contains the declaration of Layout class.
26 #ifndef _FUI_INTERNAL_LAYOUT_LAYOUT_H_
27 #define _FUI_INTERNAL_LAYOUT_LAYOUT_H_
29 #include <FOspConfig.h>
30 #include "FUi_LayoutLayoutContainer.h"
32 namespace Tizen { namespace Ui { namespace _Layout
37 class LayoutItemProxy;
41 UPDATEFLAG_ERROR = 0x10000000,
42 UPDATEFLAG_NO_FLAG = 0x00000000,
43 UPDATEFLAG_NONE_MODE = 0x00000001,
44 UPDATEFLAG_MATCH_PARENT = 0x00000002,
45 UPDATEFLAG_WRAPCONTENT = 0x00000004,
46 UPDATEFLAG_ALIGNMENT = 0x00000008
51 * @brief This class is the base class of all the Layout classes.
54 * The Layout is the base class of all the Layout classes.
55 * The Layout class support common functions.
57 class _OSP_EXPORT_ Layout
58 : public Tizen::Base::Object
62 * This is the destructor for this class.
66 virtual ~Layout(void);
69 * Gets the proxy of the current container.
71 * @return The current container proxy
74 LayoutItemProxy* GetContainerProxy(void);
77 * Sets the specified location and dimension of the layout
79 * @param[in] layoutRect The rectangle value with the specified location and dimension
82 void SetLayoutRect(const LayoutRect layoutRect);
85 * Gets the location and dimension of the layout.
87 * @return The rectangle value with the location and dimension of the layout
90 LayoutRect GetLayoutRect(void) const;
93 * Sets the alignment of the specified item.
95 * @return An error code
96 * @param[in] item The item for which the alignment is set
97 * @param[in] align The alignment
98 * @exception E_SUCCESS The method was successful.
99 * @exception E_INVALID_STATE This instance is in an invalid state.
100 * @exception E_INVALID_ARG The alignment parameter is invalid.
103 result SetItemAlignment(const LayoutItem& item, const ItemAlign align);
106 * Gets the alignment of the specified item.
108 * @return An error code
109 * @param[in] item The item to get the alignment
110 * @param[out] align The alignment
111 * @exception E_SUCCESS The method was successful.
112 * @exception E_INVALID_STATE This instance is in an invalid state.
115 result GetItemAlignment(const LayoutItem& Item, ItemAlign& align) const;
118 * Sets the margin of the specified item.
120 * @return An error code
121 * @param[in] item The item for which the margin is set
122 * @param[in] margin The margin
123 * @exception E_SUCCESS The method was successful.
124 * @exception E_INVALID_STATE This instance is in an invalid state.
127 result SetItemMargin(const LayoutItem& item, const ItemMargin margin);
130 * Gets the margin of the specified item.
132 * @return An error code
133 * @param[in] item The item to get the margin
134 * @param[out] margin The margin
135 * @exception E_SUCCESS The method was successful.
136 * @exception E_INVALID_STATE This instance is in an invalid state.
139 result GetItemMargin(const LayoutItem& item, ItemMargin& margin) const;
142 * Sets the width of the specified item with the match policy.
144 * @return An error code
145 * @param[in] item The item for which the width is set
146 * @patam[in] matchMode The match policy
147 * @exception E_SUCCESS The method was successful.
148 * @exception E_INVALID_STATE This instance is in an invalid state.
151 result SetItemWidthMatchMode(const LayoutItem& item, const LayoutMatchMode matchMode);
154 * Gets the width of the specified item with the match policy.
156 * @return An error code
157 * @param[in] item The item to get the match policy of the width
158 * @patam[out] matchMode The match policy
159 * @exception E_SUCCESS The method was successful.
160 * @exception E_INVALID_STATE This instance is in an invalid state.
163 result GetItemWidthMatchMode(const LayoutItem& item, LayoutMatchMode& matchMode) const;
166 * Sets the height of the specified item with the match policy.
168 * @return An error code
169 * @param[in] item The item for which the height is set
170 * @patam[in] matchMode The match policy
171 * @exception E_SUCCESS The method was successful.
172 * @exception E_INVALID_STATE This instance is in an invalid state.
175 result SetItemHeightMatchMode(const LayoutItem& item, const LayoutMatchMode matchMode);
178 * Gets the height of the specified item with the match policy.
180 * @return An error code
181 * @param[in] item The item to get the match policy of the height
182 * @patam[out] matchMode The match policy
183 * @exception E_SUCCESS The method was successful.
184 * @exception E_INVALID_STATE This instance is in an invalid state.
187 result GetItemHeightMatchMode(const LayoutItem& item, LayoutMatchMode& matchMode) const;
190 * Updates the all layout.
192 * @return An error code
193 * @exception E_SUCCESS The method was successful.
194 * @exception E_INVALID_STATE This instance is in an invalid state.
197 result UpdateLayout(void);
199 void SetUpdateState(bool state);
202 * Updates the current layout & all affected layout.
204 * @return An error code
205 * @exception E_SUCCESS The method was successful.
206 * @exception E_INVALID_STATE This instance is in an invalid state.
209 result PartialUpdateLayout(void);
212 * Adds the item at the end of the list maintained by the layout.
214 * @return An error code
215 * @param[in] addItem The item to add to the list.
216 * @exception E_SUCCESS The method was successful.
217 * @exception E_INVALID_STATE This instance is in an invalid state.
220 virtual result AddItem(LayoutItem& addItem);
223 * Removes the item from the list maintained by the layout.
225 * @return An error code
226 * @param[in] removeItem The item to remove from list.
227 * @exception E_SUCCESS The method was successful.
228 * @exception E_INVALID_STATE This instance is in an invalid state.
231 result RemoveItem(const LayoutItem& removeItem);
236 * @return An error code
237 * @param[in] viewPosX The x coordinate
238 * @param[in] viewPosY The y coordinate
239 * @exception E_SUCCESS The method was successful.
240 * @exception E_INVALID_STATE The layout have a item instance that is in an invalid state.
243 result OnChangeViewPosition(int viewPosX, int viewPosY);
246 * Sets the base location and dimension of the specified item.
248 * @return An error code
249 * @param[in] item The item for which the base location and dimension are set
250 * @patam[in] baseRect The rectangle value with the location and dimension
251 * @exception E_SUCCESS The method was successful.
252 * @exception E_INVALID_STATE This instance is in an invalid state.
255 result SetItemBaseRect(const LayoutItem& item, const LayoutRect baseRect);
258 * Gets the base location and dimension of the specified item.
260 * @return An error code
261 * @param[in] item The item to get the base location and dimension
262 * @patam[out] baseRect The rectangle value with the location and dimension
263 * @exception E_SUCCESS The method was successful.
264 * @exception E_INVALID_STATE This instance is in an invalid state.
267 result GetItemBaseRect(const LayoutItem& item, LayoutRect& baseRect) const;
270 * Checks whether the specified item exists in list.
272 * @return @c true, if the item exists @n
273 * @c false, otherwise
274 * @param[in] The item to check.
277 bool ItemExists(LayoutItem& item);
281 * This is the default constructor for this class.
288 * Calculates the bounds of all children for the specified alignment mode.
290 * @return An error code
291 * @param[in] alignMode
292 * @exception E_SUCCESS The method was successful.
293 * @exception E_INVALID_STATE This instance is in an invalid state.
296 result CalculateAlignment(const LayoutAlignMode alignMode = BOTH);
299 * Overrides this method to provide user-specific layouting code.
301 * @return An error code
304 * @param[in] layoutUpdating
305 * @exception E_SUCCESS The method was successful.
306 * @exception E_INVALID_STATE This instance is in an invalid state.
309 virtual result OnLayout(float width, float height, bool layoutUpdating) = 0;
311 void SetPartialUpdateFlag(bool flag);
312 void SetItemList(ProxyList* pItemList);
313 ProxyList* GetProxyList(void) const;
317 * This is the copy constructor for this class.
321 Layout(const Layout&);
324 * This is the substitution operator for this class.
328 Layout& operator =(const Layout&);
331 * Set the layout container.
333 * @return An error code
334 * @param[in] pContainer
335 * @exception E_SUCCESS The method was successful.
336 * @exception E_INVALID_STATE This instance is in an invalid state.
339 result SetContainer(LayoutContainer* pContainer);
342 * Creates the layout proxy for the specified item.
344 * @return The created proxy.
348 LayoutItemProxy* CreateProxy(LayoutItem& item);
351 * Set the root layout flag.
353 * @param[in] rootCheck
356 void SetRootLayout(bool rootCheck);
359 * Checks the specified item whether it is already in the item list or not.
361 * @return An error code
362 * @param[in] checkItem The item to check whether it is already in the list or not
363 * @exception E_SUCCESS The specified item is not in the item list.
364 * @exception E_INVALID_STATE This instance is in an invalid state.
365 * @exception E_INVALID_ARG The specified item parameter is null.
368 result CheckItem(const LayoutItem& checkItem);
371 * Internal method of UpdateLayout() and PartialUpdateLayout().
373 * @return An error code
377 result UpdateLayoutInternal(LayoutUpdateFlag updateFlag);
380 * Runs the OnLayout() for pLayout.
382 * @return An error code
386 result OnLayoutTrigger(Layout& layout, bool layoutUpdating);
389 * Gets the update flag for parent layout.
391 * @return LayoutUpdateFlag
395 LayoutUpdateFlag CheckParentFlag(void);
398 * Gets the update flag for current layout.
400 * @return LayoutUpdateFlag
404 LayoutUpdateFlag CheckCurrentFlag(void);
407 * Internal method of CheckParentFlag() and CheckCurrentFlag().
409 * @return LayoutUpdateFlag
413 LayoutUpdateFlag CheckFlagInternal(LayoutItemProxy& containerProxy);
416 * Checks whether the layout has the container.
422 bool HasLayoutContainer(void);
424 result DetermineWindowRectToAllItem(void);
425 result OnDetermine(void);
428 ProxyList* __pProxyList;
434 LayoutItemProxy* __pContainerProxy;
438 bool __partialUpdateState;
439 bool __determineState;
441 friend class LayoutContainer;
444 }}} // Tizen::Ui::_Layout
446 #endif // _FUI_INTERNAL_LAYOUT_LAYOUT_H_