|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUIFLOWLAYOUT_H__ |
|
21 #define __HUIFLOWLAYOUT_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <uiacceltk/HuiLayout.h> |
|
26 |
|
27 |
|
28 /** |
|
29 * Flow layout positions children next to each other either horizontally or |
|
30 * vertically. The sizes of child visuals are not changed by default. |
|
31 * |
|
32 * The layout inner padding is used to determine the gap between children. |
|
33 * |
|
34 * Flow layout takes system wide layout mirroring into consideration by |
|
35 * querying the mirroring state through AknLayoutUtils::LayoutMirrored(). |
|
36 * In western locales the visuals are layed out from left to right whereas |
|
37 * in arabic locale for instance the visuals are layed out from right to left. |
|
38 * Mirroring is considered only when the flow is horizontal. Vertical flow layout |
|
39 * will always lay visuals from top to bottom. |
|
40 */ |
|
41 NONSHARABLE_CLASS(CHuiFlowLayout) : public CHuiLayout |
|
42 { |
|
43 public: |
|
44 |
|
45 /** Flow directions. */ |
|
46 enum TFlowDirection |
|
47 { |
|
48 /** |
|
49 * Flow horizontally. System wide layout mirroring is considered |
|
50 * to determine whether visuals are layed from left to right |
|
51 * or from right to left. |
|
52 * @see AknLayoutUtils::LayoutMirrored() |
|
53 */ |
|
54 EFlowHorizontal = 0, |
|
55 |
|
56 /** Flow vertically. */ |
|
57 EFlowVertical |
|
58 }; |
|
59 |
|
60 /** Mode flags that specify how the flow is laid out. */ |
|
61 enum TMode |
|
62 { |
|
63 /** Center the children perpendicular to the flow direction. |
|
64 For example, if the flow direction is horizontal (left->right) |
|
65 this flag will center the children vertically along the flow. */ |
|
66 EModeCenterPerpendicular = 0x1, |
|
67 |
|
68 /** Fit the children perpendicular to the flow direction. |
|
69 For example, if the flow direction is horizontal, the children |
|
70 will be vertically resized to fit the layout's rectangle. */ |
|
71 EModeFitPerpendicular = 0x2, |
|
72 }; |
|
73 |
|
74 |
|
75 /* Constructors and destructor. */ |
|
76 |
|
77 /** |
|
78 * Construct a new flow layout and append it to a control. |
|
79 * |
|
80 * @param aDirection Flow direction. |
|
81 * @param aOwnerControl Control that will own the new layout visual. |
|
82 * @param aParentLayout Parent layout for the new layout visual. |
|
83 * |
|
84 * @return Pointer to the new layout visual. The owner control retains |
|
85 * ownership of the returned visual. Do not delete the returned |
|
86 * visual manually. |
|
87 */ |
|
88 IMPORT_C static CHuiFlowLayout* AddNewL(CHuiControl& aOwnerControl, |
|
89 TFlowDirection aDirection, |
|
90 CHuiLayout* aParentLayout = 0); |
|
91 |
|
92 /** |
|
93 * Constructor. |
|
94 */ |
|
95 CHuiFlowLayout(MHuiVisualOwner& aOwner); |
|
96 |
|
97 /** |
|
98 * Second-phase constructor. |
|
99 */ |
|
100 void ConstructL(); |
|
101 |
|
102 /** |
|
103 * Destructor. |
|
104 */ |
|
105 IMPORT_C virtual ~CHuiFlowLayout(); |
|
106 |
|
107 |
|
108 /* Methods. */ |
|
109 |
|
110 IMPORT_C void SetSize(const THuiRealSize& aSize, TInt aTransitionTime=0); |
|
111 |
|
112 TBool ChildSize(TInt aOrdinal, TSize& aSize); |
|
113 |
|
114 TBool ChildPos(TInt aOrdinal, TPoint& aPos); |
|
115 |
|
116 TInt ChildRect(TInt aOrdinal, THuiRealRect& aRect); |
|
117 |
|
118 /** |
|
119 * Sets the direction of the flow. |
|
120 * |
|
121 * @param aDirection Flow direction. |
|
122 */ |
|
123 IMPORT_C void SetFlowDirection(TFlowDirection aDirection); |
|
124 |
|
125 /** |
|
126 * Sets the centering mode of the flow. This sets/clears the |
|
127 * EModeCenterPerpendicular flag. Calling this is equivalent to calling |
|
128 * SetMode() with that flag included or missing from the mode. |
|
129 * |
|
130 * @param aCentering <code>ETrue</code> to set the EModeCenterPerpendicular mode. |
|
131 * <code>EFalse</code> to clear it. |
|
132 * |
|
133 * @note This method could be deprecated in the future, since SetMode() |
|
134 * does the same thing. |
|
135 */ |
|
136 IMPORT_C void SetCentering(TBool aCentering); |
|
137 |
|
138 /** |
|
139 * Sets the mode of the flow. The mode flags determine how the flow layout |
|
140 * behaves. |
|
141 * |
|
142 * @param aMode Mode flags (OR'd together). |
|
143 * |
|
144 * @see CHuiFlowLayout::TMode |
|
145 */ |
|
146 IMPORT_C void SetMode(TInt aMode); |
|
147 |
|
148 /** |
|
149 * Returns the mode flags of the flow. |
|
150 * |
|
151 * @see CHuiFlowLayout::TMode |
|
152 * |
|
153 * @return Returns the current mode flags. |
|
154 */ |
|
155 IMPORT_C TInt Mode() const; |
|
156 |
|
157 private: |
|
158 |
|
159 /* Private methods */ |
|
160 |
|
161 |
|
162 private: |
|
163 |
|
164 /** Direction of the flow: horizontal or vertical. */ |
|
165 TFlowDirection iDirection; |
|
166 |
|
167 /** Mode flags of the flow. */ |
|
168 TInt iMode; |
|
169 |
|
170 }; |
|
171 |
|
172 #endif // __HUIFLOWLAYOUT_H__ |