diff -r 5456b4e8b3a8 -r 3321d3e205b6 idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockface.cpp --- a/idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockface.cpp Wed Sep 01 12:32:46 2010 +0100 +++ b/idlehomescreen/xmluirendering/renderingplugins/xnclockfactory/src/xnclockface.cpp Tue Sep 14 20:58:58 2010 +0300 @@ -38,6 +38,9 @@ _LIT( KAmPmFormat, "%B" ); _LIT( KTimeFormat, "%J%:1%T" ); +_LIT( KClockFont, "EAknLogicalFontSecondaryFont" ); +_LIT( KAmpmFont, "EAknLogicalFontSecondaryFont" ); + // ============================ MEMBER FUNCTIONS =============================== // ----------------------------------------------------------------------------- @@ -86,123 +89,134 @@ // ----------------------------------------------------------------------------- // CXnClockFaceDigital::DrawL -// (other items were commented in a header). // ----------------------------------------------------------------------------- // void CXnClockFaceDigital::DrawL( CXnClockAdapter& aAdapter, CWindowGc& aGc, - const TRect& aRect, const TTime& aTime ) - { + CXnNodePluginIf& aNode, const TTime& aTime, CXnNodePluginIf* aAmpm ) + { TBuf< KMaxTimeFormatSpec > time; aTime.FormatL( time, KTimeFormat() ); - TBuf< KMaxTimeFormatSpec > ampm; - aTime.FormatL( ampm, KAmPmFormat() ); - AknTextUtils::LanguageSpecificNumberConversion( time ); - const CAknLayoutFont* clockFont( - aAdapter.FontL( CXnClockAdapter::EDigitalFont ) ); - - const CAknLayoutFont* ampmFont( - aAdapter.FontL( CXnClockAdapter::EAmPmFont ) ); - - const CAknLayoutFont* dateFont( - aAdapter.FontL( CXnClockAdapter::EDateFont ) ); - - const TRgb& color( aAdapter.TextColorL() ); - - CXnNodePluginIf* date( aAdapter.Date() ); - - const TInt deltaHeight( aRect.Height() - clockFont->TextPaneHeight() ); - TInt offset( clockFont->TextPaneTopToBaseline() + deltaHeight / 2 ); - - if( date ) + const CAknLayoutFont* clockFont( CreateFontL( aAdapter, aNode, EClock ) ); + if ( !clockFont ) { - // When date string is shown, time string must be lifted up - offset -= ( dateFont->TextPaneHeight() / 2 ); + return; } - // Measure the full width of the time string - TInt textWidth( AknBidiTextUtils::MeasureTextBoundsWidth( *clockFont, time, - CFont::TMeasureTextInput::EFVisualOrder ) ); + const TRgb& color( CreateColorL( aAdapter, aNode, EClock) ); - TInt extraWidth( aRect.Width() - textWidth ); - - TInt margin( extraWidth / 2 ); + const TInt deltaHeight( aNode.Rect().Height() - clockFont->TextPaneHeight() ); + TInt offset( clockFont->TextPaneTopToBaseline() + deltaHeight / 2 ); + + CGraphicsContext::TTextAlign align = aAdapter.GetTextAlignL( aNode ); aGc.SetPenColor( color ); + aGc.UseFont( clockFont ); + aGc.DrawText( time, aNode.Rect(), offset, align ); + aGc.DiscardFont(); - aGc.UseFont( clockFont ); - - CGraphicsContext::TTextAlign align; + if( TLocale().TimeFormat() == ETime12 && aAmpm ) + { + DrawAmpmL( aAdapter, aGc, aTime, *aAmpm ); + } + } - TBool mirrored( AknLayoutUtils::LayoutMirrored() ); +// ----------------------------------------------------------------------------- +// CXnClockFaceDigital::DrawAmpmL +// ----------------------------------------------------------------------------- +// +void CXnClockFaceDigital::DrawAmpmL( CXnClockAdapter& aAdapter, + CWindowGc& aGc, + const TTime& aTime, + CXnNodePluginIf& aAmpm ) + { + TBuf< KMaxTimeFormatSpec > ampm; + aTime.FormatL( ampm, KAmPmFormat() ); + ampm.Trim(); + + const CAknLayoutFont* ampmFont( CreateFontL( aAdapter, aAmpm, EAmpm ) ); + if ( !ampmFont ) + { + return; + } + + const TRgb& color( CreateColorL( aAdapter, aAmpm, EAmpm) ); + + const TInt deltaHeight( aAmpm.Rect().Height() - ampmFont->TextPaneHeight() ); + TInt offset( ampmFont->TextPaneTopToBaseline() + deltaHeight / 2 ); + + CGraphicsContext::TTextAlign align = aAdapter.GetTextAlignL( aAmpm ); - if( mirrored ) + aGc.SetPenColor( color ); + aGc.UseFont( ampmFont ); + aGc.DrawText( ampm, aAmpm.Rect(), offset, align ); + aGc.DiscardFont(); + } + +// ----------------------------------------------------------------------------- +// CXnClockFaceDigital::CreateFontL +// ----------------------------------------------------------------------------- +// +const CAknLayoutFont* CXnClockFaceDigital::CreateFontL( CXnClockAdapter& aAdapter, + CXnNodePluginIf& aNode, + TXnClockFontType aFontType) + { + if ( aFontType == EClock ) { - align = CGraphicsContext::ERight; + if ( !iClockFont ) + { + aAdapter.CreateFontL( aNode, KClockFont, iClockFont ); + } + return CAknLayoutFont::AsCAknLayoutFontOrNull( iClockFont ); } else { - align = CGraphicsContext::ELeft; - } - - aGc.DrawText( time, aRect, offset, align, margin ); - - aGc.DiscardFont(); - - if( TLocale().TimeFormat() == ETime12 ) - { - TRect ampmRect( aRect ); - TInt ampmHeight( ampmFont->TextPaneHeight() ); - - if( mirrored ) + if ( !iAmpmFont ) { - align = CGraphicsContext::ELeft; - } - else - { - align = CGraphicsContext::ERight; + aAdapter.CreateFontL( aNode, KAmpmFont, iAmpmFont ); } - - ampmRect.iTl.iY += ampmHeight; - - aGc.UseFont( ampmFont ); - - aGc.DrawText( ampm, ampmRect, offset, align, margin ); - - aGc.DiscardFont(); + return CAknLayoutFont::AsCAknLayoutFontOrNull( iAmpmFont ); } + } - if( date ) +// ----------------------------------------------------------------------------- +// CXnClockFaceDigital::CreateColorL +// ----------------------------------------------------------------------------- +// +const TRgb& CXnClockFaceDigital::CreateColorL( CXnClockAdapter& aAdapter, + CXnNodePluginIf& aNode, + TXnClockFontType aFontType ) + { + if ( aFontType == EClock ) { - const TDesC* dateStr( &KNullDesC() ); - - CXnText* textIf( NULL ); - - XnComponentInterface::MakeInterfaceL( textIf, date->AppIfL() ); - - if( textIf ) + if ( !iIsFaceColorSet ) { - dateStr = textIf->Text(); + aAdapter.CreateColorL( aNode, iFaceColor ); + iIsFaceColorSet = ETrue; } + return iFaceColor; + } + else + { + if ( !iIsAmpmColorSet ) + { + aAdapter.CreateColorL( aNode, iAmpmColor ); + iIsAmpmColorSet = ETrue; + } + return iAmpmColor; + } + } - // Measure the full width of the time string - TInt dateWidth( AknBidiTextUtils::MeasureTextBoundsWidth( *dateFont, *dateStr, - CFont::TMeasureTextInput::EFVisualOrder ) ); - - TInt width( aRect.Width() - dateWidth ); - TInt margin( width / 2 ); - - // Move date string down by text pane height and 5% of rect height - offset += dateFont->TextPaneHeight() + ( aRect.Height() / 20 ); - - aGc.UseFont( dateFont ); - - aGc.DrawText( *dateStr, aRect, offset, align, margin ); - - aGc.DiscardFont(); - } +// ----------------------------------------------------------------------------- +// CXnClockFaceDigital::ResetFont +// ----------------------------------------------------------------------------- +// +void CXnClockFaceDigital::ResetFont() + { + iClockFont = iAmpmFont = NULL; + iIsFaceColorSet = iIsAmpmColorSet = EFalse; } // ============================ MEMBER FUNCTIONS =============================== @@ -253,13 +267,12 @@ // ----------------------------------------------------------------------------- // CXnClockFaceAnalog::DrawL -// (other items were commented in a header). // ----------------------------------------------------------------------------- // void CXnClockFaceAnalog::DrawL( CXnClockAdapter& /*aAdapter*/, CWindowGc& aGc, - const TRect& aRect, const TTime& aTime ) - { - TSize faceSize( aRect.Size() ); + CXnNodePluginIf& aNode, const TTime& aTime, CXnNodePluginIf* /*aAmpm*/ ) + { + TSize faceSize( aNode.Rect().Size() ); TDateTime dateTime( aTime.DateTime() ); @@ -286,7 +299,7 @@ { User::LeaveIfError( AknIconUtils::SetSize( skinMask, faceSize ) ); - aGc.BitBltMasked( aRect.iTl, + aGc.BitBltMasked( aNode.Rect().iTl, skinBmp, TRect( TPoint( 0, 0 ), skinBmp->SizeInPixels() ), skinMask, @@ -294,18 +307,17 @@ } else { - aGc.BitBlt( aRect.iTl, skinBmp ); + aGc.BitBlt( aNode.Rect().iTl, skinBmp ); } aGc.SetBrushStyle( CGraphicsContext::ENullBrush ); aGc.SetPenStyle( CGraphicsContext::ESolidPen ); - DrawHandsL( aGc, aRect, dateTime ); + DrawHandsL( aGc, aNode.Rect(), dateTime ); } // ----------------------------------------------------------------------------- // CXnClockFaceAnalog::DrawHands -// (other items were commented in a header). // ----------------------------------------------------------------------------- // void CXnClockFaceAnalog::DrawHandsL( CWindowGc& aGc, @@ -355,5 +367,13 @@ minmask, EFalse ); } + +// ----------------------------------------------------------------------------- +// CXnClockFaceAnalog::ResetFont +// ----------------------------------------------------------------------------- +// +void CXnClockFaceAnalog::ResetFont() + { + } // End of File