diff -r 9f56a4e1b8ab -r 08e69e956a8c uifw/AvKon/aknhlist/src/akntree.cpp --- a/uifw/AvKon/aknhlist/src/akntree.cpp Mon Mar 15 12:41:34 2010 +0200 +++ b/uifw/AvKon/aknhlist/src/akntree.cpp Wed Mar 31 21:59:52 2010 +0300 @@ -33,6 +33,9 @@ #include "akntreelistinternalconstants.h" const TInt KObserverArrayGranularity = 1; +const TInt KMaxLength = 80; +// smiley text place holder +_LIT( KPlaceHolder, "\xFFF0i" ); // Tree flag definitions enum TAknTreeFlags @@ -63,6 +66,8 @@ // CAknTree::~CAknTree() { + delete iSmileyMan; + iSmileyMan = NULL; delete iOrdering; iOrdering = NULL; iCustomOrdering = NULL; iObservers.Close(); @@ -1243,6 +1248,74 @@ } } +// --------------------------------------------------------------------------- +// CAknTreeItem::InitSmiley(). +// Create smiley manager instance if there is not. +// --------------------------------------------------------------------------- +// +void CAknTree::InitSmiley() + { + if ( !iSmileyMan ) + { + TRAPD(err, iSmileyMan = CAknSmileyManager::NewL( this )); + if ( err != KErrNone ) + { + delete iSmileyMan; + iSmileyMan = NULL; + } + } + } + +// --------------------------------------------------------------------------- +// CAknTreeItem::DrawSmiley +// Draw smiley icon, if it is just plain text, just draw like DrawText. +// --------------------------------------------------------------------------- +// +void CAknTree::DrawSmiley(CWindowGc& aGc, const TRect& aRect, + const TAknTextComponentLayout& aTextLayout, + const TDesC& aText, const CFont* aFont, + TBool aFocused ) + { + TBuf buf = aText.Left(KMaxLength*2); + // it is possiable that this been called after ~CAknTree()... + if ( iSmileyMan && ConvertTextToSmiley(buf) > KErrNone ) + { + TRgb textColor; + TAknsQsnTextColorsIndex index = + aFocused ? EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6; + AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor, + KAknsIIDQsnTextColors, index ); + aGc.SetPenColor( textColor ); + + TAknLayoutText layoutText; + layoutText.LayoutText( aRect, aTextLayout.LayoutLine(), aFont ); + TInt l = Min( layoutText.Font()->TextWidthInPixels( KPlaceHolder ), + layoutText.Font()->FontMaxHeight()); + TSize s( l, l); + if ( iSmileySize != s ) + { + iSmileyMan->SetSize( s); + iSmileySize = s; + } + iSmileyMan->DrawText( aGc, buf, layoutText, ETrue ); + } + else + // no smiley existing... + { + DrawText( aGc, aRect, aTextLayout, aText, aFont, NULL, aFocused, EFalse); + } + } + +// --------------------------------------------------------------------------- +// CAknTreeItem::ConvertTextToSmiley +// --------------------------------------------------------------------------- +// +TInt CAknTree::ConvertTextToSmiley( TDes& aText ) + { + TInt count = 0; + TRAPD( err, count = iSmileyMan->ConvertTextToCodesL( aText )); + return err == KErrNone ? count : err; + } // --------------------------------------------------------------------------- // C++ constructor. @@ -1461,3 +1534,21 @@ __ASSERT_DEBUG( EFalse, User::Invariant() ); } +// --------------------------------------------------------------------------- +// From class MAknSmileyObserver. +// Redraw whole control when smiley image ready +// --------------------------------------------------------------------------- +// +void CAknTree::SmileyStillImageLoaded( CAknSmileyIcon* /*aSmileyIcon*/ ) + { + iList.DrawDeferred(); + } + +// --------------------------------------------------------------------------- +// From class MAknSmileyObserver. +// Empty implementation. +// --------------------------------------------------------------------------- +// +void CAknTree::SmileyAnimationChanged( CAknSmileyIcon* /*aSmileyIcon*/ ) + { + }