uifw/EikStd/coctlsrc/EIKMENUP.CPP
branchRCL_3
changeset 10 9f56a4e1b8ab
parent 9 aabf2c525e0f
child 15 08e69e956a8c
equal deleted inserted replaced
9:aabf2c525e0f 10:9f56a4e1b8ab
     1 /*
     1 /*
     2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
  2479     TInt previousTopItem = iScroller->TopItemIndex();
  2479     TInt previousTopItem = iScroller->TopItemIndex();
  2480     TInt previousSelectedItem = iSelectedItem;
  2480     TInt previousSelectedItem = iSelectedItem;
  2481     _AKNTRACE( "previousTopItem =  %d", previousTopItem );
  2481     _AKNTRACE( "previousTopItem =  %d", previousTopItem );
  2482     _AKNTRACE( "previousSelectedItem =  %d", previousSelectedItem );
  2482     _AKNTRACE( "previousSelectedItem =  %d", previousSelectedItem );
  2483 
  2483 
       
  2484     SetSelectedItem( aNewSelectedItem );
       
  2485 
       
  2486     if ( aNewSelectedItem >= 0 )
       
  2487         {
       
  2488         ScrollToMakeItemVisible( aNewSelectedItem );
       
  2489         }
       
  2490     else
       
  2491         {
       
  2492         ScrollToMakeItemVisible( 0 );
       
  2493         }
       
  2494 
  2484     ActivateGc();
  2495     ActivateGc();
  2485     CWindowGc& gc =  SystemGc();
  2496     CWindowGc& gc =  SystemGc();
  2486     PrepareGcForDrawingItems( gc );
  2497     PrepareGcForDrawingItems( gc );
  2487 
  2498     
  2488     // Scrollers top item index must be updated first because setting selected
       
  2489     // item results in animation redraw (which requires knowledge about the
       
  2490     // current top item).
       
  2491     if ( aNewSelectedItem >= 0 )
       
  2492         {
       
  2493         ScrollToMakeItemVisible( aNewSelectedItem );
       
  2494         }
       
  2495     else
       
  2496         {
       
  2497         ScrollToMakeItemVisible( 0 );
       
  2498         }
       
  2499 
       
  2500     TInt topItem = iScroller->TopItemIndex();
  2499     TInt topItem = iScroller->TopItemIndex();
  2501     TInt bottomItem = topItem + NumberOfItemsThatFitInView();
  2500     TInt bottomItem = topItem + NumberOfItemsThatFitInView();
  2502     if( bottomItem > NumberOfItemsInPane() )
  2501     if( bottomItem > NumberOfItemsInPane() )
  2503         {
  2502         {
  2504         bottomItem = NumberOfItemsInPane();
  2503         bottomItem = NumberOfItemsInPane();
  2510     if (iExtension->iSctHighlighted)
  2509     if (iExtension->iSctHighlighted)
  2511         {
  2510         {
  2512         DrawItem( gc, topItem, ERemoveHighlight );
  2511         DrawItem( gc, topItem, ERemoveHighlight );
  2513         DrawItem( gc, (bottomItem-1), ERemoveHighlight );
  2512         DrawItem( gc, (bottomItem-1), ERemoveHighlight );
  2514         }
  2513         }
  2515     SetSelectedItem( aNewSelectedItem );
       
  2516 
  2514 
  2517     PrepareHighlightFrame();
  2515     PrepareHighlightFrame();
  2518 
  2516 
  2519     if ( previousTopItem == topItem  && aNewSelectedItem >= 0 )
  2517     if ( previousTopItem == topItem  && aNewSelectedItem >= 0 )
  2520         {
  2518         {
  2526 
  2524 
  2527         if ( !iExtension->iSctHighlighted )
  2525         if ( !iExtension->iSctHighlighted )
  2528             {
  2526             {
  2529             DrawItem( gc, aNewSelectedItem, EDrawHighlight );
  2527             DrawItem( gc, aNewSelectedItem, EDrawHighlight );
  2530             }
  2528             }
  2531         }
       
  2532     else
       
  2533         {
       
  2534         /*TBool skipHighlight = EFalse;
       
  2535 
       
  2536         if (iExtension && iExtension->iSct && aNewSelectedItem == 0 &&
       
  2537             previousSelectedItem > 1)
       
  2538             {
       
  2539             skipHighlight = ETrue;
       
  2540             }
       
  2541 
       
  2542         for( TInt i = topItem; i<bottomItem; i++ )
       
  2543             {
       
  2544             if( i == aNewSelectedItem && !skipHighlight)
       
  2545                 {
       
  2546                 DrawItem( gc, i, EDrawHighlight );
       
  2547                 }
       
  2548             else
       
  2549                 {
       
  2550                 DrawItem( gc, i, ERemoveHighlight );
       
  2551                 }
       
  2552             }*/
       
  2553 
       
  2554         // update the whole menu area
       
  2555         iExtension->ViewPositionChanged( iExtension->iViewPosition );   
       
  2556 //        UpdateScrollBarThumbs();
       
  2557         }
  2529         }
  2558 
  2530 
  2559     DeactivateGc();
  2531     DeactivateGc();
  2560     
  2532     
  2561     _AKNTRACE_FUNC_EXIT;
  2533     _AKNTRACE_FUNC_EXIT;
  2716         drawingInitiated = EFalse;
  2688         drawingInitiated = EFalse;
  2717         }
  2689         }
  2718 
  2690 
  2719     if ( !drawingInitiated && !iExtension->iFullRedraw )
  2691     if ( !drawingInitiated && !iExtension->iFullRedraw )
  2720         {
  2692         {
  2721         window.Invalidate( itemRect );
  2693         TRect drawRect( itemRect ); 
  2722         window.BeginRedraw( itemRect );
  2694         drawRect.Intersection( iExtension->iItemAreaRect );
       
  2695         window.Invalidate( drawRect );
       
  2696         window.BeginRedraw( drawRect );
  2723         }
  2697         }
  2724 
  2698 
  2725     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  2699     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  2726     MAknsControlContext* cc = NULL;
  2700     MAknsControlContext* cc = NULL;
  2727     if( iExtension )
  2701     if( iExtension )
  2980     item->iPos = highlightRect.Rect().iTl.iY;
  2954     item->iPos = highlightRect.Rect().iTl.iY;
  2981     
  2955     
  2982     // don't draw separator line for the last item
  2956     // don't draw separator line for the last item
  2983     if ( drawSeparator )
  2957     if ( drawSeparator )
  2984         {
  2958         {
  2985         AknListUtils::DrawSeparator( aGc, itemRect, textColor );
  2959         AknListUtils::DrawSeparator( aGc, itemRect, textColor, skin );
  2986         }
  2960         }
  2987     
  2961     
  2988     if ( !drawingInitiated && !iExtension->iFullRedraw )
  2962     if ( !drawingInitiated && !iExtension->iFullRedraw )
  2989         {
  2963         {
  2990         Window().EndRedraw();
  2964         Window().EndRedraw();
  4017         case TPointerEvent::EButton1Up:
  3991         case TPointerEvent::EButton1Up:
  4018             {
  3992             {
  4019             _AKNTRACE( "[%s]", "TPointerEvent::EButton1Up" );
  3993             _AKNTRACE( "[%s]", "TPointerEvent::EButton1Up" );
  4020             if ( !innerRect.Contains( aPointerEvent.iPosition ) ) 
  3994             if ( !innerRect.Contains( aPointerEvent.iPosition ) ) 
  4021                 {
  3995                 {
       
  3996                 TBool highlightWasEnabled = iExtension->HighlightEnabled();
  4022                 // remove highlight in case highlight is outside of menu pane 
  3997                 // remove highlight in case highlight is outside of menu pane 
  4023                 iExtension->EnableHighlight( EFalse );
  3998                 iExtension->EnableHighlight( EFalse );
  4024                 if ( iOwner )
  3999                 if ( iOwner )
  4025                     {
  4000                     {
  4026                     RepaintHighlight();
  4001                     RepaintHighlight();
       
  4002                     }
       
  4003                 else if ( highlightWasEnabled )
       
  4004                     {
       
  4005                     DrawItem( SelectedItem(), ENoHighlight );
  4027                     }
  4006                     }
  4028                 } 
  4007                 } 
  4029             if ( iOwner && 
  4008             if ( iOwner && 
  4030                  !innerRect.Contains( aPointerEvent.iPosition ) && 
  4009                  !innerRect.Contains( aPointerEvent.iPosition ) && 
  4031                  !iExtension->iDownOnMenuArea )
  4010                  !iExtension->iDownOnMenuArea )
  5157     newTop = Max( 0, newTop );
  5136     newTop = Max( 0, newTop );
  5158     newTop = Min( newTop, count - NumberOfItemsThatFitInView() );
  5137     newTop = Min( newTop, count - NumberOfItemsThatFitInView() );
  5159     iScroller->SetTopItemIndex( newTop );
  5138     iScroller->SetTopItemIndex( newTop );
  5160     _AKNTRACE( "newTop =  %d", newTop );
  5139     _AKNTRACE( "newTop =  %d", newTop );
  5161  
  5140  
  5162     // Menu moved with keys, update panning/flicking data
       
  5163     iExtension->iListTopIndex = iScroller->TopItemIndex() * iItemHeight;
  5141     iExtension->iListTopIndex = iScroller->TopItemIndex() * iItemHeight;
  5164     iExtension->iViewPosition.iY = 
  5142     TPoint newPosition( iExtension->iViewPosition );
  5165         iExtension->iListTopIndex + iExtension->iViewHeight / 2;  
  5143     newPosition.iY = iExtension->iListTopIndex + iExtension->iViewHeight / 2;  
  5166 
  5144 
  5167     iExtension->SetOffset( 0 );
  5145     iExtension->SetOffset( 0 );
  5168 
  5146     iExtension->ViewPositionChanged( newPosition );
       
  5147     
  5169     _AKNTRACE( "iExtension->iListTopIndex =  %d", iExtension->iListTopIndex );
  5148     _AKNTRACE( "iExtension->iListTopIndex =  %d", iExtension->iListTopIndex );
  5170     _AKNTRACE( "iExtension->iViewPosition.iY =  %d", iExtension->iViewPosition.iY );
  5149     _AKNTRACE( "iExtension->iViewPosition.iY =  %d", iExtension->iViewPosition.iY );
  5171     _AKNTRACE( "[%s]", "iExtension->SetOffset( 0 )" );
  5150     _AKNTRACE( "[%s]", "iExtension->SetOffset( 0 )" );
  5172 
  5151 
  5173     _AKNTRACE_FUNC_EXIT;
  5152     _AKNTRACE_FUNC_EXIT;
  5357                 }
  5336                 }
  5358             
  5337             
  5359             TRect rect( CalculateSizeAndPosition() );
  5338             TRect rect( CalculateSizeAndPosition() );
  5360             SetExtent( rect.iTl, rect.Size() );
  5339             SetExtent( rect.iTl, rect.Size() );
  5361 
  5340 
  5362             TRAP_IGNORE( DoUpdateScrollBarL() );
       
  5363 
       
  5364             UpdateBackgroundContext( Rect() );
       
  5365             PrepareHighlightFrame();
       
  5366             SetCascadedIconSize();
       
  5367 
       
  5368             //Initialize physics engine
  5341             //Initialize physics engine
  5369             if ( iExtension->iPhysics )
  5342             if ( iExtension->iPhysics )
  5370                 {
  5343                 {
  5371                 TRAP_IGNORE ( iExtension->InitPhysicsL() );
  5344                 TRAP_IGNORE ( iExtension->InitPhysicsL() );
  5372                 iExtension->iListTopIndex = iScroller->TopItemIndex() * iItemHeight;
  5345                 iExtension->iListTopIndex = iScroller->TopItemIndex() * iItemHeight;
  5373                 iExtension->iViewPosition.iY = 
  5346                 iExtension->iViewPosition.iY = 
  5374                             iExtension->iListTopIndex + iExtension->iViewHeight / 2;  
  5347                             iExtension->iListTopIndex + iExtension->iViewHeight / 2;  
  5375                 iExtension->ViewPositionChanged( iExtension->iViewPosition );
  5348                 }             
  5376                 } 
  5349          
  5377             
  5350             TRAP_IGNORE( DoUpdateScrollBarL() );
       
  5351 
       
  5352             UpdateBackgroundContext( Rect() );
       
  5353             PrepareHighlightFrame();
       
  5354             SetCascadedIconSize();
       
  5355           
  5378             if ( iCascadeMenuPane )
  5356             if ( iCascadeMenuPane )
  5379                 {
  5357                 {
  5380                 iCascadeMenuPane->HandleResourceChange( aType );
  5358                 iCascadeMenuPane->HandleResourceChange( aType );
  5381                 } 
  5359                 } 
  5382             
  5360             
  6401 // -----------------------------------------------------------------------------
  6379 // -----------------------------------------------------------------------------
  6402 //
  6380 //
  6403 EXPORT_C void CEikMenuPane::SetItemSpecific(
  6381 EXPORT_C void CEikMenuPane::SetItemSpecific(
  6404         TInt aCommandId, TBool aItemSpecific )
  6382         TInt aCommandId, TBool aItemSpecific )
  6405     {
  6383     {
       
  6384     if ( !iExtension )
       
  6385         {
       
  6386         TRAPD( err, CheckCreateExtensionL() );
       
  6387         if ( err )
       
  6388             {
       
  6389             return;
       
  6390             }
       
  6391         }
       
  6392     
  6406     if ( iExtension->iFlags.IsSet(
  6393     if ( iExtension->iFlags.IsSet(
  6407             CEikMenuPaneExtension::ESingleClickEnabled ) )
  6394             CEikMenuPaneExtension::ESingleClickEnabled ) )
  6408         {
  6395         {
  6409         CEikMenuPaneItem::SData& itemData = ItemData( aCommandId );
  6396         CEikMenuPaneItem::SData& itemData = ItemData( aCommandId );
  6410         if ( aItemSpecific )
  6397         if ( aItemSpecific )