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