uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 20 d48ab3b357f1
child 21 978afdc0236f
equal deleted inserted replaced
19:aecbbf00d063 20:d48ab3b357f1
       
     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 
       
    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 ) );
       
   244                 }
       
   245             }
       
   246         }
       
   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 
       
   594                     && iSelectedIndex != KErrNotFound 
       
   595                     && !HasHighlight()
       
   596                     && !(iFlags & EHgScrollerSelectionMode)
       
   597                     && iActionMenu->InitMenuL() )
       
   598                 {
       
   599                 iDetector->PointerEventL( aEvent );
       
   600                 }
       
   601             }
       
   602         // Drag
       
   603         else if( aEvent.iType == TPointerEvent::EDrag && iPointerDown )
       
   604             {
       
   605             HandleDragEventL( aEvent );
       
   606             
       
   607             if( iPanning && iDetector && !HasHighlight()  )
       
   608                 iDetector->CancelAnimationL();
       
   609             }
       
   610         // End drag
       
   611         else if( aEvent.iType == TPointerEvent::EButton1Up && iPointerDown )
       
   612             {
       
   613             if( iDetector && !HasHighlight() )
       
   614                 iDetector->PointerEventL( aEvent );
       
   615             
       
   616             HandleUpEventL( aEvent );
       
   617             }
       
   618         }
       
   619     }
       
   620 
       
   621 // -----------------------------------------------------------------------------
       
   622 // CHgScroller::HandleScrollbarEventL()
       
   623 // -----------------------------------------------------------------------------
       
   624 //
       
   625 TBool CHgScroller::HandleScrollbarEventL( const TPointerEvent& aEvent )
       
   626     {
       
   627     TBool sbHandles = EFalse;
       
   628     if( iScrollbar )
       
   629         {
       
   630         sbHandles = iScrollbar->HandlePointerEventL( aEvent );
       
   631         
       
   632         if(  sbHandles 
       
   633                 && iPhysics 
       
   634                 && iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking )
       
   635             {
       
   636             iPhysics->StopPhysics();
       
   637             iScrollbar->Reset();
       
   638             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   639             if ( feedback )
       
   640                 {
       
   641                 feedback->InstantFeedback( this, ETouchFeedbackList, aEvent );
       
   642                 }
       
   643             return sbHandles;
       
   644             }
       
   645         
       
   646         if ( sbHandles && !iScrollbar->IsStatic() )
       
   647             {
       
   648             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   649             // Start drag
       
   650             if( aEvent.iType == TPointerEvent::EButton1Down )
       
   651                 {
       
   652                 if ( feedback )
       
   653                     {
       
   654                     feedback->InstantFeedback( this, ETouchFeedbackSlider, aEvent );
       
   655                     }
       
   656                 }
       
   657             else if( aEvent.iType == TPointerEvent::EButton1Up )
       
   658                 {
       
   659                 // Stop the continuous tactile feedback that may be playing
       
   660                 // at the time due to possible previous thumb dragging.
       
   661                 if ( feedback )
       
   662                     {
       
   663                     feedback->StopFeedback( this );
       
   664                     TTouchFeedbackType type = ETouchFeedbackVibra;
       
   665                     feedback->InstantFeedback( this, ETouchFeedbackSlider, type, aEvent );
       
   666                     }
       
   667                 iPopupText1.Zero();
       
   668                 iPopupText2.Zero();
       
   669                 DrawDeferred();
       
   670                 }
       
   671             }
       
   672         }
       
   673     return sbHandles;
       
   674     }
       
   675 
       
   676 // -----------------------------------------------------------------------------
       
   677 // CHgScroller::HandleDownEventL()
       
   678 // -----------------------------------------------------------------------------
       
   679 //
       
   680 void CHgScroller::HandleDownEventL( const TPointerEvent& aEvent )
       
   681     {
       
   682     if( !HasHighlight() 
       
   683             && (iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking) )
       
   684         {
       
   685         iPanning = ETrue;
       
   686         if(iDetector)
       
   687             iDetector->CancelAnimationL();
       
   688         }
       
   689     else
       
   690         {
       
   691         iPanning = EFalse;
       
   692         }
       
   693 
       
   694     iPhysics->StopPhysics();
       
   695     iPhysics->ResetFriction();
       
   696 
       
   697     iStart = aEvent.iPosition;
       
   698     iPrev = iStart;
       
   699     iStartTime.HomeTime();
       
   700 
       
   701     if(iLandscapeScrolling)
       
   702         iViewPosition.iY = iHeight / 2;
       
   703     else
       
   704         iViewPosition.iX = iWidth / 2;
       
   705     
       
   706     iFocusedIndex = KErrNotFound;
       
   707     iSelectionToFocusedItem = EFalse;
       
   708     iDrawUtils->EnableMarquee(HasHighlight());
       
   709     if(HasHighlight())
       
   710         {
       
   711         LaunchHighlightTimer();
       
   712         }
       
   713     else if( !iPanning )
       
   714         {
       
   715         // to get Handle Selected to be called for sure in single touch
       
   716         iSelectedIndex = KErrNotFound; 
       
   717         SetHighlightL();
       
   718         }
       
   719     MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   720     if ( feedback && iSelectedIndex != KErrNotFound )
       
   721         {
       
   722         feedback->InstantFeedback( this, ETouchFeedbackList, aEvent );
       
   723         }
       
   724     }
       
   725 
       
   726 // -----------------------------------------------------------------------------
       
   727 // CHgScroller::HandleDragEventL()
       
   728 // -----------------------------------------------------------------------------
       
   729 //
       
   730 void CHgScroller::HandleDragEventL( const TPointerEvent& aEvent )
       
   731     {
       
   732     TBool prevPanning = iPanning;
       
   733     if(!iPanning)
       
   734         {
       
   735         TInt delta = 0;
       
   736         if(iLandscapeScrolling)
       
   737             {
       
   738             delta = iPrev.iX - aEvent.iPosition.iX;
       
   739             }
       
   740         else
       
   741             {
       
   742             delta = iPrev.iY - aEvent.iPosition.iY;
       
   743             }
       
   744         
       
   745         delta = delta < 0 ? -delta : delta;
       
   746         iPanning = delta >= iPhysics->DragThreshold();
       
   747         }
       
   748 
       
   749     //if user has dragged onto another item
       
   750     if( !iPanning && GetSelected(iStart) != GetSelected(aEvent.iPosition) )
       
   751         {
       
   752         // after setting iPanning true, longtap is cancelled
       
   753         iPanning = ETrue;    
       
   754         }
       
   755     
       
   756     if( prevPanning != iPanning )
       
   757         {
       
   758         iPrev = aEvent.iPosition;
       
   759         DrawDeferred(); // to clear highlight
       
   760         }
       
   761     
       
   762     if(iPanning)
       
   763         {
       
   764         TPoint delta = iPrev - aEvent.iPosition;
       
   765         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
       
   766             delta = -delta;
       
   767         iPhysics->RegisterPanningPosition( delta );
       
   768         iPrev = aEvent.iPosition;
       
   769         iHighlightTimer->Cancel();
       
   770         }
       
   771     }
       
   772 
       
   773 // -----------------------------------------------------------------------------
       
   774 // CHgScroller::HandleUpEventL()
       
   775 // -----------------------------------------------------------------------------
       
   776 //
       
   777 void CHgScroller::HandleUpEventL( const TPointerEvent& aEvent )
       
   778     {
       
   779     if( iPanning )
       
   780         {
       
   781         // enable physics
       
   782         TPoint drag = iStart - aEvent.iPosition;
       
   783         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
       
   784             drag = -drag;
       
   785         iPhysics->StartPhysics(drag, iStartTime);
       
   786         iPointerDown = EFalse;
       
   787         }
       
   788     else
       
   789         {
       
   790         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   791         if ( feedback && iSelectedIndex != KErrNotFound )
       
   792             {
       
   793             feedback->InstantFeedback( this, ETouchFeedbackList, ETouchFeedbackVibra, aEvent );
       
   794             }
       
   795 
       
   796         HandleSelectionL();
       
   797         }
       
   798     }
       
   799 
       
   800 // -----------------------------------------------------------------------------
       
   801 // CHgScroller::HandleSelectionL()
       
   802 // -----------------------------------------------------------------------------
       
   803 //
       
   804 void CHgScroller::HandleSelectionL()
       
   805     {
       
   806     TInt index = GetSelected(iStart);
       
   807     if(index != KErrNotFound)
       
   808         {
       
   809         if( iFocusedIndex == KErrNotFound )
       
   810             {
       
   811             // Highlight timer hasn't triggered so lets set the highlight.
       
   812             // this is not usually the case since interval is 50ms but just to be sure.
       
   813             SetHighlightL();
       
   814             }
       
   815 
       
   816         iPointerDown = EFalse;
       
   817         
       
   818         // selection needs to be valid.
       
   819         if( iSelectedIndex >= 0 && iSelectedIndex < iItems.Count() )
       
   820             {
       
   821             if( iFlags & EHgScrollerSelectionMode || iSelectionMode != ENoSelection ) 
       
   822                 // Marking mode or shift key pressed ( or hash )
       
   823                 {
       
   824                 if( iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked )
       
   825                     {
       
   826                     UnMark( iSelectedIndex );
       
   827                     }
       
   828                 else
       
   829                     {
       
   830                     Mark( iSelectedIndex );                    
       
   831                     }
       
   832                 DrawDeferred();
       
   833                 }
       
   834             else // Selection
       
   835                 {
       
   836                 if( iSelectionToFocusedItem || !HasHighlight() )
       
   837                     {
       
   838                     if(iSelectionObserver)
       
   839                         iSelectionObserver->HandleOpenL(iSelectedIndex);
       
   840                     }
       
   841                 }
       
   842             }
       
   843         }
       
   844     else
       
   845         {
       
   846         iPointerDown = EFalse;
       
   847         }
       
   848     }
       
   849 
       
   850 // -----------------------------------------------------------------------------
       
   851 // CHgScroller::OfferKeyEventL()
       
   852 // -----------------------------------------------------------------------------
       
   853 //
       
   854 TKeyResponse CHgScroller::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   855     {
       
   856     if( iKeyUtils 
       
   857             && !(iFlags & EHgScrollerKeyMarkingDisabled)
       
   858             && iKeyUtils->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
       
   859         return EKeyWasConsumed;
       
   860     
       
   861     switch( aType )
       
   862         {
       
   863         case EEventKeyDown:
       
   864             KeyEventDown();
       
   865             break;
       
   866         case EEventKey:    
       
   867             return HandleKeyEvent( aKeyEvent );
       
   868         case EEventKeyUp:
       
   869             KeyEventUp();
       
   870         default:
       
   871             break;
       
   872         }
       
   873     
       
   874     // Let CCoeControl handle other cases.
       
   875     return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
       
   876     }
       
   877 
       
   878 // -----------------------------------------------------------------------------
       
   879 // CHgScroller::KeyEventDown()
       
   880 // -----------------------------------------------------------------------------
       
   881 //
       
   882 void CHgScroller::KeyEventDown()
       
   883     {
       
   884     iKeyRepeats = 0;
       
   885     iKeyScrollingState = ENoKeyScrolling;
       
   886     
       
   887     iPointerDown = EFalse;
       
   888     iPanning = EFalse;
       
   889     }
       
   890 
       
   891 // -----------------------------------------------------------------------------
       
   892 // CHgScroller::KeyEventUp()
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 void CHgScroller::KeyEventUp()
       
   896     {
       
   897     if( iKeyScrollingState != ENoKeyScrolling )
       
   898         {
       
   899         // Key has been released so stop the key scrolling.
       
   900         StopKeyScrolling();
       
   901         }
       
   902     }
       
   903 
       
   904 // -----------------------------------------------------------------------------
       
   905 // CHgScroller::SetItem()
       
   906 // -----------------------------------------------------------------------------
       
   907 //
       
   908 EXPORT_C void CHgScroller::SetItem(CHgItem* aItem, TInt aIndex)
       
   909     {
       
   910     if( aItem && aIndex >= 0 && aIndex < iItems.Count() )
       
   911         {
       
   912         delete iItems[aIndex];
       
   913         iItems[aIndex] = aItem;
       
   914         }
       
   915     }
       
   916 
       
   917 // -----------------------------------------------------------------------------
       
   918 // CHgScroller::AddItem()
       
   919 // -----------------------------------------------------------------------------
       
   920 //
       
   921 EXPORT_C void CHgScroller::AddItem(CHgItem* aItem)
       
   922     {
       
   923     if( aItem )
       
   924         {
       
   925         iItems.Append(aItem);
       
   926         iItemCount++;
       
   927         HandleItemCountChanged();
       
   928         if( iManager )
       
   929             {
       
   930             iManager->ItemCountChanged( iItemCount-1, EFalse, iItemCount );
       
   931             }
       
   932         }
       
   933     }
       
   934 
       
   935 // -----------------------------------------------------------------------------
       
   936 // CHgScroller::InsertItem()
       
   937 // -----------------------------------------------------------------------------
       
   938 //
       
   939 EXPORT_C void CHgScroller::InsertItem(CHgItem* aItem, TInt aIndex)
       
   940     {
       
   941     if( aItem && aIndex >= 0 )
       
   942         {
       
   943         if(aIndex < iItems.Count())
       
   944             {
       
   945             iItems.Insert(aItem, aIndex);
       
   946             }
       
   947         else
       
   948             {
       
   949             iItems.Append(aItem);
       
   950             }
       
   951         iItemCount++;
       
   952         HandleItemCountChanged();
       
   953         
       
   954         if( iManager )
       
   955             {
       
   956             iManager->ItemCountChanged( aIndex, EFalse, iItemCount );
       
   957             }
       
   958         }
       
   959     }
       
   960 
       
   961 // -----------------------------------------------------------------------------
       
   962 // CHgScroller::RemoveItem()
       
   963 // -----------------------------------------------------------------------------
       
   964 //
       
   965 EXPORT_C void CHgScroller::RemoveItem(TInt aIndex)
       
   966     {
       
   967     if( aIndex >= 0 && aIndex < iItems.Count() )
       
   968         {
       
   969         delete iItems[aIndex]; iItems[aIndex] = NULL;
       
   970         iItems.Remove(aIndex);
       
   971         iItemCount--;
       
   972         HandleItemCountChanged();
       
   973         
       
   974         if( iManager )
       
   975             {
       
   976             iManager->ItemCountChanged( aIndex, ETrue, iItemCount );
       
   977             }
       
   978         }
       
   979     }
       
   980 
       
   981 // -----------------------------------------------------------------------------
       
   982 // CHgScroller::ResizeL()
       
   983 // -----------------------------------------------------------------------------
       
   984 //
       
   985 EXPORT_C void CHgScroller::ResizeL( TInt aItemCount )
       
   986     {
       
   987     // Add More
       
   988     if( iItems.Count() < aItemCount )
       
   989         {
       
   990         while( iItems.Count() < aItemCount )
       
   991             {
       
   992             iItems.AppendL( CHgItem::NewL() );
       
   993             }
       
   994         }
       
   995     // remove from the end
       
   996     else if( iItems.Count() > aItemCount )
       
   997         {
       
   998         while( iItems.Count() > aItemCount )
       
   999             {
       
  1000             delete iItems[iItems.Count() - 1];
       
  1001             iItems.Remove( iItems.Count() - 1 );
       
  1002             }
       
  1003         }
       
  1004     else
       
  1005         {
       
  1006         return; // no change needed
       
  1007         }
       
  1008 
       
  1009     iItemCount = aItemCount;
       
  1010 
       
  1011     if( iManager )
       
  1012         {
       
  1013         iManager->ResetBuffer( iSelectedIndex, iItemCount );
       
  1014         }
       
  1015 
       
  1016     HandleItemCountChanged();
       
  1017     }
       
  1018 
       
  1019 // -----------------------------------------------------------------------------
       
  1020 // CHgScroller::ItemL()
       
  1021 // -----------------------------------------------------------------------------
       
  1022 //
       
  1023 EXPORT_C CHgItem& CHgScroller::ItemL(TInt aIndex)
       
  1024     {
       
  1025     if( aIndex < 0 || aIndex >= iItems.Count() )
       
  1026         {
       
  1027         User::Leave( KErrArgument );
       
  1028         }
       
  1029 
       
  1030     return *iItems[aIndex];
       
  1031     }
       
  1032 
       
  1033 // -----------------------------------------------------------------------------
       
  1034 // CHgScroller::ViewPositionChanged()
       
  1035 // -----------------------------------------------------------------------------
       
  1036 //
       
  1037 void CHgScroller::ViewPositionChanged( const TPoint& aNewPosition,
       
  1038                                         TBool aDrawNow,
       
  1039                                         TUint /*aFlags*/ )
       
  1040     {
       
  1041     iViewPosition = aNewPosition;
       
  1042     HandleViewPositionChanged();
       
  1043     if( aDrawNow )
       
  1044         DrawNow();
       
  1045     }
       
  1046 
       
  1047 // -----------------------------------------------------------------------------
       
  1048 // CHgScroller::ScrollBarPositionChanged()
       
  1049 // -----------------------------------------------------------------------------
       
  1050 //
       
  1051 void CHgScroller::ScrollBarPositionChanged( const TPoint& aNewPosition )
       
  1052     {
       
  1053     if( iPhysics->OngoingPhysicsAction() == CAknPhysics::EAknPhysicsActionFlicking )
       
  1054         return;
       
  1055     
       
  1056     iViewPosition = aNewPosition;
       
  1057     iPhysics->StopPhysics();
       
  1058     
       
  1059     if( iScrollBarType == EHgScrollerTimeStrip )
       
  1060         {
       
  1061         // Show first item's time.
       
  1062         TInt selectedItem = CurrentIndex();
       
  1063         if( selectedItem >= 0 && selectedItem < iItems.Count()
       
  1064                 && iItems[selectedItem]->Time().Int64() )
       
  1065             {
       
  1066             TRAP_IGNORE(
       
  1067                     iItems[selectedItem]->Time().FormatL( iPopupText1, KGanesMonthString );
       
  1068                     iItems[selectedItem]->Time().FormatL( iPopupText2, KGanesYearString );
       
  1069                 )
       
  1070             // To display month and year correctly in arabic.
       
  1071             AknTextUtils::LanguageSpecificNumberConversion( iPopupText1 );
       
  1072             AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 );
       
  1073             }
       
  1074         }
       
  1075     else if( iScrollBarType == EHgScrollerLetterStrip
       
  1076             || iScrollBarType == EHgScrollerLetterStripLite )
       
  1077         {
       
  1078         TInt selectedItem = CurrentIndex();
       
  1079         if( selectedItem >= 0 && selectedItem < iItems.Count() )
       
  1080             {
       
  1081             if(iItems[selectedItem]->Title().Length())
       
  1082                 {
       
  1083                 iPopupText1.Zero();
       
  1084                 iPopupText1.Append( iItems[selectedItem]->Title()[0] );
       
  1085                 iPopupText1.UpperCase();
       
  1086                 }
       
  1087             }
       
  1088         }
       
  1089     HandleViewPositionChanged( EFalse );
       
  1090     DrawNow();
       
  1091     }
       
  1092 
       
  1093 // -----------------------------------------------------------------------------
       
  1094 // CHgScroller::HandleNaviStripChar()
       
  1095 // -----------------------------------------------------------------------------
       
  1096 //
       
  1097 void CHgScroller::HandleNaviStripChar( const TChar& /*aChar*/ )
       
  1098     {
       
  1099     // Feature not used anymore
       
  1100     }
       
  1101 
       
  1102 // -----------------------------------------------------------------------------
       
  1103 // CHgScroller::PhysicEmulationEnded()
       
  1104 // -----------------------------------------------------------------------------
       
  1105 //
       
  1106 void CHgScroller::PhysicEmulationEnded()
       
  1107     {
       
  1108     // Nothing to do.
       
  1109     }
       
  1110 
       
  1111 // -----------------------------------------------------------------------------
       
  1112 // CHgScroller::HandleViewPositionChanged()
       
  1113 // -----------------------------------------------------------------------------
       
  1114 //
       
  1115 void CHgScroller::HandleViewPositionChanged(TBool aUpdateScrollbar)
       
  1116     {
       
  1117     TInt newRow = iLandscapeScrolling ?
       
  1118         (iViewPosition.iX-(iWidth/2))/((iRowHeight)):
       
  1119         (iViewPosition.iY-(iHeight/2))/(iRowHeight);
       
  1120     
       
  1121     if(iScrollbar && aUpdateScrollbar)
       
  1122         iScrollbar->SetViewPosition( iViewPosition - TPoint(iWidth/2, iHeight/2));
       
  1123 
       
  1124     if(newRow != iCurrentRow)
       
  1125         {
       
  1126         iCurrentRow = newRow;
       
  1127         
       
  1128         TBool needsFeedback = 
       
  1129                 ( CurrentIndex() > 0 && CurrentIndex() <= iItems.Count() )
       
  1130                 || ( iItems.Count() - CurrentIndex() > ItemsOnScreen() );
       
  1131         
       
  1132         TInt action = iPhysics->OngoingPhysicsAction();
       
  1133         if( action !=  CAknPhysics::EAknPhysicsActionNone && needsFeedback )
       
  1134             {
       
  1135             MTouchFeedback* feedback = MTouchFeedback::Instance();
       
  1136             if(feedback)
       
  1137                 feedback->InstantFeedback( this, ETouchFeedbackSensitiveList,
       
  1138                                            ETouchFeedbackVibra, TPointerEvent() );
       
  1139             }
       
  1140 
       
  1141         if(iManager)
       
  1142             {
       
  1143             iManager->SetPosition( CurrentIndex() );
       
  1144             }
       
  1145         }
       
  1146     }
       
  1147 
       
  1148 // -----------------------------------------------------------------------------
       
  1149 // CHgScroller::HandleViewPositionChanged()
       
  1150 // -----------------------------------------------------------------------------
       
  1151 //
       
  1152 TPoint CHgScroller::ViewPosition() const
       
  1153     {
       
  1154     return iViewPosition;
       
  1155     }
       
  1156 
       
  1157 // -----------------------------------------------------------------------------
       
  1158 // CHgScroller::HandleKeyEvent()
       
  1159 // -----------------------------------------------------------------------------
       
  1160 //
       
  1161 TKeyResponse CHgScroller::HandleKeyEvent(const TKeyEvent& aKeyEvent)
       
  1162     {
       
  1163     iKeyRepeats++;
       
  1164     TInt prevSelected = iSelectedIndex;
       
  1165 
       
  1166     TKeyScrollingState possibleKeyScrollingState = ENoKeyScrolling;
       
  1167     
       
  1168     switch( aKeyEvent.iCode )
       
  1169         {
       
  1170         case EKeyUpArrow:
       
  1171             if( !iLandscapeScrolling )
       
  1172                 possibleKeyScrollingState = EKeyScrollingUp;
       
  1173             break;
       
  1174         case EKeyDownArrow:
       
  1175             if( !iLandscapeScrolling )
       
  1176                 possibleKeyScrollingState = EKeyScrollingDown;
       
  1177             break;
       
  1178         case EKeyLeftArrow:
       
  1179             if( iLandscapeScrolling )
       
  1180                 possibleKeyScrollingState = EKeyScrollingLeft;
       
  1181             break;
       
  1182         case EKeyRightArrow:
       
  1183             if( iLandscapeScrolling )
       
  1184                 possibleKeyScrollingState = EKeyScrollingRight;
       
  1185             break;
       
  1186         case EKeyEnter:
       
  1187         case EKeyOK:
       
  1188             {
       
  1189             if( iSelectedIndex != KErrNotFound && HasHighlight() )
       
  1190                 {
       
  1191                 iShowHighlight = EFalse;
       
  1192                 iDrawUtils->EnableMarquee(HasHighlight());
       
  1193                 if( iSelectionObserver )
       
  1194                     TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
       
  1195                 return EKeyWasConsumed;
       
  1196                 }
       
  1197             else if( iItemCount )
       
  1198                 {
       
  1199                 iSelectedIndex = CurrentIndex();
       
  1200                 FitSelectionToView();
       
  1201                 iShowHighlight = ETrue;
       
  1202                 iDrawUtils->EnableMarquee(HasHighlight());
       
  1203                 DrawDeferred();
       
  1204                 if( iSelectionObserver )
       
  1205                     TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
       
  1206                 return EKeyWasConsumed;
       
  1207                 }
       
  1208             return EKeyWasNotConsumed;
       
  1209             }
       
  1210         default:
       
  1211             break;
       
  1212         }
       
  1213 
       
  1214     if( possibleKeyScrollingState != ENoKeyScrolling 
       
  1215         && iKeyRepeats > KPhysLaunchKeyCount
       
  1216         && iSelectionMode == ENoSelection )
       
  1217         {
       
  1218         if( !iKeyScrollingTimer->IsActive() )
       
  1219             {
       
  1220             iKeyScrollingState = possibleKeyScrollingState;
       
  1221             iKeyScrollingTimer->Start(
       
  1222                     TTimeIntervalMicroSeconds32( 0 ),
       
  1223                     TTimeIntervalMicroSeconds32( KKeyScrollingUpdateInterval ), 
       
  1224                     TCallBack( KeyScrollingTimerCallback, this ) );
       
  1225             }
       
  1226         }
       
  1227 
       
  1228     if( !HasHighlight() )
       
  1229         {
       
  1230         // DoHandleKeyEvent will move focus at the first index on screen.  
       
  1231         iSelectedIndex = KErrNotFound;
       
  1232         }
       
  1233     
       
  1234     if( DoHandleKeyEvent(aKeyEvent) )
       
  1235         {
       
  1236         iShowHighlight = ETrue;
       
  1237         iDrawUtils->EnableMarquee(HasHighlight());
       
  1238         if( iSelectedIndex != prevSelected && iSelectionObserver )
       
  1239             {
       
  1240             iDrawUtils->ResetMarquee();
       
  1241             TRAP_IGNORE( iSelectionObserver->HandleSelectL(iSelectedIndex); )
       
  1242             }
       
  1243         return EKeyWasConsumed;
       
  1244         }
       
  1245     else
       
  1246         {
       
  1247         iKeyRepeats--;
       
  1248         return EKeyWasNotConsumed;
       
  1249         }
       
  1250     }
       
  1251 
       
  1252 // -----------------------------------------------------------------------------
       
  1253 // CHgScroller::Release()
       
  1254 // -----------------------------------------------------------------------------
       
  1255 //
       
  1256 void CHgScroller::Release(TInt aReleaseStart, TInt aReleaseEnd)
       
  1257     {
       
  1258     for(; aReleaseStart <= aReleaseEnd; ++aReleaseStart)
       
  1259         {
       
  1260         if( aReleaseStart >= 0 && aReleaseStart < iItems.Count())
       
  1261             {
       
  1262             iItems[aReleaseStart]->SetIcon(NULL, iItems[aReleaseStart]->Flags());
       
  1263             }
       
  1264         }
       
  1265     }
       
  1266 
       
  1267 // -----------------------------------------------------------------------------
       
  1268 // CHgScroller::Reset()
       
  1269 // -----------------------------------------------------------------------------
       
  1270 //
       
  1271 EXPORT_C void CHgScroller::Reset()
       
  1272     {
       
  1273     if(iItemCount)
       
  1274         {
       
  1275         iItems.ResetAndDestroy();
       
  1276         iItemCount = 0;
       
  1277         iSelectedIndex = KErrNotFound;
       
  1278         
       
  1279         if( iManager )
       
  1280             {
       
  1281             iManager->ResetBuffer( iSelectedIndex, iItemCount );
       
  1282             }
       
  1283     
       
  1284         HandleItemCountChanged();
       
  1285         }
       
  1286     }
       
  1287 
       
  1288 // -----------------------------------------------------------------------------
       
  1289 // CHgScroller::SetFlags()
       
  1290 // -----------------------------------------------------------------------------
       
  1291 //
       
  1292 EXPORT_C void CHgScroller::SetFlags(TInt aFlags)
       
  1293     {
       
  1294     iFlags |= aFlags;
       
  1295     }
       
  1296 
       
  1297 // -----------------------------------------------------------------------------
       
  1298 // CHgScroller::ClearFlags()
       
  1299 // -----------------------------------------------------------------------------
       
  1300 //
       
  1301 EXPORT_C void CHgScroller::ClearFlags(TInt aFlags)
       
  1302     {
       
  1303     iFlags &= ~aFlags;    
       
  1304     }
       
  1305 
       
  1306 // -----------------------------------------------------------------------------
       
  1307 // CHgScroller::Flags()
       
  1308 // -----------------------------------------------------------------------------
       
  1309 //
       
  1310 EXPORT_C TInt CHgScroller::Flags()
       
  1311     {
       
  1312     return iFlags;
       
  1313     }
       
  1314 
       
  1315 // -----------------------------------------------------------------------------
       
  1316 // CHgScroller::SetEmptyTextL()
       
  1317 // -----------------------------------------------------------------------------
       
  1318 //
       
  1319 EXPORT_C void CHgScroller::SetEmptyTextL( const TDesC& aEmptyText )
       
  1320     {
       
  1321     delete iEmptyText;
       
  1322     iEmptyText = 0;
       
  1323     iEmptyText = aEmptyText.AllocL();
       
  1324     }
       
  1325 
       
  1326 // -----------------------------------------------------------------------------
       
  1327 // CHgScroller::ItemCount()
       
  1328 // -----------------------------------------------------------------------------
       
  1329 //
       
  1330 EXPORT_C TInt CHgScroller::ItemCount() const
       
  1331     {
       
  1332     return iItems.Count();
       
  1333     }
       
  1334 
       
  1335 // -----------------------------------------------------------------------------
       
  1336 // CHgScroller::HightlightItem()
       
  1337 // -----------------------------------------------------------------------------
       
  1338 //
       
  1339 EXPORT_C TBool CHgScroller::HightlightItem( const TDesC& aHighlightText )
       
  1340     {
       
  1341     TInt searchStartIndex = aHighlightText.Length() == 1 ||
       
  1342         iSelectedIndex == KErrNotFound ? iSelectedIndex + 1 : iSelectedIndex;
       
  1343     
       
  1344     // From selected to end
       
  1345     for(TInt i = searchStartIndex; i < iItems.Count(); ++i)
       
  1346         {
       
  1347         if(iItems[i]->Title().Length() > 0 )
       
  1348             {
       
  1349             iUpperCaseTitle.Copy( iItems[i]->Title().Left( aHighlightText.Length() ) );
       
  1350             iUpperCaseTitle.UpperCase();
       
  1351             TInt result = iUpperCaseTitle.CompareC( aHighlightText );
       
  1352 
       
  1353             if(result == 0)
       
  1354                 {
       
  1355                 iSelectedIndex = i;
       
  1356                 FitSelectionToView();
       
  1357                 DrawDeferred();
       
  1358                 return ETrue;
       
  1359                 }
       
  1360             }
       
  1361         }
       
  1362 
       
  1363     // From beginning to selected - 1
       
  1364     for(TInt i = 0; i < iSelectedIndex; ++i)
       
  1365         {
       
  1366         if(iItems[i]->Title().Length() > 0 )
       
  1367             {
       
  1368             iUpperCaseTitle.Copy( iItems[i]->Title().Left( aHighlightText.Length() ) );
       
  1369             iUpperCaseTitle.UpperCase();
       
  1370             TInt result = iUpperCaseTitle.CompareC( aHighlightText );
       
  1371 
       
  1372             if(result == 0)
       
  1373                 {
       
  1374                 iSelectedIndex = i;
       
  1375                 FitSelectionToView();
       
  1376                 DrawDeferred();
       
  1377                 return ETrue;
       
  1378                 }
       
  1379             else if( result > 0)
       
  1380                 {
       
  1381                 break;
       
  1382                 }
       
  1383             }
       
  1384         }
       
  1385     
       
  1386     return EFalse;
       
  1387     }
       
  1388 
       
  1389 // -----------------------------------------------------------------------------
       
  1390 // CHgScroller::SetDefaultIconL()
       
  1391 // -----------------------------------------------------------------------------
       
  1392 //
       
  1393 EXPORT_C void CHgScroller::SetDefaultIconL( CGulIcon* aDefaultIcon )
       
  1394     {
       
  1395     if( aDefaultIcon )
       
  1396         {
       
  1397         delete iDefaultIcon;
       
  1398         iDefaultIcon = aDefaultIcon;
       
  1399         }
       
  1400     }
       
  1401 
       
  1402 // -----------------------------------------------------------------------------
       
  1403 // CHgScroller::DisableScrollBuffer()
       
  1404 // -----------------------------------------------------------------------------
       
  1405 //
       
  1406 EXPORT_C void CHgScroller::DisableScrollBuffer()
       
  1407     {
       
  1408     delete iManager;
       
  1409     iManager = NULL;
       
  1410     }
       
  1411 
       
  1412 // -----------------------------------------------------------------------------
       
  1413 // CHgScroller::InitGraphicsL()
       
  1414 // -----------------------------------------------------------------------------
       
  1415 //
       
  1416 void CHgScroller::InitGraphicsL()
       
  1417     {
       
  1418     // Non-Skinned icons
       
  1419     // Default icon
       
  1420     if(iIndicatorManager)
       
  1421         {
       
  1422         iIndicatorManager->InitIconL(iDefaultIcon, 
       
  1423                 EMbmGanesQgn_prop_checkbox_on, EMbmGanesQgn_prop_checkbox_on_mask, iImageSize);
       
  1424 
       
  1425         iIndicatorManager->InitIndicatorsL(iIndicatorSize);
       
  1426         }
       
  1427     }
       
  1428 
       
  1429 // -----------------------------------------------------------------------------
       
  1430 // CHgScroller::SelectionChanged()
       
  1431 // -----------------------------------------------------------------------------
       
  1432 //
       
  1433 void CHgScroller::SelectionChanged()
       
  1434     {
       
  1435     }
       
  1436 
       
  1437 // -----------------------------------------------------------------------------
       
  1438 // CHgScroller::FitRowToView()
       
  1439 // -----------------------------------------------------------------------------
       
  1440 //
       
  1441 void CHgScroller::FitRowToView( TInt aRow )
       
  1442     {
       
  1443     if( iLandscapeScrolling )
       
  1444         {
       
  1445         if ( aRow*iRowHeight < iViewPosition.iX-(iWidth/2) )
       
  1446             {
       
  1447             // Item is at top but not fully visible
       
  1448             iViewPosition.iX -= (iViewPosition.iX-(iWidth/2) - ((aRow)*iRowHeight));
       
  1449             HandleViewPositionChanged();                            
       
  1450             }    
       
  1451         else if ( (aRow+1)*iRowHeight > iViewPosition.iX+(iWidth/2) )
       
  1452             {
       
  1453             // Item is at bottom but not fully visible
       
  1454             iViewPosition.iX += ((aRow+1)*iRowHeight - (iViewPosition.iX+(iWidth/2)));
       
  1455             HandleViewPositionChanged();                            
       
  1456             }        
       
  1457         }
       
  1458     else
       
  1459         {
       
  1460         if ( aRow*iRowHeight < iViewPosition.iY-(iHeight/2) )
       
  1461             {
       
  1462             // Item is at top but not fully visible
       
  1463             iViewPosition.iY -= (iViewPosition.iY-(iHeight/2) - ((aRow)*iRowHeight));
       
  1464             HandleViewPositionChanged();                            
       
  1465             }    
       
  1466         else if ( (aRow+1)*iRowHeight > iViewPosition.iY+(iHeight/2) )
       
  1467             {
       
  1468             // Item is at bottom but not fully visible
       
  1469             iViewPosition.iY += ((aRow+1)*iRowHeight - (iViewPosition.iY+(iHeight/2)));
       
  1470             HandleViewPositionChanged();                            
       
  1471             }
       
  1472         }
       
  1473     }
       
  1474 
       
  1475 // -----------------------------------------------------------------------------
       
  1476 // CHgScroller::MarqueeCallback()
       
  1477 // -----------------------------------------------------------------------------
       
  1478 //
       
  1479 TInt CHgScroller::MarqueeCallback( TAny* aSelf )
       
  1480     {
       
  1481     CHgScroller* self = static_cast<CHgScroller*>(aSelf);
       
  1482     if( self->IsDisplayed( self->iSelectedIndex ) )
       
  1483         {
       
  1484         self->DrawDeferred();
       
  1485         return ETrue;
       
  1486         }
       
  1487     else
       
  1488         {
       
  1489         return EFalse;
       
  1490         }
       
  1491     }
       
  1492 
       
  1493 // -----------------------------------------------------------------------------
       
  1494 // CHgScroller::HandleGainingForeground()
       
  1495 // -----------------------------------------------------------------------------
       
  1496 //
       
  1497 void CHgScroller::HandleGainingForeground()
       
  1498     {
       
  1499     iSelectionMode = ENoSelection;
       
  1500     iScrollbar->Reset();
       
  1501     }
       
  1502 
       
  1503 // -----------------------------------------------------------------------------
       
  1504 // CHgScroller::HandleLosingForeground()
       
  1505 // -----------------------------------------------------------------------------
       
  1506 //
       
  1507 void CHgScroller::HandleLosingForeground()
       
  1508     {
       
  1509     if( iOldWinPos == KErrNotFound 
       
  1510             || iOldWinPos == DrawableWindow()->OrdinalPosition() ) 
       
  1511         {
       
  1512         iPointerDown = EFalse;
       
  1513         }
       
  1514     
       
  1515     iPopupText1.Zero();
       
  1516     iPopupText2.Zero();
       
  1517     }
       
  1518 
       
  1519 // ---------------------------------------------------------------------------
       
  1520 // CHgScroller::LaunchHighlightTimer()
       
  1521 // ---------------------------------------------------------------------------
       
  1522 //     
       
  1523 void CHgScroller::LaunchHighlightTimer()
       
  1524     {
       
  1525     if ( !iHighlightTimer )
       
  1526         {
       
  1527         return;
       
  1528         }
       
  1529 
       
  1530     TInt highlightTimeout( 0 );
       
  1531     if ( iPhysics )
       
  1532         {
       
  1533         highlightTimeout = iPhysics->HighlightTimeout() * 1000;
       
  1534         }
       
  1535     if ( highlightTimeout == 0 )
       
  1536         {
       
  1537         highlightTimeout = KDefaultHighlightTimeout;
       
  1538         }
       
  1539 
       
  1540     iHighlightTimer->Cancel();
       
  1541     iHighlightTimer->Start( 
       
  1542         TTimeIntervalMicroSeconds32( highlightTimeout ),
       
  1543         TTimeIntervalMicroSeconds32( highlightTimeout ), 
       
  1544         TCallBack( HighlightTimerCallback, this ) );
       
  1545     }
       
  1546 
       
  1547 
       
  1548 // ---------------------------------------------------------------------------
       
  1549 // CHgScroller::HighlightTimerCallback()
       
  1550 // ---------------------------------------------------------------------------
       
  1551 //     
       
  1552 TInt CHgScroller::HighlightTimerCallback( TAny* aPtr )
       
  1553     {
       
  1554     CHgScroller* scroller = 
       
  1555         static_cast<CHgScroller*>( aPtr );
       
  1556 
       
  1557     TInt err = KErrNotFound;
       
  1558         
       
  1559     if ( scroller  )
       
  1560         {
       
  1561         TRAP( err, scroller->SetHighlightL() );
       
  1562         }
       
  1563     
       
  1564     return err;
       
  1565     }
       
  1566 
       
  1567 // ---------------------------------------------------------------------------
       
  1568 // CHgScroller::SetHighlightL()
       
  1569 // ---------------------------------------------------------------------------
       
  1570 //     
       
  1571 void CHgScroller::SetHighlightL()
       
  1572     {
       
  1573     iHighlightTimer->Cancel();
       
  1574 
       
  1575     TInt index = GetSelected(iStart);
       
  1576     if((index != KErrNotFound || !HasHighlight())
       
  1577             && iPointerDown )
       
  1578         {
       
  1579         iSelectionToFocusedItem = (index == iSelectedIndex);            
       
  1580         iSelectedIndex = index;
       
  1581         iFocusedIndex = index;
       
  1582         // Selection has changed to valid item
       
  1583         if( !iSelectionToFocusedItem && iSelectedIndex != KErrNotFound ) 
       
  1584             {
       
  1585             if( iSelectionObserver )
       
  1586                 iSelectionObserver->HandleSelectL(iSelectedIndex);
       
  1587 
       
  1588             FitSelectionToView();
       
  1589             SelectionChanged();
       
  1590             iDrawUtils->ResetMarquee();
       
  1591             }
       
  1592         DrawDeferred();
       
  1593         }
       
  1594     }
       
  1595 
       
  1596 // ---------------------------------------------------------------------------
       
  1597 // CHgScroller::SetSelectionMode()
       
  1598 // ---------------------------------------------------------------------------
       
  1599 //     
       
  1600 void CHgScroller::SetSelectionMode( TSelectionMode aMode )
       
  1601     {
       
  1602     iSelectionMode = aMode;
       
  1603     if( iSelectionMode == ESelectionPossible
       
  1604             || iSelectionMode == ENoSelection )
       
  1605         {
       
  1606         iCoeEnv->InputCapabilitiesChanged();
       
  1607         }
       
  1608     }
       
  1609 
       
  1610 // ---------------------------------------------------------------------------
       
  1611 // CHgScroller::SelectionMode()
       
  1612 // ---------------------------------------------------------------------------
       
  1613 //     
       
  1614 CHgScroller::TSelectionMode CHgScroller::SelectionMode() const
       
  1615     {
       
  1616     return iSelectionMode;
       
  1617     }
       
  1618 
       
  1619 // ---------------------------------------------------------------------------
       
  1620 // CHgScroller::KeyScrollingTimerCallback()
       
  1621 // ---------------------------------------------------------------------------
       
  1622 //     
       
  1623 TInt CHgScroller::KeyScrollingTimerCallback( TAny* aPtr )
       
  1624     {
       
  1625     CHgScroller* scroller = 
       
  1626         static_cast<CHgScroller*>( aPtr );
       
  1627 
       
  1628     TInt err = KErrNotFound;
       
  1629         
       
  1630     if ( scroller  )
       
  1631         {
       
  1632         scroller->DoKeyScrolling();
       
  1633         err = KErrNone;
       
  1634         }
       
  1635     
       
  1636     return err;
       
  1637     }
       
  1638 
       
  1639 // ---------------------------------------------------------------------------
       
  1640 // CHgScroller::DoKeyScrolling()
       
  1641 // ---------------------------------------------------------------------------
       
  1642 //     
       
  1643 void CHgScroller::DoKeyScrolling()
       
  1644     {
       
  1645     TKeyEvent keyevent;
       
  1646     
       
  1647     switch( iKeyScrollingState )
       
  1648         {
       
  1649         case EKeyScrollingUp:
       
  1650             {
       
  1651             keyevent.iCode = EKeyUpArrow;
       
  1652             HandleKeyEvent( keyevent );
       
  1653             break;
       
  1654             }
       
  1655         case EKeyScrollingDown:
       
  1656             {
       
  1657             keyevent.iCode = EKeyDownArrow;
       
  1658             HandleKeyEvent( keyevent );
       
  1659             break;
       
  1660             }
       
  1661         case EKeyScrollingLeft:
       
  1662             {
       
  1663             keyevent.iCode = EKeyLeftArrow;
       
  1664             HandleKeyEvent( keyevent );
       
  1665             break;
       
  1666             }
       
  1667         case EKeyScrollingRight:        
       
  1668             {
       
  1669             keyevent.iCode = EKeyRightArrow;
       
  1670             HandleKeyEvent( keyevent );
       
  1671             break;
       
  1672             }
       
  1673         case ENoKeyScrolling:
       
  1674         default:
       
  1675             StopKeyScrolling();
       
  1676             break;
       
  1677         }
       
  1678 
       
  1679     DrawNow();
       
  1680     }
       
  1681 
       
  1682 // ---------------------------------------------------------------------------
       
  1683 // CHgScroller::StopKeyScrolling()
       
  1684 // ---------------------------------------------------------------------------
       
  1685 //     
       
  1686 void CHgScroller::StopKeyScrolling()
       
  1687     {    
       
  1688     iKeyScrollingTimer->Cancel();
       
  1689     iKeyScrollingState = ENoKeyScrolling;
       
  1690     }
       
  1691 
       
  1692 // ---------------------------------------------------------------------------
       
  1693 // CHgScroller::FocusChanged()
       
  1694 // ---------------------------------------------------------------------------
       
  1695 //     
       
  1696 void CHgScroller::FocusChanged(TDrawNow aDrawNow)
       
  1697     {
       
  1698     if( iKeyUtils )
       
  1699         {
       
  1700         if( !(iFlags & EHgScrollerKeyMarkingDisabled) )
       
  1701             {
       
  1702             if(IsFocused())
       
  1703                 {
       
  1704                 iKeyUtils->HandleGainingFocus();
       
  1705                 }
       
  1706             else
       
  1707                 {
       
  1708                 iKeyUtils->HandleLosingFocus();
       
  1709                 }
       
  1710             }
       
  1711         else
       
  1712             {
       
  1713             iKeyUtils->HandleLosingFocus();
       
  1714             }
       
  1715         }
       
  1716 
       
  1717     CCoeControl::FocusChanged( aDrawNow );
       
  1718     }
       
  1719 
       
  1720 // ---------------------------------------------------------------------------
       
  1721 // CHgScroller::HandleResourceChange()
       
  1722 // ---------------------------------------------------------------------------
       
  1723 //     
       
  1724 void CHgScroller::HandleResourceChange( TInt aType )
       
  1725     {
       
  1726     TRAP_IGNORE(
       
  1727             // When skin changes the indicator icons must be reloaded.
       
  1728         if ( aType == KAknsMessageSkinChange )
       
  1729             {
       
  1730             delete iIndicatorManager; iIndicatorManager = NULL;
       
  1731             iIndicatorManager = CHgIndicatorManager::NewL();
       
  1732             delete iScrollbar; iScrollbar = NULL;
       
  1733             iScrollbar = CHgScrollbar::NewL(*this);
       
  1734             InitScrollbarL();
       
  1735             InitGraphicsL();
       
  1736             
       
  1737             HandleSizeChanged();
       
  1738             DrawDeferred();
       
  1739             }
       
  1740         )
       
  1741     }
       
  1742 
       
  1743 // ---------------------------------------------------------------------------
       
  1744 // CHgScroller::HandleLongTapEventL()
       
  1745 // ---------------------------------------------------------------------------
       
  1746 //     
       
  1747 void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
       
  1748                         const TPoint& aPenEventScreenLocation)
       
  1749     {
       
  1750     if( iActionMenu && !(iFlags & EHgScrollerSelectionMode) )
       
  1751         {
       
  1752         iOldWinPos = DrawableWindow()->OrdinalPosition();
       
  1753         iActionMenu->ShowMenuL(aPenEventScreenLocation);
       
  1754         iPointerDown = EFalse;
       
  1755         }
       
  1756     }
       
  1757 
       
  1758 // ---------------------------------------------------------------------------
       
  1759 // CHgScroller::CollectionState()
       
  1760 // ---------------------------------------------------------------------------
       
  1761 //     
       
  1762 TUint CHgScroller::CollectionState() const
       
  1763     {
       
  1764     TUint ret = 0;
       
  1765     
       
  1766     if( IsFocused() ) 
       
  1767         {
       
  1768         ret |= MAknCollection::EStateCollectionVisible;
       
  1769         }
       
  1770     if( HasHighlight() ) 
       
  1771         {
       
  1772         ret |= MAknCollection::EStateHighlightVisible;
       
  1773         } 
       
  1774     if( iFlags & EHgScrollerSelectionMode )
       
  1775         {
       
  1776         ret |= MAknCollection::EStateMultipleSelection;
       
  1777         for( TInt i = 0; i < iItems.Count(); ++i )
       
  1778             {
       
  1779             if( iItems[i]->Flags() & CHgItem::EHgItemFlagMarked )
       
  1780                 {
       
  1781                 ret |= MAknCollection::EStateMarkedItems; 
       
  1782                 break; 
       
  1783                 }
       
  1784             }
       
  1785         }
       
  1786     return ret; 
       
  1787     }
       
  1788 
       
  1789 // ---------------------------------------------------------------------------
       
  1790 // CHgScroller::CollectionState()
       
  1791 // ---------------------------------------------------------------------------
       
  1792 //     
       
  1793 void CHgScroller::ItemActionMenuClosed()
       
  1794     {
       
  1795     iOldWinPos = KErrNotFound;
       
  1796     DrawDeferred();
       
  1797     }
       
  1798 
       
  1799 // ---------------------------------------------------------------------------
       
  1800 // CHgScroller::CollectionState()
       
  1801 // ---------------------------------------------------------------------------
       
  1802 //     
       
  1803 TInt CHgScroller::CollectionExtension( TUint /*aExtensionId*/, TAny*& /*a0*/, TAny* /*a1*/ )
       
  1804     {
       
  1805     return KErrNone;
       
  1806     }
       
  1807 
       
  1808 // ---------------------------------------------------------------------------
       
  1809 // CHgScroller::HasHighlight()
       
  1810 // ---------------------------------------------------------------------------
       
  1811 //     
       
  1812 TBool CHgScroller::HasHighlight() const
       
  1813     {
       
  1814     return (iActionMenu == NULL) || iShowHighlight || (iFlags & EHgScrollerForceDoubleClick);
       
  1815     }
       
  1816 
       
  1817 // ---------------------------------------------------------------------------
       
  1818 // CHgScroller::ReleasePopupFont()
       
  1819 // ---------------------------------------------------------------------------
       
  1820 //     
       
  1821 void CHgScroller::ReleasePopupFont()
       
  1822     {
       
  1823     if (iPopupFont)
       
  1824         {
       
  1825         iCoeEnv->ScreenDevice()->ReleaseFont(iPopupFont);
       
  1826         iPopupFont = NULL;
       
  1827         }
       
  1828     }
       
  1829 
       
  1830 // ---------------------------------------------------------------------------
       
  1831 // CHgScroller::SetMenuProviderL()
       
  1832 // ---------------------------------------------------------------------------
       
  1833 //     
       
  1834 EXPORT_C void CHgScroller::SetMenuProviderL( MObjectProvider* aMenuProvider )
       
  1835     {
       
  1836     SetMopParent(aMenuProvider);
       
  1837     
       
  1838     if( iActionMenu )
       
  1839         {
       
  1840         iActionMenu->RemoveCollection( *this );
       
  1841         iActionMenu = NULL;
       
  1842         }
       
  1843     
       
  1844     CAknAppUi* appUi = static_cast<CAknAppUi*>(iEikonEnv->AppUi());
       
  1845     if( appUi && appUi->IsSingleClickCompatible() )
       
  1846         {
       
  1847         iActionMenu = CAknItemActionMenu::RegisterCollectionL( *this, this );
       
  1848         }
       
  1849     }
       
  1850 
       
  1851 
       
  1852 // End of File