|
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: The interface and the basic implementation for presentation elements. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef I_ALFELEMENT_H |
|
20 #define I_ALFELEMENT_H |
|
21 |
|
22 #include <alf/ialfinterfacebase.h> |
|
23 #include <alf/alftypes.h> |
|
24 #include <osn/osntypes.h> |
|
25 |
|
26 class CAlfVisual; |
|
27 class CAlfLayout; |
|
28 |
|
29 using namespace osncore; |
|
30 |
|
31 namespace duiuimodel |
|
32 { |
|
33 class DuiNode; |
|
34 } |
|
35 using namespace duiuimodel; |
|
36 |
|
37 namespace Alf |
|
38 { |
|
39 //FORWARD DECLARATION |
|
40 class IAlfVariantType; |
|
41 class IAlfBranch; |
|
42 class IAlfWidgetControl; |
|
43 class AlfCustomInitDataBase; |
|
44 class IAlfVisualTemplate; |
|
45 |
|
46 namespace alfelement |
|
47 { |
|
48 static const IfId ident= |
|
49 { |
|
50 0,"alfelement" |
|
51 }; |
|
52 } |
|
53 |
|
54 /** |
|
55 * The interface for presentation elements. |
|
56 * The presentation of a widget can be divided into parts by using |
|
57 * elements. Each element is responsible for populating and maintaining |
|
58 * a specific part of the presentation. The element creates and updates |
|
59 * visual trees according to the data provided by the control. Elements |
|
60 * may also implement presentation logic, such as visual lifetime and |
|
61 * resource management, scrolling, and animations. |
|
62 * |
|
63 * @lib alfwidgetmodel.lib |
|
64 * @since S60 ?S60_version |
|
65 * @status Draft |
|
66 */ |
|
67 class IAlfElement : public IAlfInterfaceBase |
|
68 { |
|
69 public: |
|
70 static inline const IfId& type() |
|
71 { |
|
72 return alfelement::ident; |
|
73 } |
|
74 /** |
|
75 * Get the name of the element. |
|
76 * |
|
77 * @since S60 ?S60_version |
|
78 * @return The name of the element. |
|
79 */ |
|
80 virtual const char* name() const = 0; |
|
81 |
|
82 /** |
|
83 * Create a new visual tree to the child element of this element. |
|
84 * Some elements, e.g., CAlfRecyclingGridElement and CAlfRecyclingCurvePathElement |
|
85 * implement visual lifetime management to control the creation of the |
|
86 * visual trees in the child elements. This method can be implemented to |
|
87 * control, if the visual tree should be created or not. |
|
88 * |
|
89 * @since S60 ?S60_version |
|
90 * @param aElement The child element. |
|
91 * @param aChildData The data for the new visual tree. |
|
92 * @param aData The parent branch of the added data. Used to determine the |
|
93 * visual trees that have outdated data IDs. |
|
94 * |
|
95 * @param aIndex The index of the new data . |
|
96 */ |
|
97 virtual void createChildVisualTree( IAlfElement* aElement, |
|
98 IAlfVariantType& aChildData, |
|
99 IAlfBranch& aData, |
|
100 int aIndex, uint aDataID ) = 0; |
|
101 |
|
102 /** |
|
103 * |
|
104 * |
|
105 * @since S60 ?S60_version |
|
106 * @param aData |
|
107 * @param aParentData |
|
108 * @param aIndex |
|
109 * @param aParentDataID |
|
110 * @param aParentLayout |
|
111 * @param aLayoutIndex |
|
112 * @return |
|
113 */ |
|
114 virtual CAlfVisual* createVisualTree( IAlfVariantType& aData, |
|
115 IAlfBranch& aParentData, |
|
116 int aIndex, uint aParentDataID, |
|
117 CAlfLayout* aParentLayout, |
|
118 int aLayoutIndex ) = 0; |
|
119 |
|
120 /** |
|
121 * |
|
122 * |
|
123 * @since S60 ?S60_version |
|
124 * @param aData |
|
125 * @param aDataID |
|
126 * @param aParentLayout |
|
127 * @param aLayoutIndex |
|
128 * @return |
|
129 */ |
|
130 virtual CAlfVisual* createVisualTree( IAlfVariantType& aData, |
|
131 uint aDataID, |
|
132 CAlfLayout* aParentLayout, |
|
133 int aLayoutIndex ) = 0; |
|
134 |
|
135 /** |
|
136 * |
|
137 * |
|
138 * @since S60 ?S60_version |
|
139 * @param aElement |
|
140 * @param aData |
|
141 * @param aIndex |
|
142 * @param aDataID |
|
143 * @return void |
|
144 */ |
|
145 virtual void removeChildVisualTree( IAlfElement* aElement, |
|
146 IAlfBranch& aData, |
|
147 int aIndex, uint aDataID ) = 0; |
|
148 |
|
149 /** |
|
150 * |
|
151 * |
|
152 * @since S60 ?S60_version |
|
153 * @param aParentData |
|
154 * @param aIndex |
|
155 * @param aParentDataID |
|
156 * @return void |
|
157 */ |
|
158 virtual void removeVisualTree( IAlfBranch& aParentData, int aIndex, |
|
159 uint aParentDataID ) = 0; |
|
160 |
|
161 /** |
|
162 * |
|
163 * |
|
164 * @since S60 ?S60_version |
|
165 * @param aData |
|
166 * @param aDataID |
|
167 * @return void |
|
168 */ |
|
169 virtual void removeVisualTree( IAlfVariantType& aData, uint aDataID ) = 0; |
|
170 |
|
171 /** |
|
172 * Create or update a visual tree according to the given data. A data id is assigned |
|
173 * to the created visual tree. If a visual tree with the given data id already |
|
174 * exists, the visuals are just updated. The caller is responsible for providing |
|
175 * the parent layout for the visual tree. The default parent layout may or may not |
|
176 * be used. |
|
177 * |
|
178 * @since S60 ?S60_version |
|
179 * @param aData The data for the visuals. |
|
180 * @param aOldData the old data for the visuals. The data, that is replaced. |
|
181 * @param aDataID The data id for the visual tree. |
|
182 * @return The created or updated visual tree. |
|
183 */ |
|
184 virtual void updateVisualTree( IAlfVariantType& aNewData, |
|
185 IAlfVariantType& aOldData, |
|
186 uint aDataID ) = 0; |
|
187 |
|
188 /** |
|
189 * Replace an existing visual tree with a new one. A data id is used |
|
190 * to find the visual tree to be replaced. A new data id is assigned |
|
191 * to the visual tree, and the visuals are updated according to the |
|
192 * given data. The method is used for recycling visual trees for |
|
193 * a large number of presentation instances (@see CAlfRecyclingGridElement). |
|
194 * The structure of the new visual tree should match the structure |
|
195 * of the replaced visual tree. Otherwise, the visuals structure |
|
196 * needs to be modified by creating and destroying visuals. The visual |
|
197 * tree remains in the same layout as it was before. |
|
198 * |
|
199 * @since S60 ?S60_version |
|
200 * @param aData The data for the new visuals. |
|
201 * @param aDataID The data id for the new visual tree. |
|
202 * @param aOldDataID The data id of the visual tree to be replaced. |
|
203 */ |
|
204 virtual void replaceVisualTree( IAlfVariantType& aData, |
|
205 uint aDataID, uint aOldDataID ) = 0; |
|
206 |
|
207 /** |
|
208 * |
|
209 * |
|
210 * @since S60 ?S60_version |
|
211 * @param aParentBranch |
|
212 * @param aStartIndex |
|
213 * @param aOffset |
|
214 * @param aOldParentDataId |
|
215 * @param aParentDataID |
|
216 * @return void |
|
217 */ |
|
218 virtual void updateDataIDs( IAlfBranch& aParentBranch, int aStartIndex, |
|
219 int aOffset, uint aOldParentDataId, |
|
220 uint aParentDataID ) = 0; |
|
221 |
|
222 /** |
|
223 * Get the default parent layout for the visual trees created by this element. |
|
224 * The default parent layout is used for all root level elements (@see RootElement()). |
|
225 * |
|
226 * @since S60 ?S60_version |
|
227 * @param aParentDataID The data id associated with the parent element instance. |
|
228 * @return The default layout for the visual trees created by this element, or NULL |
|
229 * if the default layout does not exist. |
|
230 */ |
|
231 virtual CAlfLayout* defaultParentLayout(uint aParentDataID) = 0; |
|
232 |
|
233 /** |
|
234 * Find a visual according to the name of the visual and the data id |
|
235 * used to create the visual tree. |
|
236 * |
|
237 * @param aName The name of the visual. |
|
238 * @param aDataID The data id associated with the visual tree. |
|
239 * @return The default layout for the visual trees created by this element. |
|
240 */ |
|
241 virtual CAlfVisual* findVisual(const char* aName, uint aDataID) = 0; |
|
242 |
|
243 /** |
|
244 * Get the data id of a visual tree created by this element. |
|
245 * |
|
246 * @param aVisual The root of the visual tree. |
|
247 * @return The data id associated with the visual tree. |
|
248 */ |
|
249 virtual uint dataID(const CAlfVisual& aVisual) const = 0; |
|
250 |
|
251 /** |
|
252 * Get the parent element of this element. Some elements may have |
|
253 * child elements (@see CAlfRecyclingGridElement). In this case, |
|
254 * the parent element is responsible for populating the child elements. |
|
255 * Elements with no parent element are called root elements and |
|
256 * populated directly by the control. |
|
257 * |
|
258 * @since S60 ?S60_version |
|
259 * @return The parent element, or NULL if this is a root element. |
|
260 */ |
|
261 virtual const IAlfElement* parentElement() const = 0 ; |
|
262 |
|
263 /** |
|
264 * Set the parent element for this element. |
|
265 * |
|
266 * @since S60 ?S60_version |
|
267 * @param aParent The parent element of this element. |
|
268 */ |
|
269 virtual void setParentElement(IAlfElement& aParent) = 0; |
|
270 |
|
271 /** |
|
272 * removes and destroys all the visuals |
|
273 * |
|
274 * @since S60 ?S60_version |
|
275 * @param aTimeMilliseconds the animation time for remove. |
|
276 */ |
|
277 virtual void removeAndDestroyVisuals( int aTimeMilliseconds ) = 0; |
|
278 |
|
279 /** |
|
280 * Checks if referred visual is part of this element. |
|
281 * |
|
282 * @since S60 ?S60_version |
|
283 * @param aVisual reference to visual under inspection. |
|
284 */ |
|
285 virtual bool contains(CAlfVisual& aVisual) const = 0; |
|
286 |
|
287 /** |
|
288 * Sets the visual template for the element. This element |
|
289 * will acquire ownership of the visual template hierarchy |
|
290 * under the given visual template. |
|
291 * Call to this method cannot throw an exception. |
|
292 * |
|
293 * @since S60 ?S60_version |
|
294 * @param aTemplate Root of the visual template hierarchy to be set |
|
295 * into the widget element. |
|
296 */ |
|
297 virtual void setVisualTemplate(IAlfVisualTemplate& aTemplate) throw() = 0; |
|
298 |
|
299 /** |
|
300 * Returns the root visual template of the visual template hierarchy |
|
301 * owned by this element. Call to this method cannot throw an exception. |
|
302 * |
|
303 * @since S60 ?S60_version |
|
304 * @param aType A descriptor to identify the type of the queried interface. |
|
305 * @return The queried interface, or NULL if the interface is not |
|
306 * supported or available. |
|
307 */ |
|
308 virtual IAlfVisualTemplate* getVisualTemplate() const throw() = 0; |
|
309 |
|
310 /** |
|
311 * Destroyes the visual template object assigned to this element and the whole |
|
312 * visual template hierarchy under it. Call to this method cannot throw an exception. |
|
313 * |
|
314 * @since S60 ?S60_version |
|
315 */ |
|
316 virtual void destroyVisualTemplate() throw() = 0; |
|
317 |
|
318 /** |
|
319 * Removes the visual template from this element. Returns pointer to the removed visual |
|
320 * template object. The ownership of the visual template object is transferred to the |
|
321 * caller. Call to this method cannot throw an exception. |
|
322 * |
|
323 * @since S60 ?S60_version |
|
324 * |
|
325 * @return The visual template object that was owned by this element. NULL if no visual |
|
326 * template hierarchy was owned by this element. |
|
327 */ |
|
328 virtual IAlfVisualTemplate* removeVisualTemplate() throw() = 0; |
|
329 |
|
330 /** |
|
331 * Destructor |
|
332 */ |
|
333 virtual ~IAlfElement(){} |
|
334 }; |
|
335 |
|
336 |
|
337 /** |
|
338 * Placeholder for information required to instantiate an element |
|
339 * via the widget factory mechanism. |
|
340 * A pointer to this structure is casted to a void pointer and sent to the |
|
341 * factory plugin. |
|
342 * @lib alfwidgetmodel.lib |
|
343 * @since S60 ?S60_version |
|
344 */ |
|
345 struct AlfElementInitData |
|
346 { |
|
347 /** |
|
348 * Owner control for the element. |
|
349 */ |
|
350 IAlfWidgetControl* mControl; |
|
351 /** |
|
352 * Element instance ID.This uniquely identifies every element instance |
|
353 * and is its name. Also see AlfElement::name(). |
|
354 */ |
|
355 char* mElementId; |
|
356 |
|
357 /** |
|
358 * Pointer to node in declaration containing information for the element. |
|
359 */ |
|
360 DuiNode* mNode; |
|
361 |
|
362 /** |
|
363 * Pointer to custom data passed via factory mechanism |
|
364 * Not Owned. |
|
365 */ |
|
366 AlfCustomInitDataBase* mCustomData; |
|
367 }; |
|
368 |
|
369 |
|
370 } // namespace Alf |
|
371 #endif // I_ALFELEMENT_H |
|
372 |
|
373 // End of File |