|
1 /* |
|
2 * Copyright (c) 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: layoutmanager implementation header. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef ALFLAYOUTMANAGERIMPL |
|
20 #define ALFLAYOUTMANAGERIMPL |
|
21 |
|
22 #include <osn/osndefines.h> |
|
23 #include <alf/alflayoutmanager.h> |
|
24 #include <alf/ialflayoutpreferences.h> |
|
25 |
|
26 using std::auto_ptr; |
|
27 |
|
28 namespace Alf |
|
29 { |
|
30 |
|
31 class CAlfWidgetControl; |
|
32 class IAlfWidget; |
|
33 class IAlfLayoutPreferences; |
|
34 |
|
35 /** |
|
36 * layoutmanager implementation class |
|
37 * |
|
38 * @lib alfwidgetmodel.lib |
|
39 * @since S60 ?S60_version |
|
40 */ |
|
41 class AlfLayoutManagerImpl : public IAlfLayoutPreferences |
|
42 { |
|
43 public: |
|
44 /** |
|
45 * layout manager constructor |
|
46 * |
|
47 * @param aLayoutType type of layout used by the manager. |
|
48 */ |
|
49 AlfLayoutManagerImpl(TAlfLayoutType aLayoutType); |
|
50 |
|
51 /** |
|
52 * destructor |
|
53 */ |
|
54 ~AlfLayoutManagerImpl(); |
|
55 |
|
56 /** |
|
57 * creates the layout used by the layoutmanager. |
|
58 * |
|
59 * @param aOwner, owner-control of the the created layout. |
|
60 * @param aParentLayout parent for the created layout |
|
61 * @param aLayoutIndex index, where created visual should be placed in the parent layout. |
|
62 */ |
|
63 void createLayout(CAlfWidgetControl& aOwner, CAlfLayout* aParentLayout, |
|
64 int aLayoutIndex); |
|
65 |
|
66 /** |
|
67 * returns the layout used by layoutmanager. |
|
68 * |
|
69 * @return layout used by this layoutmanager. |
|
70 */ |
|
71 CAlfLayout& getLayout() const; |
|
72 |
|
73 /** |
|
74 * updates the main layout |
|
75 */ |
|
76 void updateMainLayout(); |
|
77 |
|
78 /** |
|
79 * notifies the layout manager, that the control's has been |
|
80 * removed from the layout. |
|
81 * |
|
82 * @param aControl control, which size has changed. |
|
83 */ |
|
84 void childRemoved(CAlfWidgetControl* aControl); |
|
85 |
|
86 /** |
|
87 * notifies the layout manager, that the child control's layout |
|
88 * must be updated. |
|
89 * |
|
90 * @param aControl control, which size or position has changed. |
|
91 */ |
|
92 void doUpdateChildLayout(CAlfWidgetControl* aControl); |
|
93 |
|
94 /** |
|
95 * returns the rect of the control. |
|
96 * |
|
97 * @param aControl, control, which size is queried. |
|
98 * @param aRect, will receive the rect of aControl. |
|
99 */ |
|
100 bool controlRect(CAlfWidgetControl& aControl, TAlfRealRect& aRect); |
|
101 |
|
102 /** |
|
103 * sets the size and position to the widget. |
|
104 * |
|
105 * @param aWidget, widget, which size and position is being set. |
|
106 * @param aRect, rect for aWidget |
|
107 */ |
|
108 void setWidgetRect(IAlfWidget& aWidget, const TAlfRealRect &aRect); |
|
109 |
|
110 /** |
|
111 * sets the position to the widget. |
|
112 * |
|
113 * @param aWidget, widget, which position is being set. |
|
114 * @param aPos, position for aWidget |
|
115 */ |
|
116 void setWidgetPosition(IAlfWidget& aWidget, const TAlfRealPoint &aPos); |
|
117 |
|
118 /** |
|
119 * sets the size to widget. |
|
120 * |
|
121 * @param aWidget, widget, which size is being set. |
|
122 * @param aSize, new size for aWidget. |
|
123 */ |
|
124 void setWidgetSize(IAlfWidget& aWidget, const TAlfRealPoint &aSize); |
|
125 |
|
126 /** |
|
127 * updates widget size and position properties for all the children |
|
128 * to correct sizes and positions of the root visuals. |
|
129 */ |
|
130 void updateAllWidgetRects(); |
|
131 |
|
132 /** |
|
133 * @return the child visual count |
|
134 */ |
|
135 int count() const; |
|
136 |
|
137 /** |
|
138 * returns the control at aIndex. |
|
139 * |
|
140 * @param aIndex index for the control. |
|
141 * @return control at aIndex |
|
142 */ |
|
143 CAlfWidgetControl* getControl(int aIndex) const; |
|
144 |
|
145 /** |
|
146 * @return the owner control of the layoutmanager. |
|
147 */ |
|
148 CAlfWidgetControl& owner() const ; |
|
149 |
|
150 public: |
|
151 // from base class IAlfLayoutPreferences |
|
152 |
|
153 /** |
|
154 * Returns the minimum size of the layout by combining the minimum sizes of the |
|
155 * layed out visuals. |
|
156 * |
|
157 * @param aMinSize The minimum size that the object would like to be laid out to |
|
158 * @return false iff none of the layed out UI elements do not care about minimum size |
|
159 */ |
|
160 virtual bool getMinimumSize( TAlfXYMetric& aMinSize ) const; |
|
161 |
|
162 /** |
|
163 * Returns the maximum size of the layout by combining the maximum sizes of the |
|
164 * layed out visuals. |
|
165 * |
|
166 * @param aMaxSize The maximum size that the object would like to be laid out to |
|
167 * @return false iff none of the layed out UI elements do not care about maximum size |
|
168 */ |
|
169 virtual bool getMaximumSize( TAlfXYMetric& aMaxSize ) const; |
|
170 |
|
171 /** |
|
172 * Returns the size combined by all preferred sizes of child UI elements in this layout |
|
173 * when they are being layed out according to the layout manager rules. |
|
174 * |
|
175 * @param aPreferredSize Filled with the referred area occupied by child elements when |
|
176 * layed out by layouting rules in this layout manager. |
|
177 * @return False if none of the child components report their preferred size. True |
|
178 * otherwise. |
|
179 */ |
|
180 virtual bool getPreferredSize(TAlfXYMetric& aPreferredSize) const; |
|
181 |
|
182 /** |
|
183 * Set the preferred size into a presentation object. |
|
184 * |
|
185 * This is not supported on the layout manager. Users should set preferred sizes of the |
|
186 * contained UI elements. |
|
187 */ |
|
188 virtual void setPreferredSize( const TAlfXYMetric& aPreferredSize ); |
|
189 |
|
190 /** |
|
191 * returns the layout preferences for a control |
|
192 * |
|
193 * @param aControl control instance |
|
194 * @return layout preferences for a control. |
|
195 */ |
|
196 const IAlfLayoutPreferences* getLayoutPreferences(CAlfWidgetControl* aControl) const; |
|
197 |
|
198 public: |
|
199 // from base class IAlfInterfaceBase |
|
200 |
|
201 /** |
|
202 * Interface getter. |
|
203 * @see IAlfInterfaceBase::MakeInterface |
|
204 * |
|
205 * @since S60 ?S60_version |
|
206 * @param aType The type id of the queried interface. |
|
207 * @return The queried interface, or NULL if the interface is not |
|
208 * supported or available. |
|
209 */ |
|
210 virtual IAlfInterfaceBase* makeInterface( const IfId& aType ); |
|
211 |
|
212 private: |
|
213 |
|
214 /** |
|
215 * returns the control, which owns the visual |
|
216 * |
|
217 * @param aVisual visual, which the control owns. |
|
218 * @return control, which owns the visual at aIndex. |
|
219 */ |
|
220 CAlfWidgetControl* getControl(CAlfVisual& aVisual) const; |
|
221 |
|
222 /** |
|
223 * finds the root visual for a control |
|
224 * |
|
225 * @param aControl control, which rootvisual is searched |
|
226 * @return root visual |
|
227 */ |
|
228 CAlfVisual* findRootVisual(CAlfWidgetControl* aControl) const; |
|
229 |
|
230 /** |
|
231 * checks, that layout is created. If not, throws an exception. |
|
232 */ |
|
233 void checkLayout() const; |
|
234 |
|
235 private: |
|
236 |
|
237 /** |
|
238 * the layout created and used by the layout manager. |
|
239 * Destroyed along with instance of this class. |
|
240 */ |
|
241 auto_ptr<CAlfLayout> mLayout; |
|
242 |
|
243 /** |
|
244 * the layout type of mLayout |
|
245 */ |
|
246 TAlfLayoutType mLayoutType; |
|
247 }; |
|
248 |
|
249 } // namespace Alf |
|
250 |
|
251 #endif // ALFLAYOUTMANAGERIMPL |