uifw/EikStd/coctlsrc/aknstyluspopupmenucontent.cpp
branchRCL_3
changeset 55 aecbbf00d063
parent 10 9f56a4e1b8ab
child 56 d48ab3b357f1
equal deleted inserted replaced
51:fcdfafb36fe7 55:aecbbf00d063
     1 /*
     1 /*
     2 * Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2005-2009 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".
    25 #include <AknsConstants.h>
    25 #include <AknsConstants.h>
    26 #include <eikapp.h>
    26 #include <eikapp.h>
    27 #include <aknappui.h>
    27 #include <aknappui.h>
    28 #include <AknDef.h>
    28 #include <AknDef.h>
    29 #include <touchfeedback.h>
    29 #include <touchfeedback.h>
    30 #include <layoutmetadata.cdl.h>
       
    31 
    30 
    32 #include "aknstyluspopupmenuphysicshandler.h"
    31 #include "aknstyluspopupmenuphysicshandler.h"
    33 #include "aknstyluspopupmenucontent.h"
    32 #include "aknstyluspopupmenucontent.h"
    34 
    33 
    35 const TInt KItemArrayGranularity = 4;
    34 const TInt KItemArrayGranularity = 4;
   544         aCommandId );
   543         aCommandId );
   545     CleanupStack::PushL( item ); 
   544     CleanupStack::PushL( item ); 
   546     item->ConstructL( aItem );  
   545     item->ConstructL( aItem );  
   547     iItems.AppendL( item );
   546     iItems.AppendL( item );
   548     CleanupStack::Pop( item ); 
   547     CleanupStack::Pop( item ); 
       
   548 
   549     }
   549     }
   550 
   550 
   551 // ---------------------------------------------------------------------------
   551 // ---------------------------------------------------------------------------
   552 // Removes the menu item based on the given command id and frees the 
   552 // Removes the menu item based on the given command id and frees the 
   553 // memory occupied by it.
   553 // memory occupied by it.
   619                     iFirstItem = i;
   619                     iFirstItem = i;
   620                     break;
   620                     break;
   621                     }
   621                     }
   622                 }
   622                 }
   623             }
   623             }
   624         //SizeChanged();
   624         SizeChanged();
   625         }
   625         }
   626     }
   626     }
   627 
   627 
   628 // ---------------------------------------------------------------------------
   628 // ---------------------------------------------------------------------------
   629 // Returns the command id of the specified menu item.
   629 // Returns the command id of the specified menu item.
   693     TInt height = 0; // height of all menu items combined.
   693     TInt height = 0; // height of all menu items combined.
   694     TInt width = 0; // Width of menu
   694     TInt width = 0; // Width of menu
   695     TInt visibleItems = 0; // Number of visible items
   695     TInt visibleItems = 0; // Number of visible items
   696     
   696     
   697     // Find the widest visible item and count visible items
   697     // Find the widest visible item and count visible items
   698     TRect screenRect;
       
   699     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen,
       
   700                                        screenRect );
       
   701     TInt screenHeight( screenRect.Height() );
       
   702     TInt screenWidth( screenRect.Width() );
       
   703     
       
   704     const CFont* usedFont = AknLayoutUtils::FontFromId(
       
   705         AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 0 ).Font() );
       
   706     for ( TInt i = 0; i < iItems.Count(); i++ )
   698     for ( TInt i = 0; i < iItems.Count(); i++ )
   707         {
   699         {
   708         if ( iItems[i]->iVisibility == KShown )
   700         if ( iItems[i]->iVisibility == KShown )
   709             {
   701             {
   710             visibleItems++;
   702             visibleItems++;
   711             textWidth = usedFont->TextWidthInPixels( *( iItems[i]->iText ) );
   703             textWidth = AknLayoutUtils::FontFromId( AknLayoutScalable_Avkon::
       
   704             list_single_popup_submenu_pane_t1( 0 ).LayoutLine().FontId() )->TextWidthInPixels( *( iItems[i]->iText ) );
   712             width = Max( width, textWidth );
   705             width = Max( width, textWidth );
   713             }
   706             }
   714         }
   707         }
   715 
   708         
   716     if ( visibleItems == 0 )
   709     if ( visibleItems == 0 )
   717         {
   710         {
   718         return TSize( 0, 0 );
   711         return TSize( 0, 0 );
   719         }
   712         }
   720 
   713             
   721     // Check the minimum width from the layout data and adjust the width
   714     TRect mainPaneRect;
   722     // if the text would take less space than that.
   715     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
   723     TInt minWidth =
   716                                        mainPaneRect );
   724         TAknWindowComponentLayout::Compose(
       
   725             AknLayoutScalable_Avkon::popup_touch_menu_window( 0 ),
       
   726             TAknWindowComponentLayout::Compose(
       
   727                 AknLayoutScalable_Avkon::list_touch_menu_pane( 0 ),
       
   728                 AknLayoutScalable_Avkon::list_single_touch_menu_pane( 0 ) ) ).LayoutLine().iW;
       
   729     width = Max( width, minWidth );
       
   730 
       
   731     TAknWindowLineLayout listLayout = 
   717     TAknWindowLineLayout listLayout = 
   732        AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine();
   718        AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine();
   733  
   719  
   734     TAknTextLineLayout textLayout = 
   720     TAknTextLineLayout textLayout = 
   735        AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine();
   721        AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine();
   738        AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine();
   724        AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine();
   739     
   725     
   740     TInt singleItemHeight = listLayout.iH; 
   726     TInt singleItemHeight = listLayout.iH; 
   741     height = singleItemHeight * visibleItems;
   727     height = singleItemHeight * visibleItems;
   742     
   728     
   743     if ( height > screenHeight )
   729     if ( height > mainPaneRect.Height() )
   744         {
   730         {
   745         // Amount of items that fit in the popup.
   731         TInt fitsToMenu = mainPaneRect.Height() / singleItemHeight;
   746         TInt fitsToMenu = visibleItems;
       
   747 
       
   748         if ( Layout_Meta_Data::IsLandscapeOrientation() )
       
   749             {
       
   750             // In landscape orientation the max amount of items comes from
       
   751             // the layout data.
       
   752             TAknLayoutScalableParameterLimits paramLimits(
       
   753                 AknLayoutScalable_Avkon::list_single_touch_menu_pane_ParamLimits() );
       
   754             
       
   755             // Add one to the last row as it's row index starting from zero.
       
   756             fitsToMenu = paramLimits.LastRow() + 1;
       
   757             }
       
   758         else
       
   759             {
       
   760             // In potrait orientation the menu can show as many items as fit
       
   761             // on the screen.
       
   762             fitsToMenu = screenHeight / singleItemHeight;
       
   763             }
       
   764 
       
   765         height = fitsToMenu * singleItemHeight;
   732         height = fitsToMenu * singleItemHeight;
   766         TAknWindowLineLayout scrollBar = 
   733         TAknWindowLineLayout scrollBar = 
   767             AknLayoutScalable_Avkon::scroll_pane( 0 );
   734             AknLayoutScalable_Avkon::scroll_pane( 0 );
   768         width += scrollBar.iW;
   735         width += scrollBar.iW;
   769         }
   736         }
   770 
   737 
   771     width += textLayout.ir + textLayout.il;
   738     width += textLayout.ir + textLayout.il;
   772 
   739 
   773     if ( width > ( screenWidth - unit.iW ) )
   740     if ( width > ( mainPaneRect.Width() - unit.iW ) )
   774         {
   741         {
   775         width = screenWidth - ( unit.iW );
   742         width = mainPaneRect.Width() - ( unit.iW );
   776         }
   743         }
   777 
   744 
   778     return TSize( width, height );
   745     return TSize( width, height );
   779     }
   746     }
   780 
   747 
   789     
   756     
   790     if ( aType == KAknsMessageSkinChange )
   757     if ( aType == KAknsMessageSkinChange )
   791         {
   758         {
   792         // Implementation when graphics are ready.
   759         // Implementation when graphics are ready.
   793         }
   760         }
   794     else if ( aType == KEikMessageFadeAllWindows )
   761     else if ( aType == KEikDynamicLayoutVariantSwitch )
       
   762         {
       
   763 
       
   764         // Background under highlight may have changed -> we need to update
       
   765         // highlight background to animation
       
   766         if ( iExtension )
       
   767             {
       
   768             iExtension->HandleLayoutSwitch();
       
   769             }
       
   770             
       
   771         iPopUpMenu.UpdatePosition();
       
   772         }
       
   773     else if ( aType == KEikMessageFadeAllWindows ) 
   795         {
   774         {
   796         if ( Observer() ) 
   775         if ( Observer() ) 
   797             {
   776             {
   798             if ( iExtension ) 
       
   799                 {
       
   800                 iExtension->iInformObserver = EFalse;
       
   801                 } 
       
   802             // this will close the stylus popup menu
   777             // this will close the stylus popup menu
   803             TRAP_IGNORE( Observer()->HandleControlEventL( this,
   778             TRAP_IGNORE( Observer()->HandleControlEventL( this,
   804                 MCoeControlObserver::EEventRequestExit ) );
   779                 MCoeControlObserver::EEventRequestExit ) );
   805             }    
   780             }    
   806         }            
   781         }    
   807     else if ( aType == KEikDynamicLayoutVariantSwitch ) 
       
   808         {
       
   809         if ( Observer() ) 
       
   810             {
       
   811             if ( iExtension ) 
       
   812                 {
       
   813                 iExtension->iInformObserver = EFalse;
       
   814                 } 
       
   815             // this will close the stylus popup menu
       
   816             TRAP_IGNORE( Observer()->HandleControlEventL( this,
       
   817                 MCoeControlObserver::EEventRequestCancel ) );
       
   818             }    
       
   819         }            
       
   820     }
   782     }
   821 
   783 
   822 // -----------------------------------------------------------------------------
   784 // -----------------------------------------------------------------------------
   823 // CAknStylusPopUpMenuContent::HandlePointerEventL
   785 // CAknStylusPopUpMenuContent::HandlePointerEventL
   824 // -----------------------------------------------------------------------------
   786 // -----------------------------------------------------------------------------
   872     else
   834     else
   873         {
   835         {
   874         if ( iExtension && iExtension->iInformObserver && !iExtension->iObserverInformed )
   836         if ( iExtension && iExtension->iInformObserver && !iExtension->iObserverInformed )
   875             {
   837             {
   876             iExtension->iInformObserver = EFalse; 
   838             iExtension->iInformObserver = EFalse; 
   877             if ( Observer() )
   839             TRAP_IGNORE(Observer()->HandleControlEventL( this,
   878                 {
   840                 MCoeControlObserver::EEventRequestCancel )); 
   879                 TRAP_IGNORE(Observer()->HandleControlEventL( this,
       
   880                     MCoeControlObserver::EEventRequestCancel )); 
       
   881                 }
       
   882             }
   841             }
   883         if ( iSBFrame )
   842         if ( iSBFrame )
   884             {
   843             {
   885             delete iSBFrame;
   844             delete iSBFrame;
   886             iSBFrame = NULL;
   845             iSBFrame = NULL;
   962 void CAknStylusPopUpMenuContent::DrawItem(
   921 void CAknStylusPopUpMenuContent::DrawItem(
   963     CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const
   922     CWindowGc& aGc,TInt aItem,THighlightType aHighlight) const
   964     {
   923     {
   965     TRect rect( iItems[aItem]->iRect );
   924     TRect rect( iItems[aItem]->iRect );
   966     
   925     
   967     if ( !rect.IsEmpty() )
   926     // Use offset to move items smoothly.
   968         {
   927     // If physics not in use, offset is always 0.
   969         // Use offset to move items smoothly.
   928     rect.Move( TPoint( 0, -Offset() ) ); 
   970         // If physics not in use, offset is always 0.
   929 
   971         rect.Move( TPoint( 0, -Offset() ) ); 
   930     if ( aHighlight == EDrawHighlight )
   972     
   931         {
   973         if ( aHighlight == EDrawHighlight )
   932         TBool drawOk = EFalse; 
   974             {
   933         if( iExtension->iAnimation ) // Draw animated highlight
   975             TBool drawOk = EFalse; 
   934             {
   976             if( iExtension->iAnimation ) // Draw animated highlight
   935             drawOk = iExtension->iAnimation->Render( aGc, rect );
       
   936             }
       
   937         if ( !drawOk )
       
   938             {
       
   939             // Animated highlight was not available, use normal skinned
       
   940             // rendering.
       
   941             TAknLayoutRect listRect; 
       
   942             TAknLayoutRect innerRect;
       
   943 
       
   944             listRect.LayoutRect( rect, 
       
   945                 AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() );
       
   946             innerRect.LayoutRect( listRect.Rect(),
       
   947                 AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() );
       
   948             
       
   949             MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   950             aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 
       
   951             // if we have transparent highlight, draw also background under highlight
       
   952             if ( Background() )
   977                 {
   953                 {
   978                 drawOk = iExtension->iAnimation->Render( aGc, rect );
   954                 Background()->Draw( aGc, *this, rect );
   979                 }
   955                 }
       
   956             
       
   957             drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(), 
       
   958                 KAknsIIDQsnFrList, KAknsIIDDefault );
       
   959 
       
   960             //Both highlight animation and frame drawing failed. 
   980             if ( !drawOk )
   961             if ( !drawOk )
   981                 {
   962                 {
   982                 // Animated highlight was not available, use normal skinned
   963                 listRect.DrawRect( aGc ); 
   983                 // rendering.
   964                 innerRect.DrawRect( aGc ); 
   984                 TAknLayoutRect listRect; 
       
   985                 TAknLayoutRect innerRect;
       
   986     
       
   987                 listRect.LayoutRect( rect, 
       
   988                     AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() );
       
   989                 innerRect.LayoutRect( listRect.Rect(),
       
   990                     AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() );
       
   991                 
       
   992                 MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   993                 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 
       
   994                 // if we have transparent highlight, draw also background under highlight
       
   995                 if ( Background() )
       
   996                     {
       
   997                     Background()->Draw( aGc, *this, rect );
       
   998                     }
       
   999                 
       
  1000                 drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(), 
       
  1001                     KAknsIIDQsnFrList, KAknsIIDDefault );
       
  1002     
       
  1003                 //Both highlight animation and frame drawing failed. 
       
  1004                 if ( !drawOk )
       
  1005                     {
       
  1006                     listRect.DrawRect( aGc ); 
       
  1007                     innerRect.DrawRect( aGc ); 
       
  1008                     }
       
  1009                 }
   965                 }
  1010             }
   966             }
  1011     
   967         }
  1012         if ( aHighlight == ERemoveHighlight && Background() )
   968 
  1013             {
   969     if ( aHighlight == ERemoveHighlight && Background() )
  1014             Background()->Draw( aGc, *this, rect );
   970         {
  1015             }
   971         Background()->Draw( aGc, *this, rect );
  1016     
   972         }
  1017         TAknLayoutText layoutText; 
   973 
  1018         layoutText.LayoutText( rect, 
   974     TAknLayoutText layoutText; 
  1019             AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine()); 
   975     layoutText.LayoutText( rect, 
  1020     
   976         AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine()); 
  1021         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
   977 
  1022     
   978     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
  1023         TRgb textColor(layoutText.Color()); 
   979 
  1024         AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors,
   980     TRgb textColor(layoutText.Color()); 
  1025                                        EAknsCIQsnTextColorsCG20 );
   981     AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors,
  1026     
   982                                    EAknsCIQsnTextColorsCG20 );
  1027         layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor ); 
   983 
  1028 
   984     layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor ); 
  1029         if ( aItem < iLastVisibleItem )
       
  1030             {
       
  1031             AknListUtils::DrawSeparator( aGc, rect, textColor, skin );
       
  1032             }
       
  1033 		}
       
  1034     }
   985     }
  1035 
   986 
  1036 // -----------------------------------------------------------------------------
   987 // -----------------------------------------------------------------------------
  1037 // CAknStylusPopUpMenuContent::StartAnimation
   988 // CAknStylusPopUpMenuContent::StartAnimation
  1038 // -----------------------------------------------------------------------------
   989 // -----------------------------------------------------------------------------
  1099                                 CEikScrollBarFrame::EOff ) );
  1050                                 CEikScrollBarFrame::EOff ) );
  1100         return;
  1051         return;
  1101         }
  1052         }
  1102         
  1053         
  1103     TAknDoubleSpanScrollBarModel vsbarModel;
  1054     TAknDoubleSpanScrollBarModel vsbarModel;
       
  1055     TAknDoubleSpanScrollBarModel hsbarModel;
  1104     
  1056     
  1105     if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff )
  1057     if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff )
  1106         {
  1058         {
  1107         vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset();
  1059         vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset();
  1108         vsbarModel.iScrollSpan = visibleItems * singleItemHeight;
  1060         vsbarModel.iScrollSpan = visibleItems * singleItemHeight;
  1109         vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight;
  1061         vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight;
  1110 
  1062             
  1111         TAknLayoutRect scrollBarLayout;
  1063         TEikScrollBarFrameLayout layout;
  1112         scrollBarLayout.LayoutRect( listRect,
  1064         layout.iTilingMode=TEikScrollBarFrameLayout::EInclusiveRectConstant;
  1113                                     AknLayoutScalable_Avkon::scroll_pane() );
  1065         layout.SetClientMargin(0);
  1114         TRect scrollBarRect( scrollBarLayout.Rect() );
  1066         layout.SetInclusiveMargin(0);
  1115         
  1067         
  1116         iSBFrame->Tile( &vsbarModel, scrollBarRect );
  1068         TBool changed ( EFalse );
  1117         
  1069         TRect clientRect( listRect );
  1118         iSBFrame->DrawScrollBarsDeferred();
  1070         TRect inclusiveRect( listRect );
       
  1071         TRAP_IGNORE ( changed = iSBFrame->TileL( &hsbarModel, 
       
  1072                                                  &vsbarModel,
       
  1073                                                  clientRect, 
       
  1074                                                  inclusiveRect, 
       
  1075                                                  layout ) );
       
  1076         if ( changed )
       
  1077             {
       
  1078             iSBFrame->DrawScrollBarsDeferred();
       
  1079             }
  1119         }
  1080         }
  1120     }
  1081     }
  1121 
  1082 
  1122 // -----------------------------------------------------------------------------
  1083 // -----------------------------------------------------------------------------
  1123 // CAknStylusPopUpMenuContent::CalculateShownItems
  1084 // CAknStylusPopUpMenuContent::CalculateShownItems
  1222                         listRect.iBr.iX -= AknLayoutScalable_Avkon::scroll_pane().LayoutLine().iW;
  1183                         listRect.iBr.iX -= AknLayoutScalable_Avkon::scroll_pane().LayoutLine().iW;
  1223                         }
  1184                         }
  1224                     }
  1185                     }
  1225                 }
  1186                 }
  1226             }
  1187             }
  1227         else
       
  1228         	{
       
  1229             if ( AknLayoutUtils::LayoutMirrored() )
       
  1230 	            {
       
  1231                 listRect.iTl.iX += AknLayoutScalable_Avkon::scroll_pane().LayoutLine().iW;
       
  1232 	            }
       
  1233             else
       
  1234 	            {
       
  1235                 listRect.iBr.iX -= AknLayoutScalable_Avkon::scroll_pane().LayoutLine().iW;
       
  1236                 }        	
       
  1237         	}
       
  1238 
  1188 
  1239         }
  1189         }
  1240     
  1190     
  1241     // Adjust first and last item 
  1191     // Adjust first and last item 
  1242     if ( iFirstItem < firstItem )
  1192     if ( iFirstItem < firstItem )
  1293             itemRect.SetRect( TPoint( 0,0 ), TPoint( 0,0 ) );
  1243             itemRect.SetRect( TPoint( 0,0 ), TPoint( 0,0 ) );
  1294             }
  1244             }
  1295         iItems[i]->iRect = itemRect;
  1245         iItems[i]->iRect = itemRect;
  1296         }
  1246         }
  1297 
  1247 
  1298     if ( lastItem == iItems.Count() || ( Rect().Height() % singleItemHeight ) == 0 )
  1248     return lastItem;    
  1299         {
       
  1300         // substract the partially visible item
       
  1301         --lastItem;
       
  1302         }
       
  1303     
       
  1304     return lastItem; 
       
  1305     }
  1249     }
  1306 
  1250 
  1307 // ---------------------------------------------------------------------------
  1251 // ---------------------------------------------------------------------------
  1308 // From class CCoeControl
  1252 // From class CCoeControl
  1309 // CAknStylusPopUpMenuContent::SizeChanged
  1253 // CAknStylusPopUpMenuContent::SizeChanged
  1318     iPhysicsHandler->SetWorldHeight( WorldHeight() );
  1262     iPhysicsHandler->SetWorldHeight( WorldHeight() );
  1319     iPhysicsHandler->SetViewRect( Rect() );
  1263     iPhysicsHandler->SetViewRect( Rect() );
  1320 
  1264 
  1321     TRAP_IGNORE( InitPhysicsL() );
  1265     TRAP_IGNORE( InitPhysicsL() );
  1322         
  1266         
  1323     if ( ( iLastVisibleItem = CalculateShownItems( ENoScroll ) ) != KNoItemSelected )
  1267     if ( CalculateShownItems( ENoScroll ) != KNoItemSelected )
  1324         {
  1268         {
  1325         UpdateScrollBar();
  1269         UpdateScrollBar();
  1326         DrawNow();
  1270         DrawNow();
  1327         }
  1271         }
  1328     }
  1272     }
  1336     {
  1280     {
  1337     if ( AknLayoutUtils::PenEnabled() )
  1281     if ( AknLayoutUtils::PenEnabled() )
  1338         {
  1282         {
  1339         CWindowGc& gc = SystemGc();
  1283         CWindowGc& gc = SystemGc();
  1340 
  1284 
  1341         gc.SetClippingRect( Rect() );
       
  1342         
       
  1343         for ( TInt i=iFirstItem; i < iItems.Count(); i++ )
  1285         for ( TInt i=iFirstItem; i < iItems.Count(); i++ )
  1344             {
  1286             {
  1345             if ( iItems[i]->iVisibility != KHidden )
  1287             if ( iItems[i]->iVisibility != KHidden )
  1346                 {
  1288                 {
  1347                 DrawItem( gc, i, ( i == iCurrentItem ) ? EDrawHighlight : 
  1289                 DrawItem( gc, i, ( i == iCurrentItem ) ? EDrawHighlight : 
  1348                     ENoHighlight );
  1290                     ENoHighlight );
  1349                 }
  1291                 }
  1350             }
  1292             }
  1351         gc.CancelClippingRect();
       
  1352         }
  1293         }
  1353     }
  1294     }
  1354 
  1295 
  1355 
  1296 
  1356 // -----------------------------------------------------------------------------
  1297 // -----------------------------------------------------------------------------
  1410 //
  1351 //
  1411 void CAknStylusPopUpMenuContent::HandleLosingForeground()
  1352 void CAknStylusPopUpMenuContent::HandleLosingForeground()
  1412     {
  1353     {
  1413     if ( Observer() )
  1354     if ( Observer() )
  1414         {
  1355         {
  1415         if ( iExtension ) 
       
  1416             {
       
  1417             iExtension->iInformObserver = EFalse;
       
  1418             } 
       
  1419         // this will close the stylus popup menu
  1356         // this will close the stylus popup menu
  1420         TRAP_IGNORE( Observer()->HandleControlEventL( this,
  1357         TRAP_IGNORE( Observer()->HandleControlEventL( this,
  1421             MCoeControlObserver::EEventRequestExit ) );
  1358             MCoeControlObserver::EEventRequestExit ) );
  1422         }
  1359         }
  1423     }
  1360     }
  1463     if ( visibleItems == 0 )
  1400     if ( visibleItems == 0 )
  1464         {
  1401         {
  1465         return 0;
  1402         return 0;
  1466         }
  1403         }
  1467             
  1404             
       
  1405     TRect mainPaneRect;
       
  1406     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
  1407                                        mainPaneRect );
  1468     TAknWindowLineLayout listLayout = 
  1408     TAknWindowLineLayout listLayout = 
  1469        AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine();
  1409        AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine();
       
  1410  
       
  1411     TAknTextLineLayout textLayout = 
       
  1412        AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine();
       
  1413 
       
  1414     TAknWindowLineLayout unit = 
       
  1415        AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine();
  1470     
  1416     
  1471     TInt singleItemHeight = listLayout.iH; 
  1417     TInt singleItemHeight = listLayout.iH; 
  1472     TInt height = singleItemHeight * visibleItems;
  1418     TInt height = singleItemHeight * visibleItems;
  1473     return height;
  1419     return height;
  1474     }
  1420     }
  1533     {
  1479     {
  1534     return iCurrentItem;
  1480     return iCurrentItem;
  1535     }
  1481     }
  1536 
  1482 
  1537 // ---------------------------------------------------------------------------
  1483 // ---------------------------------------------------------------------------
  1538 // CAknStylusPopUpMenuContent::SelectItemL
  1484 // CAknStylusPopUpMenuContent::SelectItem
  1539 // ---------------------------------------------------------------------------
  1485 // ---------------------------------------------------------------------------
  1540 //     
  1486 //     
  1541 void CAknStylusPopUpMenuContent::SelectItemL( TInt aItem )
  1487 void CAknStylusPopUpMenuContent::SelectItem( TInt aItem )
  1542     {
  1488     {
  1543     iCurrentItem = aItem;
  1489     iCurrentItem = aItem;
  1544     if ( Observer() )
  1490     if ( Observer() )
  1545         {
  1491         {
  1546         if ( iExtension )
  1492         if ( iExtension )
  1547             {
  1493             {
  1548             iExtension->iInformObserver = EFalse; 
  1494             iExtension->iInformObserver = EFalse; 
  1549             iExtension->iObserverInformed = ETrue; 
  1495             iExtension->iObserverInformed = ETrue; 
  1550             }
  1496             }
  1551         Observer()->HandleControlEventL( this,
  1497         TRAP_IGNORE(Observer()->HandleControlEventL( this,
  1552             MCoeControlObserver::EEventStateChanged );
  1498             MCoeControlObserver::EEventStateChanged ));
  1553         }
  1499         }
  1554     }
  1500     }
  1555     
  1501