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_LayoutTableLayout.h
19 * @brief This is the header file for TableLayout class.
21 * This header file contains the declaration of TableLayout class.
26 #ifndef _FUI_INTERNAL_LAYOUT_TABLE_LAYOUT_H_
27 #define _FUI_INTERNAL_LAYOUT_TABLE_LAYOUT_H_
29 #include <FBaseColLinkedList.h>
30 #include "FUi_LayoutLayout.h"
32 namespace Tizen { namespace Ui { namespace _Layout
40 bool heightShrinkable;
41 bool heightStretchable;
53 bool widthStretchable;
59 class _OSP_EXPORT_ TableLayout
64 * This is the default constructor for this class.
71 * This is the destructor for this class.
75 virtual ~TableLayout(void);
78 * Creates the instance of TableLayout.
81 * @return The instance of TableLayout.
82 * @exception E_SUCCESS The method was successful.
83 * @exception E_OUT_OF_MEMORY Insufficient memory.
85 static TableLayout* CreateTableLayoutN(void);
91 * @return An error code
92 * @param[in] row The number of rows.
93 * @param[in] column The number of columns.
94 * @param[in] spacing The space.
95 * @exception E_SUCCESS The method was successful.
96 * @exception E_INVALID_STATE This instance is in an invalid state.
97 * @exception E_INVALID_ARG The specified input parameter is invalid.
98 * @exception E_OUT_OF_MEMORY Insufficient memory.
100 result CreateTable(int row, int column, float spacing = 0.0f);
103 * Merges from the start cell to the end cell.
106 * @return An error code
107 * @param[in] startRow The start row.
108 * @param[in] startCol The start column.
109 * @param[in] endRow The end row.
110 * @param[in] endCol The end column.
111 * @exception E_SUCCESS The method was successful.
112 * @exception E_INVALID_ARG The specified input parameter is invalid.
113 * @exception E_SYSTEM A system error occurred.
115 result Merge(int startRow, int startCol, int endRow, int endCol);
118 * Unmerges the specified cell.
121 * @return An error code
122 * @param[in] row The target row.
123 * @param[in] column The target column.
124 * @exception E_SUCCESS The method was successful.
125 * @exception E_INVALID_ARG The specified input parameter is invalid.
126 * @exception E_INVALID_STATE The target is impossible to unmerge.
128 result Unmerge(int row, int column);
131 * Gets the size of merged cell for specified row and column.
134 * @return An error code
135 * @param[in] row The target row.
136 * @param[in] column The target column.
137 * @param[out] rowSize The merged row size.
138 * @param[out] columnSize The merged column size.
139 * @exception E_SUCCESS The method was successful.
140 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
141 * @exception E_INVALID_STATE The target is merged by other cell.
143 result GetMergeSize(int row, int column, int& rowSize, int& columnSize) const;
146 * Adds the item into the empty cell.
149 * @return An error code
150 * @param[in] pAddItem The added item.
151 * @exception E_SUCCESS The method was successful.
152 * @exception E_INVALID_ARG The specified input parameter is invalid.
153 * @exception E_INVALID_STATE The target cell has been already occupied.
155 result AddItem(LayoutItem& addItem);
158 * Adds the item into the specified cell.
161 * @return An error code
162 * @param[in] pAddItem The added item.
163 * @param[in] row The target row.
164 * @param[in] column The target column.
165 * @exception E_SUCCESS The method was successful.
166 * @exception E_INVALID_ARG The specified input parameter is invalid.
167 * @exception E_INVALID_STATE The target cell has been already occupied.
169 result AddItem(LayoutItem& addItem, int row, int column, bool mergedState = false);
172 * Gets the item of the specified cell.
176 * @param[in] row The target row.
177 * @param[in] column The target column.
179 LayoutItem* GetItem(int row, int column) const;
182 * Sets the row and column of specified item.
185 * @return An error code
186 * @param[in] pItem The item to change the position.
187 * @param[in] row The target row.
188 * @param[in] column The target column.
189 * @exception E_SUCCESS The method was successful.
190 * @exception E_INVALID_ARG The specified input parameter is invalid.
191 * @exception E_INVALID_STATE The target cell has been already occupied.
193 result SetItemPosition(const LayoutItem& item, int row, int column);
196 * Gets the row and column of specified item.
199 * @return An error code
200 * @param[in] pItem The item to change the position.
201 * @param[in] row The row of item.
202 * @param[in] column The column of item.
203 * @exception E_SUCCESS The method was successful.
204 * @exception E_INVALID_ARG The specified input parameter is invalid.
206 result GetItemPosition(const LayoutItem& item, int& row, int& column) const;
209 * Swaps the position between item1 and item2.
212 * @return An error code
213 * @param[in] pItem1 The target item 1.
214 * @param[in] pItem2 The target item 2.
215 * @exception E_SUCCESS The method was successful.
216 * @exception E_INVALID_ARG The specified input parameter is invalid.
218 result SwapItemPosition(LayoutItem& item1, LayoutItem& item2);
221 * Adds the row to the table.
224 * @exception E_SUCCESS The method was successful.
225 * @exception E_OUT_OF_MEMORY Insufficient memory.
231 * Adds the column to the table.
234 * @exception E_SUCCESS The method was successful.
235 * @exception E_OUT_OF_MEMORY Insufficient memory.
238 result AddColumn(void);
241 * Deletes the specified row from the table.
244 * @return An error code
245 * @param[in] row The target row.
246 * @exception E_SUCCESS The method was successful.
247 * @exception E_INVALID_STATE This instance is in an invalid state.
248 * @exception E_INVALID_ARG The specified input parameter is invalid.
249 * @exception E_SYSTEM A system error occurred.
251 result DeleteRow(int row);
254 * Deletes the specified column from the table.
257 * @return An error code
258 * @param[in] column The target column.
259 * @exception E_SUCCESS The method was successful.
260 * @exception E_INVALID_STATE This instance is in an invalid state.
261 * @exception E_INVALID_ARG The specified input parameter is invalid.
262 * @exception E_SYSTEM A system error occurred.
264 result DeleteColumn(int column);
267 * Sets the collapse property for the specified row.
270 * @return An error code
271 * @param[in] row The target row.
272 * @param[in] collapsed The collase state.
273 * @exception E_SUCCESS The method was successful.
274 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
276 result SetRowCollapsed(int rowIndex, bool collapsed);
279 * Checks whether the row is collapsed.
282 * @return @c true, The row is collapsed @n
284 * @param[in] row The target row.
286 bool GetRowCollapsed(int rowIndex) const;
289 * Sets the collapse property for the specified column.
292 * @return An error code
293 * @param[in] column The target column.
294 * @param[in] collapsed The collase state.
295 * @exception E_SUCCESS The method was successful.
296 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
298 result SetColumnCollapsed(int column, bool collapsed);
301 * Checks whether the column is collapsed.
304 * @return @c true, The column is collapsed @n
306 * @param[in] column The target column.
308 bool GetColumnCollapsed(int column) const;
311 * Sets the shrinkable property for the specified row.
314 * @return An error code
315 * @param[in] row The target row.
316 * @param[in] shrinkable The shrinkable state.
317 * @exception E_SUCCESS The method was successful.
318 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
320 result SetRowShrinkable(int row, bool shrinkable);
323 * Checks whether the row is shrinkable.
326 * @return @c true, The row is shrinkable @n
328 * @param[in] row The target row.
329 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
331 bool GetRowShrinkable(int row) const;
334 * Sets the shrinkable property for the specified column.
337 * @return An error code
338 * @param[in] column The target column.
339 * @param[in] shrinkable The shrinkable state.
340 * @exception E_SUCCESS The method was successful.
341 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
343 result SetColumnShrinkable(int column, bool shrinkable);
346 * Checks whether the column is shrinkable.
349 * @return @c true, The column is shrinkable @n
351 * @param[in] column The target column.
352 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
354 bool GetColumnShrinkable(int column) const;
357 * Sets the stretchable property for the specified row.
360 * @return An error code
361 * @param[in] row The target row.
362 * @param[in] stretchable The stretchable state.
363 * @exception E_SUCCESS The method was successful.
364 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
366 result SetRowStretchable(int row, bool stretchable);
369 * Checks whether the row is stretchable.
372 * @return @c true, The row is stretchable @n
374 * @param[in] row The target row.
376 bool GetRowStretchable(int row) const;
379 * Sets the stretchable property for the specified column.
382 * @return An error code
383 * @param[in] column The target column.
384 * @param[in] stretchable The stretchable state.
385 * @exception E_SUCCESS The method was successful.
386 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
388 result SetColumnStretchable(int column, bool stretchable);
391 * Checks whether the column is stretchable.
394 * @return @c true, The column is stretchable @n
396 * @param[in] column The target column.
398 bool GetColumnStretchable(int column) const;
401 * Sets the spacing for the specified row.
404 * @return An error code
405 * @param[in] row The target row.
406 * @param[in] heightSpacing The space size.
407 * @exception E_SUCCESS The method was successful.
408 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
410 result SetRowSpacing(int row, float heightSpacing);
413 * Gets the spacing of the specified row.
416 * @return An error code
417 * @param[in] row The target row.
418 * @param[out] spacing The height space of target row.
419 * @exception E_SUCCESS The method was successful.
420 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
422 result GetRowSpacing(int row, float& spacing) const;
425 * Sets the spacing for specified column.
428 * @return An error code
429 * @param[in] column The target column.
430 * @param[in] widthSpacing The space size.
431 * @exception E_SUCCESS The method was successful.
432 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
434 result SetColumnSpacing(int column, float widthSpacing);
437 * Gets the spacing of the specified column.
440 * @return An error code
441 * @param[in] column The target column.
442 * @param[out] spacing The width space of target column.
443 * @exception E_SUCCESS The method was successful.
444 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
446 result GetColumnSpacing(int column, float& spacing) const;
449 * Sets the fill property for specified cell.
452 * @return An error code
453 * @param[in] row The target row.
454 * @param[in] column The target column.
455 * @param[in] fillWidth The fill width state.
456 * @param[in] fillHeight The fill height state.
457 * @exception E_SUCCESS The method was successful.
458 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
459 * @exception E_SYSTEM A system error occurred.
461 result SetFillCell(int row, int column, bool fillWidth, bool fillHeight);
464 * Checks whether the cell has fill property.
467 * @return An error code
468 * @param[in] row The target row.
469 * @param[in] column The target column.
470 * @param[out] fillWidth The fill width state of the target cell.
471 * @param[out] fillHeight The fill height state of the target cell.
472 * @exception E_SUCCESS The method was successful.
473 * @exception E_OUT_OF_RANGE Input Argument value over the max value.
474 * @exception E_SYSTEM A system error occurred.
476 result GetFillCell(int row, int column, bool& fillWidth, bool& fillHeight) const;
480 * Calculates the position and bounds of all chindren, and applies to the control.
482 * @return An error code
485 * @param[in] layoutUpdating
486 * @exception E_SUCCESS The method was successful.
487 * @exception E_INVALID_STATE This instance is in an invalid state.
490 virtual result OnLayout(float widht, float height, bool updateLayouting);
494 * This is the copy constructor for this class.
498 TableLayout(const TableLayout&);
501 * This is the substitution operator for this class.
505 TableLayout& operator =(const TableLayout&);
508 * Calculates the size of the all cell. @n
512 * @return An error code
513 * @exception E_SUCCESS The method was successful.
514 * @exception E_INVALID_STATE This instance is in an invalid state.
516 result CalculateSize(void);
519 * Calculates the size of the all shrinkable cell. @n
523 * @return An error code
524 * @param[in] windowRect
525 * @exception E_SUCCESS The method was successful.
526 * @exception E_INVALID_STATE This instance is in an invalid state.
527 * @exception E_OUT_OF_MEMORY Insufficient memory.
529 result CalculateShrinkCell(LayoutRect windowRect);
532 * Calculates the size of the all stretchable cell. @n
536 * @return An error code
537 * @param[in] windowRect
538 * @exception E_SUCCESS The method was successful.
539 * @exception E_INVALID_STATE This instance is in an invalid state.
540 * @exception E_OUT_OF_MEMORY Insufficient memory.
542 result CalculateStretchCell(LayoutRect windowRect);
545 * Calculates the size of the merged cell. @n
546 * Used by AdjustTableLayout.
549 * @return An error code
553 * @exception E_SUCCESS The method was successful.
554 * @exception E_INVALID_ARG The specified input parameter is invalid.
556 result CalculateMergeCell(int row, int column, LayoutSize& size);
559 * Calculates the size of item for alignment. @n
560 * Used by AdjustTableLayout.
563 * @return The calculated rect
564 * @param[in] pItemProxy
565 * @param[in] cellRect
566 * @param[in] itemRect
567 * @param[in] horizonEdge
568 * @param[in] verticalEdge
569 * @exception E_SUCCESS The method was successful.
570 * @exception E_INVALID_ARG The specified input parameter is invalid.
572 LayoutRect CalculateAlign(LayoutItemProxy& itemProxy, const LayoutRect cellRect, const LayoutRect itemRect, const HorizontalAlign horizonEdge, const VerticalAlign verticalEdge);
575 * Finally, adjusts the size. @n
579 * @return An error code
580 * @param[in] windowRect
581 * @param[in] updateLayouting
582 * @exception E_SUCCESS The method was successful.
583 * @exception E_INVALID_ARG The specified input parameter is invalid.
585 result AdjustTableLayout(const LayoutRect windowRect, bool updateLayouting);
588 * Gets the node of specified cell.
591 * @return The node for row and column
595 ProxyListNode* GetNode(int row, int column) const;
598 * Gets the size of the specified cell.
601 * @return An error code
602 * @param[in] cellIndex The target cell index.
603 * @param[out] rect The rect of target cell.
604 * @exception E_SUCCESS The method was successful.
605 * @exception E_INVALID_ARG The specified input parameter is invalid.
607 result GetCellSize(int cellIndex, LayoutRect& rect);
610 * Gets the row number from specified cell ID.
613 * @return The row number
614 * @param[in] id The ID of target cell.
616 int GetRow(int id) const;
619 * Gets the column number from specified cell ID.
622 * @return The column number
623 * @param[in] id The ID of target cell.
625 int GetColumn(int id) const;
628 * Makes & Gets the cell ID from specified row number and column number.
631 * @return The cell ID
632 * @param[in] row The row number
633 * @param[in] column The column number
635 int MakeCellID(int row, int column) const;
639 // Table metrics information
645 // Shrink, Stretch Count
646 int __shrinkRowCount;
647 int __shrinkColumnCount;
648 int __stretchRowCount;
649 int __stretchColumnCount;
651 bool __rowShrinkable;
652 bool __columnShrinkable;
653 bool __rowStretchable;
654 bool __columnStretchable;
658 // Columns information
659 ColumnInfo* __pColInfo;
661 static const int INVALID_CELL_ID = 0xFFFFFFFF;
662 static const int NOT_MERGED = 0xFFFFFFFE;
664 Tizen::Base::Collection::LinkedList __mergedCellList;
666 friend class TableItemInfo;
669 }}} //Tizen::Ui::_Layout
671 #endif // _FUI_INTERNAL_LAYOUT_TABLE_LAYOUT_H_