|
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: Single style implementation for the abstract tree node class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AKNSINGLESTYLETREENODE_H |
|
20 #define C_AKNSINGLESTYLETREENODE_H |
|
21 |
|
22 |
|
23 #include "akntreenode.h" |
|
24 |
|
25 |
|
26 /** |
|
27 * Single style implementation for the abstract tree node class. |
|
28 * |
|
29 * Single style tree nodes can contain single row of text, separate icon |
|
30 * for expaneded and collapsed state, and two optional icons. Each of these |
|
31 * icons can also have an alternate representation, which is used when the |
|
32 * item is highlighted. |
|
33 * |
|
34 * @lib aknhlist.lib |
|
35 * @since S60 v3.2 |
|
36 */ |
|
37 NONSHARABLE_CLASS( CAknSingleStyleTreeNode ) : public CAknTreeNode |
|
38 { |
|
39 |
|
40 public: |
|
41 |
|
42 /** Icon types for single style tree node. */ |
|
43 enum TIconType |
|
44 { |
|
45 /** Icon for node's expanded state. */ |
|
46 EExpandedIcon, |
|
47 /** Icon for node's collapsed state. */ |
|
48 ECollapsedIcon, |
|
49 /** First optional icon. */ |
|
50 EOptIcon1, |
|
51 /** Second optional icon. */ |
|
52 EOptIcon2, |
|
53 /** Highlighted icon for node's expanded state. */ |
|
54 EHighlightedExpandedIcon, |
|
55 /** Highlighted icon for node's collapsed state. */ |
|
56 EHighlightedCollapsedIcon, |
|
57 /** Highlighted first optional icon. */ |
|
58 EHighlightedOptIcon1, |
|
59 /** Highlighted second optional icon. */ |
|
60 EHighlightedOptIcon2 |
|
61 }; |
|
62 |
|
63 /** |
|
64 * Two-phased constructor. Creates a single style tree node instance. |
|
65 * |
|
66 * @param aText Text for the node. |
|
67 * |
|
68 * @param aFlags Flags. |
|
69 * |
|
70 * @return Pointer to the newly created object. |
|
71 * |
|
72 * @leave KErrNoMemory Not enough memory. |
|
73 */ |
|
74 static CAknSingleStyleTreeNode* NewL( const TDesC& aText, TUint32 aFlags ); |
|
75 |
|
76 /** |
|
77 * Otherwise identical to @c NewL, but leaves the newly created object in |
|
78 * the cleanup stack. |
|
79 * |
|
80 * @copydoc CAknSingleStyleTreeNode::NewL( const TDesC&, TUint32 ) |
|
81 * |
|
82 * @post Pointer to the newly created object is left in cleanup stack. |
|
83 */ |
|
84 static CAknSingleStyleTreeNode* NewLC( const TDesC& aText, TUint32 aFlags ); |
|
85 |
|
86 /** |
|
87 * Destructor. |
|
88 */ |
|
89 virtual ~CAknSingleStyleTreeNode(); |
|
90 |
|
91 /** |
|
92 * Text of the node. |
|
93 * |
|
94 * @return Text. |
|
95 */ |
|
96 const TDesC& Text() const; |
|
97 |
|
98 /** |
|
99 * Sets the text for the node. Does not change the position of the node |
|
100 * in the tree. |
|
101 * |
|
102 * @param aText Text. |
|
103 * |
|
104 * @param aDrawNow @c ETrue to redraw the item after the text is changed. |
|
105 * |
|
106 * @leave KErrNoMemory Not enough memory. |
|
107 */ |
|
108 void SetTextL( const TDesC& aText, TBool aDrawNow ); |
|
109 |
|
110 /** |
|
111 * Returns the icon ID set for the specified icon type. |
|
112 * |
|
113 * @param aType Type of the icon. |
|
114 * |
|
115 * @return The icon ID for the icon of specified type.The value |
|
116 * @c AknTreeListIconID::KDefault is returned, if no icon for the |
|
117 * specified type is set. |
|
118 */ |
|
119 TInt Icon( TIconType aType ) const; |
|
120 |
|
121 /** |
|
122 * Sets an icon ID for a specified tree node icon type. The icon ID |
|
123 * indicates which icon from the tree is used when the icon of specified |
|
124 * type is drawn by the node. |
|
125 * |
|
126 * @param aType The icon type for which the icon ID is changed. The type |
|
127 * has to be one of the types defined in @c TIconType enumeration. |
|
128 * |
|
129 * @param aIconId The new icon ID for the specified icon type. The value |
|
130 * @c AknTreeListIconID::KDefault indicates that the default icon |
|
131 * for the type is to be used. |
|
132 * |
|
133 * @param aDrawNow @c ETrue to redraw the item after the icon is changed. |
|
134 */ |
|
135 void SetIcon( TIconType aType, TInt aIconId, TBool aDrawNow ); |
|
136 |
|
137 /** |
|
138 * Determines which icon ID is to be used when drawing the node. The used |
|
139 * icon depends on the value of @c aFocused parameter, which icon IDs have |
|
140 * been set, and whether the node is expanded or collapsed. |
|
141 * |
|
142 * @param aFocused @c ETrue, if icon ID for focused item is required. |
|
143 * |
|
144 * @return Icon ID. |
|
145 */ |
|
146 TInt IconId( TBool aFocused ) const; |
|
147 |
|
148 /** |
|
149 * Determines which icon ID is to be used for the specified optional icon. |
|
150 * |
|
151 * @param aIndex Index specifying the optional icon. |
|
152 * |
|
153 * @param aFocused @c ETrue, if icon ID for focused item is required. |
|
154 * |
|
155 * @return Icon ID for specified optional icon. |
|
156 */ |
|
157 TInt OptionalIconId( TInt aIndex, TBool aFocused ) const; |
|
158 |
|
159 /** |
|
160 * Text variety depending on given optional icon IDs. |
|
161 * |
|
162 * @param aOptIconId1 Icon ID for first optional icon. |
|
163 * |
|
164 * @param aOptIconId2 Icon ID for second optional icon. |
|
165 * |
|
166 * @return Text layout variety. |
|
167 */ |
|
168 TInt TextVariety( TInt aOptIconId1, TInt aOptIconId2 ) const; |
|
169 |
|
170 // from base class CAknTreeItem |
|
171 |
|
172 /** |
|
173 * From CAknTreeItem. |
|
174 * Returns the type of the item. |
|
175 * |
|
176 * @return Item type. |
|
177 */ |
|
178 TInt Type() const; |
|
179 |
|
180 /** |
|
181 * From CAknTreeItem. |
|
182 * Draws the node. |
|
183 * |
|
184 * @param aGc Graphic context. |
|
185 * |
|
186 * @param aItemRect Item rectangle. |
|
187 * |
|
188 * @param aRect Rectangle that needs to be redrawn. |
|
189 * |
|
190 * @param aFocused @c ETrue, when the item is focused. |
|
191 */ |
|
192 void Draw( CWindowGc& aGc, const TRect& aItemRect, |
|
193 const TRect& aRect, TBool aFocused ) const; |
|
194 |
|
195 /** |
|
196 * From CAknTreeItem. |
|
197 * Handles pointer events. |
|
198 * |
|
199 * @param aPointerEvent Pointer event. |
|
200 * |
|
201 * @param aItemRect Item rectangle. |
|
202 */ |
|
203 void HandlePointerEventL( const TPointerEvent& aPointerEvent, |
|
204 const TRect& aItemRect ); |
|
205 |
|
206 private: |
|
207 |
|
208 /** |
|
209 * C++ constructor. |
|
210 * |
|
211 * @param aFlags Flags. |
|
212 */ |
|
213 CAknSingleStyleTreeNode( TUint32 aFlags ); |
|
214 |
|
215 /** |
|
216 * Second phase constructor. |
|
217 * |
|
218 * @param aText Text. |
|
219 */ |
|
220 void ConstructL( const TDesC& aText ); |
|
221 |
|
222 private: // data |
|
223 |
|
224 /** |
|
225 * Text. |
|
226 * Own. |
|
227 */ |
|
228 HBufC* iText; |
|
229 |
|
230 /** |
|
231 * Icon ID for expanded node icon. |
|
232 */ |
|
233 TInt iExpandedIcon; |
|
234 |
|
235 /** |
|
236 * Icon ID for collapsed node icon. |
|
237 */ |
|
238 TInt iCollapsedIcon; |
|
239 |
|
240 /** |
|
241 * Icon ID for first optional node icon. |
|
242 */ |
|
243 TInt iOptIcon1; |
|
244 |
|
245 /** |
|
246 * Icon ID for second optional node icon. |
|
247 */ |
|
248 TInt iOptIcon2; |
|
249 |
|
250 /** |
|
251 * Icon ID for highlighted expanded node icon. |
|
252 */ |
|
253 TInt iHighlightedExpandedIcon; |
|
254 |
|
255 /** |
|
256 * Icon ID for highlighted collapsed node icon. |
|
257 */ |
|
258 TInt iHighlightedCollapsedIcon; |
|
259 |
|
260 /** |
|
261 * Icon ID for first highlighted optional node icon. |
|
262 */ |
|
263 TInt iHighlightedOptIcon1; |
|
264 |
|
265 /** |
|
266 * Icon ID for second highlighted optional node icon. |
|
267 */ |
|
268 TInt iHighlightedOptIcon2; |
|
269 |
|
270 }; |
|
271 |
|
272 |
|
273 #endif // C_AKNSINGLESTYLETREENODE_H |