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