uifw/AvKon/aknhlist/src/akntree.cpp
branchRCL_3
changeset 56 d48ab3b357f1
parent 55 aecbbf00d063
equal deleted inserted replaced
55:aecbbf00d063 56:d48ab3b357f1
    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();
   773 // ---------------------------------------------------------------------------
   778 // ---------------------------------------------------------------------------
   774 //
   779 //
   775 void CAknTree::GetMarkedItemsL( TAknTreeItemID aNode,
   780 void CAknTree::GetMarkedItemsL( TAknTreeItemID aNode,
   776     RArray<TAknTreeItemID>& aMarkedItems ) const
   781     RArray<TAknTreeItemID>& aMarkedItems ) const
   777     {
   782     {
       
   783     ::CleanupClosePushL(aMarkedItems);
   778     aMarkedItems.Reset();
   784     aMarkedItems.Reset();
   779     if ( aNode == KAknTreeIIDRoot )
   785     if ( aNode == KAknTreeIIDRoot )
   780         {
   786         {
   781         // Get marked items from the tree by iterating through array.
   787         // Get marked items from the tree by iterating through array.
   782         CAknTreeItem* item = NULL;
   788         CAknTreeItem* item = NULL;
   804                 {
   810                 {
   805                 aMarkedItems.AppendL( Id( item ) );
   811                 aMarkedItems.AppendL( Id( item ) );
   806                 }
   812                 }
   807             }
   813             }
   808         }
   814         }
       
   815 	CleanupStack::Pop(&aMarkedItems);
   809     }
   816     }
   810 
   817 
   811 
   818 
   812 // ---------------------------------------------------------------------------
   819 // ---------------------------------------------------------------------------
   813 // Checks whether the specified node is empty.
   820 // Checks whether the specified node is empty.
  1241             CollapseNode( Id( item->Node() ), EFalse );
  1248             CollapseNode( Id( item->Node() ), EFalse );
  1242             }
  1249             }
  1243         }
  1250         }
  1244     }
  1251     }
  1245 
  1252 
       
  1253 // ---------------------------------------------------------------------------
       
  1254 // CAknTreeItem::InitSmiley().
       
  1255 // Create smiley manager instance if there is not.
       
  1256 // ---------------------------------------------------------------------------
       
  1257 //
       
  1258 void CAknTree::InitSmiley()
       
  1259     {
       
  1260     if ( !iSmileyMan )
       
  1261         {
       
  1262         TRAPD(err, iSmileyMan = CAknSmileyManager::NewL( this ));
       
  1263         if ( err != KErrNone )
       
  1264             {
       
  1265             delete iSmileyMan;
       
  1266             iSmileyMan = NULL;
       
  1267             }
       
  1268         }
       
  1269     }
       
  1270 
       
  1271 // ---------------------------------------------------------------------------
       
  1272 // CAknTreeItem::DrawSmiley
       
  1273 // Draw smiley icon, if it is just plain text, just draw like DrawText.
       
  1274 // ---------------------------------------------------------------------------
       
  1275 //
       
  1276 void CAknTree::DrawSmiley(CWindowGc& aGc, const TRect& aRect, 
       
  1277                           const TAknTextComponentLayout& aTextLayout, 
       
  1278                           const TDesC& aText, const CFont* aFont, 
       
  1279                           TBool aFocused )
       
  1280     {
       
  1281     TBuf<KMaxLength*2> buf = aText.Left(KMaxLength*2);
       
  1282     // it is possiable that this been called after ~CAknTree()...
       
  1283     if ( iSmileyMan && ConvertTextToSmiley(buf) > KErrNone )
       
  1284         {
       
  1285         TRgb textColor;
       
  1286         TAknsQsnTextColorsIndex index = 
       
  1287             aFocused ? EAknsCIQsnTextColorsCG10 : EAknsCIQsnTextColorsCG6;
       
  1288         AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), textColor,
       
  1289                                    KAknsIIDQsnTextColors, index );
       
  1290         aGc.SetPenColor( textColor );
       
  1291         
       
  1292         TAknLayoutText layoutText;
       
  1293         layoutText.LayoutText( aRect, aTextLayout.LayoutLine(), aFont );
       
  1294         TInt l = Min( layoutText.Font()->TextWidthInPixels( KPlaceHolder ),
       
  1295                       layoutText.Font()->FontMaxHeight());
       
  1296         TSize s( l, l);
       
  1297         if ( iSmileySize != s )
       
  1298             {
       
  1299             iSmileyMan->SetSize( s);
       
  1300             iSmileySize = s;
       
  1301             }
       
  1302         iSmileyMan->DrawText( aGc, buf, layoutText, ETrue );
       
  1303         }
       
  1304     else
       
  1305     // no smiley existing...
       
  1306         {
       
  1307         DrawText( aGc, aRect, aTextLayout, aText, aFont, NULL, aFocused, EFalse);
       
  1308         }
       
  1309     }
       
  1310 
       
  1311 // ---------------------------------------------------------------------------
       
  1312 // CAknTreeItem::ConvertTextToSmiley
       
  1313 // ---------------------------------------------------------------------------
       
  1314 //
       
  1315 TInt CAknTree::ConvertTextToSmiley( TDes& aText )
       
  1316     {
       
  1317     TInt count = 0;
       
  1318     TRAPD( err, count = iSmileyMan->ConvertTextToCodesL( aText ));
       
  1319     return err == KErrNone ? count : err;
       
  1320     }    
  1246 
  1321 
  1247 // ---------------------------------------------------------------------------
  1322 // ---------------------------------------------------------------------------
  1248 // C++ constructor.
  1323 // C++ constructor.
  1249 // ---------------------------------------------------------------------------
  1324 // ---------------------------------------------------------------------------
  1250 //
  1325 //
  1459     {
  1534     {
  1460     // The root node should never be drawn!
  1535     // The root node should never be drawn!
  1461     __ASSERT_DEBUG( EFalse, User::Invariant() );
  1536     __ASSERT_DEBUG( EFalse, User::Invariant() );
  1462     }
  1537     }
  1463 
  1538 
       
  1539 // ---------------------------------------------------------------------------
       
  1540 // From class MAknSmileyObserver.
       
  1541 // Redraw whole control when smiley image ready
       
  1542 // ---------------------------------------------------------------------------
       
  1543 //
       
  1544 void CAknTree::SmileyStillImageLoaded( CAknSmileyIcon*  /*aSmileyIcon*/ )
       
  1545     {
       
  1546     iList.DrawDeferred();
       
  1547     }
       
  1548 
       
  1549 // ---------------------------------------------------------------------------
       
  1550 // From class MAknSmileyObserver.
       
  1551 // Empty implementation.
       
  1552 // ---------------------------------------------------------------------------
       
  1553 //
       
  1554 void CAknTree::SmileyAnimationChanged( CAknSmileyIcon* /*aSmileyIcon*/ )
       
  1555     {
       
  1556     }