--- a/uifw/EikStd/coctlsrc/aknstyluspopupmenucontent.cpp Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/EikStd/coctlsrc/aknstyluspopupmenucontent.cpp Tue Aug 31 15:28:30 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -27,7 +27,6 @@
#include <aknappui.h>
#include <AknDef.h>
#include <touchfeedback.h>
-#include <layoutmetadata.cdl.h>
#include "aknstyluspopupmenuphysicshandler.h"
#include "aknstyluspopupmenucontent.h"
@@ -546,6 +545,7 @@
item->ConstructL( aItem );
iItems.AppendL( item );
CleanupStack::Pop( item );
+
}
// ---------------------------------------------------------------------------
@@ -621,7 +621,7 @@
}
}
}
- //SizeChanged();
+ SizeChanged();
}
}
@@ -695,39 +695,25 @@
TInt visibleItems = 0; // Number of visible items
// Find the widest visible item and count visible items
- TRect screenRect;
- AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen,
- screenRect );
- TInt screenHeight( screenRect.Height() );
- TInt screenWidth( screenRect.Width() );
-
- const CFont* usedFont = AknLayoutUtils::FontFromId(
- AknLayoutScalable_Avkon::list_single_popup_submenu_pane_t1( 0 ).Font() );
for ( TInt i = 0; i < iItems.Count(); i++ )
{
if ( iItems[i]->iVisibility == KShown )
{
visibleItems++;
- textWidth = usedFont->TextWidthInPixels( *( iItems[i]->iText ) );
+ textWidth = AknLayoutUtils::FontFromId( AknLayoutScalable_Avkon::
+ list_single_popup_submenu_pane_t1( 0 ).LayoutLine().FontId() )->TextWidthInPixels( *( iItems[i]->iText ) );
width = Max( width, textWidth );
}
}
-
+
if ( visibleItems == 0 )
{
return TSize( 0, 0 );
}
-
- // Check the minimum width from the layout data and adjust the width
- // if the text would take less space than that.
- TInt minWidth =
- TAknWindowComponentLayout::Compose(
- AknLayoutScalable_Avkon::popup_touch_menu_window( 0 ),
- TAknWindowComponentLayout::Compose(
- AknLayoutScalable_Avkon::list_touch_menu_pane( 0 ),
- AknLayoutScalable_Avkon::list_single_touch_menu_pane( 0 ) ) ).LayoutLine().iW;
- width = Max( width, minWidth );
-
+
+ TRect mainPaneRect;
+ AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+ mainPaneRect );
TAknWindowLineLayout listLayout =
AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine();
@@ -740,28 +726,9 @@
TInt singleItemHeight = listLayout.iH;
height = singleItemHeight * visibleItems;
- if ( height > screenHeight )
+ if ( height > mainPaneRect.Height() )
{
- // Amount of items that fit in the popup.
- TInt fitsToMenu = visibleItems;
-
- if ( Layout_Meta_Data::IsLandscapeOrientation() )
- {
- // In landscape orientation the max amount of items comes from
- // the layout data.
- TAknLayoutScalableParameterLimits paramLimits(
- AknLayoutScalable_Avkon::list_single_touch_menu_pane_ParamLimits() );
-
- // Add one to the last row as it's row index starting from zero.
- fitsToMenu = paramLimits.LastRow() + 1;
- }
- else
- {
- // In potrait orientation the menu can show as many items as fit
- // on the screen.
- fitsToMenu = screenHeight / singleItemHeight;
- }
-
+ TInt fitsToMenu = mainPaneRect.Height() / singleItemHeight;
height = fitsToMenu * singleItemHeight;
TAknWindowLineLayout scrollBar =
AknLayoutScalable_Avkon::scroll_pane( 0 );
@@ -770,9 +737,9 @@
width += textLayout.ir + textLayout.il;
- if ( width > ( screenWidth - unit.iW ) )
+ if ( width > ( mainPaneRect.Width() - unit.iW ) )
{
- width = screenWidth - ( unit.iW );
+ width = mainPaneRect.Width() - ( unit.iW );
}
return TSize( width, height );
@@ -791,32 +758,27 @@
{
// Implementation when graphics are ready.
}
- else if ( aType == KEikMessageFadeAllWindows )
+ else if ( aType == KEikDynamicLayoutVariantSwitch )
+ {
+
+ // Background under highlight may have changed -> we need to update
+ // highlight background to animation
+ if ( iExtension )
+ {
+ iExtension->HandleLayoutSwitch();
+ }
+
+ iPopUpMenu.UpdatePosition();
+ }
+ else if ( aType == KEikMessageFadeAllWindows )
{
if ( Observer() )
{
- if ( iExtension )
- {
- iExtension->iInformObserver = EFalse;
- }
// this will close the stylus popup menu
TRAP_IGNORE( Observer()->HandleControlEventL( this,
MCoeControlObserver::EEventRequestExit ) );
}
- }
- else if ( aType == KEikDynamicLayoutVariantSwitch )
- {
- if ( Observer() )
- {
- if ( iExtension )
- {
- iExtension->iInformObserver = EFalse;
- }
- // this will close the stylus popup menu
- TRAP_IGNORE( Observer()->HandleControlEventL( this,
- MCoeControlObserver::EEventRequestCancel ) );
- }
- }
+ }
}
// -----------------------------------------------------------------------------
@@ -874,11 +836,8 @@
if ( iExtension && iExtension->iInformObserver && !iExtension->iObserverInformed )
{
iExtension->iInformObserver = EFalse;
- if ( Observer() )
- {
- TRAP_IGNORE(Observer()->HandleControlEventL( this,
- MCoeControlObserver::EEventRequestCancel ));
- }
+ TRAP_IGNORE(Observer()->HandleControlEventL( this,
+ MCoeControlObserver::EEventRequestCancel ));
}
if ( iSBFrame )
{
@@ -964,73 +923,65 @@
{
TRect rect( iItems[aItem]->iRect );
- if ( !rect.IsEmpty() )
+ // Use offset to move items smoothly.
+ // If physics not in use, offset is always 0.
+ rect.Move( TPoint( 0, -Offset() ) );
+
+ if ( aHighlight == EDrawHighlight )
{
- // Use offset to move items smoothly.
- // If physics not in use, offset is always 0.
- rect.Move( TPoint( 0, -Offset() ) );
-
- if ( aHighlight == EDrawHighlight )
+ TBool drawOk = EFalse;
+ if( iExtension->iAnimation ) // Draw animated highlight
+ {
+ drawOk = iExtension->iAnimation->Render( aGc, rect );
+ }
+ if ( !drawOk )
{
- TBool drawOk = EFalse;
- if( iExtension->iAnimation ) // Draw animated highlight
+ // Animated highlight was not available, use normal skinned
+ // rendering.
+ TAknLayoutRect listRect;
+ TAknLayoutRect innerRect;
+
+ listRect.LayoutRect( rect,
+ AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() );
+ innerRect.LayoutRect( listRect.Rect(),
+ AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() );
+
+ MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+ aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
+ // if we have transparent highlight, draw also background under highlight
+ if ( Background() )
{
- drawOk = iExtension->iAnimation->Render( aGc, rect );
+ Background()->Draw( aGc, *this, rect );
}
+
+ drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(),
+ KAknsIIDQsnFrList, KAknsIIDDefault );
+
+ //Both highlight animation and frame drawing failed.
if ( !drawOk )
{
- // Animated highlight was not available, use normal skinned
- // rendering.
- TAknLayoutRect listRect;
- TAknLayoutRect innerRect;
-
- listRect.LayoutRect( rect,
- AknLayoutScalable_Avkon::list_highlight_pane_cp1().LayoutLine() );
- innerRect.LayoutRect( listRect.Rect(),
- AknLayoutScalable_Avkon::list_highlight_pane_g1_cp1().LayoutLine() );
-
- MAknsSkinInstance* skin = AknsUtils::SkinInstance();
- aGc.SetBrushStyle( CGraphicsContext::ESolidBrush );
- // if we have transparent highlight, draw also background under highlight
- if ( Background() )
- {
- Background()->Draw( aGc, *this, rect );
- }
-
- drawOk = AknsDrawUtils::DrawFrame( skin, aGc, rect, innerRect.Rect(),
- KAknsIIDQsnFrList, KAknsIIDDefault );
-
- //Both highlight animation and frame drawing failed.
- if ( !drawOk )
- {
- listRect.DrawRect( aGc );
- innerRect.DrawRect( aGc );
- }
+ listRect.DrawRect( aGc );
+ innerRect.DrawRect( aGc );
}
}
-
- if ( aHighlight == ERemoveHighlight && Background() )
- {
- Background()->Draw( aGc, *this, rect );
- }
-
- TAknLayoutText layoutText;
- layoutText.LayoutText( rect,
- AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine());
-
- MAknsSkinInstance* skin = AknsUtils::SkinInstance();
-
- TRgb textColor(layoutText.Color());
- AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors,
- EAknsCIQsnTextColorsCG20 );
-
- layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor );
+ }
+
+ if ( aHighlight == ERemoveHighlight && Background() )
+ {
+ Background()->Draw( aGc, *this, rect );
+ }
- if ( aItem < iLastVisibleItem )
- {
- AknListUtils::DrawSeparator( aGc, rect, textColor, skin );
- }
- }
+ TAknLayoutText layoutText;
+ layoutText.LayoutText( rect,
+ AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine());
+
+ MAknsSkinInstance* skin = AknsUtils::SkinInstance();
+
+ TRgb textColor(layoutText.Color());
+ AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors,
+ EAknsCIQsnTextColorsCG20 );
+
+ layoutText.DrawText( aGc, *(iItems[aItem]->iText), ETrue, textColor );
}
// -----------------------------------------------------------------------------
@@ -1101,21 +1052,31 @@
}
TAknDoubleSpanScrollBarModel vsbarModel;
+ TAknDoubleSpanScrollBarModel hsbarModel;
if ( iSBFrame->VScrollBarVisibility() != CEikScrollBarFrame::EOff )
{
vsbarModel.iThumbPosition = thumbPos * singleItemHeight + Offset();
vsbarModel.iScrollSpan = visibleItems * singleItemHeight;
vsbarModel.iThumbSpan = fitsToMenu * singleItemHeight;
-
- TAknLayoutRect scrollBarLayout;
- scrollBarLayout.LayoutRect( listRect,
- AknLayoutScalable_Avkon::scroll_pane() );
- TRect scrollBarRect( scrollBarLayout.Rect() );
+
+ TEikScrollBarFrameLayout layout;
+ layout.iTilingMode=TEikScrollBarFrameLayout::EInclusiveRectConstant;
+ layout.SetClientMargin(0);
+ layout.SetInclusiveMargin(0);
- iSBFrame->Tile( &vsbarModel, scrollBarRect );
-
- iSBFrame->DrawScrollBarsDeferred();
+ TBool changed ( EFalse );
+ TRect clientRect( listRect );
+ TRect inclusiveRect( listRect );
+ TRAP_IGNORE ( changed = iSBFrame->TileL( &hsbarModel,
+ &vsbarModel,
+ clientRect,
+ inclusiveRect,
+ layout ) );
+ if ( changed )
+ {
+ iSBFrame->DrawScrollBarsDeferred();
+ }
}
}
@@ -1224,17 +1185,6 @@
}
}
}
- else
- {
- if ( AknLayoutUtils::LayoutMirrored() )
- {
- listRect.iTl.iX += AknLayoutScalable_Avkon::scroll_pane().LayoutLine().iW;
- }
- else
- {
- listRect.iBr.iX -= AknLayoutScalable_Avkon::scroll_pane().LayoutLine().iW;
- }
- }
}
@@ -1295,13 +1245,7 @@
iItems[i]->iRect = itemRect;
}
- if ( lastItem == iItems.Count() || ( Rect().Height() % singleItemHeight ) == 0 )
- {
- // substract the partially visible item
- --lastItem;
- }
-
- return lastItem;
+ return lastItem;
}
// ---------------------------------------------------------------------------
@@ -1320,7 +1264,7 @@
TRAP_IGNORE( InitPhysicsL() );
- if ( ( iLastVisibleItem = CalculateShownItems( ENoScroll ) ) != KNoItemSelected )
+ if ( CalculateShownItems( ENoScroll ) != KNoItemSelected )
{
UpdateScrollBar();
DrawNow();
@@ -1338,8 +1282,6 @@
{
CWindowGc& gc = SystemGc();
- gc.SetClippingRect( Rect() );
-
for ( TInt i=iFirstItem; i < iItems.Count(); i++ )
{
if ( iItems[i]->iVisibility != KHidden )
@@ -1348,7 +1290,6 @@
ENoHighlight );
}
}
- gc.CancelClippingRect();
}
}
@@ -1412,10 +1353,6 @@
{
if ( Observer() )
{
- if ( iExtension )
- {
- iExtension->iInformObserver = EFalse;
- }
// this will close the stylus popup menu
TRAP_IGNORE( Observer()->HandleControlEventL( this,
MCoeControlObserver::EEventRequestExit ) );
@@ -1465,8 +1402,17 @@
return 0;
}
+ TRect mainPaneRect;
+ AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
+ mainPaneRect );
TAknWindowLineLayout listLayout =
AknLayoutScalable_Avkon::list_single_touch_menu_pane(0).LayoutLine();
+
+ TAknTextLineLayout textLayout =
+ AknLayoutScalable_Avkon::list_single_touch_menu_pane_t1().LayoutLine();
+
+ TAknWindowLineLayout unit =
+ AknLayoutScalable_Avkon::aid_value_unit2().LayoutLine();
TInt singleItemHeight = listLayout.iH;
TInt height = singleItemHeight * visibleItems;
@@ -1535,10 +1481,10 @@
}
// ---------------------------------------------------------------------------
-// CAknStylusPopUpMenuContent::SelectItemL
+// CAknStylusPopUpMenuContent::SelectItem
// ---------------------------------------------------------------------------
//
-void CAknStylusPopUpMenuContent::SelectItemL( TInt aItem )
+void CAknStylusPopUpMenuContent::SelectItem( TInt aItem )
{
iCurrentItem = aItem;
if ( Observer() )
@@ -1548,8 +1494,8 @@
iExtension->iInformObserver = EFalse;
iExtension->iObserverInformed = ETrue;
}
- Observer()->HandleControlEventL( this,
- MCoeControlObserver::EEventStateChanged );
+ TRAP_IGNORE(Observer()->HandleControlEventL( this,
+ MCoeControlObserver::EEventStateChanged ));
}
}