1 /* |
|
2 * Copyright (c) 2008 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: grid layoutpolicy private implementation header. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ALFGRIDLAYOUTPOLICYIMPL_H |
|
20 #define ALFGRIDLAYOUTPOLICYIMPL_H |
|
21 |
|
22 #include <osn/osndefines.h> |
|
23 #include <alf/alfgridlayoutmanager.h> |
|
24 #include <alf/ialfgridlayoutpolicy.h> |
|
25 |
|
26 using std::auto_ptr; |
|
27 using Alf::AlfGridLayoutManager; |
|
28 |
|
29 class CAlfControl; |
|
30 class CAlfGridLayout; |
|
31 |
|
32 namespace Alf |
|
33 { |
|
34 |
|
35 class CAlfWidgetControl; |
|
36 class AlfWidget; |
|
37 class IAlfGridLayoutPolicy; |
|
38 |
|
39 /** |
|
40 * layoutmanager implementation class |
|
41 * |
|
42 * @lib alfwidgetmodel.lib |
|
43 * @since S60 ?S60_version |
|
44 */ |
|
45 class AlfGridLayoutPolicyImpl : public IAlfGridLayoutPolicy |
|
46 { |
|
47 public: |
|
48 /** |
|
49 * layout manager constructor |
|
50 * |
|
51 * @param aLayoutType type of layout used by the manager. |
|
52 */ |
|
53 AlfGridLayoutPolicyImpl(AlfGridLayoutManager& aGridLayoutManager); |
|
54 |
|
55 /** |
|
56 * destructor |
|
57 */ |
|
58 ~AlfGridLayoutPolicyImpl(); |
|
59 |
|
60 |
|
61 |
|
62 public: |
|
63 // from IAlfGridLayoutPolicy |
|
64 |
|
65 /** |
|
66 * Sets the number and weights of blocks in this grid layout in the direction of the specified |
|
67 * dimension. Each block's weight will be set to equal the supplied value, the result |
|
68 * of which is that all blocks will be equally spaced, whatever the units. |
|
69 * |
|
70 * @see appendWeight; for more information on how weights are used to calculate layout positions. |
|
71 * |
|
72 * @note This API could be useful if then subsequent calls to @c replaceWeight are made to |
|
73 * change specific values, depending on how many of the values are different. |
|
74 * @note Calling this with aCount set to 0 will clear all of the existing weights in the direction |
|
75 * of the specified dimension. |
|
76 * @note this is the same as using metrics with unit type EAlfUnitWeight. |
|
77 * |
|
78 * @param aDim the dimension along which to fill |
|
79 * @param aCount The number of lines of blocks to fill |
|
80 * @param aWeight the weights to be used for all blocks |
|
81 * @throw AlfVisualException(EInvalidArgument), if aPos is out of bounds |
|
82 */ |
|
83 virtual void fillWeights(IAlfGridLayoutPolicy::gridLayoutDimension aDim, int aCount, const TAlfMetric& aWeight); |
|
84 |
|
85 /** |
|
86 * Add a new line of blocks to this grid layout at the last position in the direction of the |
|
87 * specified dimension. It will have the supplied weight. Weights can be any metric value, |
|
88 * hence different units can be used for each block. In particular, EAlfUnitWeight can be used |
|
89 * to represent weight values in aribtrary proportional units. |
|
90 * |
|
91 * In the case of proportional weights, the effect of this will be to cause the other blocks to |
|
92 * resize according to the new total weight. |
|
93 * |
|
94 * @note If non-relative coordinates are specified (e.g., real pixels), the combined blocks might not |
|
95 * fill the entire layout area. However, weights will always stretch to fill all available space |
|
96 * after the fixed units have been determined. Therefore, depending on circumstances it may |
|
97 * be better to use EAlfUnitWeight |
|
98 * @note For example [2 weights, 1 weight, 2 weights] in a layout of 100 pixels would result |
|
99 * in [40 pixels, 20 pixels, 40 pixels]. |
|
100 * @note For example [10 pixels, 1 weight, 15 pixels] in a layout of 100 pixels would result |
|
101 * in [10 pixels, 75 pixels, 15 pixels]. |
|
102 * |
|
103 * @param aDim the dimension to which the weight corresponds |
|
104 * @param aWeight the weight to be used for the block in the specified dimension, |
|
105 * replacing any previously existing weight for that block |
|
106 * @throw AlfVisualException(ECommonError), if memory allocation error |
|
107 */ |
|
108 virtual void appendWeight(IAlfGridLayoutPolicy::gridLayoutDimension aDim, const TAlfMetric& aWeight); |
|
109 |
|
110 /** |
|
111 * Add a new line of blocks to this grid layout at the specified position in the direciton of |
|
112 * the specified dimension. It will have the supplied weight. In the case of proportional |
|
113 * weights, the effect of this will be to cause the other blocks to resize according to the new |
|
114 * total weight. It will also mean that many child visuals will now occupy different blocks within |
|
115 * the grid according to how the blocks wrap. |
|
116 * |
|
117 * @note will leave if the specified position is greater than the number of objects currently in the array, |
|
118 * so check first by calling @c preferredDimensionCount |
|
119 * @see appendWeight for more information on how weights are used to calculate layout positions. |
|
120 * |
|
121 * @param aDim the dimension to which the weight corresponds |
|
122 * @param aWeight the weight to be used for the block in the specified dimension, |
|
123 * replacing any previously existing weight for that block |
|
124 * @param aPos the index of the block |
|
125 * @throw AlfVisualException(EInvalidArrayIndex), if aPos is out of bounds |
|
126 */ |
|
127 virtual void insertWeight(IAlfGridLayoutPolicy::gridLayoutDimension aDim, const TAlfMetric& aWeight, int aPos); |
|
128 |
|
129 /** |
|
130 * Sets the weight of a specific line of blocks in this grid layout, in the direction of the supplied dimension. |
|
131 * In the case of proportional weights, the effect of this will be to cause the |
|
132 * other blocks to resize according to the new total weight. |
|
133 * |
|
134 * @see appendWeight for more information on how weights are used to calculate layout positions. |
|
135 * |
|
136 * @param aDim the dimension to which the weight corresponds |
|
137 * @param aWeight the weight to be used for the block in the specified dimension, |
|
138 * replacing any previously existing weight for that cell |
|
139 * @param aPos the index of the cell |
|
140 * @throw AlfVisualException(EInvalidArrayIndex), if aPos is out of bounds |
|
141 */ |
|
142 virtual void replaceWeight(IAlfGridLayoutPolicy::gridLayoutDimension aDim, const TAlfMetric& aWeight, int aPos); |
|
143 |
|
144 /** |
|
145 * Remove a line of blocks from this grid layout at the specified position in the |
|
146 * specified dimension. In the case of proportional weights, the effect of this will |
|
147 * be to cause the other blocks to resize according to the new total weight. It will also mean |
|
148 * that many child visuals will now occupy different blocks within the grid according to how |
|
149 * the blocks wrap. |
|
150 * |
|
151 * @see appendWeight for more information on how weights are used to calculate layout positions. |
|
152 * |
|
153 * @param aDim the dimension to which the weight corresponds |
|
154 * @param aPos the index of the cell |
|
155 * @throw AlfVisualException(EInvalidArrayIndex), if aPos is out of bounds |
|
156 */ |
|
157 virtual void removeWeight(IAlfGridLayoutPolicy::gridLayoutDimension aDim, int aPos); |
|
158 |
|
159 /** |
|
160 * Returns the weight of a specific line of blocks in this grid layout, in the |
|
161 * specified dimension. |
|
162 * |
|
163 * @see appendWeight for more information on how weights are used to calculate layout positions. |
|
164 * |
|
165 * @param aDim the dimension to which the weight corresponds |
|
166 * @param aPos the index of the cell |
|
167 * @return the weight being used for the cell in the specified dimension, will be 0 magnitude if not set |
|
168 * @throw AlfVisualException(EInvalidArrayIndex), if aPos is out of bounds |
|
169 */ |
|
170 virtual TAlfMetric weight(IAlfGridLayoutPolicy::gridLayoutDimension aDim, int aPos) const; |
|
171 |
|
172 /** |
|
173 * Return the number of lines of blocks in this grid, along the specified dimension |
|
174 * |
|
175 * @param aDim the dimension along which to count |
|
176 * @return The number of lines of blocks in this grid. |
|
177 */ |
|
178 virtual int count(IAlfGridLayoutPolicy::gridLayoutDimension aDim) const; |
|
179 |
|
180 public: |
|
181 // from base class IAlfInterfaceBase |
|
182 |
|
183 /** |
|
184 * Interface getter. |
|
185 * @see IAlfInterfaceBase::MakeInterface |
|
186 * |
|
187 * @since S60 ?S60_version |
|
188 * @param aType The type id of the queried interface. |
|
189 * @return The queried interface, or NULL if the interface is not |
|
190 * supported or available. |
|
191 */ |
|
192 virtual IAlfInterfaceBase* makeInterface( const IfId& aType ); |
|
193 |
|
194 private: |
|
195 /** |
|
196 * returns the gridlayout used by the layoutmanager. |
|
197 */ |
|
198 CAlfGridLayout& layout() const; |
|
199 private: |
|
200 |
|
201 AlfGridLayoutManager &mGridLayoutManager; |
|
202 |
|
203 }; |
|
204 |
|
205 } // namespace Alf |
|
206 |
|
207 #endif // ALFGRIDLAYOUTPOLICYIMPL_H |
|