|
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: Implementation of class CFsTextViewerControl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //<cmail> removed __FS_ALFRED_SUPPORT flag |
|
20 //#include <fsconfig.h> |
|
21 //</cmail> removed __FS_ALFRED_SUPPORT flag |
|
22 // <cmail> SF |
|
23 #include "emailtrace.h" |
|
24 #include <alf/alfevent.h> |
|
25 #include <alf/alfstatic.h> |
|
26 #include <alf/alfenv.h> |
|
27 // </cmail> |
|
28 |
|
29 // <cmail> Needed for pointer events. "Base class modifications for using touch" |
|
30 #include <alf/alfdisplay.h> |
|
31 #include <alf/alfroster.h> |
|
32 #include <aknphysics.h> |
|
33 // </cmail> |
|
34 |
|
35 #include "fstextviewercontrol.h" |
|
36 #include "fstextviewervisualizer.h" |
|
37 #include "fstextviewervisualizerdata.h" |
|
38 #include "fstextviewerobserver.h" |
|
39 #include "fstextviewerkeys.h" |
|
40 |
|
41 // Dragging treshold in pixels, so the amount of pixels that the pointer |
|
42 // poisition can move without indicating it as dragging |
|
43 const TInt KDraggingTresholdInPixels = 20; |
|
44 |
|
45 // To be removed after aknphysics is working |
|
46 #define FS_VIEWER_DISABLE_AKN_PHYSICS |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // NewL |
|
50 // --------------------------------------------------------------------------- |
|
51 CFsTextViewerControl* CFsTextViewerControl::NewL( CAlfEnv& aEnv ) |
|
52 { |
|
53 FUNC_LOG; |
|
54 CFsTextViewerControl* self = new ( ELeave ) CFsTextViewerControl(); |
|
55 CleanupStack::PushL( self ); |
|
56 self->ConstructL(aEnv); |
|
57 CleanupStack::Pop( self ); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CFsTextViewerControl |
|
63 // --------------------------------------------------------------------------- |
|
64 CFsTextViewerControl::CFsTextViewerControl( ) |
|
65 : CAlfControl(), |
|
66 iCursorUDScroll( EFalse ), |
|
67 iScrollEventHandlingOngoing( EFalse ), |
|
68 iIsVisible( EFalse ), |
|
69 iStartHotspotAction( EFalse ) |
|
70 { |
|
71 FUNC_LOG; |
|
72 } |
|
73 |
|
74 // --------------------------------------------------------------------------- |
|
75 // ConstructL |
|
76 // --------------------------------------------------------------------------- |
|
77 void CFsTextViewerControl::ConstructL(CAlfEnv& aEnv) |
|
78 { |
|
79 FUNC_LOG; |
|
80 CAlfControl::ConstructL(aEnv); |
|
81 |
|
82 #ifndef FS_VIEWER_DISABLE_AKN_PHYSICS |
|
83 if ( CAknPhysics::FeatureEnabled() ) |
|
84 { |
|
85 CCoeControl* ctrl = NULL; |
|
86 //ctrl = CCoeEnv::Static()->AppUi()->TopFocusedControl(); |
|
87 |
|
88 iPhysics = CAknPhysics::NewL( *this, ctrl ); |
|
89 } |
|
90 #endif //FS_VIEWER_DISABLE_AKN_PHYSICS |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // ~CFsTextViewerControl |
|
95 // --------------------------------------------------------------------------- |
|
96 CFsTextViewerControl::~CFsTextViewerControl() |
|
97 { |
|
98 FUNC_LOG; |
|
99 |
|
100 delete iPhysics; |
|
101 iPhysics = NULL; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // SetVisualizer |
|
106 // --------------------------------------------------------------------------- |
|
107 void CFsTextViewerControl::SetVisualizer( CFsTextViewerVisualizer* aVis ) |
|
108 { |
|
109 FUNC_LOG; |
|
110 iVisualizer = aVis; |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // SetObserver |
|
115 // --------------------------------------------------------------------------- |
|
116 void CFsTextViewerControl::SetObserver( MFsTextViewerObserver* aObserver ) |
|
117 { |
|
118 FUNC_LOG; |
|
119 iObserver = aObserver; |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------------------------- |
|
123 // EnableCursorScroll |
|
124 // --------------------------------------------------------------------------- |
|
125 void CFsTextViewerControl::EnableCursorScroll( TBool aStatus ) |
|
126 { |
|
127 FUNC_LOG; |
|
128 iCursorUDScroll = aStatus; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CursorScroll |
|
133 // --------------------------------------------------------------------------- |
|
134 TBool CFsTextViewerControl::CursorScroll() |
|
135 { |
|
136 FUNC_LOG; |
|
137 return iCursorUDScroll; |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // SetKeys |
|
142 // --------------------------------------------------------------------------- |
|
143 void CFsTextViewerControl::SetKeys( CFsTextViewerKeys* aKeys ) |
|
144 { |
|
145 FUNC_LOG; |
|
146 iKeys = aKeys; |
|
147 } |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // Keys |
|
151 // --------------------------------------------------------------------------- |
|
152 CFsTextViewerKeys* CFsTextViewerControl::Keys() |
|
153 { |
|
154 FUNC_LOG; |
|
155 return iKeys; |
|
156 } |
|
157 |
|
158 TBool CFsTextViewerControl::IsScrollEventHandlingOngoing() |
|
159 { |
|
160 return iScrollEventHandlingOngoing; |
|
161 } |
|
162 |
|
163 void CFsTextViewerControl::NotifyControlVisibility( TBool aIsVisible, CAlfDisplay& aDisplay ) |
|
164 { |
|
165 iVisualizer->NotifyControlVisibilityChange(aIsVisible); |
|
166 |
|
167 //Add & remove extra touch events. |
|
168 if(aIsVisible && !iIsVisible) |
|
169 { |
|
170 TInt dragTreshold_X = KDraggingTresholdInPixels; |
|
171 // If AknPhysics used, get drag treshold from there |
|
172 if( iPhysics ) |
|
173 { |
|
174 dragTreshold_X = iPhysics->DragThreshold(); |
|
175 } |
|
176 |
|
177 // Currently only panning (vertical dragging) is implemented, |
|
178 // so horizontal drag treshold should be a bit bigger |
|
179 TInt dragTreshold_Y = dragTreshold_X * 2; |
|
180 |
|
181 // Add observer for long tap and drag events, set treshold for drag |
|
182 // events and disable long tap events while dragging |
|
183 aDisplay.Roster().AddPointerEventObserver( EAlfPointerEventReportLongTap, *this ); |
|
184 aDisplay.Roster().AddPointerEventObserver( EAlfPointerEventReportDrag, *this ); |
|
185 aDisplay.Roster().SetPointerDragThreshold( |
|
186 *this, TAlfXYMetric( TAlfMetric(dragTreshold_X), TAlfMetric(dragTreshold_Y) ) ); |
|
187 aDisplay.Roster().DisableLongTapEventsWhenDragging( *this ); |
|
188 iIsVisible = ETrue; |
|
189 } |
|
190 else if(!aIsVisible && iIsVisible ) |
|
191 { |
|
192 if( iPhysics ) |
|
193 { |
|
194 iPhysics->StopPhysics(); |
|
195 iPhysics->ResetFriction(); |
|
196 } |
|
197 |
|
198 aDisplay.Roster().RemovePointerEventObserver(EAlfPointerEventReportLongTap, *this); |
|
199 aDisplay.Roster().RemovePointerEventObserver(EAlfPointerEventReportDrag, *this); |
|
200 |
|
201 iIsVisible = EFalse; |
|
202 } |
|
203 |
|
204 } |
|
205 |
|
206 // --------------------------------------------------------------------------- |
|
207 // OfferEventL |
|
208 // --------------------------------------------------------------------------- |
|
209 TBool CFsTextViewerControl::OfferEventL(const TAlfEvent& aEvent) |
|
210 { |
|
211 FUNC_LOG; |
|
212 TBool retVal = EFalse; |
|
213 |
|
214 if ( aEvent.IsPointerEvent() ) |
|
215 { |
|
216 retVal = HandlePointerEventL( aEvent ); |
|
217 } |
|
218 else if( aEvent.IsKeyEvent() && aEvent.Code() == EEventKey ) |
|
219 { |
|
220 retVal = HandleKeyEventL( aEvent ); |
|
221 } |
|
222 |
|
223 return retVal; |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CFsTextViewerControl::HandleKeyEventL |
|
228 // Handle keyboard events |
|
229 // --------------------------------------------------------------------------- |
|
230 // |
|
231 TBool CFsTextViewerControl::HandleKeyEventL(const TAlfEvent& aEvent) |
|
232 { |
|
233 TBool eventHandled( EFalse ); |
|
234 |
|
235 if( iPhysics ) |
|
236 { |
|
237 iPhysics->StopPhysics(); |
|
238 iPhysics->ResetFriction(); |
|
239 } |
|
240 |
|
241 if ( aEvent.KeyEvent().iCode == iKeys->GetKeyUp() ) |
|
242 { |
|
243 TBool hotspotChanged = EFalse; |
|
244 if ( iCursorUDScroll ) |
|
245 { |
|
246 iVisualizer->MoveUpL(); |
|
247 } |
|
248 else |
|
249 { |
|
250 if ( iVisualizer->PrevVisibleHotspotL( hotspotChanged ) ) |
|
251 { |
|
252 if ( iObserver && hotspotChanged ) |
|
253 { |
|
254 iObserver->HandleTextViewerEventL( |
|
255 MFsTextViewerObserver::EFsTextViewerHotspotChanged ); |
|
256 } |
|
257 } |
|
258 else |
|
259 { |
|
260 ScrollL( MFsTextViewerObserver::EFsTextViewerScrollUp ); |
|
261 } |
|
262 } |
|
263 eventHandled = ETrue; |
|
264 } |
|
265 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyDown() ) |
|
266 { |
|
267 TBool hotspotChanged = EFalse; |
|
268 if ( iCursorUDScroll ) |
|
269 { |
|
270 iVisualizer->MoveDownL(); |
|
271 } |
|
272 else |
|
273 { |
|
274 if ( iVisualizer->NextVisibleHotspotL( hotspotChanged ) ) |
|
275 { |
|
276 if ( iObserver && hotspotChanged ) |
|
277 { |
|
278 iObserver->HandleTextViewerEventL( |
|
279 MFsTextViewerObserver::EFsTextViewerHotspotChanged ); |
|
280 } |
|
281 } |
|
282 else |
|
283 { |
|
284 ScrollL( MFsTextViewerObserver::EFsTextViewerScrollDown ); |
|
285 } |
|
286 } |
|
287 eventHandled = ETrue; |
|
288 } |
|
289 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyPgUp() ) |
|
290 { |
|
291 iVisualizer->PageUpL(); |
|
292 } |
|
293 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyPgDown() ) |
|
294 { |
|
295 iVisualizer->PageDownL(); |
|
296 } |
|
297 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyRight() ) |
|
298 { |
|
299 iVisualizer->MoveRightL(); |
|
300 if ( iVisualizer->MarkEnabled() && iObserver ) |
|
301 { |
|
302 iObserver->HandleTextViewerEventL( |
|
303 MFsTextViewerObserver::EFsTextViewerMarkChange ); |
|
304 } |
|
305 eventHandled = ETrue; |
|
306 } |
|
307 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyLeft() ) |
|
308 { |
|
309 iVisualizer->MoveLeftL(); |
|
310 if ( iVisualizer->MarkEnabled() && iObserver ) |
|
311 { |
|
312 iObserver->HandleTextViewerEventL( |
|
313 MFsTextViewerObserver::EFsTextViewerMarkChange ); |
|
314 } |
|
315 eventHandled = ETrue; |
|
316 } |
|
317 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyMark() ) |
|
318 { |
|
319 iVisualizer->SwitchMarkL(); |
|
320 if ( iVisualizer->MarkEnabled() && iObserver ) |
|
321 { |
|
322 iObserver->HandleTextViewerEventL( |
|
323 MFsTextViewerObserver::EFsTextViewerMarkStart ); |
|
324 } |
|
325 else if ( iObserver ) |
|
326 { |
|
327 iObserver->HandleTextViewerEventL( |
|
328 MFsTextViewerObserver::EFsTextViewerMarkEnd ); |
|
329 } |
|
330 eventHandled = ETrue; |
|
331 } |
|
332 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyClick() ) |
|
333 { |
|
334 iVisualizer->ClickedL(); |
|
335 if ( iVisualizer->IsHotspotHighlighted() && iObserver ) |
|
336 { |
|
337 iObserver->HandleTextViewerEventL( |
|
338 MFsTextViewerObserver::EFsTextViewerHotspotClicked ); |
|
339 } |
|
340 eventHandled = ETrue; |
|
341 } |
|
342 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyScrollUp() ) |
|
343 { |
|
344 ScrollL( MFsTextViewerObserver::EFsTextViewerScrollUp ); |
|
345 eventHandled = ETrue; |
|
346 } |
|
347 else if ( aEvent.KeyEvent().iCode == iKeys->GetKeyScrollDown() ) |
|
348 { |
|
349 ScrollL( MFsTextViewerObserver::EFsTextViewerScrollDown ); |
|
350 eventHandled = ETrue; |
|
351 } |
|
352 |
|
353 return eventHandled; |
|
354 } |
|
355 |
|
356 // --------------------------------------------------------------------------- |
|
357 // CFsTextViewerControl::HandlePointerEventL |
|
358 // Handle pointer (touch) events |
|
359 // --------------------------------------------------------------------------- |
|
360 // |
|
361 TBool CFsTextViewerControl::HandlePointerEventL(const TAlfEvent& aEvent) |
|
362 { |
|
363 TBool eventHandled( EFalse ); |
|
364 |
|
365 // Check if this event is bound to some of our visuals |
|
366 CAlfVisual* selectedVis = aEvent.Visual(); |
|
367 TFsRangedVisual* rangedVis = NULL; |
|
368 if( selectedVis ) |
|
369 { |
|
370 rangedVis = iVisualizer->Navigator()->GetRangedVisual( selectedVis ); |
|
371 } |
|
372 |
|
373 switch ( aEvent.PointerEvent().iType ) |
|
374 { |
|
375 case TPointerEvent::EButton1Down: |
|
376 { |
|
377 // Save current and original position so that those can be used in |
|
378 // drag/scrolling calculations |
|
379 iPreviousPosition = iOriginalPosition = aEvent.PointerEvent().iParentPosition; |
|
380 iIsDragging = EFalse; |
|
381 iIsFlicking = EFalse; |
|
382 |
|
383 if( iPhysics ) |
|
384 { |
|
385 iPhysics->StopPhysics(); |
|
386 iPhysics->ResetFriction(); |
|
387 iStartTime.HomeTime(); |
|
388 UpdatePhysicsL(); |
|
389 } |
|
390 |
|
391 // On button down event, move focus to highlighted hotspot |
|
392 if( rangedVis && rangedVis->iHotspot ) |
|
393 { |
|
394 // Allow future hotspot actions |
|
395 iStartHotspotAction = ETrue; |
|
396 |
|
397 // Move focus to currently pointed hotspot and report event |
|
398 // to observers |
|
399 iVisualizer->SetCurrentHotspotByCharL( rangedVis->iStart ); |
|
400 if ( iObserver ) |
|
401 { |
|
402 iObserver->HandleTextViewerEventL( MFsTextViewerObserver::EFsTextViewerHotspotChanged ); |
|
403 } |
|
404 |
|
405 eventHandled = ETrue; |
|
406 } |
|
407 } |
|
408 break; |
|
409 |
|
410 case TPointerEvent::EButton1Up: |
|
411 { |
|
412 if( iIsDragging && iPhysics ) |
|
413 { |
|
414 TPoint drag(iOriginalPosition - aEvent.PointerEvent().iParentPosition); |
|
415 iPhysics->StartPhysics(drag, iStartTime); |
|
416 iIsFlicking = ETrue; |
|
417 } |
|
418 |
|
419 // On button up event start action for focused hotspot, if hotspot |
|
420 // action allowed |
|
421 else if( iStartHotspotAction && rangedVis && rangedVis->iHotspot ) |
|
422 { |
|
423 // Hotspot action started, so disable all future actions |
|
424 iStartHotspotAction = EFalse; |
|
425 |
|
426 // Move focus to currently pointed hotspot and report event |
|
427 // to observers |
|
428 iVisualizer->SetCurrentHotspotByCharL( rangedVis->iStart ); |
|
429 if ( iObserver ) |
|
430 { |
|
431 iObserver->HandleTextViewerEventL( MFsTextViewerObserver::EFsTextViewerHotspotClicked ); |
|
432 } |
|
433 |
|
434 eventHandled = ETrue; |
|
435 } |
|
436 } |
|
437 break; |
|
438 |
|
439 case TPointerEvent::EButtonRepeat: |
|
440 { |
|
441 // On repeat event report long tap event to observers, if hotspot |
|
442 // actions are allowed |
|
443 if( iStartHotspotAction ) |
|
444 { |
|
445 // Hotspot action started, so disable all future actions |
|
446 iStartHotspotAction = EFalse; |
|
447 |
|
448 // Report long tap event to observers |
|
449 if ( iObserver ) |
|
450 { |
|
451 iObserver->HandleTextViewerEventL( MFsTextViewerObserver::EFsTextViewerHotspotLongTap ); |
|
452 } |
|
453 |
|
454 eventHandled = ETrue; |
|
455 } |
|
456 break; |
|
457 } |
|
458 |
|
459 case TPointerEvent::EDrag: |
|
460 { |
|
461 // Get current pointer position |
|
462 TPoint position = aEvent.PointerEvent().iParentPosition; |
|
463 |
|
464 // If user started dragging, cancel hotspot actions |
|
465 iStartHotspotAction = EFalse; |
|
466 iIsDragging = ETrue; |
|
467 |
|
468 if( iPhysics ) |
|
469 { |
|
470 TPoint delta( 0, iPreviousPosition.iY - position.iY ); |
|
471 iPhysics->RegisterPanningPosition( delta ); |
|
472 } |
|
473 else |
|
474 { |
|
475 // Calculate new scroll offset based on current and previous Y-positions |
|
476 TInt scrollOffset = iVisualizer->GetViewTopPosition() + ( iPreviousPosition.iY - position.iY ); |
|
477 // Ensure that thumb position is in correct range |
|
478 scrollOffset = Max( scrollOffset, 0 ); |
|
479 scrollOffset = Min( scrollOffset, iVisualizer->GetTotalHeight() - iVisualizer->iContentSize.iHeight ); |
|
480 |
|
481 ScrollL( scrollOffset ); |
|
482 } |
|
483 |
|
484 // Save current position as previous pos for future calculations |
|
485 iPreviousPosition = position; |
|
486 |
|
487 eventHandled = ETrue; |
|
488 } |
|
489 break; |
|
490 |
|
491 default: |
|
492 { |
|
493 // Unknown event, ignore. |
|
494 } |
|
495 break; |
|
496 } |
|
497 |
|
498 return eventHandled; |
|
499 } |
|
500 |
|
501 // <cmail> Change scrollbar to avkon (to support skinning & touch) |
|
502 // --------------------------------------------------------------------------- |
|
503 // Handle scrollbar events |
|
504 // --------------------------------------------------------------------------- |
|
505 // |
|
506 void CFsTextViewerControl::HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType) |
|
507 { |
|
508 iScrollEventHandlingOngoing = ETrue; |
|
509 |
|
510 if( iPhysics ) |
|
511 { |
|
512 iPhysics->StopPhysics(); |
|
513 iPhysics->ResetFriction(); |
|
514 } |
|
515 |
|
516 if ( aScrollBar == iVisualizer->GetScrollBar() ) |
|
517 { |
|
518 TInt thumbPos = -1; |
|
519 switch( aEventType ) |
|
520 { |
|
521 case EEikScrollHome : |
|
522 { |
|
523 //Jump to beginning |
|
524 thumbPos = 0; |
|
525 } |
|
526 break; |
|
527 case EEikScrollEnd : |
|
528 { |
|
529 //Jump to end |
|
530 thumbPos = iVisualizer->GetTotalHeight() - iVisualizer->iContentSize.iHeight; |
|
531 } |
|
532 break; |
|
533 default: |
|
534 { |
|
535 thumbPos = aScrollBar->ThumbPosition(); |
|
536 } |
|
537 break; |
|
538 } |
|
539 |
|
540 if( thumbPos >= 0 ) |
|
541 { |
|
542 // Ensure that thumb position is in correct range |
|
543 thumbPos = Min( thumbPos, iVisualizer->GetTotalHeight() - iVisualizer->iContentSize.iHeight ); |
|
544 |
|
545 // Scroll text viewer to thumb position with default scroll time |
|
546 ScrollL( thumbPos ); |
|
547 } |
|
548 } |
|
549 |
|
550 iScrollEventHandlingOngoing = EFalse; |
|
551 } |
|
552 |
|
553 void CFsTextViewerControl::ScrollL( |
|
554 const TInt aOffset, |
|
555 const TInt aTime /*= CFsTextViewerVisualizer::EUseDefaultScrollTime*/ ) |
|
556 { |
|
557 // Scroll text viewer to the calculated position. |
|
558 // If position is above current line offset, scroll up. |
|
559 // If position is below current line offset, scroll down. |
|
560 // If position is same as current line offset, do nothing. |
|
561 if ( aOffset < iVisualizer->GetViewTopPosition() ) |
|
562 { |
|
563 ScrollL( MFsTextViewerObserver::EFsTextViewerScrollUp, aOffset, aTime ); |
|
564 } |
|
565 else if ( aOffset > iVisualizer->GetViewTopPosition() ) |
|
566 { |
|
567 ScrollL( MFsTextViewerObserver::EFsTextViewerScrollDown, aOffset, aTime ); |
|
568 } |
|
569 } |
|
570 |
|
571 void CFsTextViewerControl::ScrollL( |
|
572 const MFsTextViewerObserver::TFsTextViewerEvent aEventDirection, |
|
573 const TInt aOffset /*= CFsTextViewerVisualizer::EUseDefaultScrollOffset*/, |
|
574 const TInt aTime /*= CFsTextViewerVisualizer::EUseDefaultScrollTime*/ ) |
|
575 { |
|
576 switch( aEventDirection ) |
|
577 { |
|
578 case MFsTextViewerObserver::EFsTextViewerScrollUp: |
|
579 { |
|
580 iVisualizer->ScrollUpL( aOffset, aTime ); |
|
581 } |
|
582 break; |
|
583 |
|
584 case MFsTextViewerObserver::EFsTextViewerScrollDown: |
|
585 { |
|
586 iVisualizer->ScrollDownL( aOffset, aTime ); |
|
587 } |
|
588 break; |
|
589 |
|
590 // No need to handle any other events here |
|
591 default: |
|
592 return; |
|
593 } |
|
594 |
|
595 if ( iObserver ) |
|
596 { |
|
597 iObserver->HandleTextViewerEventL( aEventDirection ); |
|
598 } |
|
599 } |
|
600 |
|
601 // --------------------------------------------------------------------------- |
|
602 // Update physics |
|
603 // --------------------------------------------------------------------------- |
|
604 // |
|
605 void CFsTextViewerControl::UpdatePhysicsL() |
|
606 { |
|
607 FUNC_LOG; |
|
608 if ( iPhysics ) |
|
609 { |
|
610 const TSize viewSize( iVisualizer->iContentSize ); |
|
611 const TSize worldSize( viewSize.iWidth, iVisualizer->GetTotalHeight() ); |
|
612 iPhysics->InitPhysicsL( worldSize, viewSize, EFalse ); |
|
613 } |
|
614 } |
|
615 |
|
616 /** |
|
617 * @see MAknPhysicsObserver::ViewPositionChanged |
|
618 */ |
|
619 void CFsTextViewerControl::ViewPositionChanged( |
|
620 const TPoint& aNewPosition, |
|
621 TBool /*aDrawNow*/, |
|
622 TUint /*aFlags*/ ) |
|
623 { |
|
624 // Sometimes ViewPositionChanged events come after view is already changed, |
|
625 // so adding a safety check here |
|
626 if( iIsVisible ) |
|
627 { |
|
628 TInt scrollOffset = aNewPosition.iY - iVisualizer->iContentSize.iHeight / 2; |
|
629 |
|
630 //CAlfStatic::Env().SetRefreshMode( EAlfRefreshModeManual ); |
|
631 if( iIsFlicking ) |
|
632 { |
|
633 TRAP_IGNORE( ScrollL( scrollOffset, 1 ) ); |
|
634 } |
|
635 else |
|
636 { |
|
637 TRAP_IGNORE( ScrollL( scrollOffset, 250 ) ); |
|
638 } |
|
639 //iListLayout->Env().RefreshCallBack( &iListLayout->Env() ); |
|
640 //iVisualizer->RootLayout()->UpdateChildrenLayout(); |
|
641 //CAlfStatic::Env().RefreshCallBack( &CAlfStatic::Env() ); |
|
642 //CAlfStatic::Env().SetRefreshMode( EAlfRefreshModeAutomatic ); |
|
643 } |
|
644 } |
|
645 |
|
646 /** |
|
647 * @see MAknPhysicsObserver::PhysicEmulationEnded |
|
648 */ |
|
649 void CFsTextViewerControl::PhysicEmulationEnded() |
|
650 { |
|
651 iIsFlicking = EFalse; |
|
652 } |
|
653 |
|
654 /** |
|
655 * @see MAknPhysicsObserver::ViewPosition |
|
656 */ |
|
657 TPoint CFsTextViewerControl::ViewPosition() const |
|
658 { |
|
659 return iVisualizer->GetViewCenterPosition(); |
|
660 } |