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