|
1 /* |
|
2 * Copyright (c) 2006-2009 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: Hierarchical list view item. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef T_AKNTREELISTVIEWITEM_H |
|
20 #define T_AKNTREELISTVIEWITEM_H |
|
21 |
|
22 |
|
23 #include <e32std.h> |
|
24 |
|
25 class CAknTreeItem; |
|
26 class CWindowGc; |
|
27 class CAknTreeListView; |
|
28 |
|
29 /** |
|
30 * Tree list view element responsible for drawing a row in tree list view. |
|
31 * |
|
32 * Each tree list view item contains a pointer to a tree list item that it is |
|
33 * representing in the view and a rectangle for the list item. The view item |
|
34 * is responsible for drawing the highlight for the focused item, the tree |
|
35 * structure lines for the tree list item, and mediating the redraw request |
|
36 * to the actual tree item with appropriate parameters. |
|
37 * |
|
38 * @lib aknhlist.lib |
|
39 * @since S60 v3.2 |
|
40 */ |
|
41 NONSHARABLE_CLASS( TAknTreeListViewItem ) |
|
42 { |
|
43 |
|
44 public: |
|
45 |
|
46 /** Types for hierarchical list tree structure line segments. */ |
|
47 enum TLineSegmentType |
|
48 { |
|
49 /** Straight line segment. */ |
|
50 ELineStraight, |
|
51 /** Angled ending line segment. */ |
|
52 ELineEnd, |
|
53 /** Branching line segment. */ |
|
54 ELineBranch |
|
55 }; |
|
56 |
|
57 /** |
|
58 * Default C++ constructor. |
|
59 */ |
|
60 TAknTreeListViewItem(); |
|
61 |
|
62 /** |
|
63 * C++ Constructor. |
|
64 * |
|
65 * @param aItem Tree item. |
|
66 * |
|
67 * @param aRect Rectangle of the view item. |
|
68 */ |
|
69 TAknTreeListViewItem( CAknTreeItem* aItem, const TRect& aRect ); |
|
70 |
|
71 /** |
|
72 * Copy constructor. |
|
73 * |
|
74 * @param aItem The instance to be copied. |
|
75 */ |
|
76 TAknTreeListViewItem( const TAknTreeListViewItem& aItem ); |
|
77 |
|
78 /** |
|
79 * Returns the tree item. |
|
80 * |
|
81 * @return The tree item. @c NULL, if not set. |
|
82 */ |
|
83 CAknTreeItem* Item() const; |
|
84 |
|
85 /** |
|
86 * Sets the tree item. |
|
87 * |
|
88 * @param aItem Tree item. |
|
89 */ |
|
90 void SetItem( CAknTreeItem* aItem ); |
|
91 |
|
92 /** |
|
93 * Returns the rectangle set for the view item. |
|
94 * |
|
95 * @return Size and position of the view item as rectangle. |
|
96 */ |
|
97 TRect Rect() const; |
|
98 |
|
99 /** |
|
100 * Sets the rectangle for the view item. |
|
101 * |
|
102 * @param aRect Rectangle specifying the size and position of the view item. |
|
103 */ |
|
104 void SetRect( const TRect& aRect ); |
|
105 |
|
106 |
|
107 /** |
|
108 * Sets the pointer to CAknTreeListView for the view item. |
|
109 * |
|
110 * @param aView Pointer to CAknTreeListView instance |
|
111 */ |
|
112 void SetView( CAknTreeListView* aView ); |
|
113 |
|
114 |
|
115 /** |
|
116 * Returns the rectangle for the tree item. |
|
117 * |
|
118 * @param aViewLevel The horizontal position of the view as indent steps. |
|
119 * |
|
120 * @param aIndention Specifies whether indention of items is enabled. |
|
121 * |
|
122 * @param aIndentionWidth Width of single indention step. Negative, if |
|
123 * default indention width is to be used. |
|
124 * |
|
125 * @return The rectange for the tree item. |
|
126 */ |
|
127 TRect ItemRect( TInt aViewLevel, TBool aIndention, |
|
128 TInt aIndentionWidth ) const; |
|
129 |
|
130 /** |
|
131 * Returns the highlight rectangle for the item. |
|
132 * |
|
133 * @param aViewLevel The horizontal position of the view as indent steps. |
|
134 * |
|
135 * @param aIndention Specifies whether indention of items is enabled. |
|
136 * |
|
137 * @param aIndentionWidth Width of single indention step. Negative, if |
|
138 * default indention width is to be used. |
|
139 * |
|
140 * @return The highlight rectangle. |
|
141 */ |
|
142 TRect HighlightRect( TInt aViewLevel, TBool aIndention, |
|
143 TInt aIndentionWidth ) const; |
|
144 |
|
145 /** |
|
146 * Returns the rectangle for tree structure line segment at the specified |
|
147 * horizontal position of the row. |
|
148 * |
|
149 * @param aIndex Index specifiyin the horizontal position of the |
|
150 * requested line segment rectangle. |
|
151 * |
|
152 * @return Requested tree structure line segment rectangle. |
|
153 */ |
|
154 TRect LineSegmentRect( TUint aIndex ) const; |
|
155 |
|
156 /** |
|
157 * Returns the width of one segment of tree structure lines. This value is |
|
158 * used to determine how much each tree item should be intended depending |
|
159 * on their position in tree structure. |
|
160 * |
|
161 * @return Width of one segment of tree structure lines. |
|
162 */ |
|
163 TInt LineSegmentWidth() const; |
|
164 |
|
165 /** |
|
166 * Draws the view item. |
|
167 * |
|
168 * @param aGc Graphic context. |
|
169 * |
|
170 * @param aTree Reference to the tree structure. |
|
171 * |
|
172 * @param aRect The rectangle that needs to be redrawn. |
|
173 * |
|
174 * @param aHighlight @c ETrue, if the item has highlight. |
|
175 * |
|
176 * @param aViewLevel Current level (horizontal position) of the view. |
|
177 * |
|
178 * @param aStructureLines @c ETrue, if the tree structure lines are to |
|
179 * be drawn. |
|
180 * |
|
181 * @param aIndention Specifies whether indention of items is enabled. |
|
182 * |
|
183 * @param aIndentionWidth Width of single indention step. Negative, if |
|
184 * default indention width is to be used. |
|
185 */ |
|
186 void Draw( CWindowGc& aGc, CAknTree& aTree, const TRect& aRect, |
|
187 TBool aHighlight, TInt aViewLevel, TBool aStructureLines, |
|
188 TBool aIndention, TInt aIndentionWidth ) const; |
|
189 |
|
190 /** |
|
191 * Handles pointer events. |
|
192 * |
|
193 * @param aPointerEvent Pointer event. |
|
194 * |
|
195 * @param aViewLevel The current horizontal position of the view. |
|
196 * |
|
197 * @param aIndention Specifies whether indention of items is enabled. |
|
198 * |
|
199 * @param aIndentionWidth Width of single indention step. Negative, if |
|
200 * default indention width is to be used. |
|
201 */ |
|
202 void HandlePointerEventL( const TPointerEvent& aPointerEvent, |
|
203 TInt aViewLevel, TBool aIndention, TInt aIndentionWidth ); |
|
204 |
|
205 private: |
|
206 |
|
207 /** |
|
208 * Draws a segment of hierarchical structure lines to appointed graphic |
|
209 * context. |
|
210 * |
|
211 * @param aGc Graphic context. |
|
212 * |
|
213 * @param aTree Reference to the tree structure. |
|
214 * |
|
215 * @param aSegmentRect Rectangle on graphic context co-ordinates to which |
|
216 * the tree structure line segement is drawn. |
|
217 * |
|
218 * @param aType Type of the tree structure line segment to be drawn. |
|
219 */ |
|
220 void DrawLineSegment( CWindowGc& aGc, CAknTree& aTree, |
|
221 const TRect& aSegmentRect, TLineSegmentType aType ) const; |
|
222 |
|
223 /** |
|
224 * Assignement operator. |
|
225 */ |
|
226 TAknTreeListViewItem& operator=( const TAknTreeListViewItem& ); |
|
227 |
|
228 private: // data |
|
229 |
|
230 /** |
|
231 * Pointer to tree item represented by this view item. |
|
232 * Not own. |
|
233 */ |
|
234 CAknTreeItem* iItem; |
|
235 |
|
236 /** |
|
237 * Rectangle assigned for the view item. |
|
238 */ |
|
239 TRect iRect; |
|
240 |
|
241 /** |
|
242 * The rectangle for the first segment of tree structure lines. |
|
243 */ |
|
244 TRect iLineSegmentRect; |
|
245 |
|
246 /** |
|
247 * CAknTreeListView |
|
248 */ |
|
249 CAknTreeListView* iView; |
|
250 |
|
251 }; |
|
252 |
|
253 |
|
254 #endif // T_AKNTREELISTVIEWITEM_H |