uifw/AvKon/aknhlist/src/akntreelist.cpp
changeset 0 2f259fa3e83a
child 6 9f56a4e1b8ab
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006, 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Implementation for hierarchical list base class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <akntreelistobserver.h>
       
    20 #include <AknsConstants.h>
       
    21 
       
    22 #include <AknTasHook.h> // for testability hooks
       
    23 #include "akntreelist.h"
       
    24 #include "akntreelistview.h"
       
    25 #include "akntree.h"
       
    26 
       
    27 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
    28 #include <aknlistboxtfxinternal.h> // LISTBOX EFFECTS IMPLEMENTATION
       
    29 #include <aknlistloadertfx.h>
       
    30 #endif
       
    31 const TInt KObserverArrayGranularity = 1;
       
    32 const TInt KNotInNotificationSequence = -1;
       
    33 
       
    34 
       
    35 // ======== MEMBER FUNCTIONS ========
       
    36 
       
    37 // ---------------------------------------------------------------------------
       
    38 // Destructor.
       
    39 // ---------------------------------------------------------------------------
       
    40 //
       
    41 CAknTreeList::~CAknTreeList()
       
    42     {
       
    43     AKNTASHOOK_REMOVE();
       
    44     iObservers.Close();
       
    45     delete iTree;
       
    46     delete iView;
       
    47     }
       
    48 
       
    49 
       
    50 // ---------------------------------------------------------------------------
       
    51 // Sets the flags for the list.
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 EXPORT_C void CAknTreeList::SetFlags( TUint32 aFlags )
       
    55     {
       
    56     TUint32 diff = aFlags ^ iFlags;
       
    57     if ( diff & KAknTreeListLooping )
       
    58         {
       
    59         View().SetLooping( aFlags & KAknTreeListLooping );
       
    60         }
       
    61 
       
    62     if ( diff & KAknTreeListNoStructureLines )
       
    63         {
       
    64         View().SetStructureLineVisibility( 
       
    65             !( aFlags & KAknTreeListNoStructureLines ) );
       
    66         }
       
    67 
       
    68     if ( diff & KAknTreeListMarqueeScrolling )
       
    69         {
       
    70         Tree().EnableMarquee( aFlags & KAknTreeListMarqueeScrolling );
       
    71         }
       
    72 
       
    73     if ( diff & KAknTreeListNoIndention )
       
    74         {
       
    75         View().EnableIndention( !( aFlags & KAknTreeListNoIndention ) );
       
    76         }
       
    77 
       
    78     if ( diff & KAknTreeListMarkable )
       
    79         {
       
    80         View().EnableMarking( aFlags & KAknTreeListMarkable );
       
    81         }
       
    82 
       
    83     iFlags = aFlags;
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Returns the flags set for the list.
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C TUint32 CAknTreeList::Flags() const
       
    92     {
       
    93     return iFlags;
       
    94     }
       
    95 
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Moves the specified item to specfied target node.
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 EXPORT_C void CAknTreeList::MoveItemL( TAknTreeItemID aItem,
       
   102     TAknTreeItemID aTargetNode, TBool aDrawNow )
       
   103     {
       
   104     if ( aItem != KAknTreeIIDNone && aTargetNode != KAknTreeIIDNone )
       
   105         {
       
   106         Tree().MoveItemL( aItem, aTargetNode, aDrawNow );
       
   107         }
       
   108     else if ( aDrawNow )
       
   109         {
       
   110         // Redraw is requested, although no item is moved.
       
   111         Window().Invalidate( View().Rect() );
       
   112         }
       
   113     }
       
   114 
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // Removes the specified item from the tree.
       
   118 // ---------------------------------------------------------------------------
       
   119 //
       
   120 EXPORT_C void CAknTreeList::RemoveItem( TAknTreeItemID aItem, TBool aDrawNow )
       
   121     {
       
   122     if ( aItem != KAknTreeIIDNone )
       
   123         {
       
   124         Tree().RemoveItem( aItem, aDrawNow );
       
   125         }
       
   126     else if ( aDrawNow )
       
   127         {
       
   128         // Redraw is requested, although no item is removed.
       
   129         Window().Invalidate( View().Rect() );
       
   130         }
       
   131     }
       
   132 
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // Expands the specified node.
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 EXPORT_C void CAknTreeList::ExpandNode( TAknTreeItemID aNode, TBool aDrawNow )
       
   139     {
       
   140     Tree().ExpandNode( aNode, aDrawNow );
       
   141     }
       
   142 
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // Collapses the specified node.
       
   146 // ---------------------------------------------------------------------------
       
   147 //
       
   148 EXPORT_C void CAknTreeList::CollapseNode( TAknTreeItemID aNode, TBool aDrawNow )
       
   149     {
       
   150     Tree().CollapseNode( aNode, aDrawNow );
       
   151     }
       
   152 
       
   153 
       
   154 // ---------------------------------------------------------------------------
       
   155 // Checks whether the specified node is expanded.
       
   156 // ---------------------------------------------------------------------------
       
   157 //
       
   158 EXPORT_C TBool CAknTreeList::IsExpanded( TAknTreeItemID aNode ) const
       
   159     {
       
   160     return Tree().IsExpanded( aNode );
       
   161     }
       
   162 
       
   163 
       
   164 // ---------------------------------------------------------------------------
       
   165 // Returns the item ID of focused item.
       
   166 // ---------------------------------------------------------------------------
       
   167 //
       
   168 EXPORT_C TAknTreeItemID CAknTreeList::FocusedItem() const
       
   169     {
       
   170     return Tree().Id( View().FocusedItem() );
       
   171     }
       
   172 
       
   173 
       
   174 // ---------------------------------------------------------------------------
       
   175 // Sets the focused item.
       
   176 // ---------------------------------------------------------------------------
       
   177 //
       
   178 EXPORT_C void CAknTreeList::SetFocusedItem( TAknTreeItemID aItem,
       
   179     TInt aIndex, TBool aDrawNow )
       
   180     {
       
   181     View().SetFocusedItem( Tree().Item( aItem ), aIndex, aDrawNow );
       
   182     }
       
   183 
       
   184 
       
   185 // ---------------------------------------------------------------------------
       
   186 // Returns the highlight rectangle of currently focused item.
       
   187 // ---------------------------------------------------------------------------
       
   188 //
       
   189 EXPORT_C TRect CAknTreeList::HighlightRect() const
       
   190     {
       
   191     return View().HighlightRect();
       
   192     }
       
   193 
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // Adds icon to the tree.
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 EXPORT_C TInt CAknTreeList::AddIconL( const TAknsItemID& aId,
       
   200     const TDesC& aFilename, TInt aBitmapId, TInt aMaskId,
       
   201     TScaleMode aScaleMode )
       
   202     {
       
   203     return Tree().AddIconL( aId, aFilename, aBitmapId, aMaskId, aScaleMode );
       
   204     }
       
   205 
       
   206 
       
   207 // ---------------------------------------------------------------------------
       
   208 // Adds icon to the tree. This overload gets only the bitmaps instead of 
       
   209 // parameters for creating the bitmaps.
       
   210 // ---------------------------------------------------------------------------
       
   211 //
       
   212 EXPORT_C TInt CAknTreeList::AddIconL( CFbsBitmap* aIcon, CFbsBitmap* aMask,
       
   213     TBool aTransferOwnership, TScaleMode aScaleMode )
       
   214     {
       
   215     return Tree().AddIconL( aIcon, aMask, aTransferOwnership, aScaleMode );
       
   216     }
       
   217 
       
   218 
       
   219 // ---------------------------------------------------------------------------
       
   220 // Adds colored icon to the tree.
       
   221 // ---------------------------------------------------------------------------
       
   222 //
       
   223 EXPORT_C TInt CAknTreeList::AddColorIconL( const TAknsItemID& aId,
       
   224     const TAknsItemID& aColorId, TInt aColorIndex, const TDesC& aFilename,
       
   225     TInt aBitmapId, TInt aMaskId, TRgb aDefaultColor, TScaleMode aScaleMode )
       
   226     {
       
   227     return Tree().AddColorIconL( aId, aColorId, aColorIndex, aFilename,
       
   228         aBitmapId, aMaskId, aDefaultColor, aScaleMode );
       
   229     }
       
   230 
       
   231 
       
   232 // ---------------------------------------------------------------------------
       
   233 // Assigns icon for specified icon ID.
       
   234 // ---------------------------------------------------------------------------
       
   235 //
       
   236 EXPORT_C void CAknTreeList::AssignIconL( TInt aIconId, const TAknsItemID& aId,
       
   237     const TDesC& aFilename, TInt aBitmapId, TInt aMaskId,
       
   238     TScaleMode aScaleMode )
       
   239     {
       
   240     if ( aIconId <= AknTreeListIconID::KLineStraightIndication )
       
   241         {
       
   242         // Specified icon ID is out of allowed range.
       
   243         User::Leave( KErrArgument );
       
   244         }
       
   245 
       
   246     Tree().SetIconL( aIconId, aId, aFilename, aBitmapId, aMaskId, aScaleMode );
       
   247     }
       
   248 
       
   249 
       
   250 // ---------------------------------------------------------------------------
       
   251 // Assigns icon for specified icon ID.
       
   252 // ---------------------------------------------------------------------------
       
   253 //
       
   254 EXPORT_C void CAknTreeList::AssignIconL( TInt aIconId, CFbsBitmap* aIcon,
       
   255     CFbsBitmap* aMask, TBool aTransferOwnership, TScaleMode aScaleMode )
       
   256     {
       
   257     if ( aIconId <= AknTreeListIconID::KLineStraightIndication )
       
   258         {
       
   259         // Specified icon ID is out of allowed range.
       
   260         User::Leave( KErrArgument );
       
   261         }
       
   262 
       
   263     Tree().SetIconL( aIconId, aIcon, aMask, aTransferOwnership, aScaleMode );
       
   264     }
       
   265 
       
   266 
       
   267 // ---------------------------------------------------------------------------
       
   268 // Assigns color icon for specified icon ID.
       
   269 // ---------------------------------------------------------------------------
       
   270 //
       
   271 EXPORT_C void CAknTreeList::AssignColorIconL( TInt aIconId,
       
   272     const TAknsItemID& aId, const TAknsItemID& aColorId, TInt aColorIndex,
       
   273     const TDesC& aFilename, TInt aBitmapId, TInt aMaskId, TRgb aDefaultColor,
       
   274     TScaleMode aScaleMode )
       
   275     {
       
   276     if ( aIconId <= AknTreeListIconID::KLineStraightIndication )
       
   277         {
       
   278         // Specified icon ID is out of allowed range.
       
   279         User::Leave( KErrArgument );
       
   280         }
       
   281 
       
   282     Tree().SetColorIconL( aIconId, aId, aColorId, aColorIndex, aFilename,
       
   283         aBitmapId, aMaskId, aDefaultColor, aScaleMode );
       
   284     }
       
   285 
       
   286 
       
   287 // ---------------------------------------------------------------------------
       
   288 // Removes previously added icon from the tree.
       
   289 // ---------------------------------------------------------------------------
       
   290 //
       
   291 EXPORT_C void CAknTreeList::RemoveIconL( TInt aIconId )
       
   292     {
       
   293     Tree().RemoveIconL( aIconId );
       
   294     }
       
   295 
       
   296 
       
   297 // ---------------------------------------------------------------------------
       
   298 // Returns the child count for specified node.
       
   299 // ---------------------------------------------------------------------------
       
   300 //
       
   301 EXPORT_C TInt CAknTreeList::ChildCount( TAknTreeItemID aNode ) const
       
   302     {
       
   303     return Tree().ChildCount( aNode );
       
   304     }
       
   305 
       
   306 
       
   307 // ---------------------------------------------------------------------------
       
   308 // Returns the specified child.
       
   309 // ---------------------------------------------------------------------------
       
   310 //
       
   311 EXPORT_C TAknTreeItemID CAknTreeList::Child( TAknTreeItemID aNode,
       
   312                                              TInt aIndex ) const
       
   313     {
       
   314     return Tree().Child( aNode, aIndex );
       
   315     }
       
   316 
       
   317 
       
   318 // ---------------------------------------------------------------------------
       
   319 // Returns the ID of specified item's parent.
       
   320 // ---------------------------------------------------------------------------
       
   321 //
       
   322 EXPORT_C TAknTreeItemID CAknTreeList::Parent( TAknTreeItemID aItem ) const
       
   323     {
       
   324     return Tree().Parent( aItem );
       
   325     }
       
   326 
       
   327 
       
   328 // ---------------------------------------------------------------------------
       
   329 // Returns whether the list contains the specified item.
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 EXPORT_C TBool CAknTreeList::Contains( TAknTreeItemID aItem ) const
       
   333     {
       
   334     CAknTreeItem* item;
       
   335     TInt error = Tree().GetItem( aItem, item );
       
   336     if ( !error )
       
   337         {
       
   338         return ETrue;
       
   339         }
       
   340     else
       
   341         {
       
   342         return EFalse;
       
   343         }
       
   344     }
       
   345 
       
   346 
       
   347 // ---------------------------------------------------------------------------
       
   348 // Checks whether the specified item is a node.
       
   349 // ---------------------------------------------------------------------------
       
   350 //
       
   351 EXPORT_C TBool CAknTreeList::IsNode( TAknTreeItemID aItem ) const
       
   352     {
       
   353     CAknTreeItem* item = Tree().Item( aItem );
       
   354     return item->IsNode();
       
   355     }
       
   356 
       
   357 
       
   358 // ---------------------------------------------------------------------------
       
   359 // Checks whether the specified item is a leaf.
       
   360 // ---------------------------------------------------------------------------
       
   361 //
       
   362 EXPORT_C TBool CAknTreeList::IsLeaf( TAknTreeItemID aItem ) const
       
   363     {
       
   364     CAknTreeItem* item = Tree().Item( aItem );
       
   365     return item->IsLeaf();
       
   366     }
       
   367 
       
   368 
       
   369 // ---------------------------------------------------------------------------
       
   370 // Checks whether the specified item is marked.
       
   371 // ---------------------------------------------------------------------------
       
   372 //
       
   373 EXPORT_C TBool CAknTreeList::IsMarked( TAknTreeItemID aItem ) const
       
   374     {
       
   375     return Tree().IsMarked( aItem );
       
   376     }
       
   377 
       
   378 
       
   379 // ---------------------------------------------------------------------------
       
   380 // Changes the specified item marked or unmarked.
       
   381 // ---------------------------------------------------------------------------
       
   382 //
       
   383 EXPORT_C void CAknTreeList::SetMarked( TAknTreeItemID aItem,
       
   384     TBool aMarked, TBool aDrawNow )
       
   385     {
       
   386     if ( aItem != KAknTreeIIDNone )
       
   387         {
       
   388         Tree().SetMarked( aItem, aMarked, aDrawNow );
       
   389         }
       
   390     else if ( aDrawNow )
       
   391         {
       
   392         Window().Invalidate( View().Rect() );
       
   393         }
       
   394     }
       
   395 
       
   396 
       
   397 // ---------------------------------------------------------------------------
       
   398 // Enables/disables marking for specified list item.
       
   399 // ---------------------------------------------------------------------------
       
   400 //
       
   401 EXPORT_C void CAknTreeList::EnableMarking( TAknTreeItemID aItem,
       
   402     TBool aEnable )
       
   403     {
       
   404     Tree().EnableMarking( aItem, aEnable );
       
   405     }
       
   406 
       
   407 
       
   408 // ---------------------------------------------------------------------------
       
   409 // Appends all the marked item from the list to the given array.
       
   410 // ---------------------------------------------------------------------------
       
   411 //
       
   412 EXPORT_C void CAknTreeList::GetMarkedItemsL(
       
   413     RArray<TAknTreeItemID>& aMarkedItems ) const
       
   414     {
       
   415     Tree().GetMarkedItemsL( KAknTreeIIDRoot, aMarkedItems );
       
   416     }
       
   417 
       
   418 
       
   419 // ---------------------------------------------------------------------------
       
   420 // Appends marked items from the specified node to the given array.
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 EXPORT_C void CAknTreeList::GetMarkedItemsL( TAknTreeItemID aNode,
       
   424     RArray<TAknTreeItemID>& aMarkedItems ) const
       
   425     {
       
   426     Tree().GetMarkedItemsL( aNode, aMarkedItems );
       
   427     }
       
   428 
       
   429 
       
   430 // ---------------------------------------------------------------------------
       
   431 // Returns whether the specified node is empty.
       
   432 // ---------------------------------------------------------------------------
       
   433 //
       
   434 EXPORT_C TBool CAknTreeList::IsEmpty( TAknTreeItemID aNode ) const
       
   435     {
       
   436     return Tree().IsEmpty( aNode );
       
   437     }
       
   438 
       
   439 
       
   440 // ---------------------------------------------------------------------------
       
   441 // Sets the specified item to appear non-empty, or removes the setting.
       
   442 // ---------------------------------------------------------------------------
       
   443 //
       
   444 EXPORT_C void CAknTreeList::SetNonEmpty( TAknTreeItemID aNode,
       
   445     TBool aNonEmpty, TBool aDrawNow )
       
   446     {
       
   447     Tree().SetNonEmpty( aNode, aNonEmpty, aDrawNow );
       
   448     }
       
   449 
       
   450 
       
   451 // ---------------------------------------------------------------------------
       
   452 // Checks whether the specified item is persistent.
       
   453 // ---------------------------------------------------------------------------
       
   454 //
       
   455 EXPORT_C TBool CAknTreeList::IsPersistent( TAknTreeItemID aItem ) const
       
   456     {
       
   457     return Tree().IsPersistent( aItem );
       
   458     }
       
   459 
       
   460 
       
   461 // ---------------------------------------------------------------------------
       
   462 // Sets the specified item persistent or non-persistent.
       
   463 // ---------------------------------------------------------------------------
       
   464 //
       
   465 EXPORT_C void CAknTreeList::SetPersistent( TAknTreeItemID aItem,
       
   466     TBool aPersistent )
       
   467     {
       
   468     Tree().SetPersistent( aItem, aPersistent );
       
   469     }
       
   470 
       
   471 
       
   472 // ---------------------------------------------------------------------------
       
   473 // Sets the interface used for custom tree ordering.
       
   474 // ---------------------------------------------------------------------------
       
   475 //
       
   476 EXPORT_C void CAknTreeList::Sort( MAknCustomTreeOrdering* aOrdering,
       
   477     TBool aDrawNow )
       
   478     {
       
   479     // move view to beginning, lose focus
       
   480     View().SetFocusBehaviour( EFalse );
       
   481     
       
   482     Tree().SetCustomOrdering( aOrdering, aDrawNow );
       
   483     }
       
   484 
       
   485 
       
   486 // ---------------------------------------------------------------------------
       
   487 // Sorts the specified node content with previously set ordering.
       
   488 // ---------------------------------------------------------------------------
       
   489 //
       
   490 EXPORT_C void CAknTreeList::Sort( TAknTreeItemID aNode,
       
   491     TBool aSortDescendants, TBool aDrawNow )
       
   492     {
       
   493     // move view to beginning, lose focus
       
   494     View().SetFocusBehaviour( EFalse );
       
   495     
       
   496     Tree().Sort( aNode, aSortDescendants, aDrawNow );
       
   497     }
       
   498 
       
   499 
       
   500 // ---------------------------------------------------------------------------
       
   501 // Adds the observer to the list of observers.
       
   502 // ---------------------------------------------------------------------------
       
   503 //
       
   504 EXPORT_C void CAknTreeList::AddObserverL( MAknTreeListObserver* aObserver )
       
   505     {
       
   506     // Append observer to the end of the array. This does not affect the
       
   507     // index used in notification sequence.
       
   508     iObservers.AppendL( aObserver );
       
   509     }
       
   510 
       
   511 
       
   512 // ---------------------------------------------------------------------------
       
   513 // Removes the specified observer from the list of observers.
       
   514 // ---------------------------------------------------------------------------
       
   515 //
       
   516 EXPORT_C void CAknTreeList::RemoveObserver( MAknTreeListObserver* aObserver )
       
   517     {
       
   518     TInt index = iObservers.Find( aObserver );
       
   519     if ( index != KErrNotFound )
       
   520         {
       
   521         iObservers.Remove( index );
       
   522         }
       
   523     }
       
   524 
       
   525 
       
   526 // ---------------------------------------------------------------------------
       
   527 // Notifies all of the tree list observers of the specified event.
       
   528 // ---------------------------------------------------------------------------
       
   529 //
       
   530 void CAknTreeList::NotifyObservers( MAknTreeListObserver::TEvent aEvent,
       
   531     TAknTreeItemID aItem )
       
   532     {
       
   533     // Note: Local variable index is used instead of iIndex
       
   534     // Nested calls to NotifyObservers don't work with iIndex
       
   535     for ( TInt index = 0; index < iObservers.Count(); ++index )
       
   536         {
       
   537         iObservers[index]->HandleTreeListEvent( *this, aItem, aEvent );
       
   538         }
       
   539 
       
   540     // Change index to indicate that no notification sequence is ongoing.
       
   541     iIndex = KNotInNotificationSequence;
       
   542 
       
   543     // Notify also control observer.
       
   544     if ( Observer() )
       
   545         {
       
   546         TRAP_IGNORE( Observer()->HandleControlEventL( this,
       
   547             MCoeControlObserver::EEventStateChanged ) );
       
   548         }
       
   549     }
       
   550 
       
   551 
       
   552 // ---------------------------------------------------------------------------
       
   553 // Checks whether tabulator mode function indicators are used.
       
   554 // ---------------------------------------------------------------------------
       
   555 //
       
   556 EXPORT_C TBool CAknTreeList::TabModeFunctionIndicators() const
       
   557     {
       
   558     return Tree().TabModeFunctionIndicators();
       
   559     }
       
   560 
       
   561 
       
   562 // ---------------------------------------------------------------------------
       
   563 // Changes expand and collapse function indicators.
       
   564 // ---------------------------------------------------------------------------
       
   565 //
       
   566 EXPORT_C void CAknTreeList::EnableTabModeFunctionIndicatorsL( TBool aEnable )
       
   567     {
       
   568     Tree().EnableTabModeFunctionIndicatorsL( aEnable );
       
   569     }
       
   570     
       
   571 // ---------------------------------------------------------------------------
       
   572 //  Sets the focused item and moves view so that focused item is visible
       
   573 // ---------------------------------------------------------------------------
       
   574 //    
       
   575 EXPORT_C void CAknTreeList::SetFocusedItem( TAknTreeItemID aItem )
       
   576 	{
       
   577 	View().SetFocusedItemAndView( Tree().Item( aItem ) );
       
   578 	}
       
   579 
       
   580 // ---------------------------------------------------------------------------
       
   581 //  Returns the index of focused item
       
   582 // ---------------------------------------------------------------------------
       
   583 // 
       
   584 EXPORT_C TInt CAknTreeList::FocusedItemIndex() const
       
   585 	{
       
   586 	return View().FocusedItemIndex();
       
   587 	}
       
   588 	
       
   589 	
       
   590 // ---------------------------------------------------------------------------
       
   591 //  Returns the index of requested visible item
       
   592 // ---------------------------------------------------------------------------
       
   593 // 
       
   594 EXPORT_C TInt CAknTreeList::VisibleItemIndex( TAknTreeItemID aItem ) const
       
   595 	{
       
   596 	return View().VisibleItemIndex( Tree().Item( aItem ) );
       
   597 	}
       
   598 	
       
   599 	
       
   600 
       
   601 // ---------------------------------------------------------------------------
       
   602 // Sets the interface used for custom tree ordering.
       
   603 // ---------------------------------------------------------------------------
       
   604 // 
       
   605 EXPORT_C void CAknTreeList::Sort( MAknCustomTreeOrdering* aOrdering,
       
   606     TFocusBehaviour aFocusBehaviour, TBool aDrawNow )
       
   607     {
       
   608     View().SetFocusBehaviour( ( aFocusBehaviour == ESaveFocus ) ? ETrue : EFalse );
       
   609     Tree().SetCustomOrdering( aOrdering, aDrawNow );
       
   610     }
       
   611 
       
   612 // ---------------------------------------------------------------------------
       
   613 // Sorts the specified node content with previously set ordering.
       
   614 // ---------------------------------------------------------------------------
       
   615 // 
       
   616 EXPORT_C void CAknTreeList::Sort( TAknTreeItemID aNode,
       
   617     TFocusBehaviour aFocusBehaviour, TBool aSortDescendants, TBool aDrawNow )
       
   618     {
       
   619     View().SetFocusBehaviour( ( aFocusBehaviour == ESaveFocus ) ? ETrue : EFalse );
       
   620     Tree().Sort( aNode, aSortDescendants, aDrawNow );
       
   621     }
       
   622 
       
   623 // ---------------------------------------------------------------------------
       
   624 // Sets text for the empty list.
       
   625 // ---------------------------------------------------------------------------
       
   626 // 
       
   627 EXPORT_C void CAknTreeList::SetEmptyTextL(const TDesC& aText)
       
   628 	{
       
   629 	View().SetEmptyTextL( aText );
       
   630 	}
       
   631 
       
   632 
       
   633 // ---------------------------------------------------------------------------
       
   634 // Handles key events by mediating them to the view.
       
   635 // ---------------------------------------------------------------------------
       
   636 //
       
   637 TKeyResponse CAknTreeList::OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   638     TEventCode aType )
       
   639     {
       
   640     if ( IsFocused() )
       
   641         {
       
   642         return View().OfferKeyEventL( aKeyEvent, aType );
       
   643         }
       
   644     else
       
   645         {
       
   646         return EKeyWasNotConsumed;
       
   647         }
       
   648     }
       
   649 
       
   650 
       
   651 // ---------------------------------------------------------------------------
       
   652 // Changes the visibility of the list.
       
   653 // ---------------------------------------------------------------------------
       
   654 //
       
   655 void CAknTreeList::MakeVisible( TBool aVisible )
       
   656     {
       
   657     CAknControl::MakeVisible( aVisible );
       
   658     View().MakeVisible( aVisible );
       
   659     }
       
   660 
       
   661 
       
   662 // ---------------------------------------------------------------------------
       
   663 // Changes the dimming of the list.
       
   664 // ---------------------------------------------------------------------------
       
   665 //
       
   666 void CAknTreeList::SetDimmed( TBool aDimmed )
       
   667     {
       
   668     CAknControl::SetDimmed( aDimmed );
       
   669     View().SetDimmed( aDimmed );
       
   670     }
       
   671 
       
   672 
       
   673 // ---------------------------------------------------------------------------
       
   674 // From class CCoeControl.
       
   675 // Sets the control's containing window by copying it from aContainer.
       
   676 // ---------------------------------------------------------------------------
       
   677 //
       
   678 void CAknTreeList::SetContainerWindowL( const CCoeControl& aContainer )
       
   679     {
       
   680     CAknControl::SetContainerWindowL( aContainer );
       
   681     if ( iView )
       
   682         {
       
   683         iView->SetContainerWindowL( *this );
       
   684         }
       
   685     }
       
   686 
       
   687 
       
   688 // ---------------------------------------------------------------------------
       
   689 // Sets the control as ready to be drawn.
       
   690 // ---------------------------------------------------------------------------
       
   691 //
       
   692 void CAknTreeList::ActivateL()
       
   693     {
       
   694     CAknControl::ActivateL();
       
   695     }
       
   696 
       
   697 
       
   698 // ---------------------------------------------------------------------------
       
   699 // Handles resource changes. The tree needs notification of skin change, so
       
   700 // it can reconstruct the icons for the new skin.
       
   701 // ---------------------------------------------------------------------------
       
   702 //
       
   703 void CAknTreeList::HandleResourceChange( TInt aType )
       
   704     {
       
   705     CAknControl::HandleResourceChange( aType );
       
   706     if ( aType == KAknsMessageSkinChange )
       
   707         {
       
   708         TRAP_IGNORE( Tree().HandleSkinChangeL() );
       
   709         }
       
   710     }
       
   711 
       
   712 
       
   713 // ---------------------------------------------------------------------------
       
   714 // Gets the control's input capabilities.
       
   715 // ---------------------------------------------------------------------------
       
   716 //
       
   717 TCoeInputCapabilities CAknTreeList::InputCapabilities() const
       
   718     {
       
   719     return TCoeInputCapabilities::ENavigation;
       
   720     }
       
   721 
       
   722 
       
   723 // ---------------------------------------------------------------------------
       
   724 // Handles pointer events. The pointer events are mediated to the view by
       
   725 // control framework, as the view is set as component control of the list.
       
   726 // ---------------------------------------------------------------------------
       
   727 //
       
   728 void CAknTreeList::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   729     {
       
   730     CAknControl::HandlePointerEventL( aPointerEvent );
       
   731     }
       
   732 
       
   733 
       
   734 // ---------------------------------------------------------------------------
       
   735 // From class CCoeControl.
       
   736 // ---------------------------------------------------------------------------
       
   737 //
       
   738 TInt CAknTreeList::CountComponentControls() const
       
   739     {
       
   740     return iView ? 1 : 0;
       
   741     }
       
   742 
       
   743 
       
   744 // ---------------------------------------------------------------------------
       
   745 // From class CCoeControl.
       
   746 // ---------------------------------------------------------------------------
       
   747 //
       
   748 CCoeControl* CAknTreeList::ComponentControl( TInt /*aIndex*/ ) const
       
   749     {
       
   750     return iView;
       
   751     }
       
   752 
       
   753 
       
   754 // ---------------------------------------------------------------------------
       
   755 // Default C++ constructor.
       
   756 // ---------------------------------------------------------------------------
       
   757 //
       
   758 CAknTreeList::CAknTreeList()
       
   759     : iObservers( KObserverArrayGranularity ),
       
   760       iIndex( KNotInNotificationSequence )
       
   761     {
       
   762     AKNTASHOOK_ADD( this, "CAknTreeList" );
       
   763     }
       
   764 
       
   765 
       
   766 // ---------------------------------------------------------------------------
       
   767 // Completes the construction of the base class. This variant creates a new
       
   768 // window for the list and activates it.
       
   769 // ---------------------------------------------------------------------------
       
   770 //
       
   771 void CAknTreeList::BaseConstructL()
       
   772     {
       
   773     CreateWindowL();
       
   774     BaseConstructL( *this );
       
   775     ActivateL();
       
   776     }
       
   777 
       
   778 
       
   779 // ---------------------------------------------------------------------------
       
   780 // Completes the construction of the base class. This variant assigns the
       
   781 // window of the given container to the list.
       
   782 // ---------------------------------------------------------------------------
       
   783 //
       
   784 void CAknTreeList::BaseConstructL( const CCoeControl& aContainer )
       
   785     {
       
   786     if ( this != &aContainer )
       
   787         {
       
   788         SetContainerWindowL( aContainer );
       
   789         }
       
   790     EnableDragEvents();
       
   791     iTree = CAknTree::NewL( *this, NULL );
       
   792     iView = CAknTreeListView::NewL( *this, *iTree, *this );
       
   793     
       
   794 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   795 	// LISTBOX EFFECTS IMPLEMENTATION
       
   796 	//
       
   797 	// Creates a CTfxGc and replaces the original CWindowGc with that gc.
       
   798 	//
       
   799     CWindowGc* transGc = CAknListLoader::CreateTfxGc( *this, iView->TopIndex(), 
       
   800     												iView->BottomIndex(), 
       
   801     												iView->HighlightIndex(), 
       
   802     												iView->ItemCountLimit()); 
       
   803     if( transGc )
       
   804         {
       
   805 		iView->SetGc(transGc);
       
   806         }
       
   807 	// END OF LISTBOX EFFECTS IMPLEMENTATION
       
   808 #endif // RD_UI_TRANSITION_EFFECTS_LIST
       
   809     
       
   810     iTree->AddObserverL( iView );
       
   811     }
       
   812 
       
   813 
       
   814 // ---------------------------------------------------------------------------
       
   815 // References to the tree.
       
   816 // ---------------------------------------------------------------------------
       
   817 //
       
   818 CAknTree& CAknTreeList::Tree()
       
   819     {
       
   820     __ASSERT_DEBUG( iTree != NULL, User::Invariant() );
       
   821     return *iTree;
       
   822     }
       
   823 
       
   824 
       
   825 const CAknTree& CAknTreeList::Tree() const
       
   826     {
       
   827     __ASSERT_DEBUG( iTree != NULL, User::Invariant() );
       
   828     return *iTree;
       
   829     }
       
   830 
       
   831 
       
   832 // ---------------------------------------------------------------------------
       
   833 // References to the view.
       
   834 // ---------------------------------------------------------------------------
       
   835 //
       
   836 CAknTreeListView& CAknTreeList::View()
       
   837     {
       
   838     __ASSERT_DEBUG( iView != NULL, User::Invariant() );
       
   839     return *iView;
       
   840     }
       
   841 
       
   842 
       
   843 const CAknTreeListView& CAknTreeList::View() const
       
   844     {
       
   845     __ASSERT_DEBUG( iView != NULL, User::Invariant() );
       
   846     return *iView;
       
   847     }
       
   848 
       
   849 
       
   850 // ---------------------------------------------------------------------------
       
   851 // Mediates the focus change to the view.
       
   852 // ---------------------------------------------------------------------------
       
   853 //
       
   854 void CAknTreeList::FocusChanged( TDrawNow aDrawNow )
       
   855     {
       
   856     View().SetFocus( IsFocused(), aDrawNow );
       
   857     }
       
   858 
       
   859 
       
   860 // ---------------------------------------------------------------------------
       
   861 // From class CCoeControl.
       
   862 // Mediates the size and position change to the view.
       
   863 // ---------------------------------------------------------------------------
       
   864 //
       
   865 void CAknTreeList::SizeChanged()
       
   866     {
       
   867     View().SetRect( Rect() );
       
   868     }
       
   869 
       
   870 
       
   871 // ---------------------------------------------------------------------------
       
   872 // From class CCoeControl.
       
   873 // Mediates the position change to the view.
       
   874 // ---------------------------------------------------------------------------
       
   875 //
       
   876 void CAknTreeList::PositionChanged()
       
   877     {
       
   878     View().SetPosition( TPoint() );
       
   879     }
       
   880 
       
   881 
       
   882 // ---------------------------------------------------------------------------
       
   883 // From class CCoeControl.
       
   884 // Retrieves an object of the same type as that encapsulated in aId.
       
   885 // ---------------------------------------------------------------------------
       
   886 //
       
   887 TTypeUid::Ptr CAknTreeList::MopSupplyObject( TTypeUid aId )
       
   888     {
       
   889     return CAknControl::MopSupplyObject( aId );
       
   890     }
       
   891 
       
   892 
       
   893 // ---------------------------------------------------------------------------
       
   894 // Does nothing, the draw request is mediated to the view through component
       
   895 // control structure.
       
   896 // ---------------------------------------------------------------------------
       
   897 //
       
   898 void CAknTreeList::Draw( const TRect& /*aRect*/ ) const
       
   899     {
       
   900     }
       
   901