|
1 /* |
|
2 * Copyright (c) 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: AknTreeListView physics handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AKNTREELISTPHYSICSHANDLER_H |
|
20 #define C_AKNTREELISTPHYSICSHANDLER_H |
|
21 |
|
22 |
|
23 #include <e32base.h> |
|
24 #include <aknphysicsobserveriface.h> |
|
25 |
|
26 class CAknPhysics; |
|
27 class CAknTreeItem; |
|
28 class CAknTree; |
|
29 class CAknTreeListView; |
|
30 class CWindowGc; |
|
31 class MTouchFeedback; |
|
32 /** |
|
33 * Tree list physics handler. |
|
34 * |
|
35 * @lib aknhlist |
|
36 * @since S60 v5.0 |
|
37 */ |
|
38 NONSHARABLE_CLASS( CAknTreeListPhysicsHandler ) : public CBase, |
|
39 public MAknPhysicsObserver |
|
40 { |
|
41 |
|
42 public: |
|
43 |
|
44 /** |
|
45 * Two-phased constructor. |
|
46 */ |
|
47 static CAknTreeListPhysicsHandler* NewL( CAknTreeListView* aTreeListView, |
|
48 CAknTree* aTree, |
|
49 RArray<TAknTreeListViewItem>* aItems ); |
|
50 |
|
51 /** |
|
52 * Two-phased constructor. |
|
53 */ |
|
54 static CAknTreeListPhysicsHandler* NewLC( CAknTreeListView* aTreeListView, |
|
55 CAknTree* aTree, |
|
56 RArray<TAknTreeListViewItem>* aItems ); |
|
57 /** |
|
58 * Destructor. |
|
59 */ |
|
60 virtual ~CAknTreeListPhysicsHandler(); |
|
61 |
|
62 public: |
|
63 |
|
64 /** |
|
65 * Handles the pointer event received by tree list view. |
|
66 * |
|
67 * @param aPointerEvent Pointer event to handle. |
|
68 * @param aViewLevel Tree list view level. |
|
69 * @param aMarking Item marking mode. |
|
70 * @param aShiftPressed Hw shift key. |
|
71 * @param aCtrlPressed Hw control key. |
|
72 */ |
|
73 void HandlePointerEventL( const TPointerEvent& aPointerEvent, |
|
74 const TInt& aViewLevel, |
|
75 TBool aMarking, |
|
76 TBool aShiftPressed, |
|
77 TBool aCtrlPressed ); |
|
78 |
|
79 /** |
|
80 * Handles the scroll event received by tree list view. |
|
81 * |
|
82 * @param aEventType Scroll event to handle. |
|
83 * @param aThumbPosition Scroll bar thumb position. |
|
84 */ |
|
85 void HandleScrollEventL( TEikScrollEvent aEventType, |
|
86 const TInt& aThumbPosition ); |
|
87 |
|
88 /** |
|
89 * Handles key events for scroll physics |
|
90 * |
|
91 * @param aKeyCode Hw key code. |
|
92 */ |
|
93 void HandleKeyEvent( TInt aKeyCode ); |
|
94 |
|
95 /** |
|
96 * Sets view rect. |
|
97 * |
|
98 * @param aRect New view rect. |
|
99 */ |
|
100 void SetViewRect( const TRect& aRect ); |
|
101 |
|
102 /** |
|
103 * Returns view rect. |
|
104 */ |
|
105 TRect ViewRect( ) const; |
|
106 |
|
107 /** |
|
108 * Sets item height. |
|
109 * |
|
110 * @param aHeight New item height. |
|
111 */ |
|
112 void SetItemHeight( const TInt& aHeight ); |
|
113 |
|
114 /** |
|
115 * Returns offset. Used to draw partial items. |
|
116 */ |
|
117 TInt Offset() const; |
|
118 |
|
119 /** |
|
120 * Initializes physics. |
|
121 */ |
|
122 void InitPhysicsL(); |
|
123 |
|
124 /** |
|
125 * Resets the pointer event disabling/enabling status. |
|
126 */ |
|
127 void ResetEventBlockingStatus(); |
|
128 |
|
129 /** |
|
130 * Provides vertical scroll bar parameters. |
|
131 * |
|
132 * @param aThumbSpan |
|
133 * @param aThumbPos |
|
134 * @param aScrollSpan |
|
135 */ |
|
136 void GetVScrollbarParams( TInt& aThumbSpan, |
|
137 TInt& aThumbPos, |
|
138 TInt& aScrollSpan ); |
|
139 |
|
140 /** |
|
141 * Returns ETrue if focused item is visible. |
|
142 * |
|
143 * @param aFocusedIndex Focused item index. |
|
144 * @return ETrue if focused item is visible. |
|
145 */ |
|
146 TBool FocusedItemVisible( const TInt& aFocusedIndex ) const; |
|
147 |
|
148 /** |
|
149 * Returns the first visible item index. |
|
150 * |
|
151 * @return First visible item index. |
|
152 */ |
|
153 TInt FirstVisibleItemIndex() const; |
|
154 |
|
155 /** |
|
156 * Returns the last visible item index. |
|
157 * |
|
158 * @return Last visible item index. |
|
159 */ |
|
160 TInt LastVisibleItemIndex() const; |
|
161 |
|
162 /** |
|
163 * Updates the scroll index. |
|
164 * |
|
165 * @param aScrollTop ETrue if scroll index should be adjusted according to |
|
166 * first visible item, EFalse if last item. |
|
167 */ |
|
168 void UpdateScrollIndex( const TBool& aScrollTop ); |
|
169 |
|
170 public: // From base class MAknPhysicsObserver. |
|
171 |
|
172 /** |
|
173 * Called when view position changes. |
|
174 * |
|
175 * @param aNewPosition The new position of the view. |
|
176 * @param aDrawNow @c ETrue if the screen is to be redrawn, |
|
177 * otherwise @c EFalse. |
|
178 * @param aFlags Additional flags, not used currently. |
|
179 */ |
|
180 virtual void ViewPositionChanged( const TPoint& aNewPosition, |
|
181 TBool aDrawNow = ETrue, |
|
182 TUint aFlags = 0 ); |
|
183 |
|
184 /** |
|
185 * Called when emulation has ended. |
|
186 */ |
|
187 virtual void PhysicEmulationEnded(); |
|
188 |
|
189 /** |
|
190 * Returns the observer's view position. |
|
191 * |
|
192 * @return Physics observer's view position. |
|
193 */ |
|
194 virtual TPoint ViewPosition() const; |
|
195 |
|
196 public: // New methods. |
|
197 |
|
198 /** |
|
199 * Sets graphics context used by listbox effects. |
|
200 */ |
|
201 void SetGc( CWindowGc* aGc ); |
|
202 |
|
203 private: |
|
204 |
|
205 /** |
|
206 * C++ constructor. |
|
207 */ |
|
208 CAknTreeListPhysicsHandler( CAknTreeListView* aTreeListView, |
|
209 CAknTree* aTree, |
|
210 RArray<TAknTreeListViewItem>* aItems ); |
|
211 |
|
212 /** |
|
213 * Symbian second-phase constructor. |
|
214 */ |
|
215 void ConstructL(); |
|
216 |
|
217 /** |
|
218 * Returns drag threshold. |
|
219 * |
|
220 * @return drag threshold. |
|
221 */ |
|
222 TInt DragThreshold(); |
|
223 |
|
224 /** |
|
225 * Launches the highlight timer. |
|
226 * |
|
227 * @param aWasScrolling ETrue if content was scrolling. In that case |
|
228 * highlight is drawn with timeout. |
|
229 */ |
|
230 void LaunchHighlightTimer( TBool aWasScrolling ); |
|
231 |
|
232 /** |
|
233 * Callback method for highlight timer. |
|
234 * |
|
235 * @param aThis Pointer to an instance of @c CAknTreeListView class. |
|
236 * |
|
237 * @return @c NULL, as function is intended to be called only once. |
|
238 */ |
|
239 static TInt HighlightTimerCallback( TAny* aPtr ); |
|
240 |
|
241 /** |
|
242 * Sets highlight to focused item. |
|
243 */ |
|
244 void SetHighlight(); |
|
245 |
|
246 /** |
|
247 * Moves view to correct position. |
|
248 * |
|
249 * @param ETrue to redraw the view after movement |
|
250 */ |
|
251 void ScrollView( TBool aDrawNow ); |
|
252 |
|
253 /** |
|
254 * Stops physics. |
|
255 */ |
|
256 void StopPhysics(); |
|
257 |
|
258 /** |
|
259 * Returns world height. |
|
260 * |
|
261 * @return World height. |
|
262 */ |
|
263 TInt WorldHeight(); |
|
264 |
|
265 /** |
|
266 * Returns wheter pointer click is in empty list area. |
|
267 * |
|
268 * @return ETrue if aPosition is in empty list area. |
|
269 */ |
|
270 TBool EmptyAreaClicked( TPoint aPosition ); |
|
271 |
|
272 private: // data |
|
273 |
|
274 /** |
|
275 * Scroll index. |
|
276 */ |
|
277 TInt iScrollIndex; |
|
278 |
|
279 /** |
|
280 * Previous scroll index. |
|
281 */ |
|
282 TInt iPreviousIndex; |
|
283 |
|
284 /** |
|
285 * Height of one item. |
|
286 */ |
|
287 TInt iItemHeight; |
|
288 |
|
289 /** |
|
290 * Current pointer position. |
|
291 */ |
|
292 TPoint iPosition; |
|
293 |
|
294 /** |
|
295 * Start (pointer down) position. |
|
296 */ |
|
297 TPoint iStartPosition; |
|
298 |
|
299 /** |
|
300 * View rect. |
|
301 */ |
|
302 TRect iViewRect; |
|
303 |
|
304 /** |
|
305 * ETrue if pointer events are blocked. |
|
306 */ |
|
307 TBool iEventsBlocked; |
|
308 |
|
309 /** |
|
310 * ETrue if pointer events are enabled. |
|
311 */ |
|
312 TBool iEnableEvents; |
|
313 |
|
314 /** |
|
315 * ETrue if panning functionality is activated. |
|
316 */ |
|
317 TBool iPanningActivated; |
|
318 |
|
319 /** |
|
320 * Pointer down start time. |
|
321 */ |
|
322 TTime iStartTime; |
|
323 |
|
324 /** |
|
325 * Physics. |
|
326 * Own. |
|
327 */ |
|
328 CAknPhysics *iPhysics; |
|
329 |
|
330 /** |
|
331 * Highlight timer. |
|
332 * Own. |
|
333 */ |
|
334 CPeriodic* iHighlightTimer; |
|
335 |
|
336 /** |
|
337 * Pointer to the list item to be focused by highlight timer. |
|
338 * Not own. |
|
339 */ |
|
340 CAknTreeItem* iItemToBeFocused; |
|
341 |
|
342 /** |
|
343 * Pointer to the list item to be selected. |
|
344 * Not own. |
|
345 */ |
|
346 CAknTreeItem* iItemToBeSelected; |
|
347 |
|
348 /** |
|
349 * Index of the list item to be focused by highlight timer. |
|
350 */ |
|
351 TInt iIndexToBeFocused; |
|
352 |
|
353 /** |
|
354 * Physics handler flags. |
|
355 */ |
|
356 TBitFlags iFlags; |
|
357 |
|
358 /** |
|
359 * Pointer to tree. |
|
360 * Not own. |
|
361 */ |
|
362 CAknTree* iTree; |
|
363 |
|
364 /** |
|
365 * Pointer to tree list view. |
|
366 * Not own. |
|
367 */ |
|
368 CAknTreeListView* iTreeListView; |
|
369 |
|
370 /** |
|
371 * Pointer to array for visible view items. |
|
372 * Not own. |
|
373 */ |
|
374 RArray<TAknTreeListViewItem>* iItems; |
|
375 |
|
376 /** |
|
377 * Offset between list first item position and view rect position. |
|
378 */ |
|
379 TInt iListTopOffset; |
|
380 |
|
381 /** |
|
382 * Graphics context used by the parent listbox. Needed for transition |
|
383 * effects. |
|
384 */ |
|
385 CWindowGc* iTfxGc; |
|
386 |
|
387 /** |
|
388 * Determines whether or not next up event should cause basic list |
|
389 * feedback. The value is determined always on down event. If the value |
|
390 * on up event is EFalse, feedback is not played. If the value is ETrue, |
|
391 * basic list feedback is produced. |
|
392 */ |
|
393 TBool iPlayFeedbackOnUp; |
|
394 |
|
395 /** |
|
396 * Pointer to the feedback object. Not owned. |
|
397 */ |
|
398 MTouchFeedback* iFeedback; |
|
399 // when touch down, it is true for recording physics Y of current view |
|
400 TBool iPenDown; |
|
401 // top item in current view, -1 if item's Y is negative |
|
402 TInt iOldTopItem; |
|
403 // bottom item in current view, fields count when Y is larger than |
|
404 // the last item's Y |
|
405 TInt iOldBottomItem; |
|
406 /** |
|
407 * ETrue if empty list area is clicked. |
|
408 */ |
|
409 TBool iEmptyAreaClicked; |
|
410 }; |
|
411 |
|
412 |
|
413 #endif // C_AKNPHYSICSPARAMETERPROVIDER_H |