|
1 /* |
|
2 * Copyright (c) 2007-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: Visual Item class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef MULVISUALITEM_H |
|
20 #define MULVISUALITEM_H |
|
21 |
|
22 #include <osn/osndefines.h> |
|
23 #include <osn/ustring.h> |
|
24 #include <alf/alfvarianttype.h> |
|
25 #include <memory> |
|
26 #include <map> |
|
27 #include <vector> |
|
28 #include <e32cmn.h> |
|
29 |
|
30 namespace osncore |
|
31 { |
|
32 class UString; |
|
33 } |
|
34 using namespace osncore; |
|
35 using namespace std; |
|
36 |
|
37 |
|
38 namespace Alf |
|
39 { |
|
40 |
|
41 |
|
42 //enum mulvisualitem |
|
43 namespace mulvisualitem |
|
44 { |
|
45 |
|
46 enum TVisualAttribute |
|
47 { |
|
48 KMulIcon1 = 0, |
|
49 KMulIcon2 , |
|
50 KMulIcon3 , |
|
51 KMulTitle , |
|
52 KMulTitle1 , |
|
53 KMulTitle2 , |
|
54 KMulDetail , |
|
55 KMulDate , |
|
56 KMulIndicator1 , |
|
57 KMulIndicator2 , |
|
58 KMulIndicator3 , |
|
59 KMulIndicator4 , |
|
60 KMulIndicator5, |
|
61 KMulIndicator6, |
|
62 KMulActionItem , |
|
63 KMulEnabled , |
|
64 KMulSoftkeyTitle , |
|
65 KMulLatch , |
|
66 KMulRead , |
|
67 KMulInputText, |
|
68 KMulEmptyItem , |
|
69 KVisualItemProperties, |
|
70 KVisualItemAttributes , |
|
71 KAttributeTemplate, |
|
72 KMulMaxRange, |
|
73 KMulMinRange, |
|
74 KMulTick, |
|
75 KMulPrimaryTick, |
|
76 KMulSecondaryTick, |
|
77 KMulLeftText, |
|
78 KMulRightText, |
|
79 KMulCounter1, |
|
80 KMulCounter2, |
|
81 KMulImage, |
|
82 KMulPercent1, |
|
83 KMulPercent2, |
|
84 KMul_n, |
|
85 KLastAttribute = 100 // reserved 0 to 100 |
|
86 }; |
|
87 |
|
88 }//namespace mulvisualitem |
|
89 |
|
90 /* Forward declarations*/ |
|
91 class IAlfMap; |
|
92 class IAlfContainer; |
|
93 class IMulVariantType; |
|
94 /** |
|
95 /*! @class MulVisualItem |
|
96 * @brief Client need to use this class to add data in data model. |
|
97 * |
|
98 * Visual item is set of attributes corresponding to an item in the widget. |
|
99 * The attributes added to visual item get visualized on the widget |
|
100 * |
|
101 */ |
|
102 class MulVisualItem |
|
103 { |
|
104 private: |
|
105 |
|
106 class MulAttribute; |
|
107 |
|
108 public: |
|
109 |
|
110 /** |
|
111 * Flags for attribute |
|
112 */ |
|
113 enum TAttributeFlags |
|
114 { |
|
115 EDisposable = 0x01 // attribute with this flag on can be deleted from item is it is out of visible window |
|
116 }; |
|
117 |
|
118 enum TAttributeOwnership |
|
119 { |
|
120 EDoesOwn = 0, //attribute is owned by model |
|
121 EDoesNotOwn //attribute is not owned by model |
|
122 }; |
|
123 |
|
124 public: //Constructor and Dstructor |
|
125 |
|
126 /** |
|
127 * C++ constructor. |
|
128 */ |
|
129 OSN_IMPORT MulVisualItem(); |
|
130 |
|
131 /** |
|
132 * C++ constructor. |
|
133 */ |
|
134 OSN_IMPORT MulVisualItem( const MulVisualItem& aVisualData ); |
|
135 |
|
136 /** |
|
137 * Destructor. |
|
138 */ |
|
139 OSN_IMPORT ~MulVisualItem(); |
|
140 |
|
141 public: // New mehtod |
|
142 |
|
143 /** |
|
144 * Add new attribute to visual item |
|
145 * |
|
146 * @param aName name of attribute |
|
147 * @param aValue value of attribute |
|
148 * @param aAttributeFlags property of this attribute |
|
149 */ |
|
150 //OSN_IMPORT void SetAttribute( mulvisualitem::TVisualAttribute aName, const UString& aValue,int aAttributeFlags = 0 ); |
|
151 |
|
152 /** |
|
153 * Add new attribute to visual item |
|
154 * |
|
155 * @param aName name of attribute |
|
156 * @param aValue value of attribute |
|
157 * @param aAttributeFlags property of this attribute |
|
158 */ |
|
159 OSN_IMPORT void SetAttribute( mulvisualitem::TVisualAttribute aName, int aValue,int aAttributeFlags = 0 ); |
|
160 |
|
161 /** |
|
162 * Add new attribute to visual item |
|
163 * |
|
164 * @param aName name of attribute |
|
165 * @param aValue value of attribute |
|
166 * @param aAttributeFlags property of this attribute |
|
167 */ |
|
168 OSN_IMPORT void SetAttribute( mulvisualitem::TVisualAttribute aName, const TDesC& aValue ,int aAttributeFlags = 0 ); |
|
169 |
|
170 /** |
|
171 * Add new attribute to visual item |
|
172 * |
|
173 * @param aName name of attribute |
|
174 * @param aValue value of attribute |
|
175 * @param aAttributeFlags property of this attribute |
|
176 * @param aAttributeOwership If the value is EDoesOwn then the ownership |
|
177 * of the attribute transfered to the visual item else not. |
|
178 */ |
|
179 OSN_IMPORT void SetAttribute( mulvisualitem::TVisualAttribute aName, IMulVariantType* aValue, |
|
180 int aAttributeFlags = 0,TAttributeOwnership aAttributeOwership = EDoesOwn ); |
|
181 |
|
182 /** |
|
183 * Return Value of specified attribute |
|
184 * |
|
185 * @param aName name of attribute need to retrived |
|
186 * @return Value of attribute |
|
187 */ |
|
188 OSN_IMPORT IMulVariantType* Attribute( mulvisualitem::TVisualAttribute aName ) const; |
|
189 |
|
190 /** |
|
191 * Return Value of specified attribute as integer |
|
192 * |
|
193 * @param aName name of attribute need to retrived |
|
194 * @return Value of attribute |
|
195 */ |
|
196 OSN_IMPORT int AttributeAsInt( mulvisualitem::TVisualAttribute aName ) const; |
|
197 |
|
198 /** |
|
199 * Return Value of specified attribute as String |
|
200 * |
|
201 * @param aName name of attribute need to retrived |
|
202 * @return Value of attribute |
|
203 */ |
|
204 OSN_IMPORT const TDesC& AttributeAsString( mulvisualitem::TVisualAttribute aName ) const; |
|
205 |
|
206 /** |
|
207 * Return the existing attributes of the visual item |
|
208 * @return Vector of the names of the existing attributes |
|
209 */ |
|
210 OSN_IMPORT const std::vector<mulvisualitem::TVisualAttribute> Attributes() const; |
|
211 |
|
212 |
|
213 /** |
|
214 * Return the bool value if attribute is dirty(updated and not redrawn) |
|
215 * @return bool Value of attribute dirty status |
|
216 */ |
|
217 OSN_IMPORT bool IsDirty( mulvisualitem::TVisualAttribute aAttr ) const; |
|
218 |
|
219 |
|
220 /** |
|
221 * Return the flag of the attributes |
|
222 * @param aName name of attribute need to retrived |
|
223 * @return Value of flag of the attribute |
|
224 */ |
|
225 int Flag( mulvisualitem::TVisualAttribute aName ); |
|
226 |
|
227 /** |
|
228 * Remove attribute from visual item - required by garbage collector |
|
229 * |
|
230 * @param aName Attribute name to be removed |
|
231 */ |
|
232 void RemoveAttribute( mulvisualitem::TVisualAttribute aName ); |
|
233 |
|
234 /** |
|
235 * Sets the dirty flag for a Visual attribute |
|
236 * @param aDirty sets dirty flag to true/false |
|
237 * @return void |
|
238 */ |
|
239 void SetDirty(mulvisualitem::TVisualAttribute aAttr, bool aDirty); |
|
240 |
|
241 |
|
242 /** |
|
243 * Resets the dirty flag for a Visual attribute from input Visual item |
|
244 * @param const MulVisualItem& Visual item with input dirty flags |
|
245 * @return void |
|
246 */ |
|
247 void ResetDirtyAttribute(const MulVisualItem& aVisualItem); |
|
248 |
|
249 |
|
250 private: |
|
251 |
|
252 std::map< mulvisualitem::TVisualAttribute, MulAttribute* > mVisualItem; |
|
253 // Attribute flags - indicates which attributes are dirty(need redrawing) |
|
254 // Using 2 attributes to store 36 attributes (refer TVisualAttribute) |
|
255 unsigned int mBitAttrFlag1; // stores dirty bits of first 18 attributes |
|
256 unsigned int mBitAttrFlag2; // stores dirty bits of second 18 attributes |
|
257 }; |
|
258 |
|
259 } // namespace Alf |
|
260 |
|
261 #endif //MULVISUALITEM_H |
|
262 |
|
263 //End of file |