diff -r 8466d47a6819 -r 12c456ceeff2 emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp --- a/emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp Thu Dec 17 08:39:21 2009 +0200 +++ b/emailuis/uicomponents/src/fscontrolbuttonvisualiser.cpp Thu Jan 07 12:38:38 2010 +0200 @@ -15,8 +15,6 @@ * */ - -// SF #include "emailtrace.h" #include #include @@ -29,9 +27,9 @@ #include #include #include +#include #include #include -// #include #include #include @@ -44,6 +42,9 @@ #include "fscontrolbar.h" const TInt KFsDefaultFontStyle = EAlfTextStyleNormal; +const TInt KDefaultShadowBorderWidth( 8 ); +const TReal KShadowBorderOpacity( 0.08 ); +const TInt KButtonBorderSize( 8 ); // ======== MEMBER FUNCTIONS ======== @@ -148,6 +149,7 @@ } delete iBgColorBrush; + delete iShadowBorderBrush; delete iTextFontSpec; } @@ -168,18 +170,62 @@ if ( !iBgColorBrush ) { iBgColorBrush = CAlfGradientBrush::NewL( iParent->Env() ); - SetBackgroundColor( iButtonModel->TextColor( - CFsControlButtonModel::EButtonBackground ) ); - iButtonLayout->Brushes()->AppendL( - iBgColorBrush, EAlfDoesNotHaveOwnership ); + if( iShowShadow ) + { + iBgColorBrush->SetOpacity( KShadowBorderOpacity ); + iBgColorBrush->SetColor(KRgbBlack); + } + else + { + iBgColorBrush->SetOpacity( 0 ); + } + + iBgColorBrush->SetLayer( EAlfBrushLayerBackground ); + iButtonLayout->Brushes()->AppendL( iBgColorBrush, + EAlfDoesNotHaveOwnership ); } + iUseDefaultBackground = ETrue; + + // Add a shadow border brush to outline the buttons with a shadowed border. + if ( iShowShadow && !iShadowBorderBrush ) + { + iShadowBorderBrush = CAlfShadowBorderBrush::NewL( + iParent->Env(), TAlfMetric( KDefaultShadowBorderWidth ) ); + iShadowBorderBrush->SetOpacity( KShadowBorderOpacity ); + iShadowBorderBrush->SetLayer( EAlfBrushLayerBackground ); + iButtonLayout->Brushes()->AppendL( iShadowBorderBrush, + EAlfDoesNotHaveOwnership ); + } + + UpdateVisualThemeL(); + // create needed visuals CreateButtonVisualsL(); UpdateBarLayout(); } +// --------------------------------------------------------------------------- +// CFsControlButtonVisualiser::UpdateVisualThemeL +// --------------------------------------------------------------------------- +// +void CFsControlButtonVisualiser::UpdateVisualThemeL() + { + if( iUseDefaultBackground ) + { + ClearBackgroundImage(); + iDefaultBgBrush = CAlfFrameBrush::NewL( iParent->Env(), KAknsIIDQsnFrButtonTb ); + iBgBrush = iDefaultBgBrush; + iButtonLayout->Brushes()->AppendL( iBgBrush, EAlfDoesNotHaveOwnership ); + UpdateBarLayout(); + } + else if ( iBgColorBrush ) + { + SetBackgroundColor( iButtonModel->TextColor( + CFsControlButtonModel::EButtonBackground ) ); + } + } // --------------------------------------------------------------------------- // From class CFsControlButtonVisualiserBase. @@ -338,9 +384,10 @@ // As the ownership of the new brush is gained the pointer can't be lost. CleanupStack::PushL( aImage ); - iButtonLayout->Brushes()->AppendL( aImage, EAlfDoesNotHaveOwnership ); + iButtonLayout->Brushes()->InsertL( 0, aImage, EAlfDoesNotHaveOwnership ); CleanupStack::Pop( aImage ); + iUseDefaultBackground = EFalse; iBgBrush = aImage; } @@ -365,7 +412,10 @@ EXPORT_C void CFsControlButtonVisualiser::ClearBackgroundColor() { FUNC_LOG; - iBgColorBrush->SetOpacity( 0 ); + if( iBgColorBrush ) + { + iBgColorBrush->SetOpacity( 0 ); + } } @@ -389,6 +439,7 @@ } delete iBgBrush; iBgBrush = NULL; + iDefaultBgBrush = NULL; } } @@ -631,6 +682,16 @@ // Same size for the content iButtonContentLayout->SetSize( iButtonModel->Size() ); + if( iDefaultBgBrush ) + { + TSize size = iButtonModel->Size(); + TRect fullRect = TRect( size ); + TRect innerRect = fullRect; + innerRect.Shrink( KButtonBorderSize,KButtonBorderSize ); + TRAP_IGNORE( + iDefaultBgBrush->SetFrameRectsL( innerRect, fullRect ); ); + } + if ( iLabelFirstLine ) { iLabelFirstLine->SetWrapping( textWrapping ); @@ -828,7 +889,7 @@ if ( iTextStyleManager ) { ResolveCharFormat( charFormat, iLabelFirstLine ); - charFormat.iFontPresentation.iUnderline = EUnderlineOn; + charFormat.iFontPresentation.iUnderline = EUnderlineOff; TRAPD( leaveErr, styleId = iTextStyleManager->GetStyleIDL( charFormat ) ); // Use modified style if possible, otherwise use the default @@ -850,7 +911,7 @@ if ( iTextStyleManager ) { ResolveCharFormat( charFormat, iLabelSecondLine ); - charFormat.iFontPresentation.iUnderline = EUnderlineOn; + charFormat.iFontPresentation.iUnderline = EUnderlineOff; TRAPD( leaveErr, styleId = iTextStyleManager->GetStyleIDL( charFormat ) ); // Use modified style if possible, otherwise use the default @@ -954,10 +1015,7 @@ iIconAContainer = CAlfLayout::AddNewL( *iParent, iButtonContentLayout ); iIconA = CAlfImageVisual::AddNewL( *iParent, iIconAContainer ); - // Platform layout change - //iIconA->SetScaleMode( CAlfImageVisual::EScaleNormal ); - iIconA->SetScaleMode( CAlfImageVisual::EScaleFit ); - // Platform layout change + iIconA->SetScaleMode( CAlfImageVisual::EScaleFitInside ); iIconAContainer->SetClipping( ETrue ); } @@ -1008,6 +1066,7 @@ EXPORT_C TInt CFsControlButtonVisualiser::CalculateButtonSize() { FUNC_LOG; + if ( iButtonModel->ContainsElement( ECBElemLabelFirstLine ) ) { // to get correct value from ExpandRectWithContent method @@ -1021,7 +1080,7 @@ TRect textRect( 0, 0, padding.iTl.iX + padding.iBr.iX + size.iWidth, padding.iTl.iY + padding.iBr.iY + size.iHeight ); - + if ( iButtonModel->ContainsElement( ECBElemLabelSndLine ) ) { // to get correct value from ExpandRectWithContent method @@ -1096,7 +1155,7 @@ return iIconBContainer->Size().Target().iX; } - return iButtonContentLayout->Size().Target().iX;; + return iButtonContentLayout->Size().Target().iX; } @@ -1171,40 +1230,26 @@ CFsLayoutManager::EFsLmMainSpFsCtrlbarDdmenuPaneG1, iconB, 1 ); break; - - // As a device user, I want Message List items to follow platform layouts to be consistent with other apps - - /* - REMOVED, Not needed anymore. - - case ECBTypeTwoLinesLabelOnly: - text1 = TRect(0,0,60,20); - text2 = TRect(0,0,60,20); - break; - case ECBTypeTwoLinesLabelIconA: - iconA = TRect(0,0,16,16); - text1 = TRect(0,0,60,20); - text2 = TRect(0,0,60,20); - break; - case ECBTypeTwoLinesLabelIconB: - text1 = TRect(0,0,60,20); - text2 = TRect(0,0,60,20); - iconB = TRect(0,0,16,16); - break; - case ECBTypeTwoLinesLabelTwoIcons: - iconA = TRect(0,0,16,16); - text1 = TRect(0,0,60,20); - text2 = TRect(0,0,60,20); - iconB = TRect(0,0,16,16); - break; - */ - // - default: break; } - - // Platform layout changes + + // Buttons have different sizes so adapt the used rectangle dynamically + TSize buttonSize = iButtonModel->Size(); + buttonSize -= TPoint( KButtonBorderSize, KButtonBorderSize ); // shrink frame border size + + // If there is no text in the button, center the icon to the button + if( !iLabelFirstLine || iLabelFirstLine->Text().Length() == 0 ) + { + TSize oldIconSize = iconA.Size(); + iconA.SetRect( TPoint( + iconA.iTl .iX + ( buttonSize.iWidth - oldIconSize.iWidth ) / 2, + iconA.iTl .iY + ( buttonSize.iHeight - oldIconSize.iHeight ) / 2 ), + oldIconSize ); + } + iconA.SetHeight( buttonSize.iHeight ); + text1.SetHeight( buttonSize.iHeight ); + if ( iButtonModel->ContainsElement( ECBElemIconA ) ) { const TSize& size( iconA.Size() );