uifw/AvKon/aknhlist/src/akntree.cpp
branchRCL_3
changeset 15 08e69e956a8c
parent 0 2f259fa3e83a
child 18 0aa5fbdfbc30
equal deleted inserted replaced
10:9f56a4e1b8ab 15:08e69e956a8c
    31 #include "akntreelisticon.h"
    31 #include "akntreelisticon.h"
    32 #include "akncustomtreeordering.h"
    32 #include "akncustomtreeordering.h"
    33 #include "akntreelistinternalconstants.h"
    33 #include "akntreelistinternalconstants.h"
    34 
    34 
    35 const TInt KObserverArrayGranularity = 1;
    35 const TInt KObserverArrayGranularity = 1;
       
    36 const TInt KMaxLength = 80;
       
    37 // smiley text place holder
       
    38 _LIT( KPlaceHolder, "\xFFF0i" );
    36 
    39 
    37 // Tree flag definitions
    40 // Tree flag definitions
    38 enum TAknTreeFlags
    41 enum TAknTreeFlags
    39     {
    42     {
    40     ETabModeFunctionIndicators
    43     ETabModeFunctionIndicators
    61 // Destructor.
    64 // Destructor.
    62 // ---------------------------------------------------------------------------
    65 // ---------------------------------------------------------------------------
    63 //
    66 //
    64 CAknTree::~CAknTree()
    67 CAknTree::~CAknTree()
    65     {
    68     {
       
    69     delete iSmileyMan;
       
    70     iSmileyMan = NULL;
    66     delete iOrdering; iOrdering = NULL;
    71     delete iOrdering; iOrdering = NULL;
    67     iCustomOrdering = NULL;
    72     iCustomOrdering = NULL;
    68     iObservers.Close();
    73     iObservers.Close();
    69     iItems.Close();
    74     iItems.Close();
    70     iIcons.ResetAndDestroy();
    75     iIcons.ResetAndDestroy();
  1241             CollapseNode( Id( item->Node() ), EFalse );
  1246             CollapseNode( Id( item->Node() ), EFalse );
  1242             }
  1247             }
  1243         }
  1248         }
  1244     }
  1249     }
  1245 
  1250 
       
  1251 // ---------------------------------------------------------------------------
       
  1252 // CAknTreeItem::InitSmiley().
       
  1253 // Create smiley manager instance if there is not.
       
  1254 // ---------------------------------------------------------------------------
       
  1255 //
       
  1256 void CAknTree::InitSmiley()
       
  1257     {
       
  1258     if ( !iSmileyMan )
       
  1259         {
       
  1260         TRAPD(err, iSmileyMan = CAknSmileyManager::NewL( this ));
       
  1261         if ( err != KErrNone )
       
  1262             {
       
  1263             delete iSmileyMan;
       
  1264             iSmileyMan = NULL;
       
  1265             }
       
  1266         }
       
  1267     }
       
  1268 
       
  1269 // ---------------------------------------------------------------------------
       
  1270 // CAknTreeItem::DrawSmiley
       
  1271 // Draw smiley icon, if it is just plain text, just draw like DrawText.
       
  1272 // ---------------------------------------------------------------------------
       
  1273 //
       
  1274 void CAknTree::DrawSmiley(CWindowGc& aGc, const TRect& aRect, 
       
  1275                           const TAknTextComponentLayout& aTextLayout, 
       
  1276                           const TDesC& aText, const CFont* aFont, 
       
  1277                           TBool aFocused )
       
  1278     {
       
  1279     TBuf<KMaxLength*2> buf = aText.Left(KMaxLength*2);
       
  1280     // it is possiable that this been called after ~CAknTree()...
       
  1281     if ( iSmileyMan && ConvertTextToSmiley(buf) > KErrNone )
       
  1282         {
       
  1283         TRgb textColor;
       
  1284         TAknsQsnTextColorsIndex index = 
       
  1285             aFocused ? EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6;
       
  1286         AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor,
       
  1287                                    KAknsIIDQsnTextColors, index );
       
  1288         aGc.SetPenColor( textColor );
       
  1289         
       
  1290         TAknLayoutText layoutText;
       
  1291         layoutText.LayoutText( aRect, aTextLayout.LayoutLine(), aFont );
       
  1292         TInt l = Min( layoutText.Font()->TextWidthInPixels( KPlaceHolder ),
       
  1293                       layoutText.Font()->FontMaxHeight());
       
  1294         TSize s( l, l);
       
  1295         if ( iSmileySize != s )
       
  1296             {
       
  1297             iSmileyMan->SetSize( s);
       
  1298             iSmileySize = s;
       
  1299             }
       
  1300         iSmileyMan->DrawText( aGc, buf, layoutText, ETrue );
       
  1301         }
       
  1302     else
       
  1303     // no smiley existing...
       
  1304         {
       
  1305         DrawText( aGc, aRect, aTextLayout, aText, aFont, NULL, aFocused, EFalse);
       
  1306         }
       
  1307     }
       
  1308 
       
  1309 // ---------------------------------------------------------------------------
       
  1310 // CAknTreeItem::ConvertTextToSmiley
       
  1311 // ---------------------------------------------------------------------------
       
  1312 //
       
  1313 TInt CAknTree::ConvertTextToSmiley( TDes& aText )
       
  1314     {
       
  1315     TInt count = 0;
       
  1316     TRAPD( err, count = iSmileyMan->ConvertTextToCodesL( aText ));
       
  1317     return err == KErrNone ? count : err;
       
  1318     }    
  1246 
  1319 
  1247 // ---------------------------------------------------------------------------
  1320 // ---------------------------------------------------------------------------
  1248 // C++ constructor.
  1321 // C++ constructor.
  1249 // ---------------------------------------------------------------------------
  1322 // ---------------------------------------------------------------------------
  1250 //
  1323 //
  1459     {
  1532     {
  1460     // The root node should never be drawn!
  1533     // The root node should never be drawn!
  1461     __ASSERT_DEBUG( EFalse, User::Invariant() );
  1534     __ASSERT_DEBUG( EFalse, User::Invariant() );
  1462     }
  1535     }
  1463 
  1536 
       
  1537 // ---------------------------------------------------------------------------
       
  1538 // From class MAknSmileyObserver.
       
  1539 // Redraw whole control when smiley image ready
       
  1540 // ---------------------------------------------------------------------------
       
  1541 //
       
  1542 void CAknTree::SmileyStillImageLoaded( CAknSmileyIcon*  /*aSmileyIcon*/ )
       
  1543     {
       
  1544     iList.DrawDeferred();
       
  1545     }
       
  1546 
       
  1547 // ---------------------------------------------------------------------------
       
  1548 // From class MAknSmileyObserver.
       
  1549 // Empty implementation.
       
  1550 // ---------------------------------------------------------------------------
       
  1551 //
       
  1552 void CAknTree::SmileyAnimationChanged( CAknSmileyIcon* /*aSmileyIcon*/ )
       
  1553     {
       
  1554     }