uifw/EikStd/coctlsrc/EIKMENUP.CPP
branchRCL_3
changeset 4 8ca85d2f0db7
parent 0 2f259fa3e83a
child 9 aabf2c525e0f
equal deleted inserted replaced
0:2f259fa3e83a 4:8ca85d2f0db7
    44 #include <aknconsts.h>
    44 #include <aknconsts.h>
    45 #include <avkon.mbg>
    45 #include <avkon.mbg>
    46 #include <AknsDrawUtils.h>
    46 #include <AknsDrawUtils.h>
    47 #include <AknsFrameBackgroundControlContext.h>
    47 #include <AknsFrameBackgroundControlContext.h>
    48 #include <AknBidiTextUtils.h>
    48 #include <AknBidiTextUtils.h>
    49 #include <AknMarqueeControl.h>
       
    50 #include <skinlayout.cdl.h>
    49 #include <skinlayout.cdl.h>
    51 #include <aknlayoutscalable_avkon.cdl.h>
    50 #include <aknlayoutscalable_avkon.cdl.h>
    52 #include <AknLayoutFont.h>
    51 #include <AknLayoutFont.h>
    53 
    52 
    54 #include <AknsUtils.h>
    53 #include <AknsUtils.h>
    55 #include <AknIconUtils.h>
    54 #include <AknIconUtils.h>
    56 #include <aknappui.h>
    55 #include <aknappui.h>
    57 
    56 
    58 #include <AknsEffectAnim.h>
       
    59 #include <systemwarninglevels.hrh>
       
    60 #include <layoutmetadata.cdl.h>
    57 #include <layoutmetadata.cdl.h>
    61 #include <AknStatuspaneUtils.h>
    58 #include <AknStatuspaneUtils.h>
    62 #include <aknCharMap.h>
    59 #include <aknCharMap.h>
    63 #include <gfxtranseffect/gfxtranseffect.h> //For transition effects
    60 #include <gfxtranseffect/gfxtranseffect.h> //For transition effects
    64 #include <akntranseffect.h> //For transition effects
    61 #include <akntranseffect.h> //For transition effects
    65 #include <akntransitionutils.h> // SetAllParents method
    62 #include <akntransitionutils.h> // SetAllParents method
    66 #include <featmgr.h>
    63 #include <featmgr.h>
    67 #include <hal.h>
       
    68 #include <avkondomainpskeys.h>
    64 #include <avkondomainpskeys.h>
    69 #include <e32property.h>
    65 #include <e32property.h>
    70 
       
    71 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
    72 #include <aknlistboxtfxinternal.h> // LISTBOX EFFECTS IMPLEMENTATION
       
    73 #include <aknlistloadertfx.h>
       
    74 #include <aknlistboxtfx.h>
       
    75 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
    76 
    66 
    77 #include <touchfeedback.h>
    67 #include <touchfeedback.h>
    78 #include <AknTasHook.h>
    68 #include <AknTasHook.h>
    79 #include <aknphysics.h>
    69 #include <aknphysics.h>
    80 #include <aknphysicsobserveriface.h>
    70 #include <aknphysicsobserveriface.h>
   113  * CEikmenuPane is responsible for data members of this class.
   103  * CEikmenuPane is responsible for data members of this class.
   114  *
   104  *
   115  * Extension now contains menu/submenu highlight animation functionality.
   105  * Extension now contains menu/submenu highlight animation functionality.
   116  */
   106  */
   117 NONSHARABLE_CLASS( CEikMenuPaneExtension ):
   107 NONSHARABLE_CLASS( CEikMenuPaneExtension ):
   118     public CActive,
   108     public CBase,
   119     public MCoeForegroundObserver,
       
   120     public MAknsEffectAnimObserver,
       
   121     public MCoeControlObserver,
   109     public MCoeControlObserver,
   122     public MAknPhysicsObserver    
   110     public MAknPhysicsObserver    
   123     {
   111     {
   124 public:
   112 public:
   125     enum TFlag
       
   126         {
       
   127         /**
       
   128         * If set, animation creation is attempted. If not set, animation will
       
   129         * never be created.
       
   130         */
       
   131         EFlagUseAnimation = 0
       
   132         };
       
   133         
       
   134     enum TScreen
       
   135         {
       
   136         EQhdHeight = 360,
       
   137         EQhdWidth = 640        
       
   138         };        
       
   139 
       
   140     CEikMenuPaneExtension();
   113     CEikMenuPaneExtension();
   141     ~CEikMenuPaneExtension();
   114     ~CEikMenuPaneExtension();
   142 
   115 
   143     void ConstructL( CEikMenuPane* aControl );
   116     void ConstructL( CEikMenuPane* aControl );
   144     void CreateAnimation();
       
   145     void NoAnimIfError( TInt aError );
       
   146     void UseNoAnimation();
       
   147     void FocusGained();
       
   148     void FocusLost();
       
   149 
       
   150     void HandleLayoutSwitch();
       
   151     void ChangeHighlightBackground();
       
   152     void MenuClosed();
   117     void MenuClosed();
   153 
   118 
   154     void ConstructMenuSctRowL( TDes& aSpecialChars, TInt aResourceId );
   119     void ConstructMenuSctRowL( TDes& aSpecialChars, TInt aResourceId );
   155     void ConstructMenuSctRowFromDialogL( TDes& aSpecialChars, TInt aResourceId );
   120     void ConstructMenuSctRowFromDialogL( TDes& aSpecialChars, TInt aResourceId );
   156     
   121     
   165     TBool HighlightTimerActive() const;
   130     TBool HighlightTimerActive() const;
   166     
   131     
   167     void ChangePosition( TPointerEvent& aPointerEvent );
   132     void ChangePosition( TPointerEvent& aPointerEvent );
   168     void CalculateParentEvent( const TPointerEvent& aPointerEvent, 
   133     void CalculateParentEvent( const TPointerEvent& aPointerEvent, 
   169                                TPointerEvent& aParentEvent );
   134                                TPointerEvent& aParentEvent );
   170     TRect GetBackgroundRect( const TRect& aWindowRect ) const;                               
       
   171     static void AdjustPopupLayoutData( TAknWindowLineLayout& aListScrollPaneLayout );
       
   172                                
       
   173     const TAknLayoutText GetMenuItemTextLayout(const TRect& aItemRect, TBool cascade);
       
   174 
       
   175 public: // Implementation of MCoeForegroundObserver
       
   176     void HandleGainingForeground();
       
   177     void HandleLosingForeground();
       
   178 
       
   179 public: // Implementation of MAknsEffectAnimObserver
       
   180     void AnimFrameReady( TInt aError, TInt );
       
   181     void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
   135     void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
   182 
       
   183 protected: // CActive overloads
       
   184     void DoCancel();
       
   185     void RunL();
       
   186 
       
   187 private: // New internal methods
       
   188     void Play();
       
   189     TBool DrawHighlightBackground( CFbsBitGc& aGc );
       
   190     void PostDeleteAnimation();
       
   191     void CreateAnimationL( const TSize& aHighlightSize );
       
   192     void DoResizeL( const TSize& aHighlightSize, TBool aAboutToStart );
       
   193 public:
   136 public:
   194     void ImmediateFeedback( TTouchLogicalFeedback aType,
   137     void ImmediateFeedback( TTouchLogicalFeedback aType,
   195                             TTouchFeedbackType aFbType );
   138                             TTouchFeedbackType aFbType );
   196     
   139     
   197 public:
   140 public:
   198     void StartCascadeMenuAppearTransition();
   141     void StartCascadeMenuAppearTransition();
   199 
       
   200 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   201     void CalcItemSize( MAknListBoxTfxInternal* transApi ) const;
       
   202 #endif
       
   203 
   142 
   204     /**
   143     /**
   205      * Prepares cascade menu for item specific commands.
   144      * Prepares cascade menu for item specific commands.
   206      */
   145      */
   207     void PrepareCascadeForItemCommands();
   146     void PrepareCascadeForItemCommands();
   234     /**
   173     /**
   235      * Is highlight enabled
   174      * Is highlight enabled
   236      * 
   175      * 
   237      * @return ETrue if highlight is enabled
   176      * @return ETrue if highlight is enabled
   238      */
   177      */
   239     TBool  HighlightEnabled();
   178     TBool HighlightEnabled();
   240 
   179 
   241     /**
   180     /**
   242      * Sets the default highlight to options menu
   181      * Sets the default highlight to options menu
   243      * 
   182      * 
   244      */    
   183      */    
   245     void SetDefaultHighlight();
   184     void SetDefaultHighlight();
   246     
   185     
   247 public: // Data
   186 public: // Data
   248     TBool iHasIcon;
       
   249     TBool iIsPenEnable;   
       
   250     CFbsBitmap* iCascadeBitmap;
   187     CFbsBitmap* iCascadeBitmap;
   251     CFbsBitmap* iCascadeBitmapMask;
   188     CFbsBitmap* iCascadeBitmapMask;
   252     CAknsFrameBackgroundControlContext* iBgContext;
   189     CAknsFrameBackgroundControlContext* iBgContext;
   253     TInt        iSubMenuWidthIndex;       // index for submenu layout which depends on the text length
   190     TInt        iSubMenuWidthIndex;       // index for submenu layout which depends on the text length
   254     CFbsBitmap* iCheckMarkBitmap;         // bitmap to be drawn if the item has check box set on
   191     CFbsBitmap* iCheckMarkBitmap;         // bitmap to be drawn if the item has check box set on
   255     CFbsBitmap* iCheckMarkBitmapMask;     // mask for the above bitmap
   192     CFbsBitmap* iCheckMarkBitmapMask;     // mask for the above bitmap
   256     CFbsBitmap* iRadioButtonBitmap;       // bitmap to be drawn if the item has radio button set on
   193     CFbsBitmap* iRadioButtonBitmap;       // bitmap to be drawn if the item has radio button set on
   257     CFbsBitmap* iRadioButtonBitmapMask;   // mask for the above bitmap
   194     CFbsBitmap* iRadioButtonBitmapMask;   // mask for the above bitmap
   258     TBool       iHasRadioGroup;           // is ETrue if submenu contains radio button group.
   195     TBool       iHasRadioGroup;           // is ETrue if submenu contains radio button group.
   259     TInt        iSelectedRadioButtonItem; // index of the radio button item which is currently selected (one must be selected)
   196     TInt        iSelectedRadioButtonItem; // index of the radio button item which is currently selected (one must be selected)
   260     CCoeControl* iGrabbingCBAComponent;    // component control of CBA which is currently grabbing the pointer
       
   261     CEikMenuPane* iControl;
   197     CEikMenuPane* iControl;
   262     CAknsEffectAnim* iAnimation;
       
   263     /**
       
   264     * Stored flags are explained in enumeration TFlags.
       
   265     */
       
   266     TBitFlags32 iAnimFlags;
       
   267 
       
   268     CAknCharMap* iSct;      // Menu SCT row, created only when needed.
   198     CAknCharMap* iSct;      // Menu SCT row, created only when needed.
   269     TBool iSctHighlighted;  // No "normal" menu item can be highlighted if ETrue
   199     TBool iSctHighlighted;  // No "normal" menu item can be highlighted if ETrue
   270 
   200 
   271     // Pen event related flag indicating whether the (sub)menu pane has
   201     // Pen event related flag indicating whether the (sub)menu pane has
   272     // already consumed EButton1Down or not. If false,
   202     // already consumed EButton1Down or not. If false,
   275     TBool iSpecialCharPointed;
   205     TBool iSpecialCharPointed;
   276     // transition demarcation rectangle for cascaded submenu
   206     // transition demarcation rectangle for cascaded submenu
   277     // needs to be mutable since we need to get information from Draw methods
   207     // needs to be mutable since we need to get information from Draw methods
   278     // (that are declared const)
   208     // (that are declared const)
   279     mutable TRect iCascadeDRect;
   209     mutable TRect iCascadeDRect;
   280     TBool iTransitionsOn;   // Transitions FtMgr flag on
       
   281     TBool iShowCascadeTransition;
   210     TBool iShowCascadeTransition;
   282     // For later deletion of cascade menu, this allows the transition system
   211     // For later deletion of cascade menu, this allows the transition system
   283     // to correctly handle the aborted transitions
   212     // to correctly handle the aborted transitions
   284     CEikMenuPane* iCascadeMenuObject;
   213     CEikMenuPane* iCascadeMenuObject;
   285     TBool iDraggedOutside;    
   214     TBool iDraggedOutside;    
   286     TPointerEvent iLastPointerEvent;
   215     TPointerEvent iLastPointerEvent;
   287 
       
   288 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   289     CWindowGc* iGc;
       
   290 #endif
       
   291     TInt iItemsThatFitInView;
   216     TInt iItemsThatFitInView;
   292     TRect iScrollBarRect;
   217     TRect iScrollBarRect;
   293     TRect iSctRect;
   218     TRect iSctRect;
   294     TInt iTotalNumberOfItemsInView; // this value includes partial items
       
   295 
       
   296 
       
   297     CIdle* iTaskSwapIdle;
   219     CIdle* iTaskSwapIdle;
   298     CRedirectionListener* iRedirectionListener;
   220     CRedirectionListener* iRedirectionListener;
   299     TRect iSBRect;
       
   300     RWindow* iMenuPaneWindow; // Not own, used by SCT
   221     RWindow* iMenuPaneWindow; // Not own, used by SCT
   301     TBool iLaunchCascadeMenu; 
   222     TBool iLaunchCascadeMenu; 
   302     TBool isUpdateScrollDirectly;
   223     TBool isUpdateScrollDirectly;
   303     TBool iPressedDown;      // ETrue if pointer is down, otherwise.
   224     TBool iPressedDown;      // ETrue if pointer is down, otherwise.
   304 
   225 
   313     enum TCEikMenuPaneExtensionFlags
   234     enum TCEikMenuPaneExtensionFlags
   314         {
   235         {
   315         ESingleClickEnabled,
   236         ESingleClickEnabled,
   316         EHideItemSpecificCommands,
   237         EHideItemSpecificCommands,
   317         EContextSensitive,
   238         EContextSensitive,
       
   239         ESkipScrollbarUpdate,
   318         EHighlightEnabled
   240         EHighlightEnabled
   319         };
   241         };
   320 
   242 
   321     /**
   243     /**
   322      * Menu pane extension flags.
   244      * Menu pane extension flags.
   323      */
   245      */
   324     TBitFlags iFlags;
   246     TBitFlags iFlags;
       
   247     
       
   248     /**
       
   249      * Cached rectangle occupied by menu items (excluding scrollbar's area).
       
   250      */
       
   251     TRect iItemAreaRect;
       
   252     
       
   253     /**
       
   254      * Cached rectangle occupied by menu items and scrollbar.
       
   255      */
       
   256     TRect iMenuAreaRect;
       
   257     
       
   258     /**
       
   259      * Index of the item were highlight was previously drawn to.
       
   260      * Can be KErrNotFound.
       
   261      */
       
   262     TInt iHighlightedItem;
       
   263     
       
   264     /**
       
   265      * Scrollbar's desired visibility. This is calculated in conjunction with
       
   266      * menu pane's size and used later on when calculating scrollbar's layout.
       
   267      */
       
   268     CEikScrollBarFrame::TScrollBarVisibility iScrollbarVisibility;
   325 
   269 
   326 private: // Data
   270 private: // Data
   327     CPeriodic* iTimer; // timer to launch submenu, own
   271     CPeriodic* iTimer; // timer to launch submenu, own
   328     CPeriodic* iHighlightTimer; // Timer to adjust pressed down highlight
   272     CPeriodic* iHighlightTimer; // Timer to adjust pressed down highlight
   329     TInt iVerticalOffset; // Panning offset
   273     TInt iVerticalOffset; // Panning offset
   451     { return iTopItemIndex; }
   395     { return iTopItemIndex; }
   452 
   396 
   453 inline void CEikMenuPane::CMenuScroller::SetTopItemIndex(TInt aIndex)
   397 inline void CEikMenuPane::CMenuScroller::SetTopItemIndex(TInt aIndex)
   454     { 
   398     { 
   455     iTopItemIndex=aIndex;
   399     iTopItemIndex=aIndex;
   456 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   457     if ( iMenuPane.iExtension )
       
   458         {
       
   459         iTopItemIndex = aIndex;
       
   460         }
       
   461 #endif
       
   462     }
   400     }
   463 
   401 
   464 inline CIdle* CEikMenuPane::CMenuScroller::Idle() const
   402 inline CIdle* CEikMenuPane::CMenuScroller::Idle() const
   465     { return iIdle; }
   403     { return iIdle; }
   466 
   404 
   472     iVerticalOffset = 0;
   410     iVerticalOffset = 0;
   473     iListTopIndex = 0;
   411     iListTopIndex = 0;
   474     iLastFeedbackTopItemIndex = 0;
   412     iLastFeedbackTopItemIndex = 0;
   475     iPressedDown = EFalse;
   413     iPressedDown = EFalse;
   476     iFlickActive = EFalse;
   414     iFlickActive = EFalse;
   477     
   415 
   478     TRect rect;
   416     TRect rect( iMenuPaneRect );
   479     if ( !iControl->iOwner )
       
   480         {
       
   481         rect = iMenuPaneRect;    
       
   482         }
       
   483     else
       
   484         {
       
   485         rect = iControl->Rect();    
       
   486         }    
       
   487     
   417     
   488     TInt itemHeight = iControl->iItemHeight;
   418     TInt itemHeight = iControl->iItemHeight;
   489     TInt itemsInRect = rect.Height() / itemHeight;
   419     TInt itemsInRect = rect.Height() / itemHeight;
   490     TInt totalItemHeight = iControl->TotalItemHeight();
   420     TInt totalItemHeight = iControl->TotalItemHeight();
   491 
   421 
   535 // ---------------------------------------------------------------------------
   465 // ---------------------------------------------------------------------------
   536 //
   466 //
   537 void CEikMenuPaneExtension::ViewPositionChanged( const TPoint& aNewPosition,
   467 void CEikMenuPaneExtension::ViewPositionChanged( const TPoint& aNewPosition,
   538                                                  TBool aDrawNow,
   468                                                  TBool aDrawNow,
   539                                                  TUint /*aFlags*/ )
   469                                                  TUint /*aFlags*/ )
   540     {  
   470     {
   541     _AKNTRACE_FUNC_ENTER;
   471     _AKNTRACE_FUNC_ENTER;
   542     if ( !iControl->iItemArray )
   472     TInt delta = iViewPosition.iY - aNewPosition.iY;
       
   473 
       
   474     if ( !iControl->iItemArray || delta == 0 )
   543         {
   475         {
   544         return;
   476         return;
   545         }
   477         }
   546     
   478 
   547     iListTopIndex = aNewPosition.iY - iViewHeight / 2;  
   479     iListTopIndex = aNewPosition.iY - iViewHeight / 2;  
   548     
       
   549     iListBottomIndex = aNewPosition.iY + iViewHeight - iViewHeight / 2;
   480     iListBottomIndex = aNewPosition.iY + iViewHeight - iViewHeight / 2;
   550     
       
   551     TInt delta = iViewPosition.iY - aNewPosition.iY;
       
   552     
   481     
   553     DoOffset( delta );
   482     DoOffset( delta );
   554 
   483 
   555     iViewPosition = aNewPosition; 
   484     iViewPosition = aNewPosition; 
   556     _AKNTRACE( "iListTopIndex = %d",  iListTopIndex );
   485     _AKNTRACE( "iListTopIndex = %d",  iListTopIndex );
   558     _AKNTRACE( "delta = %d",  delta );
   487     _AKNTRACE( "delta = %d",  delta );
   559     _AKNTRACE( "iViewPosition(%d,%d)",  iViewPosition.iX, iViewPosition.iY );
   488     _AKNTRACE( "iViewPosition(%d,%d)",  iViewPosition.iX, iViewPosition.iY );
   560     
   489     
   561     if ( aDrawNow )
   490     if ( aDrawNow )
   562         {
   491         {
   563         TRAP_IGNORE( iControl->DoUpdateScrollBarL() );
   492         if ( iFlags.IsClear( ESkipScrollbarUpdate ) )
   564 
   493             {
   565         if ( iControl->iOwner ) // Submenu
   494             TRAP_IGNORE( iControl->DoUpdateScrollBarL() );
   566             {
   495             }
   567             iControl->DrawNow();
   496 
   568             }
   497         // Redraw only item area if scrollbar is invisible, otherwise include 
   569         else
   498         // also scrollbar's area in order to avoid drawdeferred.
   570             {
   499         TRect drawRect( iItemAreaRect );
   571             iControl->DrawNow( TRect( iMenuPaneRect.Size() ) );
   500         
   572             }        
   501         if ( iScrollbarVisibility == CEikScrollBarFrame::EOn )
       
   502             {
       
   503             drawRect = iMenuAreaRect;
       
   504             }
       
   505 
       
   506         iControl->DrawNow( drawRect );
   573         }
   507         }
   574     _AKNTRACE_FUNC_EXIT;
   508     _AKNTRACE_FUNC_EXIT;
   575     }
   509     }
   576 
   510 
   577 
   511 
   734 
   668 
   735 void CEikMenuPaneExtension::PhysicEmulationEnded()
   669 void CEikMenuPaneExtension::PhysicEmulationEnded()
   736     {
   670     {
   737     _AKNTRACE_FUNC_ENTER;    
   671     _AKNTRACE_FUNC_ENTER;    
   738     iFlickActive = EFalse; 
   672     iFlickActive = EFalse; 
   739 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   740     MAknListBoxTfx* tfxApi = CAknListLoader::TfxApi( iGc );
       
   741 
       
   742     if ( tfxApi )
       
   743         {
       
   744         tfxApi->EnableEffects( ETrue );
       
   745         }
       
   746 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   747     _AKNTRACE_FUNC_EXIT;
   673     _AKNTRACE_FUNC_EXIT;
   748     }    
   674     }    
   749     
   675     
   750 TPoint CEikMenuPaneExtension::ViewPosition() const
   676 TPoint CEikMenuPaneExtension::ViewPosition() const
   751     {
   677     {
   934 // High CActive priority is well argumented because running the active object
   860 // High CActive priority is well argumented because running the active object
   935 // will result in animation deletion -> results in freeing resources.
   861 // will result in animation deletion -> results in freeing resources.
   936 // -----------------------------------------------------------------------------
   862 // -----------------------------------------------------------------------------
   937 //
   863 //
   938 CEikMenuPaneExtension::CEikMenuPaneExtension() :
   864 CEikMenuPaneExtension::CEikMenuPaneExtension() :
   939     CActive( EPriorityHigh ),
       
   940     // Initialise data members to zero
   865     // Initialise data members to zero
   941     iCascadeBitmap( NULL ),
   866     iCascadeBitmap( NULL ),
   942     iCascadeBitmapMask( NULL ),
   867     iCascadeBitmapMask( NULL ),
   943     iBgContext( NULL ),
   868     iBgContext( NULL ),
   944     iSubMenuWidthIndex( 1 ),
   869     iSubMenuWidthIndex( 1 ),
   946     iCheckMarkBitmapMask( NULL ),
   871     iCheckMarkBitmapMask( NULL ),
   947     iRadioButtonBitmap( NULL ),
   872     iRadioButtonBitmap( NULL ),
   948     iRadioButtonBitmapMask( NULL ),
   873     iRadioButtonBitmapMask( NULL ),
   949     iHasRadioGroup( EFalse ),
   874     iHasRadioGroup( EFalse ),
   950     iSelectedRadioButtonItem( KNoSelectedRadioButtonItem ),
   875     iSelectedRadioButtonItem( KNoSelectedRadioButtonItem ),
   951     iGrabbingCBAComponent( NULL ),
       
   952     iControl( NULL ),
   876     iControl( NULL ),
   953     iAnimation( NULL ),
       
   954     iAnimFlags ( 0 ),
       
   955     iSct( NULL ),
   877     iSct( NULL ),
   956     iSctHighlighted( EFalse ),
   878     iSctHighlighted( EFalse ),
   957     iSpecialCharPointed( EFalse )
   879     iSpecialCharPointed( EFalse )
   958 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   959     ,iGc ( NULL )
       
   960 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   961     ,iVerticalOffset( 0 )
   880     ,iVerticalOffset( 0 )
   962     ,iPhysics( NULL )
   881     ,iPhysics( NULL )
   963     ,iListTopIndex( 0 )
   882     ,iListTopIndex( 0 )
   964     ,iViewHeight( 0 )
   883     ,iViewHeight( 0 )
   965     ,iFlickActive( EFalse )
   884     ,iFlickActive( EFalse )
   966     ,iPanningActive( EFalse )
   885     ,iPanningActive( EFalse )
   967     ,iFeedback( MTouchFeedback::Instance() )
   886     ,iFeedback( MTouchFeedback::Instance() )
   968     ,iLastFeedbackTopItemIndex( 0 )
   887     ,iLastFeedbackTopItemIndex( 0 )
   969     {
   888     {
   970     iIsPenEnable = AknLayoutUtils::PenEnabled();
   889     iItemsReadyForPenSelection = !AknLayoutUtils::PenEnabled();
   971     iItemsReadyForPenSelection = !iIsPenEnable;
       
   972     iNextHighlightItem = KErrNotFound;
   890     iNextHighlightItem = KErrNotFound;
       
   891     iHighlightedItem = KErrNotFound;
   973     }
   892     }
   974 
   893 
   975 // -----------------------------------------------------------------------------
   894 // -----------------------------------------------------------------------------
   976 // CEikMenuPaneExtension::~CEikMenuPaneExtension
   895 // CEikMenuPaneExtension::~CEikMenuPaneExtension
   977 // Destructor for extension class
   896 // Destructor for extension class
   978 // -----------------------------------------------------------------------------
   897 // -----------------------------------------------------------------------------
   979 //
   898 //
   980 CEikMenuPaneExtension::~CEikMenuPaneExtension()
   899 CEikMenuPaneExtension::~CEikMenuPaneExtension()
   981     {
   900     {
   982     _AKNTRACE_FUNC_ENTER;
   901     _AKNTRACE_FUNC_ENTER;
   983 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   984     if ( CAknListLoader::TfxApiInternal( iGc ) )
       
   985         {
       
   986         delete iGc;
       
   987         }
       
   988 #endif
       
   989     Cancel(); // Cancel possibly pending request
       
   990 
       
   991     // Stop receiving foreground events
       
   992     CCoeEnv* env = CCoeEnv::Static();
       
   993     env->RemoveForegroundObserver( *this );
       
   994 
   902 
   995     delete iCascadeBitmap;
   903     delete iCascadeBitmap;
   996     iCascadeBitmap = NULL;
   904     iCascadeBitmap = NULL;
   997 
   905 
   998     delete iCascadeBitmapMask;
   906     delete iCascadeBitmapMask;
  1012 
   920 
  1013     delete iRadioButtonBitmapMask;
   921     delete iRadioButtonBitmapMask;
  1014     iRadioButtonBitmapMask = NULL;
   922     iRadioButtonBitmapMask = NULL;
  1015 
   923 
  1016     iControl = NULL;
   924     iControl = NULL;
  1017 
       
  1018     delete iAnimation;
       
  1019     iAnimation = NULL;
       
  1020 
   925 
  1021     delete iSct;
   926     delete iSct;
  1022     iSct = NULL;
   927     iSct = NULL;
  1023 
   928 
  1024     delete iCascadeMenuObject;
   929     delete iCascadeMenuObject;
  1051 //
   956 //
  1052 void CEikMenuPaneExtension::ConstructL( CEikMenuPane* aControl )
   957 void CEikMenuPaneExtension::ConstructL( CEikMenuPane* aControl )
  1053     {
   958     {
  1054     ASSERT( aControl );
   959     ASSERT( aControl );
  1055     iControl = aControl;
   960     iControl = aControl;
  1056     iAnimFlags.Set( EFlagUseAnimation ); // Animations are created by default
       
  1057     CActiveScheduler::Add( this );
       
  1058     iDraggedOutside = EFalse;
   961     iDraggedOutside = EFalse;
  1059     iLaunchCascadeMenu = EFalse;
   962     iLaunchCascadeMenu = EFalse;
  1060     iButtonDownItem = KErrNotFound;
   963     iButtonDownItem = KErrNotFound;
  1061     iTaskSwapIdle = CIdle::NewL( CActive::EPriorityHigh );
   964     iTaskSwapIdle = CIdle::NewL( CActive::EPriorityHigh );
  1062     if ( aControl->iOwner == NULL && GfxTransEffect::IsRegistered( aControl ) )
   965     if ( aControl->iOwner == NULL && GfxTransEffect::IsRegistered( aControl ) )
  1063         {
   966         {
  1064         // Delays submenu opening during appear transitions
   967         // Delays submenu opening during appear transitions
  1065         iRedirectionListener = new ( ELeave ) CRedirectionListener( *this );
   968         iRedirectionListener = new ( ELeave ) CRedirectionListener( *this );
  1066         }
   969         }
  1067 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  1068         iGc = CAknListLoader::CreateTfxGc( *aControl,
       
  1069                                            iControl->iScroller->iTopItemIndex,
       
  1070                                            iTotalNumberOfItemsInView );
       
  1071 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  1072     if ( static_cast<CAknAppUi*>(
   970     if ( static_cast<CAknAppUi*>(
  1073             iControl->ControlEnv()->AppUi() )->IsSingleClickCompatible() )
   971             iControl->ControlEnv()->AppUi() )->IsSingleClickCompatible() )
  1074         {
   972         {
  1075         iFlags.Set( ESingleClickEnabled );
   973         iFlags.Set( ESingleClickEnabled );
  1076         }
   974         }
  1082     
   980     
  1083     iBgContext = CAknsFrameBackgroundControlContext::NewL(
   981     iBgContext = CAknsFrameBackgroundControlContext::NewL(
  1084         KAknsIIDQsnFrPopup, TRect( 0, 0, 1, 1 ), TRect( 0, 0, 1, 1 ), EFalse );
   982         KAknsIIDQsnFrPopup, TRect( 0, 0, 1, 1 ), TRect( 0, 0, 1, 1 ), EFalse );
  1085     }
   983     }
  1086 
   984 
  1087 // -----------------------------------------------------------------------------
       
  1088 // CEikMenuPaneExtension::CreateAnimation
       
  1089 // -----------------------------------------------------------------------------
       
  1090 //
       
  1091 void CEikMenuPaneExtension::CreateAnimation()
       
  1092     {
       
  1093 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  1094     return;
       
  1095 #else    
       
  1096     if( !iAnimation && iAnimFlags.IsSet( EFlagUseAnimation ) )
       
  1097         {    
       
  1098         TRect rect = iControl->HighlightRect();
       
  1099         TRAPD( err, CreateAnimationL( rect.Size() ) );
       
  1100         if( KErrNone != err )
       
  1101             {
       
  1102             // Animation has not been drawn -> no need for repaint
       
  1103             UseNoAnimation();
       
  1104             }
       
  1105         }
       
  1106 #endif //RD_UI_TRANSITION_EFFECTS_LIST  
       
  1107     }
       
  1108 
       
  1109 // -----------------------------------------------------------------------------
       
  1110 // CEikMenuPaneExtension::NoAnimIfError
       
  1111 // -----------------------------------------------------------------------------
       
  1112 //
       
  1113 void CEikMenuPaneExtension::NoAnimIfError( TInt aError )
       
  1114     {
       
  1115     if( KErrNone != aError )
       
  1116         UseNoAnimation();
       
  1117     }
       
  1118 
       
  1119 // -----------------------------------------------------------------------------
       
  1120 // CEikMenuPaneExtension::UseNoAnimation
       
  1121 // Falls back to normal highlight rendering.
       
  1122 // -----------------------------------------------------------------------------
       
  1123 //
       
  1124 void CEikMenuPaneExtension::UseNoAnimation()
       
  1125     {
       
  1126     delete iAnimation;
       
  1127     iAnimation = NULL;
       
  1128 
       
  1129     // Do not attempt to create animations in the future
       
  1130     iAnimFlags.Clear( EFlagUseAnimation );
       
  1131 
       
  1132     // Stop receiving foreground events
       
  1133     CCoeEnv* env = CCoeEnv::Static();
       
  1134     env->RemoveForegroundObserver( *this );
       
  1135     }
       
  1136 
   985 
  1137 // -----------------------------------------------------------------------------
   986 // -----------------------------------------------------------------------------
  1138 // CEikMenuPaneExtension::StartCascadeMenuTimerL
   987 // CEikMenuPaneExtension::StartCascadeMenuTimerL
  1139 // Starts the timer for the sub menu launch. Timer is constructed when used for
   988 // Starts the timer for the sub menu launch. Timer is constructed when used for
  1140 // the first time
   989 // the first time
  1154     iTimer->Start( KCascadeMenuOpenDelay,
  1003     iTimer->Start( KCascadeMenuOpenDelay,
  1155                    KCascadeMenuOpenDelay,
  1004                    KCascadeMenuOpenDelay,
  1156                    TCallBack ( CascadeMenuTimerCallBack, this ) );
  1005                    TCallBack ( CascadeMenuTimerCallBack, this ) );
  1157     _AKNTRACE_FUNC_EXIT;
  1006     _AKNTRACE_FUNC_EXIT;
  1158     }
  1007     }
       
  1008 
  1159 
  1009 
  1160 // -----------------------------------------------------------------------------
  1010 // -----------------------------------------------------------------------------
  1161 // CEikMenuPaneExtension::StopCascadeMenuTimer
  1011 // CEikMenuPaneExtension::StopCascadeMenuTimer
  1162 // Stops the timer for the sub menu launch
  1012 // Stops the timer for the sub menu launch
  1163 // -----------------------------------------------------------------------------
  1013 // -----------------------------------------------------------------------------
  1258         iControl->RepaintHighlight();    
  1108         iControl->RepaintHighlight();    
  1259         }
  1109         }
  1260     _AKNTRACE_FUNC_EXIT;
  1110     _AKNTRACE_FUNC_EXIT;
  1261     }
  1111     }
  1262 
  1112 
       
  1113 
  1263 // -----------------------------------------------------------------------------
  1114 // -----------------------------------------------------------------------------
  1264 // CEikMenuPaneExtension::HighlightTimerCallBack
  1115 // CEikMenuPaneExtension::HighlightTimerCallBack
  1265 // Callback function of the timer for pressed down highlight
  1116 // Callback function of the timer for pressed down highlight
  1266 // -----------------------------------------------------------------------------
  1117 // -----------------------------------------------------------------------------
  1267 //    
  1118 //    
  1309 //
  1160 //
  1310 void CEikMenuPaneExtension::ChangePosition( TPointerEvent& aPointerEvent )    
  1161 void CEikMenuPaneExtension::ChangePosition( TPointerEvent& aPointerEvent )    
  1311     {
  1162     {
  1312     if ( !iControl->iSBFrame )
  1163     if ( !iControl->iSBFrame )
  1313         {
  1164         {
  1314         iControl->CreateScrollBarFrame();
  1165         return;
  1315         }
  1166         }
  1316     TRect scrollBarRect = iControl->iSBFrame->VerticalScrollBar()->Rect();
  1167     
  1317     TPoint scrollerTl = scrollBarRect.iTl; 
  1168     TRect scrollBarRect( iControl->iSBFrame->VerticalScrollBar()->Rect() );
  1318     TPoint scrollerBr = scrollBarRect.iBr;
  1169     TPoint scrollerTl( scrollBarRect.iTl ); 
       
  1170     TPoint scrollerBr( scrollBarRect.iBr );
  1319     TRect gapRect;           
  1171     TRect gapRect;           
  1320     // For layout that left to right
  1172     // For layout that left to right
  1321     if ( !AknLayoutUtils::LayoutMirrored() )
  1173     if ( !AknLayoutUtils::LayoutMirrored() )
  1322         {
  1174         {
  1323         TPoint rectTl( scrollerBr.iX, iControl->Rect().iTl.iY );
  1175         TPoint rectTl( scrollerBr.iX, iControl->Rect().iTl.iY );
  1361 //
  1213 //
  1362 void CEikMenuPaneExtension::CalculateParentEvent( const TPointerEvent& aPointerEvent, 
  1214 void CEikMenuPaneExtension::CalculateParentEvent( const TPointerEvent& aPointerEvent, 
  1363                            TPointerEvent& aParentEvent )
  1215                            TPointerEvent& aParentEvent )
  1364     {
  1216     {
  1365     aParentEvent.iModifiers = aPointerEvent.iModifiers;
  1217     aParentEvent.iModifiers = aPointerEvent.iModifiers;
  1366     TPoint subPos = iControl->PositionRelativeToScreen();
  1218     TPoint subPos = iControl->Position();
  1367     TPoint ownerPos = iControl->iOwner->PositionRelativeToScreen();
  1219     TPoint ownerPos = iControl->iOwner->Position();
  1368     aParentEvent.iPosition.SetXY (
  1220     aParentEvent.iPosition.SetXY (
  1369         aPointerEvent.iPosition.iX + subPos.iX - ownerPos.iX,
  1221         aPointerEvent.iPosition.iX + subPos.iX - ownerPos.iX,
  1370         aPointerEvent.iPosition.iY + subPos.iY - ownerPos.iY);
  1222         aPointerEvent.iPosition.iY + subPos.iY - ownerPos.iY);
  1371     aParentEvent.iType = aPointerEvent.iType;    
  1223     aParentEvent.iType = aPointerEvent.iType;    
  1372     }
  1224     }
  1373 
  1225 
  1374 // -----------------------------------------------------------------------------
       
  1375 // CEikMenuPaneExtension::GetBackgroundRect
       
  1376 // Get background rect for landscape mode of menu pane.
       
  1377 // -----------------------------------------------------------------------------
       
  1378 //    
       
  1379 TRect CEikMenuPaneExtension::GetBackgroundRect( const TRect& aWindowRect ) const
       
  1380     {
       
  1381     return aWindowRect;
       
  1382     }
       
  1383         
       
  1384 // -----------------------------------------------------------------------------
       
  1385 // CEikMenuPaneExtension::AdjustPopupLayoutData
       
  1386 // Adjust popup layout data for main menu pane in landscape mode
       
  1387 // -----------------------------------------------------------------------------
       
  1388 // 
       
  1389 void CEikMenuPaneExtension::AdjustPopupLayoutData( TAknWindowLineLayout& aListScrollPaneLayout )
       
  1390     {
       
  1391     TRect screenRect;
       
  1392     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, screenRect );
       
  1393     AknLayoutUtils::TAknCbaLocation cbaPosition = AknLayoutUtils::CbaLocation();
       
  1394 
       
  1395     if ( screenRect.Width() == EQhdWidth && screenRect.Height() == EQhdHeight 
       
  1396         && cbaPosition == AknLayoutUtils::EAknCbaLocationBottom ) 
       
  1397         {
       
  1398         if ( !AknLayoutUtils::LayoutMirrored() )
       
  1399             {
       
  1400             aListScrollPaneLayout.ir -= 32;
       
  1401             }
       
  1402         else
       
  1403             {
       
  1404             aListScrollPaneLayout.il -= 32;
       
  1405             }
       
  1406         }
       
  1407     } 
       
  1408 
       
  1409 
       
  1410 // -----------------------------------------------------------------------------
       
  1411 // CEikMenuPaneExtension::GetMenuItemTextLayout
       
  1412 // Get Layout of menu item text.
       
  1413 // -----------------------------------------------------------------------------
       
  1414 //
       
  1415 const TAknLayoutText CEikMenuPaneExtension::GetMenuItemTextLayout(const TRect& aItemRect, TBool cascade)
       
  1416     {
       
  1417     TAknTextLineLayout menuTextLayout;
       
  1418     
       
  1419     if ( !iControl->iOwner )
       
  1420         {
       
  1421         menuTextLayout = AknLayoutScalable_Avkon::list_single_pane_t1_cp2( cascade ? 3 : 0 ).LayoutLine();
       
  1422         }
       
  1423     else
       
  1424         {
       
  1425         if ( iHasIcon )
       
  1426             {
       
  1427             menuTextLayout = TAknTextLineLayout( AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 1 ).LayoutLine() );
       
  1428             }
       
  1429         else
       
  1430             {
       
  1431             menuTextLayout = TAknTextLineLayout( AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 0 ).LayoutLine() );
       
  1432             }
       
  1433         }
       
  1434     
       
  1435     TAknLayoutText textRect;
       
  1436     textRect.LayoutText( aItemRect, menuTextLayout );
       
  1437     return textRect;
       
  1438     }
       
  1439 
       
  1440 
       
  1441 // -----------------------------------------------------------------------------
       
  1442 // CEikMenuPaneExtension::FocusGained
       
  1443 // The owning control has gained focus -> animation should be continued.
       
  1444 // -----------------------------------------------------------------------------
       
  1445 //
       
  1446 void CEikMenuPaneExtension::FocusGained()
       
  1447     {
       
  1448     Play();
       
  1449     }
       
  1450 
       
  1451 // -----------------------------------------------------------------------------
       
  1452 // CEikMenuPaneExtension::FocusLost
       
  1453 // The owning control has lost focus -> no running animation (even if the
       
  1454 // control is partially visible).
       
  1455 // -----------------------------------------------------------------------------
       
  1456 //
       
  1457 void CEikMenuPaneExtension::FocusLost()
       
  1458     {
       
  1459     if( iAnimation )
       
  1460         {
       
  1461         NoAnimIfError( iAnimation->Pause() );
       
  1462         }
       
  1463     }
       
  1464 
       
  1465 // -----------------------------------------------------------------------------
       
  1466 // CEikMenuPaneExtension::HandleLayoutSwitch
       
  1467 // -----------------------------------------------------------------------------
       
  1468 //
       
  1469 void CEikMenuPaneExtension::HandleLayoutSwitch()
       
  1470     {
       
  1471     if( iAnimation ) // Animation exists -> try to resize
       
  1472         {
       
  1473         TRect rect( iControl->HighlightRect() );
       
  1474 
       
  1475         // Resize animation
       
  1476         TBool aboutToStart = ETrue;
       
  1477         if( iAnimation->State() == EAknsAnimStateStopped )
       
  1478             aboutToStart = EFalse;
       
  1479 
       
  1480         TRAPD( err, DoResizeL( rect.Size(), aboutToStart ) );
       
  1481         NoAnimIfError( err );
       
  1482         }
       
  1483     }
       
  1484 
       
  1485 // -----------------------------------------------------------------------------
       
  1486 // CEikMenuPaneExtension::ChangeHighlightBackground
       
  1487 // -----------------------------------------------------------------------------
       
  1488 //
       
  1489 void CEikMenuPaneExtension::ChangeHighlightBackground()
       
  1490     {
       
  1491     // Every time the current list item is changed we need to change the
       
  1492     // animation input layer (animated element is the highlight bacground that
       
  1493     // can differ between highlight positions).
       
  1494     if( iAnimation )
       
  1495         {
       
  1496         if( iAnimation->State() == EAknsAnimStateStopped  )
       
  1497             {
       
  1498             // Input layers don't exist when stopped or finished. We need to
       
  1499             // resize to create the input layers and to update the output
       
  1500             // layer.
       
  1501 
       
  1502             TRAPD( err, DoResizeL( iAnimation->Size(), EFalse ) );
       
  1503             NoAnimIfError( err );
       
  1504             }
       
  1505         else // Either paused, running or finished
       
  1506             {
       
  1507             // Update the highlight background
       
  1508             if( iAnimation->InputRgbGc() )
       
  1509                 DrawHighlightBackground( *iAnimation->InputRgbGc() );
       
  1510 
       
  1511             // We need to update the output frame (otherwise the highlight
       
  1512             // would drawn with the old output before the next new animation
       
  1513             // frame).
       
  1514             NoAnimIfError( iAnimation->UpdateOutput() );
       
  1515             }
       
  1516         }
       
  1517     }
       
  1518 
  1226 
  1519 // -----------------------------------------------------------------------------
  1227 // -----------------------------------------------------------------------------
  1520 // CEikMenuPaneExtension::MenuClosed
  1228 // CEikMenuPaneExtension::MenuClosed
  1521 // -----------------------------------------------------------------------------
  1229 // -----------------------------------------------------------------------------
  1522 //
  1230 //
  1523 void CEikMenuPaneExtension::MenuClosed()
  1231 void CEikMenuPaneExtension::MenuClosed()
  1524     {
  1232     {
  1525     _AKNTRACE_FUNC_ENTER;
  1233     _AKNTRACE_FUNC_ENTER;
  1526     delete iAnimation;
       
  1527     iAnimation = NULL;
       
  1528 
       
  1529     CCoeEnv* env = CCoeEnv::Static();
       
  1530     env->RemoveForegroundObserver( *this );
       
  1531 
       
  1532     iAnimFlags.Set( EFlagUseAnimation );
       
  1533 
       
  1534     delete iSct;
  1234     delete iSct;
  1535     iSct = NULL;
  1235     iSct = NULL;
  1536     iSctHighlighted = EFalse;
  1236     iSctHighlighted = EFalse;
  1537 #ifdef RD_UI_TRANSITION_EFFECTS_LIST  
       
  1538     iSctRect = TRect::EUninitialized;
       
  1539 #endif
       
  1540 
  1237 
  1541     if ( iCba )
  1238     if ( iCba )
  1542         {
  1239         {
  1543         iCba = NULL;
  1240         iCba = NULL;
  1544         }
  1241         }
  1552     iFlags.Clear( EContextSensitive );
  1249     iFlags.Clear( EContextSensitive );
  1553     iFlags.Clear( EHighlightEnabled );
  1250     iFlags.Clear( EHighlightEnabled );
  1554     _AKNTRACE_FUNC_EXIT;
  1251     _AKNTRACE_FUNC_EXIT;
  1555     }
  1252     }
  1556 
  1253 
  1557 // -----------------------------------------------------------------------------
       
  1558 // CEikMenuPaneExtension::HandleGainingForeground
       
  1559 // The application has gained foreground -> animation should be continued.
       
  1560 // -----------------------------------------------------------------------------
       
  1561 //
       
  1562 void CEikMenuPaneExtension::HandleGainingForeground()
       
  1563     {
       
  1564     // It is safe to start animation in this method because animation is
       
  1565     // deleted when the menu is closed -> it is not possible that menu receives
       
  1566     // foreground event while it is not visible and the animation exists.
       
  1567 
       
  1568     // We need to check if the menu has focus (to prevent running nonfocused
       
  1569     // animation because also the nonfocused menu (menu/submenu) receives
       
  1570     // foreground events)
       
  1571     Play();
       
  1572     }
       
  1573 
       
  1574 // -----------------------------------------------------------------------------
       
  1575 // CEikMenuPaneExtension::HandleLosingForeground
       
  1576 // The application lost foreground -> no running animation (even if the
       
  1577 // application is partially visible).
       
  1578 // -----------------------------------------------------------------------------
       
  1579 //
       
  1580 void CEikMenuPaneExtension::HandleLosingForeground()
       
  1581     {
       
  1582     if( iAnimation )
       
  1583         {
       
  1584         NoAnimIfError( iAnimation->Stop() );
       
  1585         }
       
  1586     }
       
  1587 
       
  1588 // -----------------------------------------------------------------------------
       
  1589 // CEikMenuPaneExtension::AnimFrameReady
       
  1590 // -----------------------------------------------------------------------------
       
  1591 //
       
  1592 void CEikMenuPaneExtension::AnimFrameReady( TInt aError, TInt )
       
  1593     {
       
  1594     if( KErrNone != aError )
       
  1595         {
       
  1596         // Animation has failed to run -> schedule the animation for
       
  1597         // deletion to fall back to normal rendering.
       
  1598         PostDeleteAnimation();
       
  1599         }
       
  1600     else if( iControl ) // Frame ok
       
  1601         {
       
  1602         if ( iControl->IsVisible() )
       
  1603             {
       
  1604             iControl->RepaintHighlight();
       
  1605             }
       
  1606         }
       
  1607     }
       
  1608 
       
  1609 // -----------------------------------------------------------------------------
       
  1610 // CEikMenuPaneExtension::DoCancel
       
  1611 // -----------------------------------------------------------------------------
       
  1612 //
       
  1613 void CEikMenuPaneExtension::DoCancel()
       
  1614     {
       
  1615     // Required method, but not needed
       
  1616     }
       
  1617 
       
  1618 
       
  1619 // -----------------------------------------------------------------------------
       
  1620 // CEikMenuPaneExtension::RunL
       
  1621 // Postponed animation deletion is done here
       
  1622 // -----------------------------------------------------------------------------
       
  1623 //
       
  1624 void CEikMenuPaneExtension::RunL()
       
  1625     {
       
  1626     UseNoAnimation();
       
  1627     }
       
  1628 
       
  1629 // -----------------------------------------------------------------------------
       
  1630 // CEikMenuPaneExtension::Play
       
  1631 // -----------------------------------------------------------------------------
       
  1632 //
       
  1633 void CEikMenuPaneExtension::Play()
       
  1634     {
       
  1635     if( !iAnimation || !iControl->IsFocused() )
       
  1636         {
       
  1637         return;
       
  1638         }
       
  1639 
       
  1640     // No need to start running/finished animation
       
  1641     if( EAknsAnimStateRunning == iAnimation->State() ||
       
  1642         EAknsAnimStateFinished == iAnimation->State() )
       
  1643         {
       
  1644         return;
       
  1645         }
       
  1646 
       
  1647     CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi());
       
  1648     if( !aui->IsForeground() )
       
  1649         {
       
  1650         return;
       
  1651         }
       
  1652 
       
  1653     if( EAknsAnimStatePaused == iAnimation->State() )
       
  1654         {
       
  1655         NoAnimIfError( iAnimation->Continue() );
       
  1656         }
       
  1657     else if( EAknsAnimStateStopped == iAnimation->State() )
       
  1658         {
       
  1659         if( iAnimation->NeedsInputLayer() )
       
  1660             {
       
  1661             TRAPD( err, DoResizeL( iAnimation->Size(), ETrue ) );
       
  1662             NoAnimIfError( err );
       
  1663 
       
  1664             if( KErrNone != err )
       
  1665                 return;
       
  1666             }
       
  1667 
       
  1668         NoAnimIfError( iAnimation->Start() );
       
  1669         }
       
  1670     }
       
  1671 
       
  1672 // -----------------------------------------------------------------------------
       
  1673 // CEikMenuPaneExtension::DrawHighlightBackground
       
  1674 // Draws skinned highlight background to the provided graphics context.
       
  1675 // -----------------------------------------------------------------------------
       
  1676 //
       
  1677 TBool CEikMenuPaneExtension::DrawHighlightBackground( CFbsBitGc& aGc )
       
  1678     {
       
  1679     // Draw the background under the current highlight. This simplified
       
  1680     // drawing, we only grab a piece from the list background bitmap.
       
  1681     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
  1682 
       
  1683     return AknsDrawUtils::DrawBackground( skin, iBgContext, iControl, aGc, TPoint(0,0),
       
  1684                                           iControl->HighlightRect(),
       
  1685                                           KAknsDrawParamRGBOnly );
       
  1686     }
       
  1687 
       
  1688 // -----------------------------------------------------------------------------
       
  1689 // CEikMenuPaneExtension::PostDeleteAnimation
       
  1690 // Schedules the animation for deletion by activating the extension itself.
       
  1691 // Deletion is postponed because in many error/failure occasions the caller has
       
  1692 // been animation and direct deletion is possibly not safe (because function
       
  1693 // stack would return through the deleted object).
       
  1694 // -----------------------------------------------------------------------------
       
  1695 //
       
  1696 void CEikMenuPaneExtension::PostDeleteAnimation()
       
  1697     {
       
  1698     TRequestStatus* status = &iStatus;
       
  1699     User::RequestComplete( status, KErrNone );
       
  1700     SetActive();
       
  1701     }
       
  1702 
       
  1703 // -----------------------------------------------------------------------------
       
  1704 // CEikMenuPaneExtension::CreateAnimationL
       
  1705 // -----------------------------------------------------------------------------
       
  1706 //
       
  1707 void CEikMenuPaneExtension::CreateAnimationL( const TSize& aHighlightSize )
       
  1708     {
       
  1709     // Create animation
       
  1710     CCoeEnv* env = CCoeEnv::Static();
       
  1711     env->AddForegroundObserverL( *this );
       
  1712 
       
  1713     delete iAnimation;
       
  1714     iAnimation = NULL;
       
  1715 
       
  1716     iAnimation = CAknsEffectAnim::NewL( this );
       
  1717     TBool ok = iAnimation->ConstructFromSkinL( KAknsIIDQsnAnimList );
       
  1718 
       
  1719     if( !ok ) // Animation for the ID was not found from the skin
       
  1720         {
       
  1721         User::Leave( KErrNotFound );
       
  1722         }
       
  1723 
       
  1724     DoResizeL( aHighlightSize, ETrue );
       
  1725 
       
  1726     Play();
       
  1727     }
       
  1728 
       
  1729 // -----------------------------------------------------------------------------
       
  1730 // CEikMenuPaneExtension::DoResizeL
       
  1731 // -----------------------------------------------------------------------------
       
  1732 //
       
  1733 void CEikMenuPaneExtension::DoResizeL(
       
  1734     const TSize& aHighlightSize, TBool aAboutToStart )
       
  1735     {
       
  1736     iAnimation->BeginConfigInputLayersL( aHighlightSize, aAboutToStart );
       
  1737 
       
  1738     if( iAnimation->InputRgbGc() )
       
  1739         DrawHighlightBackground( *iAnimation->InputRgbGc() );
       
  1740 
       
  1741     iAnimation->EndConfigInputLayersL();
       
  1742     }
       
  1743 
  1254 
  1744 // -----------------------------------------------------------------------------
  1255 // -----------------------------------------------------------------------------
  1745 // CEikMenuPaneExtension::ConstructMenuSctRowL
  1256 // CEikMenuPaneExtension::ConstructMenuSctRowL
  1746 // Creates a special characters row to be used in edit menu.
  1257 // Creates a special characters row to be used in edit menu.
  1747 // -----------------------------------------------------------------------------
  1258 // -----------------------------------------------------------------------------
  1760     iSct->ConstructMenuSctRowL(aResourceId);
  1271     iSct->ConstructMenuSctRowL(aResourceId);
  1761     iSct->SetBuffer( aSpecialChars );
  1272     iSct->SetBuffer( aSpecialChars );
  1762     if ( renew && iMenuPaneWindow && iControl )
  1273     if ( renew && iMenuPaneWindow && iControl )
  1763         {
  1274         {
  1764         iSct->SetContainerWindowL( *iControl );
  1275         iSct->SetContainerWindowL( *iControl );
  1765         if ( AknLayoutUtils::PenEnabled() )
  1276         iSct->SetGloballyCapturing( ETrue );
  1766             {
  1277         iSct->SetPointerCapture( ETrue );
  1767             iSct->SetGloballyCapturing( ETrue );
       
  1768             iSct->SetPointerCapture( ETrue );
       
  1769             }
       
  1770         }
  1278         }
  1771     _AKNTRACE_FUNC_EXIT;
  1279     _AKNTRACE_FUNC_EXIT;
  1772     }
  1280     }
  1773 
  1281 
  1774 // -----------------------------------------------------------------------------
  1282 // -----------------------------------------------------------------------------
  1789     iSct->ConstructMenuSctRowFromDialogL(aResourceId);
  1297     iSct->ConstructMenuSctRowFromDialogL(aResourceId);
  1790     iSct->SetBuffer( aSpecialChars );
  1298     iSct->SetBuffer( aSpecialChars );
  1791     if ( renew && iMenuPaneWindow && iControl)
  1299     if ( renew && iMenuPaneWindow && iControl)
  1792         {
  1300         {
  1793         iSct->SetContainerWindowL( *iControl );
  1301         iSct->SetContainerWindowL( *iControl );
  1794         if ( AknLayoutUtils::PenEnabled() )
  1302         iSct->SetGloballyCapturing( ETrue );
  1795             {
  1303         iSct->SetPointerCapture( ETrue );
  1796             iSct->SetGloballyCapturing( ETrue );
       
  1797             iSct->SetPointerCapture( ETrue );
       
  1798             }
       
  1799         }
  1304         }
  1800     }
  1305     }
  1801 
  1306 
  1802 // -----------------------------------------------------------------------------
  1307 // -----------------------------------------------------------------------------
  1803 // CEikMenuPaneExtension::HandleControlEventL
  1308 // CEikMenuPaneExtension::HandleControlEventL
  1804 // -----------------------------------------------------------------------------
  1309 // -----------------------------------------------------------------------------
  1805 //
  1310 //
  1806 void CEikMenuPaneExtension::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
  1311 void CEikMenuPaneExtension::HandleControlEventL(CCoeControl* /*aControl*/,TCoeEvent aEventType)
  1807     {
  1312     {
  1808     _AKNTRACE_FUNC_ENTER;
  1313     _AKNTRACE_FUNC_ENTER;
  1809     if ( AknLayoutUtils::PenEnabled() )
  1314     if ( aEventType == EEventStateChanged )
  1810         {
  1315         {
  1811          if(aEventType == EEventStateChanged)
  1316         // Something has been selected from CharMap
  1812             {
  1317         iSpecialCharPointed = ETrue;
  1813             // Something has been selected from CharMap
       
  1814             iSpecialCharPointed = ETrue;
       
  1815             }
       
  1816         }
  1318         }
  1817     _AKNTRACE( "aEventType = %d", aEventType );
  1319     _AKNTRACE( "aEventType = %d", aEventType );
  1818     _AKNTRACE_FUNC_EXIT;
  1320     _AKNTRACE_FUNC_EXIT;
  1819     }
  1321     }
  1820 
  1322 
  2360     iEditMenuObserver = aEditMenuObserver;
  1862     iEditMenuObserver = aEditMenuObserver;
  2361 
  1863 
  2362     CheckCreateScrollerL();
  1864     CheckCreateScrollerL();
  2363     CheckCreateExtensionL();
  1865     CheckCreateExtensionL();
  2364 
  1866 
  2365     iExtension->iTransitionsOn = FeatureManager::FeatureSupported( KFeatureIdUiTransitionEffects );
       
  2366 
       
  2367     CreateWindowL( iCoeEnv->RootWin() );
  1867     CreateWindowL( iCoeEnv->RootWin() );
  2368     EnableWindowTransparency();
  1868     EnableWindowTransparency();
  2369     SetAllowStrayPointers();
  1869     SetAllowStrayPointers();
  2370     EnableDragEvents();
  1870     EnableDragEvents();
  2371 
  1871 
  2372     TAknWindowLineLayout menuLineLayout;
  1872     iItemHeight = CalculateItemHeight();
  2373     if ( iOwner ) // submenu
       
  2374         {
       
  2375         menuLineLayout = AknLayoutScalable_Avkon::list_single_popup_submenu_pane( 0 ).LayoutLine();
       
  2376         }
       
  2377     else
       
  2378         {
       
  2379         menuLineLayout = AknLayoutScalable_Avkon::list_single_pane_cp2( 0 ).LayoutLine();
       
  2380         }
       
  2381 
       
  2382     TRect windowRect = Rect();
       
  2383     TAknLayoutRect menuLayoutRect;
       
  2384     menuLayoutRect.LayoutRect( windowRect, menuLineLayout );
       
  2385     iItemHeight = menuLayoutRect.Rect().Height();
       
  2386 
  1873 
  2387     if ( iExtension->iSct )
  1874     if ( iExtension->iSct )
  2388         {
  1875         {
  2389         RWindow* window = (RWindow*)this->DrawableWindow();
  1876         RWindow* window = (RWindow*)this->DrawableWindow();
  2390         iExtension->iMenuPaneWindow = window;
  1877         iExtension->iMenuPaneWindow = window;
  2391         iExtension->iSct->SetContainerWindowL( *this );
  1878         iExtension->iSct->SetContainerWindowL( *this );
  2392 
  1879 
  2393         if ( AknLayoutUtils::PenEnabled() )
  1880         // This is effectively the same as CCoeControl::EnableDragEvents()
  2394             {
  1881         // which is protected.
  2395             // This is effectively the same as CCoeControl::EnableDragEvents()
  1882         window->PointerFilter( EPointerFilterDrag, 0 );
  2396             // which is protected.
  1883         iExtension->iSct->SetGloballyCapturing( ETrue );
  2397             window->PointerFilter( EPointerFilterDrag, 0 );
  1884         iExtension->iSct->SetPointerCapture( ETrue );
  2398             iExtension->iSct->SetGloballyCapturing( ETrue );
  1885         iExtension->iSct->SetObserver(iExtension);
  2399             iExtension->iSct->SetPointerCapture( ETrue );
       
  2400             iExtension->iSct->SetObserver(iExtension);
       
  2401             }
       
  2402         }
  1886         }
  2403 
  1887 
  2404     if ( iOwner ) // submenu
  1888     if ( iOwner ) // submenu
  2405         {
  1889         {
  2406         SetPointerCapture( ETrue );
  1890         SetPointerCapture( ETrue );
  2414     RWindow* window = &Window();
  1898     RWindow* window = &Window();
  2415     if( window == NULL )
  1899     if( window == NULL )
  2416         User::Leave( KErrNoMemory );
  1900         User::Leave( KErrNoMemory );
  2417             
  1901             
  2418     Window().SetOrdinalPosition( 0 );
  1902     Window().SetOrdinalPosition( 0 );
  2419     
       
  2420     Window().SetPointerGrab( ETrue );
  1903     Window().SetPointerGrab( ETrue );
  2421     SetGloballyCapturing( ETrue );
  1904     SetGloballyCapturing( ETrue );
  2422 
  1905 
  2423     iExtension->iPhysics->UpdateViewWindowControl(); 
  1906     iExtension->iPhysics->UpdateViewWindowControl(); 
  2424     _AKNTRACE_FUNC_EXIT;
  1907     _AKNTRACE_FUNC_EXIT;
  2438         delete iItemArray;
  1921         delete iItemArray;
  2439         iItemArray = NULL;
  1922         iItemArray = NULL;
  2440         }
  1923         }
  2441     CreateItemArrayL();
  1924     CreateItemArrayL();
  2442 
  1925 
  2443     TAknWindowLineLayout menuLineLayout;
  1926     iItemHeight = CalculateItemHeight();
  2444     if ( iOwner ) // submenu
       
  2445         {
       
  2446         menuLineLayout = AKN_LAYOUT_WINDOW_list_single_popup_submenu_pane( 0, 0 );
       
  2447         }
       
  2448     else
       
  2449         {
       
  2450         menuLineLayout = AKN_LAYOUT_WINDOW_list_single_popup_menu_pane( 0 );
       
  2451         }
       
  2452     TRect windowRect = Rect();
       
  2453     TAknLayoutRect menuLayoutRect;
       
  2454     menuLayoutRect.LayoutRect( windowRect, menuLineLayout );
       
  2455     iItemHeight = menuLayoutRect.Rect().Height();
       
  2456 
  1927 
  2457     CheckCreateScrollerL();
  1928     CheckCreateScrollerL();
  2458     CheckCreateExtensionL();
  1929     CheckCreateExtensionL();
  2459 
  1930 
  2460     const TInt count=aReader.ReadInt16();
  1931     const TInt count=aReader.ReadInt16();
  2787     else
  2258     else
  2788         {
  2259         {
  2789         iExtension->StartCascadeMenuAppearTransition();
  2260         iExtension->StartCascadeMenuAppearTransition();
  2790         }
  2261         }
  2791 
  2262 
  2792     if( AknLayoutUtils::PenEnabled() )
  2263     TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp;
  2793         {
  2264     if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  2794         TTouchLogicalFeedback fbLogicalType = ETouchFeedbackPopUp;
  2265         {
  2795         if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  2266         fbLogicalType = ETouchFeedbackIncreasingPopUp;
  2796             {
  2267         }
  2797             fbLogicalType = ETouchFeedbackIncreasingPopUp;
  2268     iExtension->ImmediateFeedback( fbLogicalType,
  2798             }
       
  2799         iExtension->ImmediateFeedback( fbLogicalType,
       
  2800                                        ETouchFeedbackVibra );
  2269                                        ETouchFeedbackVibra );
  2801         }
       
  2802     _AKNTRACE_FUNC_EXIT;
  2270     _AKNTRACE_FUNC_EXIT;
  2803     }
  2271     }
  2804 
  2272 
  2805 // -----------------------------------------------------------------------------
  2273 // -----------------------------------------------------------------------------
  2806 // CEikMenuPane::CalculateSizeAndPosition
  2274 // CEikMenuPane::CalculateSizeAndPosition
  2821 
  2289 
  2822     if ( iExtension->iSct )
  2290     if ( iExtension->iSct )
  2823         {
  2291         {
  2824         numItemsInPane++;
  2292         numItemsInPane++;
  2825         }
  2293         }
  2826 
       
  2827     TInt maxNumItemsInMenu = AknLayoutScalable_Avkon::
       
  2828                     list_single_pane_cp2_ParamLimits().LastRow() + 1;
       
  2829     TInt maxNumItemsInSubMenu = AknLayoutScalable_Avkon::
       
  2830                     list_single_popup_submenu_pane_ParamLimits().LastRow() + 1;
       
  2831 
  2294 
  2832     TInt maxItemsInView = NumberOfItemsThatFitInView();
  2295     TInt maxItemsInView = NumberOfItemsThatFitInView();
  2833 
  2296 
  2834     if (iExtension && iExtension->iSct)
  2297     if (iExtension && iExtension->iSct)
  2835         {
  2298         {
  2864 
  2327 
  2865     CreateScrollBarFrame();
  2328     CreateScrollBarFrame();
  2866 
  2329 
  2867     iExtension->iPressedDown = EFalse;
  2330     iExtension->iPressedDown = EFalse;
  2868     iExtension->SetOffset( 0 );
  2331     iExtension->SetOffset( 0 );
  2869     iExtension->iHasIcon = MenuHasIcon();
       
  2870 
       
  2871     if ( iExtension->iTransitionsOn )
       
  2872         {
       
  2873         CAknTransitionUtils::SetAllParents( this );
       
  2874         }
       
  2875 
  2332 
  2876     const TSize screenSize( iEikonEnv->EikAppUi()->ApplicationRect().Size() );
  2333     const TSize screenSize( iEikonEnv->EikAppUi()->ApplicationRect().Size() );
  2877 
  2334 
  2878     CEikCba *cba = 0;
  2335     CEikCba *cba = 0;
  2879     MopGetObject(cba);
  2336     MopGetObject(cba);
  2890             && iCoeEnv->LastEvent().Key()->iCode == EKeyCBA1 )
  2347             && iCoeEnv->LastEvent().Key()->iCode == EKeyCBA1 )
  2891         {        
  2348         {        
  2892         SetDefaultHighlight();
  2349         SetDefaultHighlight();
  2893         }    
  2350         }    
  2894 
  2351 
  2895     TRect rect( CalculateSizeAndPosition() );
  2352     SetRect( CalculateSizeAndPosition() );
  2896     TPoint newPos( rect.iTl );
       
  2897     TSize menuSize( rect.Size() );
       
  2898 
       
  2899     SetExtent( newPos, menuSize );
       
  2900 
  2353 
  2901     // We need to set the background context when calling create for the
  2354     // We need to set the background context when calling create for the
  2902     // first time. Otherwise iExtension->iBgContext would have tiny
  2355     // first time. Otherwise iExtension->iBgContext would have tiny
  2903     // rectangles and grabbing the highlight background would produce
  2356     // rectangles and grabbing the highlight background would produce
  2904     // white.
  2357     // white.
  2905     UpdateBackgroundContext( Rect() );
  2358     UpdateBackgroundContext( Rect() );
  2906 
  2359 
  2907     // The extent has been set. This is the first safe point in code to
       
  2908     // construct animations (because before this highlight related layout code
       
  2909     // will produce invalid results
       
  2910     if( iExtension )
       
  2911         {
       
  2912         // Creates animation only if it does not exist
       
  2913         iExtension->CreateAnimation();        
       
  2914         }
       
  2915         
       
  2916     // Initialize physics engine
  2360     // Initialize physics engine
  2917     TRAP_IGNORE ( iExtension->InitPhysicsL() );
  2361     TRAP_IGNORE ( iExtension->InitPhysicsL() );
  2918         
  2362         
  2919     MakeVisible(ETrue);
  2363     MakeVisible(ETrue);
  2920     SetFocus(ETrue);
  2364     SetFocus(ETrue);
  2965     TAknLayoutRect topLeft;
  2409     TAknLayoutRect topLeft;
  2966     TAknLayoutRect bottomRight;
  2410     TAknLayoutRect bottomRight;
  2967     TAknsItemID frameIID;
  2411     TAknsItemID frameIID;
  2968     TAknsItemID frameCenterIID;
  2412     TAknsItemID frameCenterIID;
  2969     
  2413     
  2970     TRect backgroundRect( iExtension->GetBackgroundRect( aWindowRect ) );     
       
  2971         
       
  2972     if( iOwner ) //for sub menu
  2414     if( iOwner ) //for sub menu
  2973         {
  2415         {
  2974         topLeft.LayoutRect( aWindowRect, SkinLayout::Submenu_skin_placing_Line_2() );
  2416         topLeft.LayoutRect( aWindowRect, SkinLayout::Submenu_skin_placing_Line_2() );
  2975         bottomRight.LayoutRect( aWindowRect, SkinLayout::Submenu_skin_placing_Line_5() );
  2417         bottomRight.LayoutRect( aWindowRect, SkinLayout::Submenu_skin_placing_Line_5() );
  2976         frameIID = KAknsIIDQsnFrPopupSub;
  2418         frameIID = KAknsIIDQsnFrPopupSub;
  2977         frameCenterIID = KAknsIIDQsnFrPopupCenterSubmenu;
  2419         frameCenterIID = KAknsIIDQsnFrPopupCenterSubmenu;
  2978         }
  2420         }
  2979     else
  2421     else
  2980         {
  2422         {
  2981         topLeft.LayoutRect( backgroundRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_2() );
  2423         topLeft.LayoutRect( aWindowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_2() );
  2982         bottomRight.LayoutRect( backgroundRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_5() );
  2424         bottomRight.LayoutRect( aWindowRect, SkinLayout::Popup_windows_skin_placing__frame_general__Line_5() );
  2983         frameIID = KAknsIIDQsnFrPopup;
  2425         frameIID = KAknsIIDQsnFrPopup;
  2984         frameCenterIID = KAknsIIDQsnFrPopupCenterMenu;
  2426         frameCenterIID = KAknsIIDQsnFrPopupCenterMenu;
  2985         }
  2427         }
  2986 
  2428 
  2987     TRect outerRect( topLeft.Rect().iTl, bottomRight.Rect().iBr );
  2429     TRect outerRect( topLeft.Rect().iTl, bottomRight.Rect().iBr );
  3038     TInt previousSelectedItem = iSelectedItem;
  2480     TInt previousSelectedItem = iSelectedItem;
  3039     _AKNTRACE( "previousTopItem =  %d", previousTopItem );
  2481     _AKNTRACE( "previousTopItem =  %d", previousTopItem );
  3040     _AKNTRACE( "previousSelectedItem =  %d", previousSelectedItem );
  2482     _AKNTRACE( "previousSelectedItem =  %d", previousSelectedItem );
  3041 
  2483 
  3042     ActivateGc();
  2484     ActivateGc();
  3043 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3044     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  3045     if ( transApi )
       
  3046         {
       
  3047         iExtension->iGc->Activate( *DrawableWindow() );
       
  3048         }
       
  3049     CWindowGc& gc = transApi ? *iExtension->iGc : SystemGc();
       
  3050 #else
       
  3051     CWindowGc& gc =  SystemGc();
  2485     CWindowGc& gc =  SystemGc();
  3052 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3053     PrepareGcForDrawingItems( gc );
  2486     PrepareGcForDrawingItems( gc );
  3054 
  2487 
  3055     // Scrollers top item index must be updated first because setting selected
  2488     // Scrollers top item index must be updated first because setting selected
  3056     // item results in animation redraw (which requires knowledge about the
  2489     // item results in animation redraw (which requires knowledge about the
  3057     // current top item).
  2490     // current top item).
  3084     PrepareHighlightFrame();
  2517     PrepareHighlightFrame();
  3085 
  2518 
  3086     if ( previousTopItem == topItem  && aNewSelectedItem >= 0 )
  2519     if ( previousTopItem == topItem  && aNewSelectedItem >= 0 )
  3087         {
  2520         {
  3088         // then only previuosly and currently selected items should be redrawn
  2521         // then only previuosly and currently selected items should be redrawn
  3089         DrawItem( gc, previousSelectedItem, ERemoveHighlight );
  2522         if ( iExtension->iHighlightedItem != KErrNotFound )
       
  2523             {
       
  2524             DrawItem( gc, previousSelectedItem, ERemoveHighlight );
       
  2525             }
  3090 
  2526 
  3091         if ( !iExtension->iSctHighlighted )
  2527         if ( !iExtension->iSctHighlighted )
  3092             {
  2528             {
  3093             DrawItem( gc, aNewSelectedItem, EDrawHighlight );
  2529             DrawItem( gc, aNewSelectedItem, EDrawHighlight );
  3094             }
  2530             }
  3095         }
  2531         }
  3096     else
  2532     else
  3097         {
  2533         {
  3098         TBool skipHighlight = EFalse;
  2534         /*TBool skipHighlight = EFalse;
       
  2535 
  3099         if (iExtension && iExtension->iSct && aNewSelectedItem == 0 &&
  2536         if (iExtension && iExtension->iSct && aNewSelectedItem == 0 &&
  3100             previousSelectedItem > 1)
  2537             previousSelectedItem > 1)
  3101             {
  2538             {
  3102             skipHighlight = ETrue;
  2539             skipHighlight = ETrue;
  3103             }
  2540             }
       
  2541 
  3104         for( TInt i = topItem; i<bottomItem; i++ )
  2542         for( TInt i = topItem; i<bottomItem; i++ )
  3105             {
  2543             {
  3106             if( i == aNewSelectedItem && !skipHighlight)
  2544             if( i == aNewSelectedItem && !skipHighlight)
  3107                 {
  2545                 {
  3108                 DrawItem( gc, i, EDrawHighlight );
  2546                 DrawItem( gc, i, EDrawHighlight );
  3109                 }
  2547                 }
  3110             else
  2548             else
  3111                 {
  2549                 {
  3112                 DrawItem( gc, i, ERemoveHighlight );
  2550                 DrawItem( gc, i, ERemoveHighlight );
  3113                 }
  2551                 }
  3114             }
  2552             }*/
  3115         }
  2553 
  3116 
  2554         // update the whole menu area
  3117 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2555         iExtension->ViewPositionChanged( iExtension->iViewPosition );   
  3118     if ( transApi )
  2556 //        UpdateScrollBarThumbs();
  3119         {
  2557         }
  3120         iExtension->iGc->Deactivate();
  2558 
  3121         }
       
  3122 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3123     DeactivateGc();
  2559     DeactivateGc();
  3124 
  2560     
  3125     UpdateScrollBarThumbs();
       
  3126     
       
  3127     // Updating view position here prevents some flickering
       
  3128     iExtension->ViewPositionChanged( iExtension->iViewPosition );   
       
  3129 
       
  3130     _AKNTRACE_FUNC_EXIT;
  2561     _AKNTRACE_FUNC_EXIT;
  3131     }
  2562     }
  3132 
  2563 
  3133 // -----------------------------------------------------------------------------
  2564 // -----------------------------------------------------------------------------
  3134 // CEikMenuPane::PrepareGcForDrawingItems
  2565 // CEikMenuPane::PrepareGcForDrawingItems
  3135 // -----------------------------------------------------------------------------
  2566 // -----------------------------------------------------------------------------
  3136 //
  2567 //
  3137 void CEikMenuPane::PrepareGcForDrawingItems(CGraphicsContext& aGc) const
  2568 void CEikMenuPane::PrepareGcForDrawingItems(CGraphicsContext& aGc) const
  3138     {
  2569     {
  3139 
       
  3140     // BIDI
  2570     // BIDI
  3141     /*
  2571     /*
  3142      * get the fonts from the LAF!
  2572      * get the fonts from the LAF!
  3143      * Do we need to get them here? - nope - moved to DrawItem()
  2573      * Do we need to get them here? - nope - moved to DrawItem()
  3144      */    
  2574      */    
  3145 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2575     aGc.SetPenColor( iEikonEnv->ControlColor( EColorMenuPaneText, *this) );
  3146     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  3147     if ( transApi )
       
  3148         {
       
  3149         transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
       
  3150         }
       
  3151 #endif
       
  3152 
       
  3153     aGc.SetPenColor(iEikonEnv->ControlColor( EColorMenuPaneText, *this) );
       
  3154 #if defined(MENU_TEXTURED_BACKGROUND)
       
  3155     iEikonEnv->SetTexturedBrush( aGc );
       
  3156 #else
       
  3157     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  2576     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  3158     aGc.SetBrushColor( iEikonEnv->ControlColor( EColorMenuPaneBackground,*this ) );
  2577     aGc.SetBrushColor( iEikonEnv->ControlColor( EColorMenuPaneBackground,*this ) );
  3159 #endif
  2578     }
  3160 
       
  3161 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3162     if ( transApi )
       
  3163         {
       
  3164         transApi->StopDrawing();
       
  3165         }
       
  3166 #endif
       
  3167     }
       
  3168 
       
  3169 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3170 /**
       
  3171  * Iterate through the visible items in a menu and calculate minimum 
       
  3172  * item margins that dont need drawing.
       
  3173  */
       
  3174 void CEikMenuPaneExtension::CalcItemSize( MAknListBoxTfxInternal* transApi ) const
       
  3175     {
       
  3176     if ( transApi && iControl->iItemArray && iControl->iItemArray->Count() )
       
  3177         {
       
  3178         TRect marginRect(TRect::EUninitialized);
       
  3179         const TInt index = 0;
       
  3180 
       
  3181         // Specifies whether the text should be moved to give some space for icon.
       
  3182         TInt hasIcon = iControl->MenuHasIcon() ? 1 : 0;
       
  3183 
       
  3184         TAknWindowLineLayout menuPane( AKN_LAYOUT_WINDOW_list_menu_pane( 0 , 0 ) );
       
  3185         TAknWindowLineLayout singleMenuPane(
       
  3186                         AKN_LAYOUT_WINDOW_list_single_popup_menu_pane( index ) );
       
  3187         TAknTextLineLayout menuTextLayout(
       
  3188                         AKN_LAYOUT_TEXT_List_pane_texts__menu_single__Line_1(0) );
       
  3189         
       
  3190         TAknLayoutRect menuPaneRect;
       
  3191         TAknLayoutRect singleMenuPaneRect;
       
  3192         TAknLayoutText textRect;
       
  3193         
       
  3194         TBool hasCascade = EFalse;
       
  3195         TBool hasNonCascade = EFalse;
       
  3196         
       
  3197         // number of items in the whole menu
       
  3198         for(TInt i = 0; i < iControl->iItemArray->Count(); i++)
       
  3199             {
       
  3200             CEikMenuPaneItem* item = (*iControl->iItemArray)[i];
       
  3201             
       
  3202             // true if a cascade symbol must be drawn (main menu only)
       
  3203             TBool cascade = item->iData.iCascadeId != 0;
       
  3204             
       
  3205             if ( cascade )
       
  3206                 {
       
  3207                 if ( hasCascade )
       
  3208                     {
       
  3209                     if ( hasNonCascade )
       
  3210                         {
       
  3211                         break;
       
  3212                         }
       
  3213                     continue;
       
  3214                     }
       
  3215                 hasCascade = ETrue;
       
  3216                 }
       
  3217             else
       
  3218                 {
       
  3219                 if ( hasNonCascade )
       
  3220                     {
       
  3221                     if ( hasCascade )
       
  3222                         {
       
  3223                         break;
       
  3224                         }
       
  3225                     continue;
       
  3226                     }
       
  3227                 hasNonCascade = ETrue;
       
  3228                 }
       
  3229     
       
  3230             if ( !iControl->iOwner )
       
  3231                 {
       
  3232                 TAknWindowLineLayout listScrollPaneLayout( 
       
  3233                     AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
       
  3234                 AdjustPopupLayoutData( listScrollPaneLayout );                 
       
  3235                 TAknLayoutRect listScrollPaneRect;
       
  3236                 listScrollPaneRect.LayoutRect( iControl->Rect(), listScrollPaneLayout );
       
  3237     
       
  3238                 menuPane = AknLayoutScalable_Avkon::list_menu_pane( 0 ).LayoutLine();
       
  3239                 menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  3240     
       
  3241                 singleMenuPane = AknLayoutScalable_Avkon::list_single_pane_cp2( index ).LayoutLine();
       
  3242                 singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(), singleMenuPane );
       
  3243     
       
  3244                 menuTextLayout = AknLayoutScalable_Avkon::list_single_pane_t1_cp2( cascade ? 3 : 0 ).LayoutLine();
       
  3245                 }
       
  3246             else // Submenu
       
  3247                 {
       
  3248                 TBool hasDoubleSpanScrollBar = EFalse;
       
  3249                 if ( iControl->iOwner && iControl->iSBFrame && 
       
  3250                         iControl->iSBFrame->VScrollBarVisibility() )
       
  3251                     {
       
  3252                     hasDoubleSpanScrollBar = ETrue;
       
  3253                     }
       
  3254                 TAknWindowLineLayout listScrollPaneLayout( AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
       
  3255                 TAknLayoutRect listScrollPaneRect;
       
  3256                 listScrollPaneRect.LayoutRect( iControl->Rect(), listScrollPaneLayout );
       
  3257     
       
  3258                 menuPane = AknLayoutScalable_Avkon::list_submenu_pane( !hasDoubleSpanScrollBar ).LayoutLine();
       
  3259                 menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  3260     
       
  3261                 singleMenuPane = AknLayoutScalable_Avkon::list_single_popup_submenu_pane( index ).LayoutLine();
       
  3262                 singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(), singleMenuPane );
       
  3263     
       
  3264                 menuTextLayout = TAknTextLineLayout( AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( hasIcon ).LayoutLine() );
       
  3265                 }
       
  3266             
       
  3267             textRect.LayoutText( singleMenuPaneRect.Rect(), menuTextLayout );
       
  3268             if (marginRect == TRect::EUninitialized) 
       
  3269                 {
       
  3270                 marginRect = textRect.TextRect();
       
  3271                 }
       
  3272             else
       
  3273                 {
       
  3274                 marginRect.BoundingRect(textRect.TextRect());
       
  3275                 }
       
  3276             
       
  3277             if ( cascade )
       
  3278                 {
       
  3279                 TAknWindowLineLayout elementCascade( AknLayoutScalable_Avkon::list_single_pane_cp2_g3().LayoutLine());
       
  3280                 TAknLayoutRect cascadeRect;
       
  3281                 cascadeRect.LayoutRect( singleMenuPaneRect.Rect(), elementCascade );
       
  3282                 marginRect.BoundingRect(cascadeRect.Rect());
       
  3283                 }
       
  3284             else
       
  3285                 {
       
  3286                 TAknLayoutRect activeApplicationsIconRect;
       
  3287                 activeApplicationsIconRect.LayoutRect( singleMenuPaneRect.Rect(),
       
  3288                     AknLayoutScalable_Avkon::list_single_pane_g1_cp2(0).LayoutLine() );
       
  3289                 marginRect.BoundingRect(activeApplicationsIconRect.Rect());
       
  3290                 }
       
  3291             }
       
  3292 
       
  3293         if ( hasIcon )
       
  3294             {
       
  3295             TAknLayoutRect iconLayoutRect;
       
  3296             iconLayoutRect.LayoutRect( singleMenuPaneRect.Rect(),
       
  3297                 AknLayoutScalable_Avkon::list_single_popup_submenu_pane_g1().LayoutLine() );
       
  3298             marginRect.BoundingRect(iconLayoutRect.Rect());
       
  3299             }
       
  3300 
       
  3301         //send margins to tfx
       
  3302         TPoint tl ( marginRect.iTl - menuPaneRect.Rect().iTl );
       
  3303         transApi->SetPosition( MAknListBoxTfxInternal::EListTLMargin, tl );
       
  3304         
       
  3305         TPoint br( singleMenuPaneRect.Rect().Size().AsPoint() - marginRect.iBr + menuPaneRect.Rect().iTl );
       
  3306         transApi->SetPosition( MAknListBoxTfxInternal::EListBRMargin, br );
       
  3307         }
       
  3308     }
       
  3309 #endif
       
  3310 
  2579 
  3311 
  2580 
  3312 // ---------------------------------------------------------------------------
  2581 // ---------------------------------------------------------------------------
  3313 // CEikMenuPane::DrawItem
  2582 // CEikMenuPane::DrawItem
  3314 // ---------------------------------------------------------------------------
  2583 // ---------------------------------------------------------------------------
  3315 //
  2584 //
  3316 void CEikMenuPane::DrawItem( TInt aItem, THighlightType aHighlight ) const
  2585 void CEikMenuPane::DrawItem( TInt aItem, THighlightType aHighlight ) const
  3317     {
  2586     {
  3318     ActivateGc();
  2587     ActivateGc();
  3319 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3320     MAknListBoxTfxInternal* transApi = 
       
  3321         CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  3322 
       
  3323     if ( transApi )
       
  3324         {
       
  3325         iExtension->iGc->Activate( *DrawableWindow() );
       
  3326         }
       
  3327     
       
  3328     CWindowGc& gc = transApi ? *iExtension->iGc : SystemGc();
       
  3329 #else
       
  3330     CWindowGc& gc = SystemGc();
  2588     CWindowGc& gc = SystemGc();
  3331 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3332     PrepareGcForDrawingItems( gc );
  2589     PrepareGcForDrawingItems( gc );
  3333     DrawItem( gc, aItem, aHighlight );
  2590     DrawItem( gc, aItem, aHighlight );
  3334     
       
  3335 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3336     if ( transApi )
       
  3337         {
       
  3338         iExtension->iGc->Deactivate();
       
  3339         }
       
  3340 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3341     DeactivateGc();
  2591     DeactivateGc();
  3342     }
  2592     }
  3343 
  2593 
  3344 
  2594 
  3345 // ---------------------------------------------------------------------------
  2595 // ---------------------------------------------------------------------------
  3361     if ( aItem >= numItemsInArray )
  2611     if ( aItem >= numItemsInArray )
  3362         {
  2612         {
  3363         return;
  2613         return;
  3364         }
  2614         }
  3365     
  2615     
  3366     // seem to have window owning control in correct place
       
  3367     TRect windowRect = Rect();
       
  3368 
       
  3369     if ( !iOwner )
       
  3370         {
       
  3371         windowRect.iBr.iY -= ( iExtension->iCba->Rect().Height() );    
       
  3372         }
       
  3373     
       
  3374     CEikMenuPaneItem* item = (*iItemArray)[aItem];
  2616     CEikMenuPaneItem* item = (*iItemArray)[aItem];
  3375     // Max visible number of items in menu / submenu
  2617     // Max visible number of items in menu / submenu
  3376     TInt maxNumberOfItems = NumberOfItemsThatFitInView();
  2618     TInt maxNumberOfItems = NumberOfItemsThatFitInView();
  3377     
  2619     
  3378     TInt topIndex = iScroller->TopItemIndex();
  2620     TInt topIndex = iScroller->TopItemIndex();
  3402     if ( (itemLeftInBottom > 0) && (topIndex > 0) ) 
  2644     if ( (itemLeftInBottom > 0) && (topIndex > 0) ) 
  3403         {
  2645         {
  3404         index += itemLeftInBottom;
  2646         index += itemLeftInBottom;
  3405         }
  2647         }
  3406 
  2648 
  3407     TBool drawPartialItem(EFalse);
  2649     TBool drawSeparator = !( ( index + topIndex ) == numItemsInArray - 1 );
       
  2650     TBool drawPartialItem = EFalse;
       
  2651     
  3408     if ( index == maxNumberOfItems )
  2652     if ( index == maxNumberOfItems )
  3409         {
  2653         {
  3410         // We have partial items to draw because of panning so there
  2654         // We have partial items to draw because of panning so there
  3411         // is one more item to draw than normally.
  2655         // is one more item to draw than normally.
  3412         drawPartialItem = ETrue;
  2656         drawPartialItem = ETrue;
       
  2657         
  3413         // There is no layout data for the extra item, so we used the one
  2658         // There is no layout data for the extra item, so we used the one
  3414         // above it. 
  2659         // above it. 
  3415         --index;
  2660         --index;
  3416         }
  2661         }
  3417 
  2662 
  3419     if ( index < 0 || index >= maxNumberOfItems || (iExtension->iSct && index==0))
  2664     if ( index < 0 || index >= maxNumberOfItems || (iExtension->iSct && index==0))
  3420         {
  2665         {
  3421         return;  // only interested in drawing visible items
  2666         return;  // only interested in drawing visible items
  3422         }
  2667         }
  3423 
  2668 
  3424     // Collect all of the information from the Layout DLL. Initialise these
  2669     TAknTextLineLayout menuTextLayout;
  3425     // variables with DUMMY data. Then replace it with menu/submenu data.
       
  3426     TAknWindowLineLayout menuPane( AKN_LAYOUT_WINDOW_list_menu_pane( 0 , 0 ) );
       
  3427     TAknWindowLineLayout singleMenuPane(
       
  3428                     AKN_LAYOUT_WINDOW_list_single_popup_menu_pane( index ) );
       
  3429     TAknTextLineLayout menuTextLayout(
       
  3430                     AKN_LAYOUT_TEXT_List_pane_texts__menu_single__Line_1(0) );
       
  3431     TAknLayoutRect menuPaneRect;
       
  3432     TAknLayoutRect singleMenuPaneRect;
  2670     TAknLayoutRect singleMenuPaneRect;
  3433 
  2671 
  3434     if ( !iOwner )
  2672     if ( !iOwner ) // main menu
  3435         {
  2673         {
  3436         TAknWindowLineLayout listScrollPaneLayout( 
  2674         singleMenuPaneRect.LayoutRect( iExtension->iItemAreaRect,
  3437             AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
  2675             AknLayoutScalable_Avkon::list_single_pane_cp2( index ).LayoutLine() );
  3438         if ( iExtension )
  2676         menuTextLayout = 
  3439             {
  2677             AknLayoutScalable_Avkon::list_single_pane_t1_cp2( cascade ? 1 : 0 ).LayoutLine();
  3440             iExtension->AdjustPopupLayoutData( listScrollPaneLayout );
  2678         }
  3441             }        
  2679     else // submenu
  3442         TAknLayoutRect listScrollPaneRect;
  2680         {
  3443         listScrollPaneRect.LayoutRect( windowRect, listScrollPaneLayout );
  2681         singleMenuPaneRect.LayoutRect( iExtension->iItemAreaRect,
  3444 
  2682             AknLayoutScalable_Avkon::list_single_popup_submenu_pane( index ).LayoutLine() );
  3445         menuPane = AknLayoutScalable_Avkon::list_menu_pane( 0 ).LayoutLine();
  2683         
  3446         menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  3447 
       
  3448         singleMenuPane = AknLayoutScalable_Avkon::list_single_pane_cp2( index ).LayoutLine();
       
  3449         singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(), singleMenuPane );
       
  3450 
       
  3451         menuTextLayout = AknLayoutScalable_Avkon::list_single_pane_t1_cp2( cascade ? 3 : 0 ).LayoutLine();
       
  3452         }
       
  3453     else // Submenu
       
  3454         {
       
  3455         TBool hasDoubleSpanScrollBar = EFalse;
       
  3456         if ( iSBFrame && iSBFrame->VScrollBarVisibility() )
       
  3457             {
       
  3458             hasDoubleSpanScrollBar = ETrue;
       
  3459             }
       
  3460 
       
  3461         TAknWindowLineLayout listScrollPaneLayout( AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
       
  3462         TAknLayoutRect listScrollPaneRect;
       
  3463         listScrollPaneRect.LayoutRect( windowRect, listScrollPaneLayout );
       
  3464 
       
  3465         menuPane = AknLayoutScalable_Avkon::list_submenu_pane( !hasDoubleSpanScrollBar ).LayoutLine();
       
  3466         menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  3467 
       
  3468         singleMenuPane = AknLayoutScalable_Avkon::list_single_popup_submenu_pane( index ).LayoutLine();
       
  3469         singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(), singleMenuPane );
       
  3470 
       
  3471         menuTextLayout = TAknTextLineLayout( AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 0 ).LayoutLine() );
       
  3472 
       
  3473         if ( hasIcon )
  2684         if ( hasIcon )
  3474             {
  2685             {
  3475             menuTextLayout = TAknTextLineLayout( AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 1 ).LayoutLine() );
  2686             menuTextLayout = 
       
  2687                 TAknTextLineLayout( 
       
  2688                 AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 1 ).LayoutLine() );
       
  2689             }
       
  2690         else
       
  2691             {
       
  2692             menuTextLayout = 
       
  2693                 TAknTextLineLayout( 
       
  2694                 AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 0 ).LayoutLine() );
  3476             }
  2695             }
  3477         }
  2696         }
  3478 
  2697 
  3479     TRect itemRect( singleMenuPaneRect.Rect() );
  2698     TRect itemRect( singleMenuPaneRect.Rect() );
  3480      
  2699      
  3490     
  2709     
  3491     TBool drawingInitiated = ETrue;
  2710     TBool drawingInitiated = ETrue;
  3492 
  2711 
  3493     RWindow& window = Window();
  2712     RWindow& window = Window();
  3494     
  2713     
  3495     if ( &window && window.GetDrawRect() == TRect::EUninitialized )
  2714    if ( &window && window.GetDrawRect() == TRect::EUninitialized )
  3496         {
  2715         {
  3497 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3498         MAknListBoxTfxInternal* transApi =
       
  3499             CAknListLoader::TfxApiInternal( &aGc );
       
  3500         drawingInitiated = transApi && !transApi->EffectsDisabled();
       
  3501 #else
       
  3502         drawingInitiated = EFalse;
  2716         drawingInitiated = EFalse;
  3503 #endif
  2717         }
  3504         }
  2718 
  3505 
  2719     if ( !drawingInitiated && !iExtension->iFullRedraw )
  3506     if ( !drawingInitiated )
       
  3507         {
  2720         {
  3508         window.Invalidate( itemRect );
  2721         window.Invalidate( itemRect );
  3509         window.BeginRedraw( itemRect );
  2722         window.BeginRedraw( itemRect );
  3510         }
  2723         }
  3511 
  2724 
  3514     if( iExtension )
  2727     if( iExtension )
  3515         {
  2728         {
  3516         cc = iExtension->iBgContext;
  2729         cc = iExtension->iBgContext;
  3517         }
  2730         }
  3518     TBool background( ETrue );
  2731     TBool background( ETrue );
  3519 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2732 
  3520     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &aGc );
  2733     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  3521     if ( transApi && !transApi->EffectsDisabled() )
  2734     aGc.SetBrushColor( singleMenuPaneRect.Color() );
  3522         {
  2735 
  3523         iExtension->iGc->Activate( *DrawableWindow() );
  2736     // there can be partial items, so clip drawing on menu pane's item area
  3524         }
  2737     aGc.SetClippingRect( iExtension->iItemAreaRect );
  3525 #endif
  2738 
  3526 
  2739     if (!iExtension->iFullRedraw)
  3527 #ifdef RD_UI_TRANSITION_EFFECTS_LIST            
  2740         {
  3528     if ( !transApi || transApi->EffectsDisabled() )
  2741         background = AknsDrawUtils::Background(
  3529         {
  2742             skin, cc, this, aGc, itemRect,
  3530 #endif                
  2743             KAknsDrawParamNoClearUnderImage );
       
  2744         }
       
  2745 
       
  2746     if ( !background )
       
  2747         {
  3531         aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  2748         aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  3532         aGc.SetBrushColor( singleMenuPaneRect.Color() );
  2749         aGc.SetPenStyle( CGraphicsContext::ENullPen );
  3533 
  2750         aGc.SetPenColor( singleMenuPaneRect.Color() );
  3534         if(!iExtension->iFullRedraw)
  2751         aGc.SetBrushColor( singleMenuPaneRect.Color() );         
  3535             {
  2752         aGc.DrawRect( itemRect );
  3536             background = AknsDrawUtils::Background(
  2753         }
  3537                 skin, cc, this, aGc, itemRect,
       
  3538                 KAknsDrawParamNoClearUnderImage );
       
  3539             }
       
  3540 
       
  3541         if( !background )
       
  3542             {
       
  3543             aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  3544             aGc.SetPenStyle( CGraphicsContext::ENullPen );
       
  3545             aGc.SetPenColor( singleMenuPaneRect.Color() );
       
  3546             aGc.SetBrushColor( singleMenuPaneRect.Color() );         
       
  3547             aGc.DrawRect( itemRect );
       
  3548             }
       
  3549 #ifdef RD_UI_TRANSITION_EFFECTS_LIST            
       
  3550         }
       
  3551 #endif
       
  3552 
  2754 
  3553     if ( !iExtension->HighlightEnabled() )
  2755     if ( !iExtension->HighlightEnabled() )
  3554         {
  2756         {
  3555         aHighlight = ENoHighlight;
  2757         aHighlight = ENoHighlight;
  3556         }
  2758         }
  3557 
  2759     
  3558     switch ( aHighlight )
  2760     switch ( aHighlight )
  3559         {
  2761         {
  3560         case EDrawHighlight :
  2762         case EDrawHighlight :
  3561             {
  2763             {
  3562             if ( !iExtension->iSctHighlighted )
  2764             if ( !iExtension->iSctHighlighted )
  3563                 {
  2765                 {
  3564 #ifdef RD_UI_TRANSITION_EFFECTS_LIST                
  2766                 iExtension->iHighlightedItem = aItem;
  3565                 if ( transApi )
  2767 
  3566                     {
  2768                 // Because of transparency, background must be drawn here as well
  3567                     // This will remove the old bitmap
  2769                 // (as frame may be see-through)
  3568                     transApi->Invalidate( MAknListBoxTfxInternal::EListHighlight ); 
  2770                 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  3569                                        
  2771                 aGc.SetBrushColor( singleMenuPaneRect.Color() );
  3570                     transApi->BeginRedraw( MAknListBoxTfxInternal::EListHighlight,
  2772 
  3571                                            itemRect );                                           
  2773                 AknsDrawUtils::Background(
  3572                     transApi->StartDrawing( MAknListBoxTfxInternal::EListHighlight );
  2774                     skin, cc, this, aGc, itemRect,
  3573                     }
  2775                     KAknsDrawParamNoClearUnderImage );
  3574 #endif
  2776 
  3575 
  2777                 TAknLayoutRect highlightTopLeft;
  3576                 // Partial items, so prevent drawing over the edge of menu pane
  2778                 TAknLayoutRect highlightBottomRight;
  3577 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2779 
  3578                 if ( !transApi || ( transApi && transApi->EffectsDisabled() ) )
  2780                 highlightTopLeft.LayoutRect(itemRect,
  3579                     {
  2781                     SkinLayout::List_highlight_skin_placing__popup_windows__Line_2() );
  3580                     aGc.SetClippingRect(menuPaneRect.Rect());
  2782                 highlightBottomRight.LayoutRect(itemRect,
  3581                     }
  2783                     SkinLayout::List_highlight_skin_placing__popup_windows__Line_5() );
  3582 #else
  2784                 TRect outerRect( highlightTopLeft.Rect().iTl, highlightBottomRight.Rect().iBr );
  3583                 aGc.SetClippingRect(menuPaneRect.Rect());
  2785                 TRect innerRect( highlightTopLeft.Rect().iBr, highlightBottomRight.Rect().iTl );
  3584 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  2786 
  3585 
  2787                 TBool drawOk = AknsDrawUtils::DrawFrame( skin,
  3586                 TBool drawOk = EFalse;
  2788                         aGc, 
  3587                 if( iExtension->iAnimation ) // Draw animated highlight
  2789                         outerRect, 
  3588                     {
  2790                         innerRect, 
  3589 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  2791                         KAknsIIDQsnFrList, 
  3590                     if ( transApi && transApi->VerifyKml() == KErrNone )
  2792                         KAknsIIDDefault );
  3591                         {
  2793 
  3592                         Extension()->UseNoAnimation();
  2794                 // skinned highlight drawing has failed
  3593                         }
  2795                 if ( !drawOk )
  3594                     else
       
  3595                         {
       
  3596 #endif
       
  3597                     TAknLayoutRect highlightTopLeft;
       
  3598                     TAknLayoutRect highlightBottomRight;
       
  3599           
       
  3600                     highlightTopLeft.LayoutRect( itemRect,
       
  3601                         SkinLayout::List_highlight_skin_placing__popup_windows__Line_2() );
       
  3602                     highlightBottomRight.LayoutRect( itemRect,
       
  3603                         SkinLayout::List_highlight_skin_placing__popup_windows__Line_5() );
       
  3604                        
       
  3605                     TRect outerRect( highlightTopLeft.Rect().iTl, highlightBottomRight.Rect().iBr );
       
  3606 
       
  3607                     drawOk = iExtension->iAnimation->Render( aGc, outerRect );
       
  3608 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3609                         }
       
  3610 #endif
       
  3611                     }
       
  3612                 
       
  3613                 if( !drawOk )
       
  3614                     {
       
  3615                     // Animated highlight was not available, use normal skinned
       
  3616                     // rendering.
       
  3617 
       
  3618                     // Because of transparency, background must be drawn here as well
       
  3619                     // (as frame may be see-through)
       
  3620                     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
       
  3621                     aGc.SetBrushColor( singleMenuPaneRect.Color() );
       
  3622 
       
  3623                     AknsDrawUtils::Background(
       
  3624                         skin, cc, this, aGc, itemRect,
       
  3625                         KAknsDrawParamNoClearUnderImage );
       
  3626 
       
  3627                     TAknLayoutRect highlightTopLeft;
       
  3628                     TAknLayoutRect highlightBottomRight;
       
  3629 
       
  3630                     highlightTopLeft.LayoutRect(itemRect,
       
  3631                         SkinLayout::List_highlight_skin_placing__popup_windows__Line_2() );
       
  3632                     highlightBottomRight.LayoutRect(itemRect,
       
  3633                         SkinLayout::List_highlight_skin_placing__popup_windows__Line_5() );
       
  3634                     TRect outerRect( highlightTopLeft.Rect().iTl, highlightBottomRight.Rect().iBr );
       
  3635                     TRect innerRect( highlightTopLeft.Rect().iBr, highlightBottomRight.Rect().iTl );
       
  3636 
       
  3637                     drawOk = AknsDrawUtils::DrawFrame( skin, 
       
  3638                                                        aGc, 
       
  3639                                                        outerRect, 
       
  3640                                                        innerRect, 
       
  3641                                                        KAknsIIDQsnFrList, 
       
  3642                                                        KAknsIIDDefault );
       
  3643                     
       
  3644                     }
       
  3645 
       
  3646                 // Both animated highlight and normal highlight drawing have
       
  3647                 // failed.
       
  3648                 if( !drawOk )
       
  3649                     {
  2796                     {
  3650                     TAknLayoutRect shadowRect;
  2797                     TAknLayoutRect shadowRect;
  3651                     TAknLayoutRect highlightRect;
  2798                     TAknLayoutRect highlightRect;
  3652                     shadowRect.LayoutRect( itemRect,
  2799                     shadowRect.LayoutRect( itemRect,
  3653                         AKN_LAYOUT_WINDOW_Highlight_graphics__various__Line_1( itemRect ) );
  2800                         AKN_LAYOUT_WINDOW_Highlight_graphics__various__Line_1( itemRect ) );
  3655                         AKN_LAYOUT_WINDOW_Highlight_graphics__various__Line_2( itemRect ) );
  2802                         AKN_LAYOUT_WINDOW_Highlight_graphics__various__Line_2( itemRect ) );
  3656                     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  2803                     aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
  3657                     shadowRect.DrawRect( aGc );
  2804                     shadowRect.DrawRect( aGc );
  3658                     highlightRect.DrawRect( aGc );
  2805                     highlightRect.DrawRect( aGc );
  3659                     }
  2806                     }
  3660 
       
  3661                 aGc.CancelClippingRect();
       
  3662 
       
  3663 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3664                 if ( transApi )
       
  3665                     {
       
  3666                     transApi->StopDrawing();
       
  3667                     transApi->EndRedraw( MAknListBoxTfxInternal::EListHighlight );
       
  3668                     }
       
  3669 #endif
       
  3670                 }
  2807                 }
  3671             break;
  2808             break;
  3672             }
  2809             }
  3673         case ERemoveHighlight:
  2810         case ERemoveHighlight:
  3674         case ENoHighlight:
  2811         case ENoHighlight:
       
  2812             if ( iExtension->iHighlightedItem == aItem )
       
  2813                 {
       
  2814                 iExtension->iHighlightedItem = KErrNotFound;
       
  2815                 }
  3675         default:
  2816         default:
  3676             break;
  2817             break;
  3677         }
  2818         }
  3678 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3679     if ( transApi )
       
  3680         {
       
  3681         transApi->BeginRedraw( MAknListBoxTfxInternal::EListItem, itemRect, aItem );
       
  3682         transApi->StartDrawing( MAknListBoxTfxInternal::EListItem );
       
  3683         }
       
  3684 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3685 
       
  3686     // Partial items, so prevent drawing over the edge of menu pane
       
  3687 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3688     if ( !transApi || ( transApi && transApi->EffectsDisabled() ) )
       
  3689         {
       
  3690         aGc.SetClippingRect(menuPaneRect.Rect());
       
  3691         }
       
  3692 #else
       
  3693     aGc.SetClippingRect(menuPaneRect.Rect());
       
  3694 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3695 
  2819 
  3696     // Cascade
  2820     // Cascade
  3697     if ( cascade )
  2821     if ( cascade )
  3698         {
  2822         {
  3699         TAknWindowLineLayout elementCascade( AknLayoutScalable_Avkon::list_single_pane_cp2_g3().LayoutLine());
  2823         TAknWindowLineLayout elementCascade( AknLayoutScalable_Avkon::list_single_pane_cp2_g3().LayoutLine());
  3784                 }
  2908                 }
  3785             }
  2909             }
  3786         }
  2910         }
  3787 
  2911 
  3788     // Text
  2912     // Text
  3789     TAknLayoutText textRect( iExtension->GetMenuItemTextLayout( itemRect, cascade ) );
  2913     TAknLayoutText textRect;
       
  2914     textRect.LayoutText( itemRect, menuTextLayout );
  3790     TRgb textColor = textRect.Color();
  2915     TRgb textColor = textRect.Color();
       
  2916 
  3791     if ( aHighlight == EDrawHighlight ) // highlighted text
  2917     if ( aHighlight == EDrawHighlight ) // highlighted text
  3792         {
  2918         {
  3793         AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 );
  2919         AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 );
  3794         }
  2920         }
  3795     else if ( !iOwner ) // menu
  2921     else if ( !iOwner ) // menu
  3817             textColor = KRgbBlack;
  2943             textColor = KRgbBlack;
  3818             }
  2944             }
  3819        }
  2945        }
  3820     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  2946     aGc.SetBrushStyle( CGraphicsContext::ENullBrush );
  3821     aGc.SetPenColor( textColor );
  2947     aGc.SetPenColor( textColor );
  3822     aGc.UseFont( textRect.Font() );
       
  3823 
  2948 
  3824     const CFont* font = textRect.Font();
  2949     const CFont* font = textRect.Font();
  3825 
  2950 
  3826     //TBuf<CEikMenuPaneItem::SData::ENominalTextLength + KAknBidiExtraSpacePerLine> visualText; // buffer for visually ordered text
  2951     //TBuf<CEikMenuPaneItem::SData::ENominalTextLength + KAknBidiExtraSpacePerLine> visualText; // buffer for visually ordered text
  3827     TBuf<255 + KAknBidiExtraSpacePerLine> visualText; // buffer for visually ordered text
  2952     TBuf<255 + KAknBidiExtraSpacePerLine> visualText; // buffer for visually ordered text
  3844         TRect cascRect( textRect.TextRect() );
  2969         TRect cascRect( textRect.TextRect() );
  3845         cascRect.Move( position );
  2970         cascRect.Move( position );
  3846         iExtension->iCascadeDRect.SetRect( cascRect.iTl, cascRect.iBr );        
  2971         iExtension->iCascadeDRect.SetRect( cascRect.iTl, cascRect.iBr );        
  3847         }
  2972         }
  3848 
  2973 
  3849     if(iExtension->iIsPenEnable)
  2974     TAknLayoutRect highlightRect;
  3850         {
  2975     highlightRect.LayoutRect( itemRect,
  3851         TAknLayoutRect highlightRect;
  2976         AKN_LAYOUT_WINDOW_Highlight_graphics__various__Line_2( itemRect ) );
  3852         highlightRect.LayoutRect( itemRect,
  2977 
  3853             AKN_LAYOUT_WINDOW_Highlight_graphics__various__Line_2( itemRect ) );
  2978     // store the calculated y-position to the menu item,
  3854 
  2979     // so that it can be used in HandlePointerEventL()
  3855         // store the calculated y-position to the menu item,
  2980     item->iPos = highlightRect.Rect().iTl.iY;
  3856         // so that it can be used in HandlePointerEventL()
  2981     
  3857         item->iPos = highlightRect.Rect().iTl.iY;
  2982     // don't draw separator line for the last item
  3858         aGc.DiscardFont();
  2983     if ( drawSeparator )
  3859         }
  2984         {
  3860 
  2985         AknListUtils::DrawSeparator( aGc, itemRect, textColor );
  3861     if ( !drawingInitiated )
  2986         }
       
  2987     
       
  2988     if ( !drawingInitiated && !iExtension->iFullRedraw )
  3862         {
  2989         {
  3863         Window().EndRedraw();
  2990         Window().EndRedraw();
  3864         }
  2991         }
  3865 
  2992 
  3866     aGc.CancelClippingRect();
  2993     aGc.CancelClippingRect();
  3867 
       
  3868 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3869     if ( transApi && !transApi->EffectsDisabled() )
       
  3870         {
       
  3871         transApi->StopDrawing();
       
  3872         transApi->EndRedraw( MAknListBoxTfxInternal::EListItem, aItem );
       
  3873         iExtension->iGc->Deactivate();
       
  3874         }
       
  3875 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3876     }
  2994     }
  3877 
  2995 
  3878 
  2996 
  3879 // -----------------------------------------------------------------------------
  2997 // -----------------------------------------------------------------------------
  3880 // CEikMenuPane::Draw
  2998 // CEikMenuPane::Draw
  3881 // -----------------------------------------------------------------------------
  2999 // -----------------------------------------------------------------------------
  3882 //
  3000 //
  3883 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3884 EXPORT_C void CEikMenuPane::Draw( const TRect& aRect ) const
  3001 EXPORT_C void CEikMenuPane::Draw( const TRect& aRect ) const
  3885     {
  3002     {
  3886     CWindowGc& gc = ( iExtension && iExtension->iGc ) ?
       
  3887                     *iExtension->iGc : SystemGc();
       
  3888     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( &gc );
       
  3889 
       
  3890     if ( transApi )
       
  3891         {
       
  3892         iExtension->iGc->Activate( *DrawableWindow() );
       
  3893         
       
  3894         if ( !transApi->EffectsDisabled() )
       
  3895             {
       
  3896             if ( iExtension->iScrollBarRect.iTl.iX <= aRect.iTl.iX &&
       
  3897                  iExtension->iScrollBarRect.iBr.iX >= aRect.iBr.iX )
       
  3898                 {
       
  3899                 transApi->BeginRedraw( MAknListBoxTfxInternal::EListUpdateRect, aRect );
       
  3900                 iExtension->iGc->Deactivate();
       
  3901                 return;
       
  3902                 }
       
  3903         
       
  3904             iExtension->CalcItemSize( transApi );
       
  3905             }
       
  3906         }
       
  3907 #else
       
  3908 EXPORT_C void CEikMenuPane::Draw(const TRect& /*aRect*/) const
       
  3909     {
       
  3910 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3911 
       
  3912     TRect windowRect( Rect() );
       
  3913     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  3003     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  3914     MAknsControlContext* cc = NULL;
  3004     MAknsControlContext* cc = NULL;
  3915 
  3005 
  3916     if( iExtension )
  3006     if( iExtension )
  3917         {
  3007         {
  3918         cc = iExtension->iBgContext;
  3008         cc = iExtension->iBgContext;
  3919         }
  3009         }
  3920 
  3010 
  3921 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3922     if ( transApi )
       
  3923         {
       
  3924         transApi->SetListType( MAknListBoxTfxInternal::EListBoxTypeMenuPane );
       
  3925         transApi->BeginRedraw( MAknListBoxTfxInternal::EListView, windowRect );
       
  3926         }
       
  3927 #else
       
  3928     CWindowGc& gc = SystemGc();
  3011     CWindowGc& gc = SystemGc();
  3929 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3930     PrepareGcForDrawingItems( gc );
  3012     PrepareGcForDrawingItems( gc );
  3931 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  3932     if ( transApi )
       
  3933         {
       
  3934         transApi->StartDrawing( MAknListBoxTfxInternal::EListView );
       
  3935         }
       
  3936 #endif
       
  3937 
       
  3938     if ( !IsCascadeMenuPane() )
       
  3939         {
       
  3940         CFbsBitmap* cbaExtension = AknsUtils::GetCachedBitmap( skin, KAknsIIDQsnBgSlicePopup );
       
  3941         if ( cbaExtension )
       
  3942             {
       
  3943             TAknLayoutRect sliceRect;
       
  3944             sliceRect.LayoutRect( windowRect, SkinLayout::Popup_windows_skin_placing__background_slice__Line_2() );
       
  3945             AknIconUtils::SetSize( cbaExtension, sliceRect.Rect().Size() );
       
  3946             gc.BitBlt( TPoint( windowRect.iTl.iX, windowRect.iBr.iY-cbaExtension->SizeInPixels().iHeight ), cbaExtension );
       
  3947             windowRect.iBr.iY -=2; // two used as margin when rect layouts were done
       
  3948             }
       
  3949         }
       
  3950 
  3013 
  3951     TInt count=0;
  3014     TInt count=0;
       
  3015 
  3952     if( iItemArray )
  3016     if( iItemArray )
  3953         {
  3017         {
  3954         count=iItemArray->Count();
  3018         count=iItemArray->Count();
  3955         }
  3019         }
  3956 
  3020 
  3957     // Give the topmost menu item's rect to SCT if needed.
  3021     // Give the topmost menu item's rect to SCT if needed.
  3958     if ( iExtension->iSct )
  3022     if ( iExtension->iSct )
  3959         {
  3023         {
  3960         TAknLayoutRect listScrollPaneRect;
  3024         iExtension->iSct->SetMenuSctRect( ItemRect( 0 ) );
  3961         TAknLayoutRect menuPaneRect;
  3025 
  3962         TAknLayoutRect singleMenuPaneRect;
       
  3963 
       
  3964         TAknWindowLineLayout listScrollPaneLayout( 
       
  3965             AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
       
  3966         if ( iExtension )
       
  3967             {
       
  3968             iExtension->AdjustPopupLayoutData( listScrollPaneLayout );
       
  3969             }
       
  3970         listScrollPaneRect.LayoutRect( windowRect, listScrollPaneLayout );
       
  3971         menuPaneRect.LayoutRect( listScrollPaneRect.Rect(),
       
  3972              AknLayoutScalable_Avkon::list_menu_pane( 0 ).LayoutLine() );
       
  3973         singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(),
       
  3974              AknLayoutScalable_Avkon::list_single_pane_cp2( 0 ).LayoutLine() );
       
  3975         // Give the rect of the first menu item to SCT.
       
  3976         iExtension->iSct->SetMenuSctRect( singleMenuPaneRect.Rect() );
       
  3977 #ifdef RD_UI_TRANSITION_EFFECTS_LIST      
       
  3978         if( transApi )
       
  3979             {
       
  3980             iExtension->iSctRect = singleMenuPaneRect.Rect();
       
  3981             TAknLayoutRect cellLayRect;
       
  3982             cellLayRect.LayoutRect( iExtension->iSctRect,
       
  3983                 AknLayoutScalable_Avkon::cell_graphic_popup_pane( 0, 0, 0 ) );
       
  3984             iExtension->iSctRect.iTl.iX -= 1;
       
  3985             iExtension->iSctRect.iTl.iY -= 1;
       
  3986             iExtension->iSctRect.iBr.iX += 3;
       
  3987             transApi->ResetNonDrawingRects();
       
  3988             transApi->AddNonDrawingRect( iExtension->iScrollBarRect );
       
  3989             transApi->AddNonDrawingRect( iExtension->iSctRect );
       
  3990             }
       
  3991 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  3992         }
       
  3993 
       
  3994     if ( iExtension->iSct )
       
  3995         {
       
  3996         TRegionFix<4> region;
  3026         TRegionFix<4> region;
  3997         region.AddRect( Rect() );
  3027         region.AddRect( aRect );
  3998         region.SubRect( iExtension->iSct->Rect() );
  3028         region.SubRect( iExtension->iSct->Rect() );
  3999         gc.SetClippingRegion( region );
  3029         gc.SetClippingRegion( region );
  4000         }
  3030         }
  4001         
       
  4002     TRect backgroundRect( iOwner ? windowRect : iExtension->GetBackgroundRect( windowRect ) );
       
  4003         
  3031         
  4004     // The added flag removes the white bg for transparency
  3032     // The added flag removes the white bg for transparency
  4005     TBool frameDrawn = AknsDrawUtils::Background( 
  3033     TBool frameDrawn = AknsDrawUtils::Background( 
  4006         skin, cc, this, gc, backgroundRect, KAknsDrawParamNoClearUnderImage );        
  3034         skin, cc, this, gc, aRect, KAknsDrawParamNoClearUnderImage );        
  4007 
  3035 
  4008 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3036     if ( aRect.Intersects( iExtension->iItemAreaRect ) )
  4009     if ( transApi )
  3037         {
  4010         {
  3038         iExtension->iFullRedraw = ETrue;   
  4011         transApi->StopDrawing();
  3039     
  4012         }
  3040         for ( TInt ii=0;ii<count;++ii )
  4013 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  3041             {
  4014 
  3042             if(!iExtension->iSctHighlighted && ii == iSelectedItem  )
  4015     iExtension->iFullRedraw = ETrue;   
  3043                 DrawItem( gc, ii, EDrawHighlight);
  4016 
  3044             else
  4017     for ( TInt ii=0;ii<count;++ii )
  3045                 DrawItem( gc, ii, ENoHighlight);
  4018         {
  3046             }    
  4019         if(!iExtension->iSctHighlighted && ii == iSelectedItem  )
  3047       
  4020             DrawItem( gc, ii, EDrawHighlight);
  3048         iExtension->iFullRedraw = EFalse;   
  4021         else
  3049         }
  4022             DrawItem( gc, ii, ENoHighlight);
       
  4023         }    
       
  4024   
       
  4025     iExtension->iFullRedraw = EFalse;   
       
  4026 
  3050 
  4027     if ( iExtension->iSct )
  3051     if ( iExtension->iSct )
  4028         {
  3052         {
  4029 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  4030         if ( transApi )
       
  4031             {
       
  4032             transApi->StartDrawing( MAknListBoxTfxInternal::EListNotSpecified );
       
  4033             }
       
  4034 #endif
       
  4035         gc.CancelClippingRegion();
  3053         gc.CancelClippingRegion();
  4036 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3054         }
  4037         if ( transApi )
       
  4038             {
       
  4039             transApi->StopDrawing();
       
  4040             }
       
  4041 #endif
       
  4042         }
       
  4043         
       
  4044 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  4045     if ( transApi )
       
  4046         {
       
  4047         transApi->EndViewRedraw( aRect );
       
  4048         iExtension->iGc->Deactivate();
       
  4049         }
       
  4050 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  4051     }
  3055     }
  4052 
  3056 
  4053 
  3057 
  4054 // -----------------------------------------------------------------------------
  3058 // -----------------------------------------------------------------------------
  4055 // CEikMenuPane::ReportSelectionMadeL
  3059 // CEikMenuPane::ReportSelectionMadeL
  4119         // 'this' might be destroyed by calling iMenuObserver->ProcessCommandL(
  3123         // 'this' might be destroyed by calling iMenuObserver->ProcessCommandL(
  4120         // commandId ), so need to avoid crash
  3124         // commandId ), so need to avoid crash
  4121         CEikMenuPane* menu = iOwner ? iOwner : this;
  3125         CEikMenuPane* menu = iOwner ? iOwner : this;
  4122         MCoeControlObserver* observer = menu->Observer();
  3126         MCoeControlObserver* observer = menu->Observer();
  4123 
  3127 
  4124 
       
  4125         if ( commandId != EAknCmdTaskSwapper )
  3128         if ( commandId != EAknCmdTaskSwapper )
  4126             {
  3129             {
  4127             _AKNTRACE( "commandId = %d",  commandId );
  3130             _AKNTRACE( "commandId = %d",  commandId );
  4128             iMenuObserver->ProcessCommandL( commandId ); 
  3131             iMenuObserver->ProcessCommandL( commandId ); 
  4129             }
  3132             }
  4157 //
  3160 //
  4158 EXPORT_C void CEikMenuPane::FocusChanged( TDrawNow aDrawNow )
  3161 EXPORT_C void CEikMenuPane::FocusChanged( TDrawNow aDrawNow )
  4159     {
  3162     {
  4160     _AKNTRACE_FUNC_ENTER;
  3163     _AKNTRACE_FUNC_ENTER;
  4161     _AKNTRACE( "aDrawNow =  %d", aDrawNow );
  3164     _AKNTRACE( "aDrawNow =  %d", aDrawNow );
  4162     if( iExtension )
       
  4163         {
       
  4164         if ( IsFocused() )
       
  4165             {
       
  4166 #ifdef RD_UI_TRANSITION_EFFECTS_LIST        
       
  4167             // Focus must be handled here, otherwise it will come to late
       
  4168             MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  4169     
       
  4170             if ( transApi )
       
  4171                 {
       
  4172                 transApi->HandleFocusChange( ETrue );
       
  4173                 }
       
  4174 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  4175             iExtension->FocusGained();
       
  4176             }
       
  4177         else // Not focused
       
  4178             {
       
  4179             iExtension->FocusLost();
       
  4180             }
       
  4181         }
       
  4182 
  3165 
  4183     if ( !iItemArray || iItemArray->Count() == 0 )
  3166     if ( !iItemArray || iItemArray->Count() == 0 )
  4184         {
  3167         {
  4185         return;
  3168         return;
  4186         }
  3169         }
  4368     TInt newHighlight = iSelectedItem;
  3351     TInt newHighlight = iSelectedItem;
  4369     TBool loopScrolling = ETrue;
  3352     TBool loopScrolling = ETrue;
  4370     TInt itemAfterLastItem = loopScrolling ? 0 : max;
  3353     TInt itemAfterLastItem = loopScrolling ? 0 : max;
  4371     TInt itemAfterFirstItem = loopScrolling ? max : 0;
  3354     TInt itemAfterFirstItem = loopScrolling ? max : 0;
  4372 
  3355 
  4373 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3356     // Scroll highlighted item so that it becomes visible,
  4374     CWindowGc& gc = iExtension->iGc ? *iExtension->iGc : SystemGc();
  3357     // if it is not visible before (scrolling with scroll bar
  4375     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( &gc );
  3358     // can cause highlighted item to go out of screen)
  4376 #endif //RD_UI_TRANSITION_EFFECTS_LIST
  3359     TInt topItem = iScroller->TopItemIndex();
  4377 
  3360     TInt bottomItem = topItem + NumberOfItemsThatFitInView();
  4378     if(iExtension->iIsPenEnable)
  3361           
  4379         {
  3362     if ( iExtension->Offset() < 0 ) 
  4380         _AKNTRACE( "[%s]", "iExtension->iIsPenEnable = TRUE" );
  3363         {
  4381         // Scroll highlighted item so that it becomes visible,
  3364         // Extra bottom item when panning
  4382         // if it is not visible before (scrolling with scroll bar
  3365         bottomItem++;
  4383         // can cause highlighted item to go out of screen)
  3366         }
  4384         TInt topItem = iScroller->TopItemIndex();
  3367     
  4385         TInt bottomItem = topItem + NumberOfItemsThatFitInView();
  3368     if( bottomItem > NumberOfItemsInPane() )
  4386               
  3369         {
  4387         if ( iExtension->Offset() < 0 ) 
  3370         bottomItem = NumberOfItemsInPane();
  4388             {
  3371         }
  4389             // Extra bottom item when panning
  3372     _AKNTRACE( "topItem = %d,bottomItem = %d", topItem,bottomItem );
  4390             bottomItem++;
  3373 
  4391             }
  3374     if ( aType != EEventKeyDown && iSelectedItem != ENothingSelected &&
  4392         
  3375         !(iExtension->iSctHighlighted && topItem == 0) &&
  4393         if( bottomItem > NumberOfItemsInPane() )
  3376         (iSelectedItem < topItem || iSelectedItem > bottomItem - 1) )
  4394             {
  3377         {
  4395             bottomItem = NumberOfItemsInPane();
  3378         _AKNTRACE( "[%s]", "ScrollToMakeItemVisible(iSelectedItem);" );
  4396             }
  3379         ScrollToMakeItemVisible(iSelectedItem);
  4397         _AKNTRACE( "topItem = %d,bottomItem = %d", topItem,bottomItem );
  3380 
  4398 
  3381         ActivateGc();
  4399         if ( aType != EEventKeyDown && iSelectedItem != ENothingSelected &&
  3382         CWindowGc& gc = SystemGc();
  4400             !(iExtension->iSctHighlighted && topItem == 0) &&
  3383         PrepareGcForDrawingItems( gc );
  4401             (iSelectedItem < topItem || iSelectedItem > bottomItem - 1) )
  3384 
  4402             {
  3385         // draw all items that are needed.
  4403             _AKNTRACE( "[%s]", "ScrollToMakeItemVisible(iSelectedItem);" );
  3386         for( TInt i = 0; i < count; i++ )
  4404             ScrollToMakeItemVisible(iSelectedItem);
  3387             {
  4405 
  3388             if( i == iSelectedItem && !iExtension->iSctHighlighted)
  4406             ActivateGc();
  3389                 {
  4407 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3390                 DrawItem( gc, i, EDrawHighlight );
  4408             if ( transApi )
       
  4409                 {
       
  4410                 iExtension->iGc->Activate( *DrawableWindow() );
       
  4411                 }
  3391                 }
  4412 #else
  3392             else
  4413             CWindowGc& gc = SystemGc();
  3393                 {
  4414 #endif // RD_UI_TRANSITION_EFFECTS_LIST
  3394                 DrawItem( gc, i, ERemoveHighlight );
  4415             PrepareGcForDrawingItems( gc );
       
  4416 
       
  4417             // draw all items that are needed.
       
  4418             for( TInt i = 0; i < count; i++ )
       
  4419                 {
       
  4420                 if( i == iSelectedItem && !iExtension->iSctHighlighted)
       
  4421                     {
       
  4422                     DrawItem( gc, i, EDrawHighlight );
       
  4423                     }
       
  4424                 else
       
  4425                     {
       
  4426                     DrawItem( gc, i, ERemoveHighlight );
       
  4427                     }
       
  4428                 }
  3395                 }
  4429 
  3396             }
  4430 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3397 
  4431             if ( transApi )
  3398         DeactivateGc();
  4432                 {
  3399         _AKNTRACE( "[%s]", "OfferKeyEventL return 9" );
  4433                 iExtension->iGc->Deactivate();
  3400         _AKNTRACE_FUNC_EXIT;
  4434                 }
  3401         return EKeyWasConsumed;
  4435 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  4436             DeactivateGc();
       
  4437             _AKNTRACE( "[%s]", "OfferKeyEventL return 9" );
       
  4438             _AKNTRACE_FUNC_EXIT;
       
  4439             return EKeyWasConsumed;
       
  4440             }
       
  4441         }
  3402         }
  4442 
  3403 
  4443     if ( iSelectedItem != ENothingSelected || iExtension->iSctHighlighted )
  3404     if ( iSelectedItem != ENothingSelected || iExtension->iSctHighlighted )
  4444         {
  3405         {
  4445         switch ( code )
  3406         switch ( code )
  4452                 return EKeyWasConsumed;
  3413                 return EKeyWasConsumed;
  4453 // AKNLAF start
  3414 // AKNLAF start
  4454 // loop scrolling always used in options menus
  3415 // loop scrolling always used in options menus
  4455             case EKeyDownArrow:
  3416             case EKeyDownArrow:
  4456             	_AKNTRACE( "[%s]", "OfferKeyEventL(EKeyDownArrow)" );
  3417             	_AKNTRACE( "[%s]", "OfferKeyEventL(EKeyDownArrow)" );
  4457 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  4458                 if ( transApi )
       
  4459                     {
       
  4460                     transApi->SetMoveType(
       
  4461                             MAknListBoxTfxInternal::EListMoveDown );
       
  4462                     }
       
  4463 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
  4464                 if ( iExtension->iSctHighlighted && iExtension->iSct )
  3418                 if ( iExtension->iSctHighlighted && iExtension->iSct )
  4465                     {
  3419                     {
  4466                     iExtension->iSctHighlighted = EFalse;
  3420                     iExtension->iSctHighlighted = EFalse;
  4467                     MoveHighlightTo( ++newHighlight );
  3421                     MoveHighlightTo( ++newHighlight );
  4468                     iExtension->iSct->HighlightSctRow( iExtension->iSctHighlighted );
  3422                     iExtension->iSct->HighlightSctRow( iExtension->iSctHighlighted );
  4484                     }
  3438                     }
  4485                 keyResponse = EKeyWasConsumed;
  3439                 keyResponse = EKeyWasConsumed;
  4486                 break;
  3440                 break;
  4487             case EKeyUpArrow:
  3441             case EKeyUpArrow:
  4488             	_AKNTRACE( "[%s]", "OfferKeyEventL(EKeyUpArrow)" );
  3442             	_AKNTRACE( "[%s]", "OfferKeyEventL(EKeyUpArrow)" );
  4489 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  4490                 if ( transApi )
       
  4491                     {
       
  4492                     transApi->SetMoveType(
       
  4493                             MAknListBoxTfxInternal::EListMoveUp );
       
  4494                     }
       
  4495 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
  4496                 if ( iExtension->iSct &&
  3443                 if ( iExtension->iSct &&
  4497                     iSelectedItem == 0 && !iExtension->iSctHighlighted )
  3444                     iSelectedItem == 0 && !iExtension->iSctHighlighted )
  4498                     {
  3445                     {
  4499                     iExtension->iSctHighlighted = ETrue;
  3446                     iExtension->iSctHighlighted = ETrue;
  4500                     MoveHighlightTo( ENothingSelected );
  3447                     MoveHighlightTo( ENothingSelected );
  4693         return;
  3640         return;
  4694         }
  3641         }
  4695         
  3642         
  4696     TInt count( NumberOfItemsInPane() );
  3643     TInt count( NumberOfItemsInPane() );
  4697         
  3644         
  4698     if ( iExtension->iIsPenEnable )
  3645     // Scroll highlighted item so that it becomes visible
  4699         {
  3646     // if it is not visible before (scrolling with scroll bar
  4700         // Scroll highlighted item so that it becomes visible
  3647     // can cause highlighted item to go out of screen).
  4701         // if it is not visible before (scrolling with scroll bar
  3648     TInt topItem( iScroller->TopItemIndex() );
  4702         // can cause highlighted item to go out of screen).
  3649     TInt bottomItem( topItem + NumberOfItemsThatFitInView() );
  4703         TInt topItem( iScroller->TopItemIndex() );
  3650     if ( bottomItem > count )
  4704         TInt bottomItem( topItem + NumberOfItemsThatFitInView() );
  3651         {
  4705         if ( bottomItem > count )
  3652         bottomItem = count;
  4706             {
  3653         }
  4707             bottomItem = count;
  3654 
  4708             }
  3655     if ( iExtension->Offset() < 0 &&
  4709    
  3656          ( iSelectedItem == topItem || iSelectedItem == bottomItem ) )
  4710         if ( iExtension->Offset() < 0 &&
  3657         {
  4711              ( iSelectedItem == topItem || iSelectedItem == bottomItem ) )
  3658         // Restoring offset with "simulated" ok key event.         
  4712             {
  3659         iExtension->RestoreOffset( EKeyOK ); 
  4713             // Restoring offset with "simulated" ok key event.         
  3660         }    
  4714             iExtension->RestoreOffset( EKeyOK ); 
  3661     else if ( iSelectedItem < topItem ||
  4715             }    
  3662               iSelectedItem > bottomItem - 1 )
  4716         else if ( iSelectedItem < topItem ||
  3663         {
  4717                   iSelectedItem > bottomItem - 1 )
  3664         if ( count > iSelectedItem )
  4718             {
  3665             {
  4719             if ( count > iSelectedItem )
  3666             if ( iExtension->iSctHighlighted && iExtension->iSct )
  4720                 {
  3667                 {
  4721                 if ( iExtension->iSctHighlighted && iExtension->iSct )
  3668                 TKeyEvent key;
       
  3669                 key.iCode = EKeyOK;
       
  3670                 key.iModifiers = 0;
       
  3671 
       
  3672                 TKeyResponse keyResponse( EKeyWasNotConsumed );
       
  3673                 TEventCode type( EEventNull );
       
  3674                 keyResponse = iExtension->iSct->OfferKeyEventL( key,
       
  3675                                                                 type );
       
  3676                 if ( keyResponse == EKeyWasConsumed )
  4722                     {
  3677                     {
  4723                     TKeyEvent key;
  3678                     ReportSelectionMadeL();
  4724                     key.iCode = EKeyOK;
       
  4725                     key.iModifiers = 0;
       
  4726 
       
  4727                     TKeyResponse keyResponse( EKeyWasNotConsumed );
       
  4728                     TEventCode type( EEventNull );
       
  4729                     keyResponse = iExtension->iSct->OfferKeyEventL( key,
       
  4730                                                                     type );
       
  4731                     if ( keyResponse == EKeyWasConsumed )
       
  4732                         {
       
  4733                         ReportSelectionMadeL();
       
  4734                         }
       
  4735                     _AKNTRACE( "[%s]" "ActivateCurrentItemL return 2" );
       
  4736                     _AKNTRACE_FUNC_EXIT;
       
  4737                     return;
       
  4738                     }
  3679                     }
       
  3680                 _AKNTRACE( "[%s]" "ActivateCurrentItemL return 2" );
       
  3681                 _AKNTRACE_FUNC_EXIT;
       
  3682                 return;
  4739                 }
  3683                 }
  4740 
  3684             }
  4741             iExtension->isUpdateScrollDirectly = ETrue;
  3685 
  4742             ScrollToMakeItemVisible( iSelectedItem );
  3686         iExtension->isUpdateScrollDirectly = ETrue;
  4743             iExtension->isUpdateScrollDirectly = EFalse;
  3687         ScrollToMakeItemVisible( iSelectedItem );
  4744 
  3688         iExtension->isUpdateScrollDirectly = EFalse;
  4745             ActivateGc();
  3689 
  4746 
  3690         ActivateGc();
  4747 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3691         CWindowGc& gc = SystemGc();
  4748 
  3692         PrepareGcForDrawingItems( gc );
  4749             MAknListBoxTfxInternal *transApi =
  3693 
  4750                 CAknListLoader::TfxApiInternal( iExtension->iGc );
  3694         // Draw all items that are needed.
  4751             if ( transApi )
  3695         for ( TInt i = 0; i < count; i++ )
  4752                 {
  3696             {
  4753                 iExtension->iGc->Activate( *DrawableWindow() );
  3697             if ( i == iSelectedItem && !iExtension->iSctHighlighted )
       
  3698                 {
       
  3699                 DrawItem( gc, i, EDrawHighlight );
  4754                 }
  3700                 }
  4755             CWindowGc& gc = transApi ? *iExtension->iGc : SystemGc();
  3701             else
  4756 
  3702                 {
  4757 #else
  3703                 DrawItem( gc, i, ERemoveHighlight );
  4758 
       
  4759             CWindowGc& gc = SystemGc();
       
  4760 
       
  4761 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  4762 
       
  4763             PrepareGcForDrawingItems( gc );
       
  4764 
       
  4765             // Draw all items that are needed.
       
  4766             for ( TInt i = 0; i < count; i++ )
       
  4767                 {
       
  4768                 if ( i == iSelectedItem && !iExtension->iSctHighlighted )
       
  4769                     {
       
  4770                     DrawItem( gc, i, EDrawHighlight );
       
  4771                     }
       
  4772                 else
       
  4773                     {
       
  4774                     DrawItem( gc, i, ERemoveHighlight );
       
  4775                     }
       
  4776                 }
  3704                 }
  4777 
  3705             }
  4778 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  3706 
  4779 
  3707         DeactivateGc();
  4780             if ( transApi )
  3708         _AKNTRACE( "[%s]" "ActivateCurrentItemL return 3" );
  4781                 {
  3709         _AKNTRACE_FUNC_EXIT;
  4782                 iExtension->iGc->Deactivate();
  3710         return;
  4783                 }
       
  4784 
       
  4785 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  4786 
       
  4787             DeactivateGc();
       
  4788             _AKNTRACE( "[%s]" "ActivateCurrentItemL return 3" );
       
  4789             _AKNTRACE_FUNC_EXIT;
       
  4790             return;
       
  4791             }
       
  4792         }
  3711         }
  4793 
  3712 
  4794     if ( iCascadeMenuPane )
  3713     if ( iCascadeMenuPane )
  4795         {
  3714         {
  4796         iCascadeMenuPane->ActivateCurrentItemL();
  3715         iCascadeMenuPane->ActivateCurrentItemL();
  4907 // Handles pointer events.
  3826 // Handles pointer events.
  4908 // ----------------------------------------------------------------------------
  3827 // ----------------------------------------------------------------------------
  4909 //
  3828 //
  4910 EXPORT_C void CEikMenuPane::HandlePointerEventL( const TPointerEvent& aPointerEvent )
  3829 EXPORT_C void CEikMenuPane::HandlePointerEventL( const TPointerEvent& aPointerEvent )
  4911     {
  3830     {
  4912     if( !AknLayoutUtils::PenEnabled() )
       
  4913         {
       
  4914         return;
       
  4915         }
       
  4916 
       
  4917     _AKNTRACE_FUNC_ENTER;
  3831     _AKNTRACE_FUNC_ENTER;
  4918 
  3832 
  4919     if ( iOwner && !IsVisible() )
  3833     if ( iOwner && !IsVisible() )
  4920         {
  3834         {
  4921         _AKNTRACE( "[%s]", "HandlePointerEventL return 1" );
  3835         _AKNTRACE( "[%s]", "HandlePointerEventL return 1" );
  4947         }    
  3861         }    
  4948     else
  3862     else
  4949         {
  3863         {
  4950         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
  3864         if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
  4951             {
  3865             {
  4952             if( AknLayoutUtils::PenEnabled() )
  3866             if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  4953                 {
  3867                 {
  4954                 if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  3868                 iExtension->ImmediateFeedback( ETouchFeedbackDecreasingPopUp );
  4955                     {
  3869                 }
  4956                     iExtension->ImmediateFeedback( ETouchFeedbackDecreasingPopUp );
  3870             else
  4957                     }
  3871                 {
  4958                 else
  3872                 iExtension->ImmediateFeedback( ETouchFeedbackPopUp );
  4959                     {
       
  4960                     iExtension->ImmediateFeedback( ETouchFeedbackPopUp );
       
  4961                     }
       
  4962                 }
  3873                 }
  4963             iExtension->iShowCascadeTransition = ETrue;
  3874             iExtension->iShowCascadeTransition = ETrue;
  4964             CloseCascadeMenu();  
  3875             CloseCascadeMenu();  
  4965             IgnoreEventsUntilNextPointerUp();
  3876             IgnoreEventsUntilNextPointerUp();
  4966             _AKNTRACE( "[%s]", "HandlePointerEventL return 2" );
  3877             _AKNTRACE( "[%s]", "HandlePointerEventL return 2" );
  5046     const TRect innerRect = iBorder.InnerRect( Rect() );
  3957     const TRect innerRect = iBorder.InnerRect( Rect() );
  5047     TRect menuSctRect;
  3958     TRect menuSctRect;
  5048     // Get the option item's rect in Menu SCT
  3959     // Get the option item's rect in Menu SCT
  5049     if ( iExtension->iSct )
  3960     if ( iExtension->iSct )
  5050         {
  3961         {
  5051         TAknLayoutRect menuPaneRect;
  3962         menuSctRect = iExtension->iItemAreaRect;
  5052         TAknWindowLineLayout menuPane;
       
  5053         
       
  5054         TAknWindowLineLayout listScrollPaneLayout( 
       
  5055             AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
       
  5056         if ( iExtension )
       
  5057             {
       
  5058             iExtension->AdjustPopupLayoutData( listScrollPaneLayout );
       
  5059             }
       
  5060         TAknLayoutRect listScrollPaneRect;
       
  5061         listScrollPaneRect.LayoutRect( Rect(), listScrollPaneLayout );
       
  5062         
       
  5063         menuPane = AknLayoutScalable_Avkon::list_menu_pane( 0 ).LayoutLine();
       
  5064         menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  5065         menuSctRect = menuPaneRect.Rect();
       
  5066         }
  3963         }
  5067     TRect cascadeMenuRect(0,0,0,0);
  3964     TRect cascadeMenuRect(0,0,0,0);
  5068 
  3965 
  5069     // Y coordinate for pointer event
  3966     // Y coordinate for pointer event
  5070     const TInt yPos = aPointerEvent.iPosition.iY;
  3967     const TInt yPos = aPointerEvent.iPosition.iY;
  5087 
  3984 
  5088 
  3985 
  5089     // if submenu, then move it's rect coordinates to relative to parent.
  3986     // if submenu, then move it's rect coordinates to relative to parent.
  5090     if ( iCascadeMenuPane  )
  3987     if ( iCascadeMenuPane  )
  5091         {
  3988         {
  5092         TPoint subPos = iCascadeMenuPane->PositionRelativeToScreen();
  3989         TPoint subPos = iCascadeMenuPane->Position();
  5093         cascadeMenuRect = TRect(subPos-PositionRelativeToScreen(), iCascadeMenuPane->Size());
  3990         cascadeMenuRect = TRect(subPos-Position(), iCascadeMenuPane->Size());
  5094         }
  3991         }
  5095 
  3992 
  5096     // Pointerevent in case we need to pass event from submenu to parent
  3993     // Pointerevent in case we need to pass event from submenu to parent
  5097     TPointerEvent parentEvent;   
  3994     TPointerEvent parentEvent;   
  5098 
  3995 
  5100     if ( iExtension && iExtension->iDraggedOutside )
  3997     if ( iExtension && iExtension->iDraggedOutside )
  5101         {
  3998         {
  5102         iExtension->StopCascadeMenuTimer();
  3999         iExtension->StopCascadeMenuTimer();
  5103         iExtension->ResetPressedHighlight();
  4000         iExtension->ResetPressedHighlight();
  5104         }
  4001         }
  5105 
       
  5106 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  5107     MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal(
       
  5108                                                             iExtension->iGc );
       
  5109     TBool effects = transApi && !transApi->EffectsDisabled();
       
  5110 #endif
       
  5111 
  4002 
  5112     switch (aPointerEvent.iType )
  4003     switch (aPointerEvent.iType )
  5113         {
  4004         {
  5114         case TPointerEvent::EButton1Up:
  4005         case TPointerEvent::EButton1Up:
  5115             {
  4006             {
  5306                 if ( iCascadeMenuPane )
  4197                 if ( iCascadeMenuPane )
  5307                     {
  4198                     {
  5308                     // if submenu, and clicked outside of it
  4199                     // if submenu, and clicked outside of it
  5309                     if ( !cascadeMenuRect.Contains( aPointerEvent.iPosition ) )
  4200                     if ( !cascadeMenuRect.Contains( aPointerEvent.iPosition ) )
  5310                         {
  4201                         {
  5311                         if( AknLayoutUtils::PenEnabled() )
  4202                         if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  5312                             {                            
  4203                             {
  5313                             if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  4204                             iExtension->ImmediateFeedback( ETouchFeedbackDecreasingPopUp );
  5314                                 {
  4205                             }
  5315                                 iExtension->ImmediateFeedback( ETouchFeedbackDecreasingPopUp );
  4206                         else
  5316                                 }
  4207                             {
  5317                             else
  4208                             iExtension->ImmediateFeedback( ETouchFeedbackPopUp );
  5318                                 {
       
  5319                                 iExtension->ImmediateFeedback( ETouchFeedbackPopUp );
       
  5320                                 }
       
  5321                             }
  4209                             }
  5322                         //Just close sub menu
  4210                         //Just close sub menu
  5323                         iExtension->iShowCascadeTransition = ETrue;
  4211                         iExtension->iShowCascadeTransition = ETrue;
  5324                         CloseCascadeMenu();
  4212                         CloseCascadeMenu();
  5325                         iExtension->EnableHighlight( EFalse );
  4213                         iExtension->EnableHighlight( EFalse );
  5354                                     // from sct to normal menu item
  4242                                     // from sct to normal menu item
  5355                                     iExtension->iSctHighlighted = EFalse;
  4243                                     iExtension->iSctHighlighted = EFalse;
  5356                                     iExtension->iSct->HighlightSctRow( iExtension->iSctHighlighted );
  4244                                     iExtension->iSct->HighlightSctRow( iExtension->iSctHighlighted );
  5357                                     }
  4245                                     }
  5358 
  4246 
  5359 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  5360                                 if ( effects )
       
  5361                                     {
       
  5362                                     transApi->SetMoveType( MAknListBoxTfxInternal::EListTap );
       
  5363                                     }
       
  5364 #endif
       
  5365                                 iExtension->iPressedDown = ETrue;
  4247                                 iExtension->iPressedDown = ETrue;
  5366 
  4248 
  5367                                 // Start timer for pressed highlight
  4249                                 // Start timer for pressed highlight
  5368                                 if ( !noSelection )
  4250                                 if ( !noSelection )
  5369                                     {
  4251                                     {
  5380                                     }
  4262                                     }
  5381                                 if ( noSelection )
  4263                                 if ( noSelection )
  5382                                     {
  4264                                     {
  5383                                     iExtension->iButtonDownItem = KErrNotFound;
  4265                                     iExtension->iButtonDownItem = KErrNotFound;
  5384                                     }
  4266                                     }
  5385 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  4267 
  5386                                 if ( effects )
       
  5387                                     {
       
  5388                                     transApi->Draw( Rect() );
       
  5389                                     }
       
  5390 #endif
       
  5391                                 // if new item has submenu, show it
  4268                                 // if new item has submenu, show it
  5392                                 if ( item->iData.iCascadeId )
  4269                                 if ( item->iData.iCascadeId )
  5393                                     {
  4270                                     {
  5394                                     if ( !iExtension->IsCascadeMenuTimerActive() )
  4271                                     if ( !iExtension->IsCascadeMenuTimerActive() )
  5395                                         {
  4272                                         {
  5413                     _AKNTRACE_FUNC_EXIT;
  4290                     _AKNTRACE_FUNC_EXIT;
  5414                     return iOwner->HandlePointerEventL( parentEvent );
  4291                     return iOwner->HandlePointerEventL( parentEvent );
  5415                     }
  4292                     }
  5416                 else
  4293                 else
  5417                     {
  4294                     {
  5418                     if ( iExtension->iIsPenEnable ) 
  4295                     // For finger usability, extend to the right.
       
  4296                     TRect innerToRightRect;
       
  4297                     if ( AknLayoutUtils::LayoutMirrored() )
  5419                         {
  4298                         {
  5420                         // For finger usability, extend to the right.
  4299                         innerToRightRect = TRect( Rect().iTl, innerRect.iBr );
  5421                         TRect innerToRightRect;
  4300                         }
  5422                         if ( AknLayoutUtils::LayoutMirrored() )
  4301                     else
       
  4302                         {
       
  4303                         innerToRightRect = TRect( innerRect.iTl, Rect().iBr );
       
  4304                         }
       
  4305                     // Keep opened
       
  4306                     if ( innerToRightRect.Contains( aPointerEvent.iPosition ) ) 
       
  4307                         {
       
  4308                         break;
       
  4309                         }
       
  4310 
       
  4311                     // clicked outside, then close menu case by case
       
  4312                     if ( iCascadeMenuPane )
       
  4313                         {
       
  4314                         if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
  5423                             {
  4315                             {
  5424                             innerToRightRect = TRect( Rect().iTl, innerRect.iBr );
  4316                             iExtension->ImmediateFeedback( ETouchFeedbackDecreasingPopUp );
  5425                             }
  4317                             }
  5426                         else
  4318                         else
  5427                             {
  4319                             {
  5428                             innerToRightRect = TRect( innerRect.iTl, Rect().iBr );
  4320                             iExtension->ImmediateFeedback( ETouchFeedbackPopUp );
  5429                             }
       
  5430                         // Keep opened
       
  5431                         if ( innerToRightRect.Contains( aPointerEvent.iPosition ) ) 
       
  5432                             {
       
  5433                             break;
       
  5434                             }
       
  5435                         }
       
  5436                     // clicked outside, then close menu case by case
       
  5437                     if ( iCascadeMenuPane )
       
  5438                         {
       
  5439                         if( AknLayoutUtils::PenEnabled() )
       
  5440                             {                            
       
  5441                             if ( CAknTransitionUtils::TransitionsEnabled( AknTransEffect::EComponentTransitionsOff ) )
       
  5442                                 {
       
  5443                                 iExtension->ImmediateFeedback( ETouchFeedbackDecreasingPopUp );
       
  5444                                 }
       
  5445                             else
       
  5446                                 {
       
  5447                                 iExtension->ImmediateFeedback( ETouchFeedbackPopUp );
       
  5448                                 }
       
  5449                             }
  4321                             }
  5450                         iExtension->iShowCascadeTransition = ETrue;
  4322                         iExtension->iShowCascadeTransition = ETrue;
  5451                         CloseCascadeMenu(); //Just close sub menu.
  4323                         CloseCascadeMenu(); //Just close sub menu.
  5452                         iExtension->EnableHighlight( EFalse );
  4324                         iExtension->EnableHighlight( EFalse );
  5453                         RepaintHighlight();
  4325                         RepaintHighlight();
  5492                 iExtension->iButtonDownItem = KErrNotFound;
  4364                 iExtension->iButtonDownItem = KErrNotFound;
  5493                 iExtension->ResetPressedHighlight();
  4365                 iExtension->ResetPressedHighlight();
  5494                 iExtension->iNextHighlightItem = KErrNotFound;
  4366                 iExtension->iNextHighlightItem = KErrNotFound;
  5495                 iExtension->iPanningActive = ETrue;
  4367                 iExtension->iPanningActive = ETrue;
  5496                 iExtension->EnableHighlight( EFalse );
  4368                 iExtension->EnableHighlight( EFalse );
  5497 
       
  5498 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  5499                 MAknListBoxTfx* tfxApi = CAknListLoader::TfxApi( iExtension->iGc );
       
  5500 
       
  5501                 if ( tfxApi )
       
  5502                     {
       
  5503                     tfxApi->EnableEffects( EFalse );
       
  5504                     }
       
  5505 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  5506                 }    
  4369                 }    
  5507                          
  4370                          
  5508             if ( iExtension->iPanningActive )
  4371             if ( iExtension->iPanningActive )
  5509                 {
  4372                 {
  5510                 TPoint delta( 
  4373                 TPoint delta( 
  5541                             // if submenu open and touched item is not the one which opened submenu, then close submenu
  4404                             // if submenu open and touched item is not the one which opened submenu, then close submenu
  5542                             if ( (ii != iSelectedItem)
  4405                             if ( (ii != iSelectedItem)
  5543                                     && !cascadeMenuRect.Contains(
  4406                                     && !cascadeMenuRect.Contains(
  5544                                             aPointerEvent.iPosition ) )
  4407                                             aPointerEvent.iPosition ) )
  5545                                 {
  4408                                 {
  5546                                 if ( AknLayoutUtils::PenEnabled() )
  4409                                 if ( CAknTransitionUtils::TransitionsEnabled(
       
  4410                                         AknTransEffect::EComponentTransitionsOff ) )
  5547                                     {
  4411                                     {
  5548                                     if ( CAknTransitionUtils::TransitionsEnabled(
  4412                                     iExtension->ImmediateFeedback(
  5549                                             AknTransEffect::EComponentTransitionsOff ) )
  4413                                             ETouchFeedbackDecreasingPopUp );
  5550                                         {
  4414                                     }
  5551                                         iExtension->ImmediateFeedback(
  4415                                 else
  5552                                                 ETouchFeedbackDecreasingPopUp );
  4416                                     {
  5553                                         }
  4417                                     iExtension->ImmediateFeedback(
  5554                                     else
  4418                                             ETouchFeedbackPopUp );
  5555                                         {
       
  5556                                         iExtension->ImmediateFeedback(
       
  5557                                                 ETouchFeedbackPopUp );
       
  5558                                         }
       
  5559                                     }
  4419                                     }
  5560                                 iExtension->iShowCascadeTransition = ETrue;
  4420                                 iExtension->iShowCascadeTransition = ETrue;
  5561                                 CloseCascadeMenu();
  4421                                 CloseCascadeMenu();
  5562                                 }
  4422                                 }
  5563                             }
  4423                             }
  5566                             TInt oldSelected = iSelectedItem;
  4426                             TInt oldSelected = iSelectedItem;
  5567                             // update highlight to new item
  4427                             // update highlight to new item
  5568                             if ( oldSelected != ii )
  4428                             if ( oldSelected != ii )
  5569                                 {
  4429                                 {
  5570                                 iExtension->iPressedDown = EFalse;
  4430                                 iExtension->iPressedDown = EFalse;
  5571 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  5572                                 if ( effects
       
  5573                                         && !iExtension->iShowCascadeTransition )
       
  5574                                     {
       
  5575                                     transApi->SetMoveType(
       
  5576                                             MAknListBoxTfxInternal::EListDrag );
       
  5577                                     }
       
  5578 #endif
       
  5579                                 }
  4431                                 }
  5580                             TRect screenRect( TPoint( KMinTInt, KMinTInt ),
  4432                             TRect screenRect( TPoint( KMinTInt, KMinTInt ),
  5581                                     TPoint( KMaxTInt, KMaxTInt ) );
  4433                                     TPoint( KMaxTInt, KMaxTInt ) );
  5582                             TRect repeatRect( screenRect.iTl.iX, item->iPos,
  4434                             TRect repeatRect( screenRect.iTl.iX, item->iPos,
  5583                                     screenRect.iBr.iX, item->iPos
  4435                                     screenRect.iBr.iX, item->iPos
  5816 // -----------------------------------------------------------------------------
  4668 // -----------------------------------------------------------------------------
  5817 //
  4669 //
  5818 EXPORT_C void CEikMenuPane::SetSelectedItem( TInt aSelectedItem )
  4670 EXPORT_C void CEikMenuPane::SetSelectedItem( TInt aSelectedItem )
  5819     {
  4671     {
  5820     iSelectedItem = (aSelectedItem >= NumberOfItemsInPane() ) ? 0 : aSelectedItem;
  4672     iSelectedItem = (aSelectedItem >= NumberOfItemsInPane() ) ? 0 : aSelectedItem;
  5821 
       
  5822     if( iExtension )
       
  5823         iExtension->ChangeHighlightBackground();
       
  5824     }
  4673     }
  5825 
  4674 
  5826 // -----------------------------------------------------------------------------
  4675 // -----------------------------------------------------------------------------
  5827 // CEikMenuPane::SelectedItem
  4676 // CEikMenuPane::SelectedItem
  5828 // -----------------------------------------------------------------------------
  4677 // -----------------------------------------------------------------------------
  5914 //----------------------------------------------------------------------------
  4763 //----------------------------------------------------------------------------
  5915 //
  4764 //
  5916 void CEikMenuPane::HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType )
  4765 void CEikMenuPane::HandleScrollEventL( CEikScrollBar* aScrollBar, TEikScrollEvent aEventType )
  5917     {
  4766     {
  5918     _AKNTRACE_FUNC_ENTER;
  4767     _AKNTRACE_FUNC_ENTER;
  5919     if( !AknLayoutUtils::PenEnabled())
       
  5920         {
       
  5921         return;
       
  5922         }
       
  5923 
  4768 
  5924     _AKNTRACE( "[%s]", "Stop physics engine");
  4769     _AKNTRACE( "[%s]", "Stop physics engine");
  5925     iExtension->iPhysics->StopPhysics();
  4770     iExtension->iPhysics->StopPhysics();
  5926     iExtension->iPhysics->ResetFriction();
  4771     iExtension->iPhysics->ResetFriction();
  5927 
  4772 
  5965         }
  4810         }
  5966 
  4811 
  5967     // Items that becomes topmost and downmost items
  4812     // Items that becomes topmost and downmost items
  5968     TInt newTopItem = 0;
  4813     TInt newTopItem = 0;
  5969 
  4814 
  5970 
       
  5971     // if update is not wanted, do nothing.
  4815     // if update is not wanted, do nothing.
  5972     if ( update )
  4816     if ( update )
  5973         {
  4817         {
  5974 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  5975         MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal(
       
  5976                 iExtension->iGc );
       
  5977         TBool effects = transApi && !transApi->EffectsDisabled();
       
  5978 #endif
       
  5979 
       
  5980         switch (aEventType)
  4818         switch (aEventType)
  5981             {
  4819             {
  5982             case EEikScrollUp:
  4820             case EEikScrollUp:
  5983                 {
  4821                 {
  5984                 _AKNTRACE( "[%s]", "EEikScrollUp");
  4822                 _AKNTRACE( "[%s]", "EEikScrollUp");
  6036 
  4874 
  6037             case EEikScrollPageDown:
  4875             case EEikScrollPageDown:
  6038                 {
  4876                 {
  6039                 _AKNTRACE( "[%s]", "EEikScrollPageDown");
  4877                 _AKNTRACE( "[%s]", "EEikScrollPageDown");
  6040                 _AKNTRACE( "bottomItem = %d", bottomItem);
  4878                 _AKNTRACE( "bottomItem = %d", bottomItem);
  6041                 // if last item is not visible
  4879                 update = ETrue;
  6042                 if ( bottomItem < countOfItems)
       
  6043                     {
       
  6044                     // move menu to show one site down or then downmost items.
       
  6045                     newTopItem = (bottomItem <=  (countOfItems - itemsThatFitToView)) ? (topItem + itemsThatFitToView) : (countOfItems - itemsThatFitToView);
       
  6046                     }
       
  6047                 else
       
  6048                     {
       
  6049                     update = EFalse;
       
  6050                     }
       
  6051                 _AKNTRACE( "newTopItem = %d", newTopItem);
       
  6052                 _AKNTRACE( "update = %d", update);
  4880                 _AKNTRACE( "update = %d", update);
  6053                 }
  4881                 }
  6054                 break;
  4882                 break;
  6055 
  4883 
  6056             case EEikScrollThumbDragVert:
  4884             case EEikScrollThumbDragVert:
  6057                 {
  4885                 {
  6058                 _AKNTRACE( "[%s]", "EEikScrollThumbDragVert");
  4886                 _AKNTRACE( "[%s]", "EEikScrollThumbDragVert");
  6059 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  6060 
       
  6061                 if ( effects )
       
  6062                     {
       
  6063                     MAknListBoxTfx* tfxApi = CAknListLoader::TfxApi( iExtension->iGc );
       
  6064                     
       
  6065                     if ( tfxApi )
       
  6066                         {
       
  6067                         tfxApi->EnableEffects( EFalse );
       
  6068                         effects = EFalse;
       
  6069                         }
       
  6070                     }
       
  6071 #endif
       
  6072                 // new thumb position
  4887                 // new thumb position
  6073                 TInt thumb = aScrollBar->ThumbPosition();
  4888                 TInt thumb = aScrollBar->ThumbPosition();
  6074                 _AKNTRACE( "thumb = %d", thumb);
  4889                 _AKNTRACE( "thumb = %d", thumb);
  6075 
  4890                 update = ETrue;
  6076                 // did dragging cause scrolling
       
  6077                 if ( thumb != topItem )
       
  6078                     {
       
  6079                     newTopItem = thumb;
       
  6080                     }
       
  6081                 else
       
  6082                     {
       
  6083                     update = EFalse;
       
  6084                     }
       
  6085                 _AKNTRACE( "newTopItem = %d", newTopItem);
       
  6086                 _AKNTRACE( "update = %d", update);
  4891                 _AKNTRACE( "update = %d", update);
  6087                 }
  4892                 }
  6088                 break;
  4893                 break;
  6089 
  4894 
  6090             case EEikScrollThumbReleaseVert:
       
  6091                 {
       
  6092 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  6093                 MAknListBoxTfx* tfxApi = CAknListLoader::TfxApi( iExtension->iGc );
       
  6094                 
       
  6095                 if ( tfxApi )
       
  6096                     {
       
  6097                     tfxApi->EnableEffects( ETrue );
       
  6098                     }
       
  6099 #endif
       
  6100                 }
       
  6101                 return;
       
  6102                 
       
  6103             default:
  4895             default:
  6104                 update = EFalse;
  4896                 update = EFalse;
  6105                 break;
  4897                 break;
  6106             }
  4898             }
  6107 
  4899 
  6108 
  4900         // if topItem changed, then draw menu again.
  6109 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
  4901         if ( newTopItem != topItem || update )
  6110             if ( effects )
  4902             {
  6111                 {
  4903             iExtension->iListTopIndex = aScrollBar->ThumbPosition();
  6112                 transApi->SetMoveType( newTopItem > topItem ?
  4904             TPoint newPosition( iExtension->iViewPosition.iX,
  6113                     MAknListBoxTfxInternal::EListScrollDown :
  4905                     iExtension->iListTopIndex + iExtension->iViewHeight / 2 );
  6114                     MAknListBoxTfxInternal::EListScrollUp );
       
  6115                 }
       
  6116 #endif
       
  6117 
       
  6118             
  4906             
  6119             iExtension->iListTopIndex = aScrollBar->ThumbPosition();
  4907             iExtension->iFlags.Set( CEikMenuPaneExtension::ESkipScrollbarUpdate );
  6120                            
  4908             iExtension->ViewPositionChanged( newPosition );
  6121             iExtension->iViewPosition.iY = 
  4909             iExtension->iFlags.Clear( CEikMenuPaneExtension::ESkipScrollbarUpdate );
  6122                 iExtension->iListTopIndex + iExtension->iViewHeight / 2;              
  4910             }
  6123                           
       
  6124             iExtension->ViewPositionChanged( iExtension->iViewPosition );
       
  6125 
       
  6126         }
  4911         }
  6127     _AKNTRACE_FUNC_EXIT;
  4912     _AKNTRACE_FUNC_EXIT;
  6128     }
  4913     }
       
  4914 
  6129 
  4915 
  6130 // -----------------------------------------------------------------------------
  4916 // -----------------------------------------------------------------------------
  6131 // CEikMenuPane::CreateScrollBarFrame
  4917 // CEikMenuPane::CreateScrollBarFrame
  6132 // -----------------------------------------------------------------------------
  4918 // -----------------------------------------------------------------------------
  6133 //
  4919 //
  6138     TRAPD( err,( iSBFrame = new(ELeave) CEikScrollBarFrame( this, iScroller, ETrue, ETrue ) ) );
  4924     TRAPD( err,( iSBFrame = new(ELeave) CEikScrollBarFrame( this, iScroller, ETrue, ETrue ) ) );
  6139     if ( !err )
  4925     if ( !err )
  6140         {
  4926         {
  6141         CEikScrollBarFrame::TScrollBarVisibility visibility = CEikScrollBarFrame::EOn;
  4927         CEikScrollBarFrame::TScrollBarVisibility visibility = CEikScrollBarFrame::EOn;
  6142 
  4928 
  6143         if ( iOwner && ( iItemArray->Count() <= NumberOfItemsThatFitInView() ) )
  4929         if ( iItemArray->Count() <= NumberOfItemsThatFitInView() )
  6144             {
  4930             {
  6145             // submenu with less than 6 items
  4931             // all items fit, no need to show the scrollbar
  6146             visibility = CEikScrollBarFrame::EOff;
  4932             visibility = CEikScrollBarFrame::EOff;
  6147             }
  4933             }
  6148         TRAP_IGNORE( iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, visibility /*CEikScrollBarFrame::EAuto*/ ) );
  4934 
  6149 
  4935         TRAP_IGNORE( iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, visibility ) );
  6150         TRAP_IGNORE( iSBFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse, ETrue, EFalse ) );
  4936         TRAP_IGNORE( iSBFrame->CreateDoubleSpanScrollBarsL( EFalse, EFalse, ETrue, EFalse ) );
  6151         iSBFrame->DrawBackground( EFalse, EFalse );
  4937         iSBFrame->DrawBackground( EFalse, EFalse );
  6152         UpdateScrollBar();
  4938         UpdateScrollBar();
  6153         }
  4939         }
  6154     }
  4940     }
  6158 // CEikMenuPane::UpdateScrollBar
  4944 // CEikMenuPane::UpdateScrollBar
  6159 // -----------------------------------------------------------------------------
  4945 // -----------------------------------------------------------------------------
  6160 //
  4946 //
  6161 void CEikMenuPane::UpdateScrollBar()
  4947 void CEikMenuPane::UpdateScrollBar()
  6162     {
  4948     {
  6163     if ( !CheckCreateScroller() )
  4949     if ( !CheckCreateScroller() || !IsVisible() )
  6164         return;
  4950         return;
  6165     CIdle* idle = iScroller->Idle();
  4951     CIdle* idle = iScroller->Idle();
  6166     if ( idle && !idle->IsActive() )
  4952     if ( idle && !idle->IsActive() )
  6167         idle->Start( TCallBack( CEikMenuPane::UpdateScrollBarCallBackL, this ) );
  4953         idle->Start( TCallBack( CEikMenuPane::UpdateScrollBarCallBackL, this ) );
  6168     }
  4954     }
  6169 
  4955 
       
  4956 
  6170 // -----------------------------------------------------------------------------
  4957 // -----------------------------------------------------------------------------
  6171 // CEikMenuPane::UpdateScrollBarCallBackL
  4958 // CEikMenuPane::UpdateScrollBarCallBackL
  6172 // -----------------------------------------------------------------------------
  4959 // -----------------------------------------------------------------------------
  6173 //
  4960 //
  6174 TInt CEikMenuPane::UpdateScrollBarCallBackL( TAny* aObj )
  4961 TInt CEikMenuPane::UpdateScrollBarCallBackL( TAny* aObj )
  6175     { // static
  4962     { // static
  6176     REINTERPRET_CAST(CEikMenuPane*,aObj)->DoUpdateScrollBarL();
  4963     REINTERPRET_CAST(CEikMenuPane*,aObj)->DoUpdateScrollBarL();
  6177     return 0;
  4964     return 0;
  6178     }
  4965     }
       
  4966 
  6179 
  4967 
  6180 // -----------------------------------------------------------------------------
  4968 // -----------------------------------------------------------------------------
  6181 // CEikMenuPane::DoUpdateScrollBarL
  4969 // CEikMenuPane::DoUpdateScrollBarL
  6182 // -----------------------------------------------------------------------------
  4970 // -----------------------------------------------------------------------------
  6183 //
  4971 //
  6187         return;
  4975         return;
  6188     _AKNTRACE_FUNC_ENTER;
  4976     _AKNTRACE_FUNC_ENTER;
  6189     TEikScrollBarModel hSbarModel;
  4977     TEikScrollBarModel hSbarModel;
  6190     TEikScrollBarModel vSbarModel;
  4978     TEikScrollBarModel vSbarModel;
  6191 
  4979 
  6192     TRect menuPaneRect;
  4980     TRect clientRect( iExtension->iMenuPaneRect.Size() );
  6193     if ( !iOwner )
       
  6194         {
       
  6195         menuPaneRect = iExtension->iMenuPaneRect;    
       
  6196         }
       
  6197     else
       
  6198         {
       
  6199         menuPaneRect = Rect();    
       
  6200         }
       
  6201     
       
  6202     TRect clientRect( menuPaneRect.Size() ); 
       
  6203 
  4981 
  6204     // Panning uses pixel resolution scrollbar
  4982     // Panning uses pixel resolution scrollbar
  6205     vSbarModel.iThumbPosition = iExtension->iListTopIndex;      
  4983     vSbarModel.iThumbPosition = iExtension->iListTopIndex;      
  6206     vSbarModel.iScrollSpan = TotalItemHeight();
  4984     vSbarModel.iScrollSpan = TotalItemHeight();
  6207     vSbarModel.iThumbSpan = iExtension->iViewHeight;
  4985     vSbarModel.iThumbSpan = iExtension->iViewHeight;
  6216     TEikScrollBarFrameLayout layout;
  4994     TEikScrollBarFrameLayout layout;
  6217     layout.SetClientMargin( 0 );
  4995     layout.SetClientMargin( 0 );
  6218     layout.SetInclusiveMargin( 0 );
  4996     layout.SetInclusiveMargin( 0 );
  6219     layout.iTilingMode = TEikScrollBarFrameLayout::EClientRectConstant;
  4997     layout.iTilingMode = TEikScrollBarFrameLayout::EClientRectConstant;
  6220 
  4998 
  6221     // For main menupane scrollbar is always shown, for submenu only when needed
  4999     CEikScrollBarFrame::TScrollBarVisibility visibility = 
  6222     if ( !iOwner )
  5000             iSBFrame->ScrollBarVisibility( CEikScrollBar::EVertical );
  6223         {
  5001     
  6224         iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, CEikScrollBarFrame::EOn );
  5002     // scrollbar is shown only if needed
  6225         }
  5003     if ( iExtension->iScrollbarVisibility == CEikScrollBarFrame::EOn 
  6226     else
  5004             && visibility == CEikScrollBarFrame::EOff )
  6227         {
  5005         {
  6228         TInt maxItems = NumberOfItemsThatFitInView();
  5006         iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
  6229         TInt count = iItemArray->Count();
  5007                 CEikScrollBarFrame::EOn );
  6230         iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff,
  5008         iExtension->iScrollBarRect = iSBFrame->VerticalScrollBar()->Rect();
  6231             (count > maxItems) ? CEikScrollBarFrame::EOn : CEikScrollBarFrame::EOff );
  5009         }
  6232         }
  5010     else if ( iExtension->iScrollbarVisibility == CEikScrollBarFrame::EOff 
  6233 
  5011             && visibility == CEikScrollBarFrame::EOn )
       
  5012         {
       
  5013         iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, 
       
  5014                 CEikScrollBarFrame::EOff );
       
  5015         iExtension->iScrollBarRect = TRect::EUninitialized;
       
  5016         }
       
  5017     
  6234     TAknLayoutRect scrollLayoutRect;
  5018     TAknLayoutRect scrollLayoutRect;
  6235     if ( !iOwner )
  5019     scrollLayoutRect.LayoutRect( clientRect, 
  6236         {
  5020             AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
  6237         TAknWindowLineLayout listScrollPaneLayout( 
  5021     scrollBarInclusiveRect = scrollLayoutRect.Rect();
  6238             AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
  5022     scrollBarClientRect = scrollBarInclusiveRect;
  6239         if ( iExtension )
  5023 
  6240             {
  5024     AknLayoutUtils::LayoutVerticalScrollBar( iSBFrame, scrollBarClientRect,
  6241             iExtension->AdjustPopupLayoutData( listScrollPaneLayout );
  5025       AknLayoutScalable_Avkon::scroll_pane_cp4().LayoutLine());
  6242             }
       
  6243         scrollLayoutRect.LayoutRect( clientRect, listScrollPaneLayout );
       
  6244         scrollBarInclusiveRect =  scrollLayoutRect.Rect();
       
  6245         scrollBarClientRect = scrollBarInclusiveRect;
       
  6246 
       
  6247         AknLayoutUtils::LayoutVerticalScrollBar( iSBFrame, scrollBarClientRect,
       
  6248             AknLayoutScalable_Avkon::scroll_pane_cp25(0).LayoutLine() );
       
  6249         }
       
  6250     else
       
  6251         {
       
  6252         scrollLayoutRect.LayoutRect( clientRect, 
       
  6253                 AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
       
  6254         scrollBarInclusiveRect = scrollLayoutRect.Rect();
       
  6255         scrollBarClientRect = scrollBarInclusiveRect;
       
  6256 
       
  6257         AknLayoutUtils::LayoutVerticalScrollBar( iSBFrame, scrollBarClientRect,
       
  6258           AknLayoutScalable_Avkon::scroll_pane_cp4().LayoutLine());
       
  6259         }
       
  6260 
  5026 
  6261     iSBFrame->TileL( &hDsSbarModel, &vDsSbarModel, scrollBarClientRect, scrollBarInclusiveRect, layout );
  5027     iSBFrame->TileL( &hDsSbarModel, &vDsSbarModel, scrollBarClientRect, scrollBarInclusiveRect, layout );
  6262     iSBFrame->SetVFocusPosToThumbPos( vDsSbarModel.FocusPosition() );
  5028     iSBFrame->SetVFocusPosToThumbPos( vDsSbarModel.FocusPosition() );
  6263     
       
  6264 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  6265     MAknListBoxTfxInternal* transApi = CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  6266     if ( iSBFrame->VerticalScrollBar() &&
       
  6267          iSBFrame->VScrollBarVisibility() == CEikScrollBarFrame::EOn )
       
  6268         {
       
  6269         iExtension->iScrollBarRect = iSBFrame->VerticalScrollBar()->Rect();
       
  6270         }
       
  6271     else
       
  6272         {
       
  6273         iExtension->iScrollBarRect = TRect::EUninitialized;
       
  6274         }
       
  6275     if ( transApi )
       
  6276         {
       
  6277         transApi->ResetNonDrawingRects();
       
  6278         transApi->AddNonDrawingRect( iExtension->iScrollBarRect );
       
  6279         transApi->AddNonDrawingRect( iExtension->iSctRect );
       
  6280         }
       
  6281 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
  6282     if ( iSBFrame->VerticalScrollBar() &&
       
  6283          iSBFrame->VScrollBarVisibility() == CEikScrollBarFrame::EOn )
       
  6284         {
       
  6285         iExtension->iSBRect = iSBFrame->VerticalScrollBar()->Rect();       
       
  6286         }
       
  6287     else
       
  6288         {
       
  6289         iExtension->iSBRect = TRect::EUninitialized;
       
  6290         }        
       
  6291     _AKNTRACE_FUNC_EXIT;
  5029     _AKNTRACE_FUNC_EXIT;
  6292     }
  5030     }
  6293 
  5031 
       
  5032 
  6294 // -----------------------------------------------------------------------------
  5033 // -----------------------------------------------------------------------------
  6295 // CEikMenuPane::UpdateScrollBarThumbs
  5034 // CEikMenuPane::UpdateScrollBarThumbs
  6296 // -----------------------------------------------------------------------------
  5035 // -----------------------------------------------------------------------------
  6297 //
  5036 //
  6298 void CEikMenuPane::UpdateScrollBarThumbs()
  5037 void CEikMenuPane::UpdateScrollBarThumbs()
  6300     if ( iSBFrame )
  5039     if ( iSBFrame )
  6301         {
  5040         {
  6302         iSBFrame->SetVFocusPosToThumbPos( iExtension->iListTopIndex );             
  5041         iSBFrame->SetVFocusPosToThumbPos( iExtension->iListTopIndex );             
  6303         }
  5042         }
  6304     }
  5043     }
       
  5044 
  6305 
  5045 
  6306 // -----------------------------------------------------------------------------
  5046 // -----------------------------------------------------------------------------
  6307 // CEikMenuPane::ScrollToMakeItemVisible
  5047 // CEikMenuPane::ScrollToMakeItemVisible
  6308 // -----------------------------------------------------------------------------
  5048 // -----------------------------------------------------------------------------
  6309 //
  5049 //
  6354             }        
  5094             }        
  6355         }
  5095         }
  6356     _AKNTRACE_FUNC_EXIT;
  5096     _AKNTRACE_FUNC_EXIT;
  6357     return;
  5097     return;
  6358     }
  5098     }
       
  5099 
  6359 
  5100 
  6360 // -----------------------------------------------------------------------------
  5101 // -----------------------------------------------------------------------------
  6361 // CEikMenuPane::Scroll
  5102 // CEikMenuPane::Scroll
  6362 // -----------------------------------------------------------------------------
  5103 // -----------------------------------------------------------------------------
  6363 //
  5104 //
  6398 
  5139 
  6399     _AKNTRACE_FUNC_EXIT;
  5140     _AKNTRACE_FUNC_EXIT;
  6400     return;
  5141     return;
  6401     }
  5142     }
  6402 
  5143 
       
  5144 
  6403 // -----------------------------------------------------------------------------
  5145 // -----------------------------------------------------------------------------
  6404 // CEikMenuPane::ViewRect
  5146 // CEikMenuPane::ViewRect
  6405 // -----------------------------------------------------------------------------
  5147 // -----------------------------------------------------------------------------
  6406 //
  5148 //
  6407 TRect CEikMenuPane::ViewRect() const
  5149 TRect CEikMenuPane::ViewRect() const
  6408     {
  5150     {
  6409     return Rect();
  5151     return Rect();
  6410     }
  5152     }
       
  5153 
  6411 
  5154 
  6412 // -----------------------------------------------------------------------------
  5155 // -----------------------------------------------------------------------------
  6413 // CEikMenuPane::NumberOfItemsThatFitInView
  5156 // CEikMenuPane::NumberOfItemsThatFitInView
  6414 // -----------------------------------------------------------------------------
  5157 // -----------------------------------------------------------------------------
  6415 //
  5158 //
  6418     TInt subst = 0;
  5161     TInt subst = 0;
  6419     if ( iExtension->iSct )
  5162     if ( iExtension->iSct )
  6420         {
  5163         {
  6421         subst = 1;
  5164         subst = 1;
  6422         }
  5165         }
  6423 #ifdef RD_UI_TRANSITION_EFFECTS_LIST        
  5166 
  6424     iExtension->iItemsThatFitInView = iOwner ? AknLayoutScalable_Avkon::
  5167     iExtension->iItemsThatFitInView = iOwner ? AknLayoutScalable_Avkon::
  6425         list_single_popup_submenu_pane_ParamLimits().LastRow() + 1 :
  5168         list_single_popup_submenu_pane_ParamLimits().LastRow() + 1 :
  6426         AknLayoutScalable_Avkon::
  5169         AknLayoutScalable_Avkon::
  6427         list_single_pane_cp2_ParamLimits().LastRow() + 1 - subst;
  5170         list_single_pane_cp2_ParamLimits().LastRow() + 1 - subst;
  6428         if ( Layout_Meta_Data::IsLandscapeOrientation() 
  5171         if ( Layout_Meta_Data::IsLandscapeOrientation() 
  6429              && iExtension->iItemsThatFitInView == 6 )
  5172              && iExtension->iItemsThatFitInView == 6 )
  6430             {
  5173             {
  6431             iExtension->iItemsThatFitInView --;
  5174             iExtension->iItemsThatFitInView --;
  6432             }
  5175             }
  6433         
  5176         
  6434     if ( iExtension->iPhysics && iExtension->Offset() != 0 )
       
  6435         {
       
  6436         // with kinetic scrolling there can be partial items on the screen 
       
  6437         iExtension->iTotalNumberOfItemsInView = iExtension->iItemsThatFitInView + 1;
       
  6438         }
       
  6439         
       
  6440     return iExtension->iItemsThatFitInView;
  5177     return iExtension->iItemsThatFitInView;
  6441 #else
  5178     }
  6442     return iOwner ? AknLayoutScalable_Avkon::
  5179 
  6443         list_single_popup_submenu_pane_ParamLimits().LastRow() + 1 :
       
  6444         AknLayoutScalable_Avkon::
       
  6445         list_single_pane_cp2_ParamLimits().LastRow() + 1 - subst;
       
  6446 #endif
       
  6447     }
       
  6448 
  5180 
  6449 // -----------------------------------------------------------------------------
  5181 // -----------------------------------------------------------------------------
  6450 // CEikMenuPane::TotalItemHeight
  5182 // CEikMenuPane::TotalItemHeight
  6451 // -----------------------------------------------------------------------------
  5183 // -----------------------------------------------------------------------------
  6452 //
  5184 //
  6480         {
  5212         {
  6481         TRAP( err,( iScroller = CMenuScroller::NewL( *this ) ) );
  5213         TRAP( err,( iScroller = CMenuScroller::NewL( *this ) ) );
  6482         }
  5214         }
  6483     return err == KErrNone;
  5215     return err == KErrNone;
  6484     }
  5216     }
       
  5217 
  6485 
  5218 
  6486 // -----------------------------------------------------------------------------
  5219 // -----------------------------------------------------------------------------
  6487 // CEikMenuPane::CheckCreateScrollerL
  5220 // CEikMenuPane::CheckCreateScrollerL
  6488 // -----------------------------------------------------------------------------
  5221 // -----------------------------------------------------------------------------
  6489 //
  5222 //
  6597 
  5330 
  6598             UpdateBackgroundContext( Rect() );
  5331             UpdateBackgroundContext( Rect() );
  6599             PrepareHighlightFrame();
  5332             PrepareHighlightFrame();
  6600             SetCascadedIconSize();
  5333             SetCascadedIconSize();
  6601 
  5334 
  6602             // Background under highlight may have changed -> we need to update
       
  6603             // highlight background to animation
       
  6604             if( iExtension )
       
  6605                 {
       
  6606                 iExtension->HandleLayoutSwitch();
       
  6607                 }
       
  6608                           
       
  6609 #ifdef RD_UI_TRANSITION_EFFECTS_LIST        
       
  6610             MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  6611             if ( transApi )
       
  6612                 {
       
  6613                 transApi->Remove( MAknListBoxTfxInternal:: EListEverything );
       
  6614                 }
       
  6615 #endif    
       
  6616             
       
  6617             //Initialize physics engine
  5335             //Initialize physics engine
  6618             if ( iExtension->iPhysics )
  5336             if ( iExtension->iPhysics )
  6619                 {
  5337                 {
  6620                 TRAP_IGNORE ( iExtension->InitPhysicsL() );
  5338                 TRAP_IGNORE ( iExtension->InitPhysicsL() );
  6621                 iExtension->iListTopIndex = iScroller->TopItemIndex() * iItemHeight;
  5339                 iExtension->iListTopIndex = iScroller->TopItemIndex() * iItemHeight;
  6669                 }
  5387                 }
  6670             }
  5388             }
  6671         }
  5389         }
  6672     else if ( aType == KAknMessageFocusLost )
  5390     else if ( aType == KAknMessageFocusLost )
  6673         {
  5391         {
  6674         if ( iExtension && iExtension->HighlightEnabled() )
  5392         if ( iCascadeMenuPane )
       
  5393             {
       
  5394             iCascadeMenuPane->HandleResourceChange( aType );
       
  5395             }
       
  5396         else if ( iExtension && iExtension->HighlightEnabled() )
  6675             {
  5397             {
  6676             iExtension->EnableHighlight( EFalse, EFalse );
  5398             iExtension->EnableHighlight( EFalse, EFalse );
  6677             DrawItem( iSelectedItem, ENoHighlight );
  5399             DrawItem( iSelectedItem, ENoHighlight );
  6678             }
  5400             }
  6679         }
  5401         }
  6941     _AKNTRACE_FUNC_ENTER;
  5663     _AKNTRACE_FUNC_ENTER;
  6942     TRect retVal;
  5664     TRect retVal;
  6943 
  5665 
  6944     // it can be only in submenu in case when scalable layout is available
  5666     // it can be only in submenu in case when scalable layout is available
  6945     TBool hasIcon = MenuHasIcon();
  5667     TBool hasIcon = MenuHasIcon();
  6946     TBool hasDoubleSpanScrollBar = EFalse;
  5668 
  6947 
  5669     // scrollbar is shown only if needed
  6948     if ( iSBFrame && iSBFrame->VScrollBarVisibility() )
  5670     if ( iItemArray->Count() > NumberOfItemsThatFitInView() )
  6949         {
  5671         {
  6950         _AKNTRACE( "[%s]", "hasDoubleSpanScrollBar = ETrue;" );
  5672         iExtension->iScrollbarVisibility = CEikScrollBarFrame::EOn;
  6951         hasDoubleSpanScrollBar = ETrue;
  5673         }
  6952         }
  5674     else
  6953 
  5675         {
       
  5676         iExtension->iScrollbarVisibility = CEikScrollBarFrame::EOff;
       
  5677         }
       
  5678     
  6954     TRect parentMenuRect;
  5679     TRect parentMenuRect;
  6955     AknLayoutUtils::TAknCbaLocation cbaPosition = AknLayoutUtils::CbaLocation();    
  5680     AknLayoutUtils::TAknCbaLocation cbaPosition = AknLayoutUtils::CbaLocation();    
  6956                 
  5681                 
  6957     if ( !iOwner )
  5682     if ( !iOwner )
  6958         {
  5683         {
  7040 
  5765 
  7041     _AKNTRACE( "parentMenuRect.iTl.iX = %d", parentMenuRect.iTl.iX );
  5766     _AKNTRACE( "parentMenuRect.iTl.iX = %d", parentMenuRect.iTl.iX );
  7042     _AKNTRACE( "parentMenuRect.iTl.iY = %d", parentMenuRect.iTl.iY );
  5767     _AKNTRACE( "parentMenuRect.iTl.iY = %d", parentMenuRect.iTl.iY );
  7043     _AKNTRACE( "parentMenuRect.Width() = %d", parentMenuRect.Width() );
  5768     _AKNTRACE( "parentMenuRect.Width() = %d", parentMenuRect.Width() );
  7044     _AKNTRACE( "parentMenuRect.Height( = %d", parentMenuRect.Height() );
  5769     _AKNTRACE( "parentMenuRect.Height( = %d", parentMenuRect.Height() );
  7045     // if we have landscape layout then main menu should be positioned vertically centered
       
  7046     TRect appRect( iEikonEnv->EikAppUi()->ApplicationRect() );
       
  7047 
  5770 
  7048     if ( !iOwner ) // main menu
  5771     if ( !iOwner ) // main menu
  7049         {
  5772         {
  7050         // Embedded cba
  5773         // Embedded cba
  7051         TRect screen;
  5774         TRect screen;
  7061 
  5784 
  7062         // CEikMenuPane rect contains empty space. We want the popup content
  5785         // CEikMenuPane rect contains empty space. We want the popup content
  7063         // to be in correct place - so we calculate correct position for
  5786         // to be in correct place - so we calculate correct position for
  7064         // background and move control rect to match new background top left
  5787         // background and move control rect to match new background top left
  7065         // position.
  5788         // position.
  7066         TRect backgroundRect( iExtension->GetBackgroundRect( parentMenuRect ) );
       
  7067         TPoint backgroundRectPos( 
  5789         TPoint backgroundRectPos( 
  7068             AknPopupUtils::Position( backgroundRect.Size(), ETrue ) );
  5790             AknPopupUtils::Position( parentMenuRect.Size(), ETrue ) );
  7069         
  5791         
  7070         retVal = parentMenuRect;
  5792         retVal = parentMenuRect;
  7071         retVal.Move( backgroundRectPos - backgroundRect.iTl );
  5793         retVal.Move( backgroundRectPos - parentMenuRect.iTl );
  7072         
  5794         
  7073         // Set embedded cba rect
  5795         // Set embedded cba rect
  7074         if ( iExtension->iCba )
  5796         if ( iExtension->iCba )
  7075             {
  5797             {
  7076             // There is hidden extra touch space for scroll bar in landscape
  5798             // There is hidden extra touch space for scroll bar in landscape
  7077             TInt xOffset = backgroundRect.iTl.iX - parentMenuRect.iTl.iX ; 
  5799             TInt xOffset = parentMenuRect.iTl.iX - parentMenuRect.iTl.iX ; 
  7078             iExtension->iCba->SetRect( TRect( 
  5800             iExtension->iCba->SetRect( TRect( 
  7079                 xOffset,
  5801                 xOffset,
  7080                 menuRect.Height(),
  5802                 menuRect.Height(),
  7081                 backgroundRect.Width() + xOffset,
  5803                 parentMenuRect.Width() + xOffset,
  7082                 menuRect.Height() + cbaRect.Rect().Height() ) );
  5804                 menuRect.Height() + cbaRect.Rect().Height() ) );
  7083             }
  5805             }
  7084 
  5806 
  7085         iExtension->iMenuPaneRect = TRect( retVal.iTl, 
  5807         iExtension->iMenuPaneRect = TRect( retVal.iTl, 
  7086                                            TSize ( menuRect.Size() ) );
  5808                                            TSize ( menuRect.Size() ) );
  7087                                         
  5809 
       
  5810         TInt variety = 4;
       
  5811         
       
  5812         // reserve area for scrollbar only if it's shown
       
  5813         if ( iExtension->iScrollbarVisibility == CEikScrollBarFrame::EOn )
       
  5814             {
       
  5815             variety = 0;
       
  5816             }
       
  5817 
       
  5818         TAknLayoutRect layoutRect;
       
  5819         layoutRect.LayoutRect( TRect( iExtension->iMenuPaneRect.Size() ), 
       
  5820                 AknLayoutScalable_Avkon::listscroll_popup_sub_pane( 0 ) );
       
  5821         
       
  5822         iExtension->iMenuAreaRect = layoutRect.Rect();
       
  5823         
       
  5824         layoutRect.LayoutRect( iExtension->iMenuAreaRect,
       
  5825                 AknLayoutScalable_Avkon::list_menu_pane( variety ) );
       
  5826 
       
  5827         iExtension->iItemAreaRect = layoutRect.Rect();
       
  5828         
  7088         _AKNTRACE( "[%s]", "the layout of main menu return" );
  5829         _AKNTRACE( "[%s]", "the layout of main menu return" );
  7089         _AKNTRACE_FUNC_EXIT;                               
  5830         _AKNTRACE_FUNC_EXIT;                               
  7090         return retVal;
  5831         return retVal;
  7091         }
  5832         }
  7092 
  5833 
  7095     TInt parentCount = iOwner->iItemArray->Count(); // There must be at least one parent item for a submenu to have popped up.
  5836     TInt parentCount = iOwner->iItemArray->Count(); // There must be at least one parent item for a submenu to have popped up.
  7096 
  5837 
  7097     iExtension->iSubMenuWidthIndex = KAlternativeSubmenuWidths - 1;
  5838     iExtension->iSubMenuWidthIndex = KAlternativeSubmenuWidths - 1;
  7098 
  5839 
  7099     TAknLayoutRect parentListScrollLayoutRect;     // listscroll_menu_pane
  5840     TAknLayoutRect parentListScrollLayoutRect;     // listscroll_menu_pane
  7100     TAknLayoutRect parentPaneLayoutRect;           // list_menu_pane
       
  7101 
  5841 
  7102     TAknTextLineLayout subMenuText;                // layout for the text when item is not indicated
  5842     TAknTextLineLayout subMenuText;                // layout for the text when item is not indicated
  7103     TAknTextLineLayout subMenuIconText;            // layout for the text when item is indicated
  5843     TAknTextLineLayout subMenuIconText;            // layout for the text when item is indicated
  7104 
  5844 
  7105     TAknWindowLineLayout parentListScrollPaneLayout( 
  5845     TAknWindowLineLayout parentListScrollPaneLayout( 
  7106         AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
  5846         AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
  7107     if ( iExtension )
       
  7108         {
       
  7109         iExtension->AdjustPopupLayoutData( parentListScrollPaneLayout );
       
  7110         }    
       
  7111     parentListScrollLayoutRect.LayoutRect( parentMenuRect, parentListScrollPaneLayout );    
  5847     parentListScrollLayoutRect.LayoutRect( parentMenuRect, parentListScrollPaneLayout );    
  7112     parentPaneLayoutRect.LayoutRect( parentListScrollLayoutRect.Rect(),
       
  7113         AknLayoutScalable_Avkon::list_menu_pane(0).LayoutLine() );
       
  7114     subMenuText = AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1(0).LayoutLine();
  5848     subMenuText = AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1(0).LayoutLine();
  7115     subMenuIconText = AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1(1).LayoutLine();
  5849     subMenuIconText = AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1(1).LayoutLine();
  7116 
  5850 
  7117     // Choose correct submenu width
  5851     // Choose correct submenu width
  7118     // Find the narrowest layout that will accommodate the text
  5852     // Find the narrowest layout that will accommodate the text
  7131         textWidth = font->TextWidthInPixels( item->iData.iText );
  5865         textWidth = font->TextWidthInPixels( item->iData.iText );
  7132         maxTextWidth = Max( maxTextWidth, textWidth );
  5866         maxTextWidth = Max( maxTextWidth, textWidth );
  7133         }
  5867         }
  7134 
  5868 
  7135     // find the suitable item width, so that the text would be visible
  5869     // find the suitable item width, so that the text would be visible
       
  5870     TInt submenuVariety = 1;
       
  5871     
       
  5872     if ( iExtension->iScrollbarVisibility == CEikScrollBarFrame::EOn )
       
  5873         {
       
  5874         submenuVariety = 0;
       
  5875         }
       
  5876 
  7136     for ( ii = 6; ii < KAlternativeSubmenuWidths + 6; ++ii )
  5877     for ( ii = 6; ii < KAlternativeSubmenuWidths + 6; ++ii )
  7137         {
  5878         {
  7138         TAknWindowLineLayout submenuLayout( AknLayoutScalable_Avkon::popup_submenu_window( ii ).LayoutLine() );
  5879         TAknWindowLineLayout submenuLayout( AknLayoutScalable_Avkon::popup_submenu_window( ii ).LayoutLine() );
  7139         TAknLayoutRect submenuRect;
  5880         TAknLayoutRect submenuRect;
  7140         submenuRect.LayoutRect( parentListScrollLayoutRect.Rect(), submenuLayout );
  5881         submenuRect.LayoutRect( parentListScrollLayoutRect.Rect(), submenuLayout );
  7141 
  5882 
  7142         TAknWindowLineLayout listScrollPaneLayout( AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
  5883         TAknWindowLineLayout listScrollPaneLayout( AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
  7143         TAknLayoutRect listScrollPaneRect;
  5884         TAknLayoutRect listScrollPaneRect;
  7144         listScrollPaneRect.LayoutRect( submenuRect.Rect(), listScrollPaneLayout );
  5885         listScrollPaneRect.LayoutRect( submenuRect.Rect(), listScrollPaneLayout );
  7145 
  5886 
  7146         TAknWindowLineLayout listSubmenuPaneLayout( AknLayoutScalable_Avkon::list_submenu_pane( !hasDoubleSpanScrollBar ).LayoutLine() );
  5887         TAknWindowLineLayout listSubmenuPaneLayout( AknLayoutScalable_Avkon::list_submenu_pane( submenuVariety ).LayoutLine() );
  7147         TAknLayoutRect listSubmenuPaneRect;
  5888         TAknLayoutRect listSubmenuPaneRect;
  7148         listSubmenuPaneRect.LayoutRect( listScrollPaneRect.Rect(), listSubmenuPaneLayout );
  5889         listSubmenuPaneRect.LayoutRect( listScrollPaneRect.Rect(), listSubmenuPaneLayout );
  7149 
  5890 
  7150         TAknLayoutText textIconLayout;
  5891         TAknLayoutText textIconLayout;
  7151         textIconLayout.LayoutText( listSubmenuPaneRect.Rect(), subMenuIconText);
  5892         textIconLayout.LayoutText( listSubmenuPaneRect.Rect(), subMenuIconText);
  7173 
  5914 
  7174     // Position of submenu depends upon parent size and position of selected item. Position is 1 at bottom up to six at top
  5915     // Position of submenu depends upon parent size and position of selected item. Position is 1 at bottom up to six at top
  7175     TInt parentPos = iOwner->iScroller->TopItemIndex() - iOwner->SelectedItem() +
  5916     TInt parentPos = iOwner->iScroller->TopItemIndex() - iOwner->SelectedItem() +
  7176         Min( parentCount, iOwner->NumberOfItemsThatFitInView() );
  5917         Min( parentCount, iOwner->NumberOfItemsThatFitInView() );
  7177 
  5918 
  7178     TInt index =  iOwner->SelectedItem() - iOwner->iScroller->TopItemIndex();
  5919     TRect parentSelectedItemRect( iOwner->HighlightRect() );
  7179     TInt rows = AknLayoutScalable_Avkon::list_single_pane_cp2_ParamLimits().LastRow();
  5920     parentSelectedItemRect.Move( iOwner->Position() );
  7180 
       
  7181     // This condition may be true if less items fits to menu view than sub-menu view
       
  7182     // and sub-menu under sub-menu is launched.
       
  7183     if (index > rows)
       
  7184         {
       
  7185         // Change the out-of-boundary index to last legal one.
       
  7186         index = rows;
       
  7187         }
       
  7188 
       
  7189     TAknLayoutRect parentSelectedItemRect;
       
  7190     parentSelectedItemRect.LayoutRect( parentPaneLayoutRect.Rect(),
       
  7191         AknLayoutScalable_Avkon::list_single_pane_cp2( index ).LayoutLine() );
       
  7192 
  5921 
  7193     TAknLayoutRect submenuWindowRect;
  5922     TAknLayoutRect submenuWindowRect;
  7194     // To prevent a panic in layout code, count has to be at least 1 even if
  5923     // To prevent a panic in layout code, count has to be at least 1 even if
  7195     // submenu is empty. Otherwise the index is out of bounds.
  5924     // submenu is empty. Otherwise the index is out of bounds.
  7196     if ( count == 0 )
  5925     if ( count == 0 )
  7225     enum { EFloating, EBottom } subMenuPos;
  5954     enum { EFloating, EBottom } subMenuPos;
  7226 
  5955 
  7227     if ( ( Layout_Meta_Data::IsLandscapeOrientation()
  5956     if ( ( Layout_Meta_Data::IsLandscapeOrientation()
  7228         && cbaPosition != AknLayoutUtils::EAknCbaLocationBottom ) )
  5957         && cbaPosition != AknLayoutUtils::EAknCbaLocationBottom ) )
  7229         {
  5958         {
  7230         if ( ( parentSelectedItemRect.Rect().iTl.iY + submenuWindowRect.Rect().Height() ) >
  5959         if ( ( parentSelectedItemRect.iTl.iY + submenuWindowRect.Rect().Height() ) >
  7231                 aWindowRect.iBr.iY )
  5960                 aWindowRect.iBr.iY )
  7232             {
  5961             {
  7233             subMenuPos = EBottom;
  5962             subMenuPos = EBottom;
  7234             }
  5963             }
  7235         else
  5964         else
  7277                 TSize( submenuWindowRect.Rect().Width() + widthOffset, submenuWindowRect.Rect().Height() ) );
  6006                 TSize( submenuWindowRect.Rect().Width() + widthOffset, submenuWindowRect.Rect().Height() ) );
  7278             }
  6007             }
  7279         }
  6008         }
  7280     else  // floating
  6009     else  // floating
  7281         {
  6010         {
  7282         TInt yPos = parentSelectedItemRect.Rect().iTl.iY -
  6011         TInt yPos = parentSelectedItemRect.iTl.iY -
  7283             ( listScrollPaneRect.Rect().iTl.iY - submenuWindowRect.Rect().iTl.iY );
  6012             ( listScrollPaneRect.Rect().iTl.iY - submenuWindowRect.Rect().iTl.iY );
  7284 
  6013 
  7285         // When a submenu is floating, make sure that the possible panning offset of the
  6014         // When a submenu is floating, make sure that the possible panning offset of the
  7286         // parent menu is taken into account.
  6015         // parent menu is taken into account.
  7287         yPos += iOwner->iExtension->Offset();
  6016         yPos += iOwner->iExtension->Offset();
  7306             TInt offset = retVal.iBr.iY - 
  6035             TInt offset = retVal.iBr.iY - 
  7307                 iOwner->iExtension->iMenuPaneRect.iBr.iY;
  6036                 iOwner->iExtension->iMenuPaneRect.iBr.iY;
  7308             retVal.Move( 0, -offset );
  6037             retVal.Move( 0, -offset );
  7309             }
  6038             }
  7310         }
  6039         }
       
  6040     
       
  6041     if ( retVal.iTl.iY < 0 )
       
  6042         {
       
  6043         retVal.Move( 0, -retVal.iTl.iY );
       
  6044         }
       
  6045 
       
  6046     iExtension->iMenuPaneRect = retVal;
       
  6047 
       
  6048     TAknLayoutRect layoutRect;
       
  6049     layoutRect.LayoutRect( TRect( iExtension->iMenuPaneRect.Size() ), 
       
  6050             AknLayoutScalable_Avkon::listscroll_popup_sub_pane( 0 ) );
       
  6051     
       
  6052     iExtension->iMenuAreaRect = layoutRect.Rect();
       
  6053     
       
  6054     layoutRect.LayoutRect( iExtension->iMenuAreaRect,
       
  6055             AknLayoutScalable_Avkon::list_submenu_pane( submenuVariety ) );
       
  6056 
       
  6057     iExtension->iItemAreaRect = layoutRect.Rect();
       
  6058     
  7311     _AKNTRACE( "[%s]", "the layout of sub menu return" );
  6059     _AKNTRACE( "[%s]", "the layout of sub menu return" );
  7312     _AKNTRACE_FUNC_EXIT;  
  6060     _AKNTRACE_FUNC_EXIT;  
  7313     return retVal;
  6061     return retVal;
  7314     }
  6062     }
  7315 
  6063 
  7326     // TopItemIndex. Which results in negative index. This "fix" prevents from
  6074     // TopItemIndex. Which results in negative index. This "fix" prevents from
  7327     // crashing the menu.
  6075     // crashing the menu.
  7328     if( index < 0 )
  6076     if( index < 0 )
  7329         index = 0;
  6077         index = 0;
  7330 
  6078 
  7331     // It is possible that this method is called when iItemArray is NULL.  In
       
  7332     // that case we fake numItems as 1 to make layout code work.
       
  7333     TInt maxItems = NumberOfItemsThatFitInView();
       
  7334     TInt numItems = Min( Max( 1, iItemArray->Count() ), maxItems );
       
  7335     if( !iItemArray )
       
  7336         numItems = 1;
       
  7337     
       
  7338     // When physics is enabled highlight can be moved to partially visible
  6079     // When physics is enabled highlight can be moved to partially visible
  7339     // item which is at the bottom of menu. This causes layout panic and to 
  6080     // item which is at the bottom of menu. This causes layout panic and to 
  7340     // avoid that we reduce index by one.
  6081     // avoid that we reduce index by one.
  7341     if ( index == maxItems )
  6082     if ( index == NumberOfItemsThatFitInView() )
  7342         {
  6083         {
  7343         index--;
  6084         index--;
  7344         }
  6085         }
  7345    
  6086    
  7346     TRect windowRect = Rect();
  6087     return ItemRect( index );
  7347 
       
  7348     TAknWindowLineLayout menuPane( AKN_LAYOUT_WINDOW_list_menu_pane( 0 , 0 ) );
       
  7349     TAknWindowLineLayout singleMenuPane( AKN_LAYOUT_WINDOW_list_single_popup_menu_pane( index ) );
       
  7350     TAknLayoutRect menuPaneRect;
       
  7351     TAknLayoutRect singleMenuPaneRect;
       
  7352 
       
  7353     TBool hasDoubleSpanScrollBar = EFalse;
       
  7354 
       
  7355     if ( iSBFrame && iSBFrame->VScrollBarVisibility() )
       
  7356         {
       
  7357         hasDoubleSpanScrollBar = ETrue;
       
  7358         }
       
  7359 
       
  7360     if ( !iOwner )
       
  7361         {
       
  7362         TAknWindowLineLayout listScrollPaneLayout( 
       
  7363             AknLayoutScalable_Avkon::listscroll_menu_pane(0).LayoutLine() );
       
  7364         if ( iExtension )
       
  7365             {
       
  7366             iExtension->AdjustPopupLayoutData( listScrollPaneLayout );
       
  7367             }                            
       
  7368         TAknLayoutRect listScrollPaneRect;
       
  7369         listScrollPaneRect.LayoutRect( windowRect, listScrollPaneLayout );
       
  7370 
       
  7371         menuPane = AknLayoutScalable_Avkon::list_menu_pane( 0 ).LayoutLine();
       
  7372         menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  7373 
       
  7374         singleMenuPane = AknLayoutScalable_Avkon::list_single_pane_cp2( index ).LayoutLine();
       
  7375         singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(), singleMenuPane );
       
  7376         }
       
  7377     else // Submenu
       
  7378         {
       
  7379         TAknWindowLineLayout listScrollPaneLayout( AknLayoutScalable_Avkon::listscroll_popup_sub_pane().LayoutLine() );
       
  7380         TAknLayoutRect listScrollPaneRect;
       
  7381         listScrollPaneRect.LayoutRect( windowRect, listScrollPaneLayout );
       
  7382 
       
  7383         menuPane = AknLayoutScalable_Avkon::list_submenu_pane( !hasDoubleSpanScrollBar ).LayoutLine();
       
  7384         menuPaneRect.LayoutRect( listScrollPaneRect.Rect(), menuPane );
       
  7385 
       
  7386         singleMenuPane = AknLayoutScalable_Avkon::list_single_popup_submenu_pane( index ).LayoutLine();
       
  7387         singleMenuPaneRect.LayoutRect( menuPaneRect.Rect(), singleMenuPane );
       
  7388         }
       
  7389 
       
  7390     // Compared to normal DrawItem the highlight rect step is omitted because
       
  7391     // it would shift the highlight towards left.
       
  7392 
       
  7393     return singleMenuPaneRect.Rect();
       
  7394     }
  6088     }
  7395 
  6089 
  7396 
  6090 
  7397 // -----------------------------------------------------------------------------
  6091 // -----------------------------------------------------------------------------
  7398 // CEikMenuPane::PrepareHighlightFrame
  6092 // CEikMenuPane::PrepareHighlightFrame
  7434 
  6128 
  7435     if( itemData )
  6129     if( itemData )
  7436         {
  6130         {
  7437         AknIconUtils::SetSize( itemData->Bitmap(),  cascadeRect.Rect().Size() );
  6131         AknIconUtils::SetSize( itemData->Bitmap(),  cascadeRect.Rect().Size() );
  7438         }
  6132         }
  7439 
       
  7440     else
  6133     else
  7441         {
  6134         {
  7442         if (iExtension->iCascadeBitmap)
  6135         if (iExtension->iCascadeBitmap)
  7443             {
  6136             {
  7444             AknIconUtils::SetSize( iExtension->iCascadeBitmap,  cascadeRect.Rect().Size() );
  6137             AknIconUtils::SetSize( iExtension->iCascadeBitmap,  cascadeRect.Rect().Size() );
  7477 // -----------------------------------------------------------------------------
  6170 // -----------------------------------------------------------------------------
  7478 //
  6171 //
  7479 EXPORT_C TInt CEikMenuPane::CountComponentControls() const
  6172 EXPORT_C TInt CEikMenuPane::CountComponentControls() const
  7480     {
  6173     {
  7481     TInt count = 0;
  6174     TInt count = 0;
  7482     if ( iSBFrame && iSBFrame->VerticalScrollBar() &&
  6175     if ( iSBFrame && iSBFrame->VerticalScrollBar() )
  7483                             !( iSBFrame->VerticalScrollBar()->OwnsWindow() ) )
       
  7484         {
  6176         {
  7485         count = 1;
  6177         count = 1;
  7486         }
  6178         }
  7487     if ( iExtension->iSct )
  6179     if ( iExtension->iSct )
  7488         {
  6180         {
  7505     {
  6197     {
  7506     switch ( aIndex)
  6198     switch ( aIndex)
  7507         {
  6199         {
  7508         case 0:
  6200         case 0:
  7509             {
  6201             {
  7510             if ( iSBFrame && iSBFrame->VerticalScrollBar() &&
  6202             if ( iSBFrame && iSBFrame->VerticalScrollBar() )
  7511                         !( iSBFrame->VerticalScrollBar()->OwnsWindow() ) )
       
  7512                 {
  6203                 {
  7513                 return iSBFrame->VerticalScrollBar();
  6204                 return iSBFrame->VerticalScrollBar();
  7514                 }
  6205                 }
  7515             }
  6206             }
  7516         case 1:
  6207         case 1:
  7549     __ASSERT_ALWAYS( iExtension, Panic( EEikPanicNullPointer ) );
  6240     __ASSERT_ALWAYS( iExtension, Panic( EEikPanicNullPointer ) );
  7550     return iExtension;
  6241     return iExtension;
  7551     }
  6242     }
  7552 
  6243 
  7553 
  6244 
       
  6245 // -----------------------------------------------------------------------------
       
  6246 // CEikMenuPane::CheckCreateExtensionL
       
  6247 // -----------------------------------------------------------------------------
       
  6248 //
  7554 void CEikMenuPane::CheckCreateExtensionL()
  6249 void CEikMenuPane::CheckCreateExtensionL()
  7555     {
  6250     {
  7556     if ( !iExtension )
  6251     if ( !iExtension )
  7557         {
  6252         {
  7558         iExtension = new (ELeave) CEikMenuPaneExtension;
  6253         iExtension = new (ELeave) CEikMenuPaneExtension;
  7559         iExtension->ConstructL( this );
  6254         iExtension->ConstructL( this );
  7560         }
  6255         }
       
  6256     }
       
  6257 
       
  6258 
       
  6259 // -----------------------------------------------------------------------------
       
  6260 // CEikMenuPane::ItemRect
       
  6261 // -----------------------------------------------------------------------------
       
  6262 //
       
  6263 TRect CEikMenuPane::ItemRect( TInt aItemIndex ) const
       
  6264     {
       
  6265     // this method is valid for the main menu only
       
  6266     TInt lastRow = AknLayoutScalable_Avkon::list_single_pane_cp2_ParamLimits().LastRow();
       
  6267     aItemIndex = Min( aItemIndex, lastRow );
       
  6268 
       
  6269     TAknLayoutRect layoutRect;
       
  6270     layoutRect.LayoutRect( iExtension->iItemAreaRect,
       
  6271             AknLayoutScalable_Avkon::list_single_pane_cp2( aItemIndex ) );
       
  6272             
       
  6273     return layoutRect.Rect();
       
  6274     }
       
  6275 
       
  6276 
       
  6277 // -----------------------------------------------------------------------------
       
  6278 // CEikMenuPane::CalculateItemHeight
       
  6279 // -----------------------------------------------------------------------------
       
  6280 //
       
  6281 TInt CEikMenuPane::CalculateItemHeight() const
       
  6282     {
       
  6283     TAknWindowLineLayout menuLineLayout;
       
  6284 
       
  6285     if ( iOwner ) // submenu
       
  6286         {
       
  6287         menuLineLayout = 
       
  6288             AknLayoutScalable_Avkon::list_single_popup_submenu_pane( 0 ).LayoutLine();
       
  6289         }
       
  6290     else
       
  6291         {
       
  6292         menuLineLayout = 
       
  6293             AknLayoutScalable_Avkon::list_single_pane_cp2( 0 ).LayoutLine();
       
  6294         }
       
  6295 
       
  6296     TAknLayoutRect menuLayoutRect;
       
  6297     menuLayoutRect.LayoutRect( Rect(), menuLineLayout );
       
  6298     
       
  6299     return menuLayoutRect.Rect().Height();
  7561     }
  6300     }
  7562 
  6301 
  7563 
  6302 
  7564 // -----------------------------------------------------------------------------
  6303 // -----------------------------------------------------------------------------
  7565 // CEikMenuPane::ConstructMenuSctRowL
  6304 // CEikMenuPane::ConstructMenuSctRowL
  7707 
  6446 
  7708     //iExtension->StartCascadeMenuDisappearTransition();
  6447     //iExtension->StartCascadeMenuDisappearTransition();
  7709     if ( iCascadeMenuPane->IsVisible() )
  6448     if ( iCascadeMenuPane->IsVisible() )
  7710         {
  6449         {
  7711         okToDraw = AknsUtils::SkinInstance() != NULL;
  6450         okToDraw = AknsUtils::SkinInstance() != NULL;
  7712 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
  7713         MAknListBoxTfxInternal *transApi = CAknListLoader::TfxApiInternal( iExtension->iGc );
       
  7714         if ( transApi && okToDraw )
       
  7715             {
       
  7716             iCascadeMenuPane->SetFocus( EFalse, EDrawNow );
       
  7717             }
       
  7718 #endif
       
  7719         // Stop ongoing comp. transitions, this is mostly for fast clicking
  6451         // Stop ongoing comp. transitions, this is mostly for fast clicking
  7720         // cases to make sure that no "scrap" is left behind.
  6452         // cases to make sure that no "scrap" is left behind.
  7721         GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort );
  6453         GfxTransEffect::NotifyExternalState( ENotifyGlobalAbort );
       
  6454 
  7722         // cascade menu "cancel" animation. This does not apply
  6455         // cascade menu "cancel" animation. This does not apply
  7723         // when something is chosen from the menu
  6456         // when something is chosen from the menu
  7724 
  6457         if ( iExtension->iShowCascadeTransition && okToDraw )
  7725     if( iExtension->iShowCascadeTransition && okToDraw )
  6458             {
  7726         {
  6459             iCascadeMenuPane->SetParent( this );
  7727         iCascadeMenuPane->SetParent( this );
  6460     
  7728 
  6461             GfxTransEffect::Begin( iCascadeMenuPane, KGfxControlDisappearAction );
  7729         GfxTransEffect::Begin( iCascadeMenuPane, KGfxControlDisappearAction );
  6462             GfxTransEffect::SetDemarcation( iCascadeMenuPane, iExtension->iCascadeDRect );
  7730         GfxTransEffect::SetDemarcation( iCascadeMenuPane, iExtension->iCascadeDRect );
  6463             iCascadeMenuPane->MakeVisible( EFalse );
  7731 
  6464             GfxTransEffect::End( iCascadeMenuPane );
  7732         iCascadeMenuPane->MakeVisible( EFalse );
       
  7733 
       
  7734         GfxTransEffect::End( iCascadeMenuPane );
       
  7735 
       
  7736             }
  6465             }
  7737         }
  6466         }
  7738 
  6467 
  7739         // deregister right away since cascade menu is deleted
  6468         // deregister right away since cascade menu is deleted
  7740     GfxTransEffect::Deregister( iCascadeMenuPane );
  6469     GfxTransEffect::Deregister( iCascadeMenuPane );