author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 21:48:24 +0300 | |
branch | RCL_3 |
changeset 59 | 978afdc0236f |
parent 56 | d48ab3b357f1 |
child 64 | 85902f042028 |
permissions | -rw-r--r-- |
56 | 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
// INCLUDE FILES |
|
19 |
#include <ganes/HgScroller.h> |
|
20 |
||
21 |
#include <aknphysics.h> |
|
22 |
||
23 |
#include <ganes/HgScrollBufferObserverIface.h> |
|
24 |
#include <ganes/HgSelectionObserverIface.h> |
|
25 |
#include <ganes/HgMarkingObserverIface.h> |
|
26 |
#include <ganes/HgItem.h> |
|
27 |
#include "HgScrollbar.h" |
|
28 |
#include "HgScrollBufferManager.h" |
|
29 |
#include "HgConstants.h" |
|
30 |
#include "HgPopupDrawer.h" |
|
31 |
#include "HgMarquee.h" |
|
32 |
#include "HgDrawUtils.h" |
|
33 |
#include "HgIndicatorManager.h" |
|
34 |
#include "HgTextFind.h" |
|
35 |
#include "HgKeyUtils.h" |
|
36 |
||
37 |
#include <ganes.mbg> |
|
38 |
||
39 |
#include <AknIconUtils.h> |
|
40 |
#include <avkon.mbg> |
|
41 |
#include <AknsDrawUtils.h> |
|
42 |
#include <touchfeedback.h> |
|
43 |
#include <gulicon.h> |
|
44 |
#include <AknUtils.h> |
|
45 |
#include <layoutmetadata.cdl.h> |
|
46 |
#include <AknLayout2ScalableDef.h> |
|
47 |
#include <aknitemactionmenu.h> |
|
48 |
#include <aknappui.h> |
|
49 |
||
50 |
#include <featdiscovery.h> |
|
51 |
||
52 |
// ============================ MEMBER FUNCTIONS =============================== |
|
53 |
||
54 |
// ----------------------------------------------------------------------------- |
|
55 |
// CHgScroller::ConstructL() |
|
56 |
// Symbian 2nd phase constructor can leave. |
|
57 |
// ----------------------------------------------------------------------------- |
|
58 |
// |
|
59 |
void CHgScroller::ConstructL (const TRect& aRect, RWsSession* aSession ) |
|
60 |
{ |
|
61 |
// Create a window for this application view |
|
62 |
CreateWindowL ( ); |
|
63 |
EnableDragEvents(); |
|
64 |
ClaimPointerGrab(); |
|
65 |
||
66 |
iUpperCaseTitle.CreateL( KMaxSearchLenght ); |
|
67 |
iPopupText1.CreateL( KMaxPopupTextLength ); |
|
68 |
iPopupText2.CreateL( KMaxPopupTextLength ); |
|
69 |
||
70 |
iScrollbar = CHgScrollbar::NewL(*this); |
|
71 |
iPopupDrawer = new (ELeave) THgPopupDrawer(); |
|
72 |
iPhysics = CAknPhysics::NewL(*this, this); |
|
73 |
||
74 |
TCallBack callback(CHgScroller::MarqueeCallback, this); |
|
75 |
iDrawUtils = CHgDrawUtils::NewL( callback ); |
|
76 |
||
77 |
iIndicatorManager = CHgIndicatorManager::NewL(); |
|
78 |
||
79 |
/* |
|
80 |
// Enable key search only in non-touch or hybrid (touch + qwerty) devices |
|
81 |
if( !AknLayoutUtils::PenEnabled() || |
|
82 |
CFeatureDiscovery::IsFeatureSupportedL(TUid::Uid(KFeatureIdQwertyInput)) ) |
|
83 |
{ |
|
84 |
iTextFind = CHgTextFind::NewL( *this ); |
|
85 |
iKeyUtils = CHgKeyUtils::NewL(*this); |
|
86 |
} |
|
87 |
*/ |
|
88 |
||
89 |
// Init Stuff |
|
90 |
if( aSession ) |
|
91 |
{ |
|
92 |
InitScreenL( aRect, *aSession ); |
|
93 |
} |
|
94 |
else |
|
95 |
{ |
|
96 |
InitScreenL( aRect ); |
|
97 |
} |
|
98 |
||
99 |
iHighlightTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
100 |
iKeyScrollingTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
101 |
||
102 |
CAknAppUi* appUi = static_cast<CAknAppUi*>(iEikonEnv->AppUi()); |
|
103 |
if( appUi && appUi->IsSingleClickCompatible() ) |
|
104 |
{ |
|
105 |
iDetector = CAknLongTapDetector::NewL(this); |
|
106 |
iActionMenu = CAknItemActionMenu::RegisterCollectionL( *this ); |
|
107 |
} |
|
108 |
||
109 |
iDrawUtils->EnableMarquee(HasHighlight()); |
|
110 |
||
111 |
InitItemsL(); |
|
112 |
||
113 |
iCoeEnv->AddForegroundObserverL( *this ); |
|
114 |
} |
|
115 |
||
116 |
// ----------------------------------------------------------------------------- |
|
117 |
// CHgScroller::InputCapabilities() |
|
118 |
// ----------------------------------------------------------------------------- |
|
119 |
// |
|
120 |
TCoeInputCapabilities CHgScroller::InputCapabilities() const |
|
121 |
{ |
|
122 |
TCoeInputCapabilities cap( TCoeInputCapabilities::ENone ); |
|
123 |
||
124 |
if(iTextFind) |
|
125 |
{ |
|
126 |
MCoeFepAwareTextEditor* editor = NULL; |
|
127 |
||
128 |
if( iSelectionMode == ENoSelection |
|
129 |
&& iFlags & EHgScrollerSearchWithQWERTY ) |
|
130 |
editor = iTextFind; |
|
131 |
||
132 |
cap = TCoeInputCapabilities( TCoeInputCapabilities::EAllText, |
|
133 |
editor, |
|
134 |
NULL ); |
|
135 |
||
136 |
cap.SetObjectProvider( const_cast<CHgScroller*>(this) ); |
|
137 |
} |
|
138 |
||
139 |
return cap; |
|
140 |
} |
|
141 |
||
142 |
// ----------------------------------------------------------------------------- |
|
143 |
// CHgScroller::InitScreenL() |
|
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// |
|
146 |
EXPORT_C void CHgScroller::InitScreenL( const TRect& /*aRect*/, RWsSession& /*aSession*/ ) |
|
147 |
{ |
|
148 |
// DSA not supported anymore. |
|
149 |
User::Leave( KErrNotSupported ); |
|
150 |
} |
|
151 |
||
152 |
// ----------------------------------------------------------------------------- |
|
153 |
// CHgScroller::InitScreenL() |
|
154 |
// ----------------------------------------------------------------------------- |
|
155 |
// |
|
156 |
EXPORT_C void CHgScroller::InitScreenL( const TRect& aRect ) |
|
157 |
{ |
|
158 |
// Set the windows size |
|
159 |
SetRect ( aRect ); |
|
160 |
} |
|
161 |
||
162 |
// ----------------------------------------------------------------------------- |
|
163 |
// CHgScroller::RefreshScreen() |
|
164 |
// ----------------------------------------------------------------------------- |
|
165 |
// |
|
166 |
EXPORT_C void CHgScroller::RefreshScreen( TInt aIndex ) |
|
167 |
{ |
|
168 |
if( IsDisplayed( aIndex ) ) |
|
169 |
DrawDeferred(); |
|
170 |
} |
|
171 |
||
172 |
// ----------------------------------------------------------------------------- |
|
173 |
// CHgScroller::FirstIndexOnScreen() |
|
174 |
// ----------------------------------------------------------------------------- |
|
175 |
// |
|
176 |
EXPORT_C TInt CHgScroller::FirstIndexOnScreen() |
|
177 |
{ |
|
178 |
return CurrentIndex(); |
|
179 |
} |
|
180 |
||
181 |
// ----------------------------------------------------------------------------- |
|
182 |
// CHgScroller::SetFirstIndexOnScreen() |
|
183 |
// ----------------------------------------------------------------------------- |
|
184 |
// |
|
185 |
EXPORT_C void CHgScroller::SetFirstIndexOnScreen( TInt aFirstIndexOnScreen ) |
|
186 |
{ |
|
187 |
FitTopItemToView( aFirstIndexOnScreen ); |
|
188 |
} |
|
189 |
||
190 |
// ----------------------------------------------------------------------------- |
|
191 |
// CHgScroller::ItemsOnScreen() |
|
192 |
// ----------------------------------------------------------------------------- |
|
193 |
// |
|
194 |
EXPORT_C TInt CHgScroller::ItemsOnScreen() |
|
195 |
{ |
|
196 |
return iItemsOnScreen; |
|
197 |
} |
|
198 |
||
199 |
// ----------------------------------------------------------------------------- |
|
200 |
// CHgScroller::SelectedIndex() |
|
201 |
// ----------------------------------------------------------------------------- |
|
202 |
// |
|
203 |
EXPORT_C TInt CHgScroller::SelectedIndex() |
|
204 |
{ |
|
205 |
return iSelectedIndex; |
|
206 |
} |
|
207 |
||
208 |
// ----------------------------------------------------------------------------- |
|
209 |
// CHgScroller::SetSelectedIndex() |
|
210 |
// ----------------------------------------------------------------------------- |
|
211 |
// |
|
212 |
EXPORT_C void CHgScroller::SetSelectedIndex( TInt aIndex ) |
|
213 |
{ |
|
214 |
if( aIndex >= 0 && aIndex < iItems.Count() ) |
|
215 |
{ |
|
216 |
if( !IsDisplayed( aIndex ) ) |
|
217 |
{ |
|
218 |
iSelectedIndex = iItems.Count() - 1; |
|
219 |
FitSelectionToView(); |
|
220 |
} |
|
221 |
||
222 |
iSelectedIndex = aIndex; |
|
223 |
// Move view position so that it is fully visible. |
|
224 |
FitSelectionToView(); |
|
225 |
SelectionChanged(); |
|
226 |
} |
|
227 |
} |
|
228 |
||
229 |
// ----------------------------------------------------------------------------- |
|
230 |
// CHgScroller::Mark() |
|
231 |
// ----------------------------------------------------------------------------- |
|
232 |
// |
|
233 |
EXPORT_C void CHgScroller::Mark( TInt aIndex ) |
|
234 |
{ |
|
235 |
if( aIndex >= 0 && aIndex < iItems.Count() ) |
|
236 |
{ |
|
237 |
if( !(iItems[aIndex]->Flags() & CHgItem::EHgItemFlagMarked) ) |
|
238 |
{ |
|
239 |
iItems[aIndex]->SetFlags( CHgItem::EHgItemFlagMarked ); |
|
240 |
if( iMarkingObserver ) |
|
241 |
{ |
|
242 |
TRAP_IGNORE( iMarkingObserver->HandleMarkingL( aIndex, ETrue ) ); |
|
243 |
} |
|
244 |
} |
|
245 |
} |
|
246 |
} |
|
247 |
||
248 |
// ----------------------------------------------------------------------------- |
|
249 |
// CHgScroller::UnMark() |
|
250 |
// ----------------------------------------------------------------------------- |
|
251 |
// |
|
252 |
EXPORT_C void CHgScroller::UnMark( TInt aIndex ) |
|
253 |
{ |
|
254 |
if( aIndex >= 0 && aIndex < iItems.Count() ) |
|
255 |
{ |
|
256 |
if( iItems[aIndex]->Flags() & CHgItem::EHgItemFlagMarked ) |
|
257 |
{ |
|
258 |
iItems[aIndex]->ClearFlags( CHgItem::EHgItemFlagMarked ); |
|
259 |
if( iMarkingObserver ) |
|
260 |
{ |
|
261 |
TRAP_IGNORE( iMarkingObserver->HandleMarkingL( aIndex, EFalse ) ); |
|
262 |
} |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
||
267 |
// ----------------------------------------------------------------------------- |
|
268 |
// CHgScroller::MarkAll() |
|
269 |
// ----------------------------------------------------------------------------- |
|
270 |
// |
|
271 |
EXPORT_C void CHgScroller::MarkAll() |
|
272 |
{ |
|
273 |
for(TInt i = 0; i < iItems.Count(); ++i) |
|
274 |
{ |
|
275 |
iItems[i]->SetFlags( CHgItem::EHgItemFlagMarked ); |
|
276 |
} |
|
277 |
||
278 |
DrawDeferred(); |
|
279 |
} |
|
280 |
||
281 |
// ----------------------------------------------------------------------------- |
|
282 |
// CHgScroller::UnMarkAll() |
|
283 |
// ----------------------------------------------------------------------------- |
|
284 |
// |
|
285 |
EXPORT_C void CHgScroller::UnMarkAll() |
|
286 |
{ |
|
287 |
for(TInt i = 0; i < iItems.Count(); ++i) |
|
288 |
{ |
|
289 |
iItems[i]->ClearFlags(CHgItem::EHgItemFlagMarked); |
|
290 |
} |
|
291 |
||
292 |
DrawDeferred(); |
|
293 |
} |
|
294 |
||
295 |
// ----------------------------------------------------------------------------- |
|
296 |
// CHgScroller::GetMarkedItemsL() |
|
297 |
// ----------------------------------------------------------------------------- |
|
298 |
// |
|
299 |
EXPORT_C void CHgScroller::GetMarkedItemsL( RArray<TInt>& aIndexes ) |
|
300 |
{ |
|
301 |
::CleanupClosePushL(aIndexes); |
|
302 |
for(TInt i = 0; i < iItems.Count(); ++i) |
|
303 |
{ |
|
304 |
if(iItems[i]->Flags() & CHgItem::EHgItemFlagMarked ) |
|
305 |
{ |
|
306 |
aIndexes.AppendL( i ); |
|
307 |
} |
|
308 |
} |
|
309 |
CleanupStack::Pop(&aIndexes); |
|
310 |
} |
|
311 |
||
312 |
// ----------------------------------------------------------------------------- |
|
313 |
// CHgScroller::EnableScrollBufferL() |
|
314 |
// ----------------------------------------------------------------------------- |
|
315 |
// |
|
316 |
EXPORT_C void CHgScroller::EnableScrollBufferL( |
|
317 |
MHgScrollBufferObserver& aObserver, |
|
318 |
TInt aBufferSize, |
|
319 |
TInt aBufferTreshold ) |
|
320 |
{ |
|
321 |
delete iManager; iManager = NULL; |
|
322 |
||
323 |
iManager = CHgScrollBufferManager::NewL( |
|
324 |
aObserver, |
|
325 |
aBufferSize, |
|
326 |
aBufferTreshold, |
|
327 |
CurrentIndex(), |
|
328 |
iItemCount); |
|
329 |
||
330 |
iManager->SetBufferOwner( *this ); |
|
331 |
} |
|
332 |
||
333 |
// ----------------------------------------------------------------------------- |
|
334 |
// CHgScroller::EnableNaviStripL() |
|
335 |
// ----------------------------------------------------------------------------- |
|
336 |
// |
|
337 |
EXPORT_C void CHgScroller::SetScrollBarTypeL( THgScrollBarType aType ) |
|
338 |
{ |
|
339 |
iScrollBarType = aType; |
|
340 |
DrawDeferred(); |
|
341 |
} |
|
342 |
||
343 |
// ----------------------------------------------------------------------------- |
|
344 |
// CHgScroller::SetSelectionObserver() |
|
345 |
// ----------------------------------------------------------------------------- |
|
346 |
// |
|
347 |
EXPORT_C void CHgScroller::SetSelectionObserver( MHgSelectionObserver& aObserver ) |
|
348 |
{ |
|
349 |
iSelectionObserver = &aObserver; |
|
350 |
} |
|
351 |
||
352 |
// ----------------------------------------------------------------------------- |
|
353 |
// CHgScroller::SetMarkingObserver() |
|
354 |
// ----------------------------------------------------------------------------- |
|
355 |
// |
|
356 |
EXPORT_C void CHgScroller::SetMarkingObserver( MHgMarkingObserver& aObserver ) |
|
357 |
{ |
|
358 |
iMarkingObserver = &aObserver; |
|
359 |
} |
|
360 |
||
361 |
// ----------------------------------------------------------------------------- |
|
362 |
// CHgScroller::CHgScroller() |
|
363 |
// C++ default constructor can NOT contain any code, that might leave. |
|
364 |
// ----------------------------------------------------------------------------- |
|
365 |
// |
|
366 |
CHgScroller::CHgScroller( |
|
367 |
TInt aItemCount, |
|
368 |
CGulIcon* aDefaultIcon ) |
|
369 |
: iDefaultIcon( aDefaultIcon ), |
|
370 |
iItemCount(aItemCount), |
|
371 |
iCurrentRow(-1), |
|
372 |
iSelectedIndex(KErrNotFound), |
|
373 |
iScrollBarType( EHgScrollerScrollBar ), |
|
374 |
iResetViewPosition(ETrue), |
|
375 |
iOldWinPos(KErrNotFound) |
|
376 |
{ |
|
377 |
// No implementation required |
|
378 |
} |
|
379 |
||
380 |
// ----------------------------------------------------------------------------- |
|
381 |
// CHgScroller::~CHgScroller() |
|
382 |
// Destructor. |
|
383 |
// ----------------------------------------------------------------------------- |
|
384 |
// |
|
385 |
EXPORT_C CHgScroller::~CHgScroller ( ) |
|
386 |
{ |
|
387 |
iCoeEnv->RemoveForegroundObserver( *this ); |
|
388 |
ReleasePopupFont(); |
|
389 |
||
390 |
iItems.ResetAndDestroy(); |
|
391 |
||
392 |
delete iManager; |
|
393 |
delete iPhysics; |
|
394 |
delete iScrollbar; |
|
395 |
delete iEmptyText; |
|
396 |
delete iDefaultIcon; |
|
397 |
delete iPopupDrawer; |
|
398 |
delete iDrawUtils; |
|
399 |
delete iHighlightTimer; |
|
400 |
delete iIndicatorManager; |
|
401 |
delete iKeyUtils; |
|
402 |
delete iTextFind; |
|
403 |
delete iKeyScrollingTimer; |
|
404 |
delete iDetector; |
|
405 |
||
406 |
if(iActionMenu) |
|
407 |
iActionMenu->RemoveCollection(*this); |
|
408 |
||
409 |
iUpperCaseTitle.Close(); |
|
410 |
iPopupText1.Close(); |
|
411 |
iPopupText2.Close(); |
|
412 |
||
413 |
} |
|
414 |
||
415 |
// ----------------------------------------------------------------------------- |
|
416 |
// CHgScroller::InitPhysicsL() |
|
417 |
// ----------------------------------------------------------------------------- |
|
418 |
// |
|
419 |
void CHgScroller::InitPhysicsL() |
|
420 |
{ |
|
421 |
// For to be able to pan on a empty area. |
|
422 |
// The world is set to be at least the size of the view. |
|
423 |
TSize worldSize = TotalSize(); |
|
424 |
||
425 |
if( !iLandscapeScrolling && (worldSize.iHeight <= iHeight) ) |
|
426 |
{ |
|
427 |
worldSize.iHeight = iHeight; |
|
428 |
iResetViewPosition = ETrue; |
|
429 |
} |
|
430 |
||
431 |
if( iLandscapeScrolling && (worldSize.iWidth <= iWidth) ) |
|
432 |
{ |
|
433 |
worldSize.iWidth = iWidth; |
|
434 |
iResetViewPosition = ETrue; |
|
435 |
} |
|
436 |
||
437 |
iPhysics->InitPhysicsL( worldSize, |
|
438 |
TSize(iWidth, iHeight), |
|
439 |
iLandscapeScrolling); |
|
440 |
} |
|
441 |
||
442 |
// ----------------------------------------------------------------------------- |
|
443 |
// CHgScroller::Draw() |
|
444 |
// Draws the display. |
|
445 |
// ----------------------------------------------------------------------------- |
|
446 |
// |
|
447 |
void CHgScroller::Draw ( const TRect& aRect ) const |
|
448 |
{ |
|
449 |
CWindowGc& gc = SystemGc(); |
|
450 |
||
451 |
// Flush screen buffer |
|
452 |
InitDrawBuffer(); |
|
453 |
||
454 |
DoDraw( aRect ); |
|
455 |
||
456 |
if( iScrollbar && iItemCount ) |
|
457 |
{ |
|
458 |
iScrollbar->Draw( gc ); |
|
459 |
} |
|
460 |
||
461 |
if( iPopupDrawer ) |
|
462 |
{ |
|
463 |
if(iPopupText2.Length() > 0) |
|
464 |
{ |
|
465 |
iPopupDrawer->Draw( gc, |
|
466 |
iPopupText1, |
|
467 |
iPopupText2 |
|
468 |
); |
|
469 |
} |
|
470 |
else if( iPopupText1.Length( ) > 0 ) |
|
471 |
{ |
|
472 |
if( iScrollBarType == EHgScrollerLetterStrip |
|
473 |
|| iScrollBarType == EHgScrollerLetterStripLite ) |
|
474 |
{ |
|
475 |
iPopupDrawer->DrawNaviChar( gc, iPopupText1 ); |
|
476 |
} |
|
477 |
else |
|
478 |
{ |
|
479 |
iPopupDrawer->Draw( gc, iPopupText1 ); |
|
480 |
} |
|
481 |
} |
|
482 |
else if( iTextFind && iTextFind->Text().Length() > 0 ) |
|
483 |
{ |
|
484 |
iPopupDrawer->Draw( gc, iTextFind->Text() ); |
|
485 |
} |
|
486 |
} |
|
487 |
} |
|
488 |
||
489 |
// ----------------------------------------------------------------------------- |
|
490 |
// CHgScroller::InitDrawBuffer() |
|
491 |
// ----------------------------------------------------------------------------- |
|
492 |
// |
|
493 |
void CHgScroller::InitDrawBuffer() const |
|
494 |
{ |
|
495 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
496 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
497 |
AknsDrawUtils::DrawBackground( skin, cc, this, SystemGc(), |
|
498 |
TPoint(0,0), Rect(), KAknsDrawParamDefault ); |
|
499 |
} |
|
500 |
||
501 |
// ----------------------------------------------------------------------------- |
|
502 |
// CHgScroller::SizeChanged() |
|
503 |
// Called by framework when the view size is changed. |
|
504 |
// ----------------------------------------------------------------------------- |
|
505 |
// |
|
506 |
void CHgScroller::SizeChanged ( ) |
|
507 |
{ |
|
508 |
iWidth = Rect().Width(); |
|
509 |
iHeight = Rect().Height(); |
|
510 |
||
511 |
HandleItemCountChanged(); |
|
512 |
||
513 |
if( iPopupDrawer ) |
|
514 |
{ |
|
515 |
ReleasePopupFont(); |
|
516 |
||
517 |
TFontSpec fontSpecTitle = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont)->FontSpecInTwips(); |
|
518 |
fontSpecTitle.iHeight = KFocusTextFontSize; // set height |
|
519 |
iCoeEnv->ScreenDevice()->GetNearestFontInTwips(iPopupFont, fontSpecTitle); |
|
520 |
||
521 |
iPopupDrawer->Init( Rect(), iPopupFont ); |
|
522 |
} |
|
523 |
||
524 |
if(iResetViewPosition) |
|
525 |
{ |
|
526 |
iViewPosition = TPoint(iWidth/2, iHeight/2); |
|
527 |
iResetViewPosition = EFalse; |
|
528 |
} |
|
529 |
||
530 |
HandleViewPositionChanged(); |
|
531 |
||
532 |
TRAP_IGNORE( InitGraphicsL(); ) |
|
533 |
DrawDeferred ( ); |
|
534 |
} |
|
535 |
||
536 |
// ----------------------------------------------------------------------------- |
|
537 |
// CHgScroller::HandleItemCountChaged() |
|
538 |
// ----------------------------------------------------------------------------- |
|
539 |
// |
|
540 |
void CHgScroller::HandleItemCountChanged() |
|
541 |
{ |
|
542 |
HandleSizeChanged(); |
|
543 |
||
544 |
if( iSelectedIndex >= iItemCount ) |
|
545 |
{ |
|
546 |
iSelectedIndex = iItemCount - 1; |
|
547 |
SelectionChanged(); |
|
548 |
} |
|
549 |
||
550 |
TRAP_IGNORE ( |
|
551 |
InitScrollbarL(); |
|
552 |
InitPhysicsL(); |
|
553 |
) |
|
554 |
} |
|
555 |
||
556 |
// ----------------------------------------------------------------------------- |
|
557 |
// CHgScroller::InitScrollbarL() |
|
558 |
// ----------------------------------------------------------------------------- |
|
559 |
// |
|
560 |
void CHgScroller::InitScrollbarL() |
|
561 |
{ |
|
562 |
if( iScrollbar ) |
|
563 |
{ |
|
564 |
TBool prevStatic = iScrollbar->IsStatic(); |
|
565 |
iScrollbar->InitScrollBarL( Rect(), |
|
566 |
TotalSize(), |
|
567 |
TSize(iWidth, iHeight), |
|
568 |
iLandscapeScrolling); |
|
569 |
||
570 |
iScrollbar->SetViewPosition( iViewPosition - TPoint(iWidth/2, iHeight/2)); |
|
571 |
||
572 |
if(prevStatic != iScrollbar->IsStatic()) |
|
573 |
HandleScrollbarVisibilityChange( !iScrollbar->IsStatic() ); |
|
574 |
} |
|
575 |
} |
|
576 |
// ----------------------------------------------------------------------------- |
|
577 |
// CHgScroller::HandlePointerEventL() |
|
578 |
// ----------------------------------------------------------------------------- |
|
579 |
// |
|
580 |
void CHgScroller::HandlePointerEventL( const TPointerEvent& aEvent ) |
|
581 |
{ |
|
582 |
if( !HandleScrollbarEventL( aEvent ) && iItemCount ) |
|
583 |
{ |
|
584 |
iShowHighlight = EFalse; |
|
585 |
||
586 |
// Start drag |
|
587 |
if( aEvent.iType == TPointerEvent::EButton1Down ) |
|
588 |
{ |
|
589 |
iPointerDown = ETrue; |
|
590 |
HandleDownEventL( aEvent ); |
|
591 |
||
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
592 |
// Long tap is supported in marking mode only for an item that is marked. |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
593 |
const TBool validIndex = iSelectedIndex != KErrNotFound && |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
594 |
iSelectedIndex >= 0 && iSelectedIndex < iItems.Count(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
595 |
const TBool selectionMode = iFlags & EHgScrollerSelectionMode; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
596 |
const TBool longTapEnabled = validIndex && (!selectionMode || |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
597 |
(selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked)); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
598 |
|
56 | 599 |
if( iDetector |
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
600 |
&& longTapEnabled |
56 | 601 |
&& !HasHighlight() |
602 |
&& iActionMenu->InitMenuL() ) |
|
603 |
{ |
|
604 |
iDetector->PointerEventL( aEvent ); |
|
605 |
} |
|
606 |
} |
|
607 |
// Drag |
|
608 |
else if( aEvent.iType == TPointerEvent::EDrag && iPointerDown ) |
|
609 |
{ |
|
610 |
HandleDragEventL( aEvent ); |
|
611 |
||
612 |
if( iPanning && iDetector && !HasHighlight() ) |
|
613 |
iDetector->CancelAnimationL(); |
|
614 |
} |
|
615 |
// End drag |
|
616 |
else if( aEvent.iType == TPointerEvent::EButton1Up && iPointerDown ) |
|
617 |
{ |
|
618 |
if( iDetector && !HasHighlight() ) |
|
619 |
iDetector->PointerEventL( aEvent ); |
|
620 |
||
621 |
HandleUpEventL( aEvent ); |
|
622 |
} |
|
623 |
} |
|
624 |
} |
|
625 |
||
626 |
// ----------------------------------------------------------------------------- |
|
627 |
// CHgScroller::HandleScrollbarEventL() |
|
628 |
// ----------------------------------------------------------------------------- |
|
629 |
// |
|
630 |
TBool CHgScroller::HandleScrollbarEventL( const TPointerEvent& aEvent ) |
|
631 |
{ |
|
632 |
TBool sbHandles = EFalse; |
|
633 |
if( iScrollbar ) |
|
634 |
{ |
|
635 |
sbHandles = iScrollbar->HandlePointerEventL( aEvent ); |
|
636 |
||
637 |
if( sbHandles |
|
638 |
&& iPhysics |
|
639 |
&& iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking ) |
|
640 |
{ |
|
641 |
iPhysics->StopPhysics(); |
|
642 |
iScrollbar->Reset(); |
|
643 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
644 |
if ( feedback ) |
|
645 |
{ |
|
646 |
feedback->InstantFeedback( this, ETouchFeedbackList, aEvent ); |
|
647 |
} |
|
648 |
return sbHandles; |
|
649 |
} |
|
650 |
||
651 |
if ( sbHandles && !iScrollbar->IsStatic() ) |
|
652 |
{ |
|
653 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
654 |
// Start drag |
|
655 |
if( aEvent.iType == TPointerEvent::EButton1Down ) |
|
656 |
{ |
|
657 |
if ( feedback ) |
|
658 |
{ |
|
659 |
feedback->InstantFeedback( this, ETouchFeedbackSlider, aEvent ); |
|
660 |
} |
|
661 |
} |
|
662 |
else if( aEvent.iType == TPointerEvent::EButton1Up ) |
|
663 |
{ |
|
664 |
// Stop the continuous tactile feedback that may be playing |
|
665 |
// at the time due to possible previous thumb dragging. |
|
666 |
if ( feedback ) |
|
667 |
{ |
|
668 |
feedback->StopFeedback( this ); |
|
669 |
TTouchFeedbackType type = ETouchFeedbackVibra; |
|
670 |
feedback->InstantFeedback( this, ETouchFeedbackSlider, type, aEvent ); |
|
671 |
} |
|
672 |
iPopupText1.Zero(); |
|
673 |
iPopupText2.Zero(); |
|
674 |
DrawDeferred(); |
|
675 |
} |
|
676 |
} |
|
677 |
} |
|
678 |
return sbHandles; |
|
679 |
} |
|
680 |
||
681 |
// ----------------------------------------------------------------------------- |
|
682 |
// CHgScroller::HandleDownEventL() |
|
683 |
// ----------------------------------------------------------------------------- |
|
684 |
// |
|
685 |
void CHgScroller::HandleDownEventL( const TPointerEvent& aEvent ) |
|
686 |
{ |
|
687 |
if( !HasHighlight() |
|
688 |
&& (iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking) ) |
|
689 |
{ |
|
690 |
iPanning = ETrue; |
|
691 |
if(iDetector) |
|
692 |
iDetector->CancelAnimationL(); |
|
693 |
} |
|
694 |
else |
|
695 |
{ |
|
696 |
iPanning = EFalse; |
|
697 |
} |
|
698 |
||
699 |
iPhysics->StopPhysics(); |
|
700 |
iPhysics->ResetFriction(); |
|
701 |
||
702 |
iStart = aEvent.iPosition; |
|
703 |
iPrev = iStart; |
|
704 |
iStartTime.HomeTime(); |
|
705 |
||
706 |
if(iLandscapeScrolling) |
|
707 |
iViewPosition.iY = iHeight / 2; |
|
708 |
else |
|
709 |
iViewPosition.iX = iWidth / 2; |
|
710 |
||
711 |
iFocusedIndex = KErrNotFound; |
|
712 |
iSelectionToFocusedItem = EFalse; |
|
713 |
iDrawUtils->EnableMarquee(HasHighlight()); |
|
714 |
if(HasHighlight()) |
|
715 |
{ |
|
716 |
LaunchHighlightTimer(); |
|
717 |
} |
|
718 |
else if( !iPanning ) |
|
719 |
{ |
|
720 |
// to get Handle Selected to be called for sure in single touch |
|
721 |
iSelectedIndex = KErrNotFound; |
|
722 |
SetHighlightL(); |
|
723 |
} |
|
724 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
725 |
if ( feedback && iSelectedIndex != KErrNotFound ) |
|
726 |
{ |
|
727 |
feedback->InstantFeedback( this, ETouchFeedbackList, aEvent ); |
|
728 |
} |
|
729 |
} |
|
730 |
||
731 |
// ----------------------------------------------------------------------------- |
|
732 |
// CHgScroller::HandleDragEventL() |
|
733 |
// ----------------------------------------------------------------------------- |
|
734 |
// |
|
735 |
void CHgScroller::HandleDragEventL( const TPointerEvent& aEvent ) |
|
736 |
{ |
|
737 |
TBool prevPanning = iPanning; |
|
738 |
if(!iPanning) |
|
739 |
{ |
|
740 |
TInt delta = 0; |
|
741 |
if(iLandscapeScrolling) |
|
742 |
{ |
|
743 |
delta = iPrev.iX - aEvent.iPosition.iX; |
|
744 |
} |
|
745 |
else |
|
746 |
{ |
|
747 |
delta = iPrev.iY - aEvent.iPosition.iY; |
|
748 |
} |
|
749 |
||
750 |
delta = delta < 0 ? -delta : delta; |
|
751 |
iPanning = delta >= iPhysics->DragThreshold(); |
|
752 |
} |
|
753 |
||
754 |
//if user has dragged onto another item |
|
755 |
if( !iPanning && GetSelected(iStart) != GetSelected(aEvent.iPosition) ) |
|
756 |
{ |
|
757 |
// after setting iPanning true, longtap is cancelled |
|
758 |
iPanning = ETrue; |
|
759 |
} |
|
760 |
||
761 |
if( prevPanning != iPanning ) |
|
762 |
{ |
|
763 |
iPrev = aEvent.iPosition; |
|
764 |
DrawDeferred(); // to clear highlight |
|
765 |
} |
|
766 |
||
767 |
if(iPanning) |
|
768 |
{ |
|
769 |
TPoint delta = iPrev - aEvent.iPosition; |
|
770 |
if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored()) |
|
771 |
delta = -delta; |
|
772 |
iPhysics->RegisterPanningPosition( delta ); |
|
773 |
iPrev = aEvent.iPosition; |
|
774 |
iHighlightTimer->Cancel(); |
|
775 |
} |
|
776 |
} |
|
777 |
||
778 |
// ----------------------------------------------------------------------------- |
|
779 |
// CHgScroller::HandleUpEventL() |
|
780 |
// ----------------------------------------------------------------------------- |
|
781 |
// |
|
782 |
void CHgScroller::HandleUpEventL( const TPointerEvent& aEvent ) |
|
783 |
{ |
|
784 |
if( iPanning ) |
|
785 |
{ |
|
786 |
// enable physics |
|
787 |
TPoint drag = iStart - aEvent.iPosition; |
|
788 |
if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored()) |
|
789 |
drag = -drag; |
|
790 |
iPhysics->StartPhysics(drag, iStartTime); |
|
791 |
iPointerDown = EFalse; |
|
792 |
} |
|
793 |
else |
|
794 |
{ |
|
795 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
796 |
if ( feedback && iSelectedIndex != KErrNotFound ) |
|
797 |
{ |
|
798 |
feedback->InstantFeedback( this, ETouchFeedbackList, ETouchFeedbackVibra, aEvent ); |
|
799 |
} |
|
800 |
||
801 |
HandleSelectionL(); |
|
802 |
} |
|
803 |
} |
|
804 |
||
805 |
// ----------------------------------------------------------------------------- |
|
806 |
// CHgScroller::HandleSelectionL() |
|
807 |
// ----------------------------------------------------------------------------- |
|
808 |
// |
|
809 |
void CHgScroller::HandleSelectionL() |
|
810 |
{ |
|
811 |
TInt index = GetSelected(iStart); |
|
812 |
if(index != KErrNotFound) |
|
813 |
{ |
|
814 |
if( iFocusedIndex == KErrNotFound ) |
|
815 |
{ |
|
816 |
// Highlight timer hasn't triggered so lets set the highlight. |
|
817 |
// this is not usually the case since interval is 50ms but just to be sure. |
|
818 |
SetHighlightL(); |
|
819 |
} |
|
820 |
||
821 |
iPointerDown = EFalse; |
|
822 |
||
823 |
// selection needs to be valid. |
|
824 |
if( iSelectedIndex >= 0 && iSelectedIndex < iItems.Count() ) |
|
825 |
{ |
|
826 |
if( iFlags & EHgScrollerSelectionMode || iSelectionMode != ENoSelection ) |
|
827 |
// Marking mode or shift key pressed ( or hash ) |
|
828 |
{ |
|
829 |
if( iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked ) |
|
830 |
{ |
|
831 |
UnMark( iSelectedIndex ); |
|
832 |
} |
|
833 |
else |
|
834 |
{ |
|
835 |
Mark( iSelectedIndex ); |
|
836 |
} |
|
837 |
DrawDeferred(); |
|
838 |
} |
|
839 |
else // Selection |
|
840 |
{ |
|
841 |
if( iSelectionToFocusedItem || !HasHighlight() ) |
|
842 |
{ |
|
843 |
if(iSelectionObserver) |
|
844 |
iSelectionObserver->HandleOpenL(iSelectedIndex); |
|
845 |
} |
|
846 |
} |
|
847 |
} |
|
848 |
} |
|
849 |
else |
|
850 |
{ |
|
851 |
iPointerDown = EFalse; |
|
852 |
} |
|
853 |
} |
|
854 |
||
855 |
// ----------------------------------------------------------------------------- |
|
856 |
// CHgScroller::OfferKeyEventL() |
|
857 |
// ----------------------------------------------------------------------------- |
|
858 |
// |
|
859 |
TKeyResponse CHgScroller::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
860 |
{ |
|
861 |
if( iKeyUtils |
|
862 |
&& !(iFlags & EHgScrollerKeyMarkingDisabled) |
|
863 |
&& iKeyUtils->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed ) |
|
864 |
return EKeyWasConsumed; |
|
865 |
||
866 |
switch( aType ) |
|
867 |
{ |
|
868 |
case EEventKeyDown: |
|
869 |
KeyEventDown(); |
|
870 |
break; |
|
871 |
case EEventKey: |
|
872 |
return HandleKeyEvent( aKeyEvent ); |
|
873 |
case EEventKeyUp: |
|
874 |
KeyEventUp(); |
|
875 |
default: |
|
876 |
break; |
|
877 |
} |
|
878 |
||
879 |
// Let CCoeControl handle other cases. |
|
880 |
return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); |
|
881 |
} |
|
882 |
||
883 |
// ----------------------------------------------------------------------------- |
|
884 |
// CHgScroller::KeyEventDown() |
|
885 |
// ----------------------------------------------------------------------------- |
|
886 |
// |
|
887 |
void CHgScroller::KeyEventDown() |
|
888 |
{ |
|
889 |
iKeyRepeats = 0; |
|
890 |
iKeyScrollingState = ENoKeyScrolling; |
|
891 |
||
892 |
iPointerDown = EFalse; |
|
893 |
iPanning = EFalse; |
|
894 |
} |
|
895 |
||
896 |
// ----------------------------------------------------------------------------- |
|
897 |
// CHgScroller::KeyEventUp() |
|
898 |
// ----------------------------------------------------------------------------- |
|
899 |
// |
|
900 |
void CHgScroller::KeyEventUp() |
|
901 |
{ |
|
902 |
if( iKeyScrollingState != ENoKeyScrolling ) |
|
903 |
{ |
|
904 |
// Key has been released so stop the key scrolling. |
|
905 |
StopKeyScrolling(); |
|
906 |
} |
|
907 |
} |
|
908 |
||
909 |
// ----------------------------------------------------------------------------- |
|
910 |
// CHgScroller::SetItem() |
|
911 |
// ----------------------------------------------------------------------------- |
|
912 |
// |
|
913 |
EXPORT_C void CHgScroller::SetItem(CHgItem* aItem, TInt aIndex) |
|
914 |
{ |
|
915 |
if( aItem && aIndex >= 0 && aIndex < iItems.Count() ) |
|
916 |
{ |
|
917 |
delete iItems[aIndex]; |
|
918 |
iItems[aIndex] = aItem; |
|
919 |
} |
|
920 |
} |
|
921 |
||
922 |
// ----------------------------------------------------------------------------- |
|
923 |
// CHgScroller::AddItem() |
|
924 |
// ----------------------------------------------------------------------------- |
|
925 |
// |
|
926 |
EXPORT_C void CHgScroller::AddItem(CHgItem* aItem) |
|
927 |
{ |
|
928 |
if( aItem ) |
|
929 |
{ |
|
930 |
iItems.Append(aItem); |
|
931 |
iItemCount++; |
|
932 |
HandleItemCountChanged(); |
|
933 |
if( iManager ) |
|
934 |
{ |
|
935 |
iManager->ItemCountChanged( iItemCount-1, EFalse, iItemCount ); |
|
936 |
} |
|
937 |
} |
|
938 |
} |
|
939 |
||
940 |
// ----------------------------------------------------------------------------- |
|
941 |
// CHgScroller::InsertItem() |
|
942 |
// ----------------------------------------------------------------------------- |
|
943 |
// |
|
944 |
EXPORT_C void CHgScroller::InsertItem(CHgItem* aItem, TInt aIndex) |
|
945 |
{ |
|
946 |
if( aItem && aIndex >= 0 ) |
|
947 |
{ |
|
948 |
if(aIndex < iItems.Count()) |
|
949 |
{ |
|
950 |
iItems.Insert(aItem, aIndex); |
|
951 |
} |
|
952 |
else |
|
953 |
{ |
|
954 |
iItems.Append(aItem); |
|
955 |
} |
|
956 |
iItemCount++; |
|
957 |
HandleItemCountChanged(); |
|
958 |
||
959 |
if( iManager ) |
|
960 |
{ |
|
961 |
iManager->ItemCountChanged( aIndex, EFalse, iItemCount ); |
|
962 |
} |
|
963 |
} |
|
964 |
} |
|
965 |
||
966 |
// ----------------------------------------------------------------------------- |
|
967 |
// CHgScroller::RemoveItem() |
|
968 |
// ----------------------------------------------------------------------------- |
|
969 |
// |
|
970 |
EXPORT_C void CHgScroller::RemoveItem(TInt aIndex) |
|
971 |
{ |
|
972 |
if( aIndex >= 0 && aIndex < iItems.Count() ) |
|
973 |
{ |
|
974 |
delete iItems[aIndex]; iItems[aIndex] = NULL; |
|
975 |
iItems.Remove(aIndex); |
|
976 |
iItemCount--; |
|
977 |
HandleItemCountChanged(); |
|
978 |
||
979 |
if( iManager ) |
|
980 |
{ |
|
981 |
iManager->ItemCountChanged( aIndex, ETrue, iItemCount ); |
|
982 |
} |
|
983 |
} |
|
984 |
} |
|
985 |
||
986 |
// ----------------------------------------------------------------------------- |
|
987 |
// CHgScroller::ResizeL() |
|
988 |
// ----------------------------------------------------------------------------- |
|
989 |
// |
|
990 |
EXPORT_C void CHgScroller::ResizeL( TInt aItemCount ) |
|
991 |
{ |
|
992 |
// Add More |
|
993 |
if( iItems.Count() < aItemCount ) |
|
994 |
{ |
|
995 |
while( iItems.Count() < aItemCount ) |
|
996 |
{ |
|
997 |
iItems.AppendL( CHgItem::NewL() ); |
|
998 |
} |
|
999 |
} |
|
1000 |
// remove from the end |
|
1001 |
else if( iItems.Count() > aItemCount ) |
|
1002 |
{ |
|
1003 |
while( iItems.Count() > aItemCount ) |
|
1004 |
{ |
|
1005 |
delete iItems[iItems.Count() - 1]; |
|
1006 |
iItems.Remove( iItems.Count() - 1 ); |
|
1007 |
} |
|
1008 |
} |
|
1009 |
else |
|
1010 |
{ |
|
1011 |
return; // no change needed |
|
1012 |
} |
|
1013 |
||
1014 |
iItemCount = aItemCount; |
|
1015 |
||
1016 |
if( iManager ) |
|
1017 |
{ |
|
1018 |
iManager->ResetBuffer( iSelectedIndex, iItemCount ); |
|
1019 |
} |
|
1020 |
||
1021 |
HandleItemCountChanged(); |
|
1022 |
} |
|
1023 |
||
1024 |
// ----------------------------------------------------------------------------- |
|
1025 |
// CHgScroller::ItemL() |
|
1026 |
// ----------------------------------------------------------------------------- |
|
1027 |
// |
|
1028 |
EXPORT_C CHgItem& CHgScroller::ItemL(TInt aIndex) |
|
1029 |
{ |
|
1030 |
if( aIndex < 0 || aIndex >= iItems.Count() ) |
|
1031 |
{ |
|
1032 |
User::Leave( KErrArgument ); |
|
1033 |
} |
|
1034 |
||
1035 |
return *iItems[aIndex]; |
|
1036 |
} |
|
1037 |
||
1038 |
// ----------------------------------------------------------------------------- |
|
1039 |
// CHgScroller::ViewPositionChanged() |
|
1040 |
// ----------------------------------------------------------------------------- |
|
1041 |
// |
|
1042 |
void CHgScroller::ViewPositionChanged( const TPoint& aNewPosition, |
|
1043 |
TBool aDrawNow, |
|
1044 |
TUint /*aFlags*/ ) |
|
1045 |
{ |
|
1046 |
iViewPosition = aNewPosition; |
|
1047 |
HandleViewPositionChanged(); |
|
1048 |
if( aDrawNow ) |
|
1049 |
DrawNow(); |
|
1050 |
} |
|
1051 |
||
1052 |
// ----------------------------------------------------------------------------- |
|
1053 |
// CHgScroller::ScrollBarPositionChanged() |
|
1054 |
// ----------------------------------------------------------------------------- |
|
1055 |
// |
|
1056 |
void CHgScroller::ScrollBarPositionChanged( const TPoint& aNewPosition ) |
|
1057 |
{ |
|
1058 |
if( iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking ) |
|
1059 |
return; |
|
1060 |
||
1061 |
iViewPosition = aNewPosition; |
|
1062 |
iPhysics->StopPhysics(); |
|
1063 |
||
1064 |
if( iScrollBarType == EHgScrollerTimeStrip ) |
|
1065 |
{ |
|
1066 |
// Show first item's time. |
|
1067 |
TInt selectedItem = CurrentIndex(); |
|
1068 |
if( selectedItem >= 0 && selectedItem < iItems.Count() |
|
1069 |
&& iItems[selectedItem]->Time().Int64() ) |
|
1070 |
{ |
|
1071 |
TRAP_IGNORE( |
|
1072 |
iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString ); |
|
1073 |
iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString ); |
|
1074 |
) |
|
1075 |
// To display month and year correctly in arabic. |
|
1076 |
AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 ); |
|
1077 |
AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 ); |
|
1078 |
} |
|
1079 |
} |
|
1080 |
else if( iScrollBarType == EHgScrollerLetterStrip |
|
1081 |
|| iScrollBarType == EHgScrollerLetterStripLite ) |
|
1082 |
{ |
|
1083 |
TInt selectedItem = CurrentIndex(); |
|
1084 |
if( selectedItem >= 0 && selectedItem < iItems.Count() ) |
|
1085 |
{ |
|
1086 |
if(iItems[selectedItem]->Title().Length()) |
|
1087 |
{ |
|
1088 |
iPopupText1.Zero(); |
|
1089 |
iPopupText1.Append( iItems[selectedItem]->Title()[0] ); |
|
1090 |
iPopupText1.UpperCase(); |
|
1091 |
} |
|
1092 |
} |
|
1093 |
} |
|
1094 |
HandleViewPositionChanged( EFalse ); |
|
1095 |
DrawNow(); |
|
1096 |
} |
|
1097 |
||
1098 |
// ----------------------------------------------------------------------------- |
|
1099 |
// CHgScroller::HandleNaviStripChar() |
|
1100 |
// ----------------------------------------------------------------------------- |
|
1101 |
// |
|
1102 |
void CHgScroller::HandleNaviStripChar( const TChar& /*aChar*/ ) |
|
1103 |
{ |
|
1104 |
// Feature not used anymore |
|
1105 |
} |
|
1106 |
||
1107 |
// ----------------------------------------------------------------------------- |
|
1108 |
// CHgScroller::PhysicEmulationEnded() |
|
1109 |
// ----------------------------------------------------------------------------- |
|
1110 |
// |
|
1111 |
void CHgScroller::PhysicEmulationEnded() |
|
1112 |
{ |
|
1113 |
// Nothing to do. |
|
1114 |
} |
|
1115 |
||
1116 |
// ----------------------------------------------------------------------------- |
|
1117 |
// CHgScroller::HandleViewPositionChanged() |
|
1118 |
// ----------------------------------------------------------------------------- |
|
1119 |
// |
|
1120 |
void CHgScroller::HandleViewPositionChanged(TBool aUpdateScrollbar) |
|
1121 |
{ |
|
1122 |
TInt newRow = iLandscapeScrolling ? |
|
1123 |
(iViewPosition.iX-(iWidth/2))/((iRowHeight)): |
|
1124 |
(iViewPosition.iY-(iHeight/2))/(iRowHeight); |
|
1125 |
||
1126 |
if(iScrollbar && aUpdateScrollbar) |
|
1127 |
iScrollbar->SetViewPosition( iViewPosition - TPoint(iWidth/2, iHeight/2)); |
|
1128 |
||
1129 |
if(newRow != iCurrentRow) |
|
1130 |
{ |
|
1131 |
iCurrentRow = newRow; |
|
1132 |
||
1133 |
TBool needsFeedback = |
|
1134 |
( CurrentIndex() > 0 && CurrentIndex() <= iItems.Count() ) |
|
1135 |
|| ( iItems.Count() - CurrentIndex() > ItemsOnScreen() ); |
|
1136 |
||
1137 |
TInt action = iPhysics->OngoingPhysicsAction(); |
|
1138 |
if( action != CAknPhysics::EAknPhysicsActionNone && needsFeedback ) |
|
1139 |
{ |
|
1140 |
MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1141 |
if(feedback) |
|
1142 |
feedback->InstantFeedback( this, ETouchFeedbackSensitiveList, |
|
1143 |
ETouchFeedbackVibra, TPointerEvent() ); |
|
1144 |
} |
|
1145 |
||
1146 |
if(iManager) |
|
1147 |
{ |
|
1148 |
iManager->SetPosition( CurrentIndex() ); |
|
1149 |
} |
|
1150 |
} |
|
1151 |
} |
|
1152 |
||
1153 |
// ----------------------------------------------------------------------------- |
|
1154 |
// CHgScroller::HandleViewPositionChanged() |
|
1155 |
// ----------------------------------------------------------------------------- |
|
1156 |
// |
|
1157 |
TPoint CHgScroller::ViewPosition() const |
|
1158 |
{ |
|
1159 |
return iViewPosition; |
|
1160 |
} |
|
1161 |
||
1162 |
// ----------------------------------------------------------------------------- |
|
1163 |
// CHgScroller::HandleKeyEvent() |
|
1164 |
// ----------------------------------------------------------------------------- |
|
1165 |
// |
|
1166 |
TKeyResponse CHgScroller::HandleKeyEvent(const TKeyEvent& aKeyEvent) |
|
1167 |
{ |
|
1168 |
iKeyRepeats++; |
|
1169 |
TInt prevSelected = iSelectedIndex; |
|
1170 |
||
1171 |
TKeyScrollingState possibleKeyScrollingState = ENoKeyScrolling; |
|
1172 |
||
1173 |
switch( aKeyEvent.iCode ) |
|
1174 |
{ |
|
1175 |
case EKeyUpArrow: |
|
1176 |
if( !iLandscapeScrolling ) |
|
1177 |
possibleKeyScrollingState = EKeyScrollingUp; |
|
1178 |
break; |
|
1179 |
case EKeyDownArrow: |
|
1180 |
if( !iLandscapeScrolling ) |
|
1181 |
possibleKeyScrollingState = EKeyScrollingDown; |
|
1182 |
break; |
|
1183 |
case EKeyLeftArrow: |
|
1184 |
if( iLandscapeScrolling ) |
|
1185 |
possibleKeyScrollingState = EKeyScrollingLeft; |
|
1186 |
break; |
|
1187 |
case EKeyRightArrow: |
|
1188 |
if( iLandscapeScrolling ) |
|
1189 |
possibleKeyScrollingState = EKeyScrollingRight; |
|
1190 |
break; |
|
1191 |
case EKeyEnter: |
|
1192 |
case EKeyOK: |
|
1193 |
{ |
|
1194 |
if( iSelectedIndex != KErrNotFound && HasHighlight() ) |
|
1195 |
{ |
|
1196 |
iShowHighlight = EFalse; |
|
1197 |
iDrawUtils->EnableMarquee(HasHighlight()); |
|
1198 |
if( iSelectionObserver ) |
|
1199 |
TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); ) |
|
1200 |
return EKeyWasConsumed; |
|
1201 |
} |
|
1202 |
else if( iItemCount ) |
|
1203 |
{ |
|
1204 |
iSelectedIndex = CurrentIndex(); |
|
1205 |
FitSelectionToView(); |
|
1206 |
iShowHighlight = ETrue; |
|
1207 |
iDrawUtils->EnableMarquee(HasHighlight()); |
|
1208 |
DrawDeferred(); |
|
1209 |
if( iSelectionObserver ) |
|
1210 |
TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); ) |
|
1211 |
return EKeyWasConsumed; |
|
1212 |
} |
|
1213 |
return EKeyWasNotConsumed; |
|
1214 |
} |
|
1215 |
default: |
|
1216 |
break; |
|
1217 |
} |
|
1218 |
||
1219 |
if( possibleKeyScrollingState != ENoKeyScrolling |
|
1220 |
&& iKeyRepeats > KPhysLaunchKeyCount |
|
1221 |
&& iSelectionMode == ENoSelection ) |
|
1222 |
{ |
|
1223 |
if( !iKeyScrollingTimer->IsActive() ) |
|
1224 |
{ |
|
1225 |
iKeyScrollingState = possibleKeyScrollingState; |
|
1226 |
iKeyScrollingTimer->Start( |
|
1227 |
TTimeIntervalMicroSeconds32( 0 ), |
|
1228 |
TTimeIntervalMicroSeconds32( KKeyScrollingUpdateInterval ), |
|
1229 |
TCallBack( KeyScrollingTimerCallback, this ) ); |
|
1230 |
} |
|
1231 |
} |
|
1232 |
||
1233 |
if( !HasHighlight() ) |
|
1234 |
{ |
|
1235 |
// DoHandleKeyEvent will move focus at the first index on screen. |
|
1236 |
iSelectedIndex = KErrNotFound; |
|
1237 |
} |
|
1238 |
||
1239 |
if( DoHandleKeyEvent(aKeyEvent) ) |
|
1240 |
{ |
|
1241 |
iShowHighlight = ETrue; |
|
1242 |
iDrawUtils->EnableMarquee(HasHighlight()); |
|
1243 |
if( iSelectedIndex != prevSelected && iSelectionObserver ) |
|
1244 |
{ |
|
1245 |
iDrawUtils->ResetMarquee(); |
|
1246 |
TRAP_IGNORE( iSelectionObserver->HandleSelectL(iSelectedIndex); ) |
|
1247 |
} |
|
1248 |
return EKeyWasConsumed; |
|
1249 |
} |
|
1250 |
else |
|
1251 |
{ |
|
1252 |
iKeyRepeats--; |
|
1253 |
return EKeyWasNotConsumed; |
|
1254 |
} |
|
1255 |
} |
|
1256 |
||
1257 |
// ----------------------------------------------------------------------------- |
|
1258 |
// CHgScroller::Release() |
|
1259 |
// ----------------------------------------------------------------------------- |
|
1260 |
// |
|
1261 |
void CHgScroller::Release(TInt aReleaseStart, TInt aReleaseEnd) |
|
1262 |
{ |
|
1263 |
for(; aReleaseStart <= aReleaseEnd; ++aReleaseStart) |
|
1264 |
{ |
|
1265 |
if( aReleaseStart >= 0 && aReleaseStart < iItems.Count()) |
|
1266 |
{ |
|
1267 |
iItems[aReleaseStart]->SetIcon(NULL, iItems[aReleaseStart]->Flags()); |
|
1268 |
} |
|
1269 |
} |
|
1270 |
} |
|
1271 |
||
1272 |
// ----------------------------------------------------------------------------- |
|
1273 |
// CHgScroller::Reset() |
|
1274 |
// ----------------------------------------------------------------------------- |
|
1275 |
// |
|
1276 |
EXPORT_C void CHgScroller::Reset() |
|
1277 |
{ |
|
1278 |
if(iItemCount) |
|
1279 |
{ |
|
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1280 |
iHighlightTimer->Cancel(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1281 |
iPointerDown = EFalse; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1282 |
if(iDetector) |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1283 |
iDetector->CancelAnimationL(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1284 |
iPanning = EFalse; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1285 |
|
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1286 |
iPhysics->StopPhysics(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1287 |
iPhysics->ResetFriction(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1288 |
|
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1289 |
iFocusedIndex = KErrNotFound; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1290 |
iSelectionToFocusedItem = EFalse; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1291 |
iDrawUtils->EnableMarquee(false); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1292 |
|
56 | 1293 |
iItems.ResetAndDestroy(); |
1294 |
iItemCount = 0; |
|
1295 |
iSelectedIndex = KErrNotFound; |
|
1296 |
||
1297 |
if( iManager ) |
|
1298 |
{ |
|
1299 |
iManager->ResetBuffer( iSelectedIndex, iItemCount ); |
|
1300 |
} |
|
1301 |
||
1302 |
HandleItemCountChanged(); |
|
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1303 |
|
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1304 |
iViewPosition = TPoint(iWidth/2, iHeight/2); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1305 |
HandleViewPositionChanged(); |
56 | 1306 |
} |
1307 |
} |
|
1308 |
||
1309 |
// ----------------------------------------------------------------------------- |
|
1310 |
// CHgScroller::SetFlags() |
|
1311 |
// ----------------------------------------------------------------------------- |
|
1312 |
// |
|
1313 |
EXPORT_C void CHgScroller::SetFlags(TInt aFlags) |
|
1314 |
{ |
|
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1315 |
const TBool currentSelectionMode = iFlags & EHgScrollerSelectionMode; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1316 |
const TBool newSelectionMode = aFlags & EHgScrollerSelectionMode; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1317 |
if( currentSelectionMode != newSelectionMode ) |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1318 |
{ |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1319 |
// when selection mode changes we need to repaint |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1320 |
DrawDeferred(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1321 |
} |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1322 |
|
56 | 1323 |
iFlags |= aFlags; |
1324 |
} |
|
1325 |
||
1326 |
// ----------------------------------------------------------------------------- |
|
1327 |
// CHgScroller::ClearFlags() |
|
1328 |
// ----------------------------------------------------------------------------- |
|
1329 |
// |
|
1330 |
EXPORT_C void CHgScroller::ClearFlags(TInt aFlags) |
|
1331 |
{ |
|
1332 |
iFlags &= ~aFlags; |
|
1333 |
} |
|
1334 |
||
1335 |
// ----------------------------------------------------------------------------- |
|
1336 |
// CHgScroller::Flags() |
|
1337 |
// ----------------------------------------------------------------------------- |
|
1338 |
// |
|
1339 |
EXPORT_C TInt CHgScroller::Flags() |
|
1340 |
{ |
|
1341 |
return iFlags; |
|
1342 |
} |
|
1343 |
||
1344 |
// ----------------------------------------------------------------------------- |
|
1345 |
// CHgScroller::SetEmptyTextL() |
|
1346 |
// ----------------------------------------------------------------------------- |
|
1347 |
// |
|
1348 |
EXPORT_C void CHgScroller::SetEmptyTextL( const TDesC& aEmptyText ) |
|
1349 |
{ |
|
1350 |
delete iEmptyText; |
|
1351 |
iEmptyText = 0; |
|
1352 |
iEmptyText = aEmptyText.AllocL(); |
|
1353 |
} |
|
1354 |
||
1355 |
// ----------------------------------------------------------------------------- |
|
1356 |
// CHgScroller::ItemCount() |
|
1357 |
// ----------------------------------------------------------------------------- |
|
1358 |
// |
|
1359 |
EXPORT_C TInt CHgScroller::ItemCount() const |
|
1360 |
{ |
|
1361 |
return iItems.Count(); |
|
1362 |
} |
|
1363 |
||
1364 |
// ----------------------------------------------------------------------------- |
|
1365 |
// CHgScroller::HightlightItem() |
|
1366 |
// ----------------------------------------------------------------------------- |
|
1367 |
// |
|
1368 |
EXPORT_C TBool CHgScroller::HightlightItem( const TDesC& aHighlightText ) |
|
1369 |
{ |
|
1370 |
TInt searchStartIndex = aHighlightText.Length() == 1 || |
|
1371 |
iSelectedIndex == KErrNotFound ? iSelectedIndex + 1 : iSelectedIndex; |
|
1372 |
||
1373 |
// From selected to end |
|
1374 |
for(TInt i = searchStartIndex; i < iItems.Count(); ++i) |
|
1375 |
{ |
|
1376 |
if(iItems[i]->Title().Length() > 0 ) |
|
1377 |
{ |
|
1378 |
iUpperCaseTitle.Copy( iItems[i]->Title().Left( aHighlightText.Length() ) ); |
|
1379 |
iUpperCaseTitle.UpperCase(); |
|
1380 |
TInt result = iUpperCaseTitle.CompareC( aHighlightText ); |
|
1381 |
||
1382 |
if(result == 0) |
|
1383 |
{ |
|
1384 |
iSelectedIndex = i; |
|
1385 |
FitSelectionToView(); |
|
1386 |
DrawDeferred(); |
|
1387 |
return ETrue; |
|
1388 |
} |
|
1389 |
} |
|
1390 |
} |
|
1391 |
||
1392 |
// From beginning to selected - 1 |
|
1393 |
for(TInt i = 0; i < iSelectedIndex; ++i) |
|
1394 |
{ |
|
1395 |
if(iItems[i]->Title().Length() > 0 ) |
|
1396 |
{ |
|
1397 |
iUpperCaseTitle.Copy( iItems[i]->Title().Left( aHighlightText.Length() ) ); |
|
1398 |
iUpperCaseTitle.UpperCase(); |
|
1399 |
TInt result = iUpperCaseTitle.CompareC( aHighlightText ); |
|
1400 |
||
1401 |
if(result == 0) |
|
1402 |
{ |
|
1403 |
iSelectedIndex = i; |
|
1404 |
FitSelectionToView(); |
|
1405 |
DrawDeferred(); |
|
1406 |
return ETrue; |
|
1407 |
} |
|
1408 |
else if( result > 0) |
|
1409 |
{ |
|
1410 |
break; |
|
1411 |
} |
|
1412 |
} |
|
1413 |
} |
|
1414 |
||
1415 |
return EFalse; |
|
1416 |
} |
|
1417 |
||
1418 |
// ----------------------------------------------------------------------------- |
|
1419 |
// CHgScroller::SetDefaultIconL() |
|
1420 |
// ----------------------------------------------------------------------------- |
|
1421 |
// |
|
1422 |
EXPORT_C void CHgScroller::SetDefaultIconL( CGulIcon* aDefaultIcon ) |
|
1423 |
{ |
|
1424 |
if( aDefaultIcon ) |
|
1425 |
{ |
|
1426 |
delete iDefaultIcon; |
|
1427 |
iDefaultIcon = aDefaultIcon; |
|
1428 |
} |
|
1429 |
} |
|
1430 |
||
1431 |
// ----------------------------------------------------------------------------- |
|
1432 |
// CHgScroller::DisableScrollBuffer() |
|
1433 |
// ----------------------------------------------------------------------------- |
|
1434 |
// |
|
1435 |
EXPORT_C void CHgScroller::DisableScrollBuffer() |
|
1436 |
{ |
|
1437 |
delete iManager; |
|
1438 |
iManager = NULL; |
|
1439 |
} |
|
1440 |
||
1441 |
// ----------------------------------------------------------------------------- |
|
1442 |
// CHgScroller::InitGraphicsL() |
|
1443 |
// ----------------------------------------------------------------------------- |
|
1444 |
// |
|
1445 |
void CHgScroller::InitGraphicsL() |
|
1446 |
{ |
|
1447 |
// Non-Skinned icons |
|
1448 |
// Default icon |
|
1449 |
if(iIndicatorManager) |
|
1450 |
{ |
|
1451 |
iIndicatorManager->InitIconL(iDefaultIcon, |
|
1452 |
EMbmGanesQgn_prop_checkbox_on, EMbmGanesQgn_prop_checkbox_on_mask, iImageSize); |
|
1453 |
||
1454 |
iIndicatorManager->InitIndicatorsL(iIndicatorSize); |
|
1455 |
} |
|
1456 |
} |
|
1457 |
||
1458 |
// ----------------------------------------------------------------------------- |
|
1459 |
// CHgScroller::SelectionChanged() |
|
1460 |
// ----------------------------------------------------------------------------- |
|
1461 |
// |
|
1462 |
void CHgScroller::SelectionChanged() |
|
1463 |
{ |
|
1464 |
} |
|
1465 |
||
1466 |
// ----------------------------------------------------------------------------- |
|
1467 |
// CHgScroller::FitRowToView() |
|
1468 |
// ----------------------------------------------------------------------------- |
|
1469 |
// |
|
1470 |
void CHgScroller::FitRowToView( TInt aRow ) |
|
1471 |
{ |
|
1472 |
if( iLandscapeScrolling ) |
|
1473 |
{ |
|
1474 |
if ( aRow*iRowHeight < iViewPosition.iX-(iWidth/2) ) |
|
1475 |
{ |
|
1476 |
// Item is at top but not fully visible |
|
1477 |
iViewPosition.iX -= (iViewPosition.iX-(iWidth/2) - ((aRow)*iRowHeight)); |
|
1478 |
HandleViewPositionChanged(); |
|
1479 |
} |
|
1480 |
else if ( (aRow+1)*iRowHeight > iViewPosition.iX+(iWidth/2) ) |
|
1481 |
{ |
|
1482 |
// Item is at bottom but not fully visible |
|
1483 |
iViewPosition.iX += ((aRow+1)*iRowHeight - (iViewPosition.iX+(iWidth/2))); |
|
1484 |
HandleViewPositionChanged(); |
|
1485 |
} |
|
1486 |
} |
|
1487 |
else |
|
1488 |
{ |
|
1489 |
if ( aRow*iRowHeight < iViewPosition.iY-(iHeight/2) ) |
|
1490 |
{ |
|
1491 |
// Item is at top but not fully visible |
|
1492 |
iViewPosition.iY -= (iViewPosition.iY-(iHeight/2) - ((aRow)*iRowHeight)); |
|
1493 |
HandleViewPositionChanged(); |
|
1494 |
} |
|
1495 |
else if ( (aRow+1)*iRowHeight > iViewPosition.iY+(iHeight/2) ) |
|
1496 |
{ |
|
1497 |
// Item is at bottom but not fully visible |
|
1498 |
iViewPosition.iY += ((aRow+1)*iRowHeight - (iViewPosition.iY+(iHeight/2))); |
|
1499 |
HandleViewPositionChanged(); |
|
1500 |
} |
|
1501 |
} |
|
1502 |
} |
|
1503 |
||
1504 |
// ----------------------------------------------------------------------------- |
|
1505 |
// CHgScroller::MarqueeCallback() |
|
1506 |
// ----------------------------------------------------------------------------- |
|
1507 |
// |
|
1508 |
TInt CHgScroller::MarqueeCallback( TAny* aSelf ) |
|
1509 |
{ |
|
1510 |
CHgScroller* self = static_cast<CHgScroller*>(aSelf); |
|
1511 |
if( self->IsDisplayed( self->iSelectedIndex ) ) |
|
1512 |
{ |
|
1513 |
self->DrawDeferred(); |
|
1514 |
return ETrue; |
|
1515 |
} |
|
1516 |
else |
|
1517 |
{ |
|
1518 |
return EFalse; |
|
1519 |
} |
|
1520 |
} |
|
1521 |
||
1522 |
// ----------------------------------------------------------------------------- |
|
1523 |
// CHgScroller::HandleGainingForeground() |
|
1524 |
// ----------------------------------------------------------------------------- |
|
1525 |
// |
|
1526 |
void CHgScroller::HandleGainingForeground() |
|
1527 |
{ |
|
1528 |
iSelectionMode = ENoSelection; |
|
1529 |
iScrollbar->Reset(); |
|
1530 |
} |
|
1531 |
||
1532 |
// ----------------------------------------------------------------------------- |
|
1533 |
// CHgScroller::HandleLosingForeground() |
|
1534 |
// ----------------------------------------------------------------------------- |
|
1535 |
// |
|
1536 |
void CHgScroller::HandleLosingForeground() |
|
1537 |
{ |
|
1538 |
if( iOldWinPos == KErrNotFound |
|
1539 |
|| iOldWinPos == DrawableWindow()->OrdinalPosition() ) |
|
1540 |
{ |
|
1541 |
iPointerDown = EFalse; |
|
1542 |
} |
|
1543 |
||
1544 |
iPopupText1.Zero(); |
|
1545 |
iPopupText2.Zero(); |
|
1546 |
} |
|
1547 |
||
1548 |
// --------------------------------------------------------------------------- |
|
1549 |
// CHgScroller::LaunchHighlightTimer() |
|
1550 |
// --------------------------------------------------------------------------- |
|
1551 |
// |
|
1552 |
void CHgScroller::LaunchHighlightTimer() |
|
1553 |
{ |
|
1554 |
if ( !iHighlightTimer ) |
|
1555 |
{ |
|
1556 |
return; |
|
1557 |
} |
|
1558 |
||
1559 |
TInt highlightTimeout( 0 ); |
|
1560 |
if ( iPhysics ) |
|
1561 |
{ |
|
1562 |
highlightTimeout = iPhysics->HighlightTimeout() * 1000; |
|
1563 |
} |
|
1564 |
if ( highlightTimeout == 0 ) |
|
1565 |
{ |
|
1566 |
highlightTimeout = KDefaultHighlightTimeout; |
|
1567 |
} |
|
1568 |
||
1569 |
iHighlightTimer->Cancel(); |
|
1570 |
iHighlightTimer->Start( |
|
1571 |
TTimeIntervalMicroSeconds32( highlightTimeout ), |
|
1572 |
TTimeIntervalMicroSeconds32( highlightTimeout ), |
|
1573 |
TCallBack( HighlightTimerCallback, this ) ); |
|
1574 |
} |
|
1575 |
||
1576 |
||
1577 |
// --------------------------------------------------------------------------- |
|
1578 |
// CHgScroller::HighlightTimerCallback() |
|
1579 |
// --------------------------------------------------------------------------- |
|
1580 |
// |
|
1581 |
TInt CHgScroller::HighlightTimerCallback( TAny* aPtr ) |
|
1582 |
{ |
|
1583 |
CHgScroller* scroller = |
|
1584 |
static_cast<CHgScroller*>( aPtr ); |
|
1585 |
||
1586 |
TInt err = KErrNotFound; |
|
1587 |
||
1588 |
if ( scroller ) |
|
1589 |
{ |
|
1590 |
TRAP( err, scroller->SetHighlightL() ); |
|
1591 |
} |
|
1592 |
||
1593 |
return err; |
|
1594 |
} |
|
1595 |
||
1596 |
// --------------------------------------------------------------------------- |
|
1597 |
// CHgScroller::SetHighlightL() |
|
1598 |
// --------------------------------------------------------------------------- |
|
1599 |
// |
|
1600 |
void CHgScroller::SetHighlightL() |
|
1601 |
{ |
|
1602 |
iHighlightTimer->Cancel(); |
|
1603 |
||
1604 |
TInt index = GetSelected(iStart); |
|
1605 |
if((index != KErrNotFound || !HasHighlight()) |
|
1606 |
&& iPointerDown ) |
|
1607 |
{ |
|
1608 |
iSelectionToFocusedItem = (index == iSelectedIndex); |
|
1609 |
iSelectedIndex = index; |
|
1610 |
iFocusedIndex = index; |
|
1611 |
// Selection has changed to valid item |
|
1612 |
if( !iSelectionToFocusedItem && iSelectedIndex != KErrNotFound ) |
|
1613 |
{ |
|
1614 |
if( iSelectionObserver ) |
|
1615 |
iSelectionObserver->HandleSelectL(iSelectedIndex); |
|
1616 |
||
1617 |
FitSelectionToView(); |
|
1618 |
SelectionChanged(); |
|
1619 |
iDrawUtils->ResetMarquee(); |
|
1620 |
} |
|
1621 |
DrawDeferred(); |
|
1622 |
} |
|
1623 |
} |
|
1624 |
||
1625 |
// --------------------------------------------------------------------------- |
|
1626 |
// CHgScroller::SetSelectionMode() |
|
1627 |
// --------------------------------------------------------------------------- |
|
1628 |
// |
|
1629 |
void CHgScroller::SetSelectionMode( TSelectionMode aMode ) |
|
1630 |
{ |
|
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1631 |
if( aMode != iSelectionMode ) |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1632 |
{ |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1633 |
DrawDeferred(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1634 |
} |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1635 |
|
56 | 1636 |
iSelectionMode = aMode; |
1637 |
if( iSelectionMode == ESelectionPossible |
|
1638 |
|| iSelectionMode == ENoSelection ) |
|
1639 |
{ |
|
1640 |
iCoeEnv->InputCapabilitiesChanged(); |
|
1641 |
} |
|
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1642 |
|
56 | 1643 |
} |
1644 |
||
1645 |
// --------------------------------------------------------------------------- |
|
1646 |
// CHgScroller::SelectionMode() |
|
1647 |
// --------------------------------------------------------------------------- |
|
1648 |
// |
|
1649 |
CHgScroller::TSelectionMode CHgScroller::SelectionMode() const |
|
1650 |
{ |
|
1651 |
return iSelectionMode; |
|
1652 |
} |
|
1653 |
||
1654 |
// --------------------------------------------------------------------------- |
|
1655 |
// CHgScroller::KeyScrollingTimerCallback() |
|
1656 |
// --------------------------------------------------------------------------- |
|
1657 |
// |
|
1658 |
TInt CHgScroller::KeyScrollingTimerCallback( TAny* aPtr ) |
|
1659 |
{ |
|
1660 |
CHgScroller* scroller = |
|
1661 |
static_cast<CHgScroller*>( aPtr ); |
|
1662 |
||
1663 |
TInt err = KErrNotFound; |
|
1664 |
||
1665 |
if ( scroller ) |
|
1666 |
{ |
|
1667 |
scroller->DoKeyScrolling(); |
|
1668 |
err = KErrNone; |
|
1669 |
} |
|
1670 |
||
1671 |
return err; |
|
1672 |
} |
|
1673 |
||
1674 |
// --------------------------------------------------------------------------- |
|
1675 |
// CHgScroller::DoKeyScrolling() |
|
1676 |
// --------------------------------------------------------------------------- |
|
1677 |
// |
|
1678 |
void CHgScroller::DoKeyScrolling() |
|
1679 |
{ |
|
1680 |
TKeyEvent keyevent; |
|
1681 |
||
1682 |
switch( iKeyScrollingState ) |
|
1683 |
{ |
|
1684 |
case EKeyScrollingUp: |
|
1685 |
{ |
|
1686 |
keyevent.iCode = EKeyUpArrow; |
|
1687 |
HandleKeyEvent( keyevent ); |
|
1688 |
break; |
|
1689 |
} |
|
1690 |
case EKeyScrollingDown: |
|
1691 |
{ |
|
1692 |
keyevent.iCode = EKeyDownArrow; |
|
1693 |
HandleKeyEvent( keyevent ); |
|
1694 |
break; |
|
1695 |
} |
|
1696 |
case EKeyScrollingLeft: |
|
1697 |
{ |
|
1698 |
keyevent.iCode = EKeyLeftArrow; |
|
1699 |
HandleKeyEvent( keyevent ); |
|
1700 |
break; |
|
1701 |
} |
|
1702 |
case EKeyScrollingRight: |
|
1703 |
{ |
|
1704 |
keyevent.iCode = EKeyRightArrow; |
|
1705 |
HandleKeyEvent( keyevent ); |
|
1706 |
break; |
|
1707 |
} |
|
1708 |
case ENoKeyScrolling: |
|
1709 |
default: |
|
1710 |
StopKeyScrolling(); |
|
1711 |
break; |
|
1712 |
} |
|
1713 |
||
1714 |
DrawNow(); |
|
1715 |
} |
|
1716 |
||
1717 |
// --------------------------------------------------------------------------- |
|
1718 |
// CHgScroller::StopKeyScrolling() |
|
1719 |
// --------------------------------------------------------------------------- |
|
1720 |
// |
|
1721 |
void CHgScroller::StopKeyScrolling() |
|
1722 |
{ |
|
1723 |
iKeyScrollingTimer->Cancel(); |
|
1724 |
iKeyScrollingState = ENoKeyScrolling; |
|
1725 |
} |
|
1726 |
||
1727 |
// --------------------------------------------------------------------------- |
|
1728 |
// CHgScroller::FocusChanged() |
|
1729 |
// --------------------------------------------------------------------------- |
|
1730 |
// |
|
1731 |
void CHgScroller::FocusChanged(TDrawNow aDrawNow) |
|
1732 |
{ |
|
1733 |
if( iKeyUtils ) |
|
1734 |
{ |
|
1735 |
if( !(iFlags & EHgScrollerKeyMarkingDisabled) ) |
|
1736 |
{ |
|
1737 |
if(IsFocused()) |
|
1738 |
{ |
|
1739 |
iKeyUtils->HandleGainingFocus(); |
|
1740 |
} |
|
1741 |
else |
|
1742 |
{ |
|
1743 |
iKeyUtils->HandleLosingFocus(); |
|
1744 |
} |
|
1745 |
} |
|
1746 |
else |
|
1747 |
{ |
|
1748 |
iKeyUtils->HandleLosingFocus(); |
|
1749 |
} |
|
1750 |
} |
|
1751 |
||
1752 |
CCoeControl::FocusChanged( aDrawNow ); |
|
1753 |
} |
|
1754 |
||
1755 |
// --------------------------------------------------------------------------- |
|
1756 |
// CHgScroller::HandleResourceChange() |
|
1757 |
// --------------------------------------------------------------------------- |
|
1758 |
// |
|
1759 |
void CHgScroller::HandleResourceChange( TInt aType ) |
|
1760 |
{ |
|
1761 |
TRAP_IGNORE( |
|
1762 |
// When skin changes the indicator icons must be reloaded. |
|
1763 |
if ( aType == KAknsMessageSkinChange ) |
|
1764 |
{ |
|
1765 |
delete iIndicatorManager; iIndicatorManager = NULL; |
|
1766 |
iIndicatorManager = CHgIndicatorManager::NewL(); |
|
1767 |
delete iScrollbar; iScrollbar = NULL; |
|
1768 |
iScrollbar = CHgScrollbar::NewL(*this); |
|
1769 |
InitScrollbarL(); |
|
1770 |
InitGraphicsL(); |
|
1771 |
||
1772 |
HandleSizeChanged(); |
|
1773 |
DrawDeferred(); |
|
1774 |
} |
|
1775 |
) |
|
1776 |
} |
|
1777 |
||
1778 |
// --------------------------------------------------------------------------- |
|
1779 |
// CHgScroller::HandleLongTapEventL() |
|
1780 |
// --------------------------------------------------------------------------- |
|
1781 |
// |
|
1782 |
void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/, |
|
1783 |
const TPoint& aPenEventScreenLocation) |
|
1784 |
{ |
|
59
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1785 |
// Long tap is supported in marking mode only for an item that is marked. |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1786 |
const TBool validIndex = iSelectedIndex != KErrNotFound && |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1787 |
iSelectedIndex >= 0 && iSelectedIndex < iItems.Count(); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1788 |
const TBool selectionMode = iFlags & EHgScrollerSelectionMode; |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1789 |
const TBool longTapEnabled = validIndex && (!selectionMode || |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1790 |
(selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked)); |
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1791 |
|
978afdc0236f
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
56
diff
changeset
|
1792 |
if( iActionMenu && longTapEnabled ) |
56 | 1793 |
{ |
1794 |
iOldWinPos = DrawableWindow()->OrdinalPosition(); |
|
1795 |
iActionMenu->ShowMenuL(aPenEventScreenLocation); |
|
1796 |
iPointerDown = EFalse; |
|
1797 |
} |
|
1798 |
} |
|
1799 |
||
1800 |
// --------------------------------------------------------------------------- |
|
1801 |
// CHgScroller::CollectionState() |
|
1802 |
// --------------------------------------------------------------------------- |
|
1803 |
// |
|
1804 |
TUint CHgScroller::CollectionState() const |
|
1805 |
{ |
|
1806 |
TUint ret = 0; |
|
1807 |
||
1808 |
if( IsFocused() ) |
|
1809 |
{ |
|
1810 |
ret |= MAknCollection::EStateCollectionVisible; |
|
1811 |
} |
|
1812 |
if( HasHighlight() ) |
|
1813 |
{ |
|
1814 |
ret |= MAknCollection::EStateHighlightVisible; |
|
1815 |
} |
|
1816 |
if( iFlags & EHgScrollerSelectionMode ) |
|
1817 |
{ |
|
1818 |
ret |= MAknCollection::EStateMultipleSelection; |
|
1819 |
for( TInt i = 0; i < iItems.Count(); ++i ) |
|
1820 |
{ |
|
1821 |
if( iItems[i]->Flags() & CHgItem::EHgItemFlagMarked ) |
|
1822 |
{ |
|
1823 |
ret |= MAknCollection::EStateMarkedItems; |
|
1824 |
break; |
|
1825 |
} |
|
1826 |
} |
|
1827 |
} |
|
1828 |
return ret; |
|
1829 |
} |
|
1830 |
||
1831 |
// --------------------------------------------------------------------------- |
|
1832 |
// CHgScroller::CollectionState() |
|
1833 |
// --------------------------------------------------------------------------- |
|
1834 |
// |
|
1835 |
void CHgScroller::ItemActionMenuClosed() |
|
1836 |
{ |
|
1837 |
iOldWinPos = KErrNotFound; |
|
1838 |
DrawDeferred(); |
|
1839 |
} |
|
1840 |
||
1841 |
// --------------------------------------------------------------------------- |
|
1842 |
// CHgScroller::CollectionState() |
|
1843 |
// --------------------------------------------------------------------------- |
|
1844 |
// |
|
1845 |
TInt CHgScroller::CollectionExtension( TUint /*aExtensionId*/, TAny*& /*a0*/, TAny* /*a1*/ ) |
|
1846 |
{ |
|
1847 |
return KErrNone; |
|
1848 |
} |
|
1849 |
||
1850 |
// --------------------------------------------------------------------------- |
|
1851 |
// CHgScroller::HasHighlight() |
|
1852 |
// --------------------------------------------------------------------------- |
|
1853 |
// |
|
1854 |
TBool CHgScroller::HasHighlight() const |
|
1855 |
{ |
|
1856 |
return (iActionMenu == NULL) || iShowHighlight || (iFlags & EHgScrollerForceDoubleClick); |
|
1857 |
} |
|
1858 |
||
1859 |
// --------------------------------------------------------------------------- |
|
1860 |
// CHgScroller::ReleasePopupFont() |
|
1861 |
// --------------------------------------------------------------------------- |
|
1862 |
// |
|
1863 |
void CHgScroller::ReleasePopupFont() |
|
1864 |
{ |
|
1865 |
if (iPopupFont) |
|
1866 |
{ |
|
1867 |
iCoeEnv->ScreenDevice()->ReleaseFont(iPopupFont); |
|
1868 |
iPopupFont = NULL; |
|
1869 |
} |
|
1870 |
} |
|
1871 |
||
1872 |
// --------------------------------------------------------------------------- |
|
1873 |
// CHgScroller::SetMenuProviderL() |
|
1874 |
// --------------------------------------------------------------------------- |
|
1875 |
// |
|
1876 |
EXPORT_C void CHgScroller::SetMenuProviderL( MObjectProvider* aMenuProvider ) |
|
1877 |
{ |
|
1878 |
SetMopParent(aMenuProvider); |
|
1879 |
||
1880 |
if( iActionMenu ) |
|
1881 |
{ |
|
1882 |
iActionMenu->RemoveCollection( *this ); |
|
1883 |
iActionMenu = NULL; |
|
1884 |
} |
|
1885 |
||
1886 |
CAknAppUi* appUi = static_cast<CAknAppUi*>(iEikonEnv->AppUi()); |
|
1887 |
if( appUi && appUi->IsSingleClickCompatible() ) |
|
1888 |
{ |
|
1889 |
iActionMenu = CAknItemActionMenu::RegisterCollectionL( *this, this ); |
|
1890 |
} |
|
1891 |
} |
|
1892 |
||
1893 |
||
1894 |
// End of File |