uifw/AvKon/aknhlist/inc/akntreelistview.h
changeset 0 2f259fa3e83a
child 6 9f56a4e1b8ab
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2009 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:  Hierarchical list view.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AKNTREELISTVIEW_H
       
    20 #define C_AKNTREELISTVIEW_H
       
    21 
       
    22 
       
    23 #include <AknControl.h> // CAknControl
       
    24 #include <eiksbobs.h>   // MEikScrollBarObserver
       
    25 #include <AknsEffectAnim.h>
       
    26 #include <AknsItemID.h>
       
    27 #include <babitflags.h>
       
    28 #include <eikcmobs.h>
       
    29 #include <akntreelistobserver.h>
       
    30 #include <akncollection.h>
       
    31 #include <aknlongtapdetector.h>
       
    32 
       
    33 #include "akntreeobserver.h"
       
    34 #include "akntreelistviewitem.h"
       
    35 
       
    36 class CAknTreeNode;
       
    37 class CAknTreeList;
       
    38 class TAknWindowComponentLayout;
       
    39 class CAknsBasicBackgroundControlContext;
       
    40 class CEikScrollBarFrame;
       
    41 class CAknTreeListPhysicsHandler;
       
    42 class CAknItemActionMenu;
       
    43 
       
    44 /**
       
    45  *  Hierarchical list view.
       
    46  *
       
    47  *  The hierarchical list view is responsible of maintaining the set of tree
       
    48  *  view items representing which of the tree items are currently visible,
       
    49  *  handling pointer and keyboard events, and drawing the requested part of
       
    50  *  the view.
       
    51  *
       
    52  *  @lib aknhlist.lib
       
    53  *  @since S60 v3.2
       
    54  */
       
    55 NONSHARABLE_CLASS( CAknTreeListView ) : public CAknControl,
       
    56                                         public MEikScrollBarObserver,
       
    57                                         public MAknTreeObserver,
       
    58                                         public MAknsEffectAnimObserver,
       
    59                                         public MEikCommandObserver,
       
    60                                         public MAknCollection,
       
    61                                         public MAknLongTapDetectorCallBack
       
    62                                         
       
    63     {
       
    64 
       
    65 public:
       
    66 
       
    67     /**
       
    68      * Two-phased constructor.
       
    69      *
       
    70      * @param aContainer Container for the view.
       
    71      *
       
    72      * @param aTree Reference to the tree structure.
       
    73      *
       
    74      * @param aList Reference to the list.
       
    75      *
       
    76      * @return Pointer to newly constructed object.
       
    77      */
       
    78     static CAknTreeListView* NewL( const CCoeControl& aContainer,
       
    79         CAknTree& aTree, CAknTreeList& aList );
       
    80 
       
    81     /**
       
    82      * Destructor.
       
    83      */
       
    84     virtual ~CAknTreeListView();
       
    85 
       
    86     /**
       
    87      * Utility method for calculating the rectangle of a layout component.
       
    88      *
       
    89      * @param aParent Parent rectangle for the required rectangle.
       
    90      *
       
    91      * @param aComponentLayout Component layout for the required component.
       
    92      *
       
    93      * @return Required rectangle.
       
    94      */
       
    95     static TRect RectFromLayout( const TRect& aParent,
       
    96         const TAknWindowComponentLayout& aComponentLayout );
       
    97 
       
    98     /**
       
    99      * Sets the focused item and its position in the view. 
       
   100      *
       
   101      * @param aItem The item to be focused. @c NULL, if no item is focused.
       
   102      *
       
   103      * @param aIndex Position of the focused item in the view as an index. If
       
   104      *      the index is less than zero or greater than or equal to the number
       
   105      *      of items in the view, the focused item is changed, but the items
       
   106      *      in the view are not changed.
       
   107      *
       
   108      * @param aDrawNow @c ETrue to redraw the view after the focused item has
       
   109      *      been changed.
       
   110      */
       
   111     void SetFocusedItem( CAknTreeItem* aItem, TInt aIndex, TBool aDrawNow );
       
   112 
       
   113     /**
       
   114      * Sets the focused item and its position in the view. Moves view so that 
       
   115      * focused item is allways visible.
       
   116      *
       
   117      * @param aItem The item to be focused.
       
   118      *
       
   119      */
       
   120     void SetFocusedItemAndView( CAknTreeItem* aItem );
       
   121     
       
   122     /**
       
   123      * Gets the index of the focused item on the screen. Possible values are
       
   124      * from 0 to max. number of visible lines - 1. Value -1 is
       
   125      * returned if no item is focused or focused item is not visible. 
       
   126      *
       
   127      * @return index of the focused item on the screen.
       
   128      */
       
   129     TInt FocusedItemIndex() const;
       
   130     
       
   131     
       
   132     TInt VisibleItemIndex( CAknTreeItem* aItem ) const;
       
   133 
       
   134     
       
   135     /**
       
   136      * Sets focus behaviour after sorting. 
       
   137      *
       
   138      * @c ESaveFocus saves focus in the item where it was before sorting, 
       
   139      * @c EMoveFocusToFirstItem changes view to the beginning of the list
       
   140      * and moves focus to the first item.  
       
   141      *
       
   142      * @return index of the focused item on the screen.
       
   143      */
       
   144     void SetFocusBehaviour( TBool saveFocus );
       
   145 
       
   146     /**
       
   147      * Returns pointer to the focused item.
       
   148      *
       
   149      * @return Pointer to the focused item. @c NULL, if no item is focused.
       
   150      */
       
   151     CAknTreeItem* FocusedItem() const;
       
   152 
       
   153     /**
       
   154      * Returns the highlight rectangle for the currently focused item. The
       
   155      * returned rectangle is empty, if no visible item is highlighted.
       
   156      *
       
   157      * @return Highlight rectangle.
       
   158      */
       
   159     TRect HighlightRect() const;
       
   160 
       
   161     /**
       
   162      * Returns whether the list is looping or non-looping.
       
   163      *
       
   164      * @return @c ETrue, if the list is looping.
       
   165      */
       
   166     TBool IsLooping() const;
       
   167 
       
   168     /**
       
   169      * Sets the list looping or non-looping.
       
   170      *
       
   171      * @param aLooping @c ETrue to set list looping, @c EFalse to set list
       
   172      *      non-looping.
       
   173      */
       
   174     void SetLooping( TBool aLooping );
       
   175 
       
   176     /**
       
   177      * Returns whether the list structure lines are visible.
       
   178      *
       
   179      * @return @c ETrue, if the tree structure lines are set visible.
       
   180      */
       
   181     TBool StructureLines() const;
       
   182 
       
   183     /**
       
   184      * Sets the visibility of structure lines.
       
   185      *
       
   186      * @param aVisible @c ETrue to set the tree structure lines visible,
       
   187      *       @c EFalse to set them invisible.
       
   188      */
       
   189     void SetStructureLineVisibility( TBool aVisible );
       
   190 
       
   191     /**
       
   192      * Returns whether the indention of list items is enabled.
       
   193      *
       
   194      * @return @c ETrue, if indention is enabled.
       
   195      */
       
   196     TBool Indention() const;
       
   197 
       
   198     /**
       
   199      * Sets the indention of list items enabled or disabled.
       
   200      *
       
   201      * @param aEnabled @c ETrue ot enable indention, @c EFalse to disable it.
       
   202      */
       
   203     void EnableIndention( TBool aEnable );
       
   204 
       
   205     /**
       
   206      * Returns the width of single indention step.
       
   207      *
       
   208      * @return Width of indention step. Negative value is returned when
       
   209      *      the default indention step width is to be used.
       
   210      */
       
   211     TInt IndentionWidth() const;
       
   212 
       
   213     /**
       
   214      * Sets the width of one indention step.
       
   215      *
       
   216      * @param aIndentionWidth The size of the indention step. Negative value
       
   217      *      can be used to use the default indention step width in current
       
   218      *      layout, which is based on the structure line segment width.
       
   219      */
       
   220     void SetIndentionWidth( TInt aIndentionWidth );
       
   221 
       
   222     /**
       
   223      * Checks whether marking is enabled. When marking is enabled, the list
       
   224      * items can be marked and unmarked with pointer and key events specified
       
   225      * for markable lists.
       
   226      *
       
   227      * @return @c ETrue, if marking of list items is enabled.
       
   228      */
       
   229     TBool IsMarkable() const;
       
   230 
       
   231     /**
       
   232      * Enables or disables the marking of list items.
       
   233      *
       
   234      * @param aEnable @c ETrue to enable marking, @c EFalse to disable it.
       
   235      */
       
   236     void EnableMarking( TBool aEnable );
       
   237 
       
   238     /**
       
   239      * Sets text for the empty list. This text is visible if the list box 
       
   240      * has no items.
       
   241      *
       
   242      * @param aText The text for the empty list.
       
   243      */
       
   244     void SetEmptyTextL(const TDesC& aText);
       
   245 
       
   246     /**
       
   247      * Initializes physics.
       
   248      */
       
   249     void InitPhysicsL();
       
   250     
       
   251     /**
       
   252      * Sets highlight to item to be focused.
       
   253      *
       
   254      * @param aItemToBeFocused Focused item.
       
   255      * @param aIndexToBeFocused Focused item index.
       
   256      */
       
   257     void SetHighlight( CAknTreeItem* aItemToBeFocused,
       
   258                        const TInt& aIndexToBeFocused );
       
   259                       
       
   260     /**
       
   261      * Selects the item.
       
   262      *
       
   263      * @param aSelectedItem Item to be selected.
       
   264      */
       
   265     void SelectItem( CAknTreeItem* aSelectedItem );
       
   266 
       
   267     /**
       
   268      * Returns the count how many visible items fits to screen.
       
   269      *
       
   270      * @return Visible items count.
       
   271      */
       
   272     TInt VisibleItemCount() const;
       
   273 
       
   274     /**
       
   275      * Sets the pressed down state.
       
   276      * 
       
   277      * @param aPressedDown ETrue if highlight should be 
       
   278      * drawn in pressed-down state.
       
   279      */
       
   280     void SetPressedDownState( const TBool& aPressedDown );
       
   281 
       
   282     /**
       
   283      * Updates the tree list view.
       
   284      */
       
   285     void UpdateTreeListView( const TInt& aFirstItem, const TBool& aDrawNow );
       
   286 
       
   287     /**
       
   288      * Returns the offset value.
       
   289      *
       
   290      * @return Offset value.
       
   291      */
       
   292     TInt Offset() const;
       
   293     
       
   294     /**
       
   295      * Changes the marking of specified item when marking is enabled.
       
   296      *
       
   297      * @param aItem Pointer to the marked item.
       
   298      *
       
   299      * @param aMarked @c ETrue to mark item, @c EFalse to unmark it.
       
   300      *
       
   301      * @param aDrawNow @c ETrue to request redraw.
       
   302      */
       
   303     void MarkItem( CAknTreeItem* aItem, TBool aMarked, TBool aDrawNow );
       
   304 
       
   305     /**
       
   306      * Changes the marking of specified set of items when marking is enabled.
       
   307      *
       
   308      * @param aItem Pointer to the first of the marked items.
       
   309      *
       
   310      * @param aLast Pointer to the last of the marked items.
       
   311      *
       
   312      * @param aMarked @c ETrue to mark thee specified items, @c EFalse to
       
   313      *      unmark them.
       
   314      *
       
   315      * @param aDrawNow @c ETrue to request redraw.
       
   316      */
       
   317     void MarkItems( CAknTreeItem* aFirst, CAknTreeItem* aLast, TBool aMarked,
       
   318         TBool aDrawNow );
       
   319 
       
   320 // from base class CCoeControl
       
   321 
       
   322     /**
       
   323      * From CCoeControl.
       
   324      * Handles key events.
       
   325      *
       
   326      * @param aKeyEvent Key event.
       
   327      *
       
   328      * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or 
       
   329      *      @c EEventKeyDown.
       
   330      */
       
   331     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
   332         TEventCode aType );
       
   333 
       
   334     /**
       
   335      * From CCoeControl.
       
   336      * Changes the visibility of the hierarchical list.
       
   337      *
       
   338      * @param aVisible @c ETrue to make the list visible, @c EFalse to make
       
   339      *      it invisible.
       
   340      */
       
   341     void MakeVisible( TBool aVisible );
       
   342 
       
   343     /**
       
   344      * From CCoeControl.
       
   345      * Sets the control's containing window by copying it from aContainer.
       
   346      *
       
   347      * @param aContainer Container.
       
   348      */
       
   349     void SetContainerWindowL( const CCoeControl& aContainer );
       
   350 
       
   351     /**
       
   352      * From CCoeControl.
       
   353      * Handles a change to the control's resources.
       
   354      *
       
   355      * @param aType A message UID value. 
       
   356      */
       
   357     void HandleResourceChange( TInt aType );
       
   358 
       
   359     /**
       
   360      * From CCoeControl.
       
   361      * Handles pointer events.
       
   362      *
       
   363      * @param aPointerEvent Pointer event.
       
   364      */
       
   365     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   366 
       
   367     /** 
       
   368      * From CCoeControl.
       
   369      * Gets the number of controls contained in a compound control.
       
   370      *
       
   371      * @return The number of component controls contained by this control.
       
   372      */
       
   373     TInt CountComponentControls() const;
       
   374 
       
   375     /**
       
   376      * From CCoeControl.
       
   377      * Gets an indexed component of a compound control.
       
   378      *
       
   379      * @param aIndex The index of the control.
       
   380      *
       
   381      * @return The component control with an index of aIndex.
       
   382      */
       
   383     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   384 
       
   385 // from base class MEikScrollBarObserver
       
   386 
       
   387     /**
       
   388      * From MEikScrollBarObserver.
       
   389      * Handles events from scroll bar.
       
   390      *
       
   391      * @param aScrollBar Pointer to the scrollbar.
       
   392      *
       
   393      * @param aEventType Event type.
       
   394      */
       
   395     void HandleScrollEventL( CEikScrollBar* aScrollBar,
       
   396         TEikScrollEvent aEventType );
       
   397 
       
   398 // from base class MAknTreeObserver
       
   399 
       
   400     /**
       
   401      * From MAknTreeObserver.
       
   402      * Handles event from the tree structure.
       
   403      *
       
   404      * @param aEvent Tree event.
       
   405      *
       
   406      * @param aItem Tree item targeted by the specified event.
       
   407      *
       
   408      * @param aDrawNow @c ETrue, when the view should be redrawn.
       
   409      */
       
   410     void HandleTreeEvent( TEvent aEvent, CAknTreeItem* aItem,
       
   411         TBool aDrawNow );
       
   412 
       
   413 // from base class MAknsEffectAnimObserver
       
   414 
       
   415     /**
       
   416      * From MAknsEffectAnimObserver.
       
   417      * Animation frame is ready to be drawn.
       
   418      *
       
   419      * @param aError @c KErrNone, if frame has been succesfully created and
       
   420      *      is available for drawing. Otherwise animation has internally
       
   421      *      failed and will not be used by the tree list view anymore.
       
   422      *
       
   423      * @param aAnimId Not currently used.
       
   424      */
       
   425     void AnimFrameReady( TInt aError, TInt aAnimId );
       
   426 
       
   427 // from base class MEikCommandObserver
       
   428 
       
   429     /**
       
   430      * From MEikCommandObserver.
       
   431      * Handles user commands.
       
   432      *
       
   433      * @param ID of the commmand to respond to.
       
   434      */
       
   435     void ProcessCommandL( TInt aCommandId );
       
   436 
       
   437 
       
   438 
       
   439 #ifdef RD_UI_TRANSITION_EFFECTS_LIST
       
   440 // ---------------------------------------------------------------------------
       
   441 // Sets the tfxgc for effects
       
   442 // ---------------------------------------------------------------------------
       
   443 //
       
   444 void SetGc( CWindowGc* aGc);
       
   445 
       
   446 TInt& ItemCountLimit();
       
   447 TInt& HighlightIndex();
       
   448 TInt& TopIndex();
       
   449 TInt& BottomIndex();
       
   450 
       
   451 void UpdateIndexes();
       
   452 
       
   453 TInt iItemCountLimit;
       
   454 TInt iHighlightIndex;
       
   455 TInt iTopIndex;
       
   456 TInt iBottomIndex;
       
   457 
       
   458 #endif //RD_UI_TRANSITION_EFFECTS_LIST
       
   459 
       
   460 public:  // new method
       
   461     /**
       
   462      * Report event to tree list observers. Use it to aviod dependency of 
       
   463      * @c CAknTreeList
       
   464      * 
       
   465      * @param aEvent The event to be notified.
       
   466      * 
       
   467      * @param aItem ID of the tree item related to the event.
       
   468      */
       
   469     void ReportTreeListEvent( MAknTreeListObserver::TEvent aEvent, 
       
   470                               TAknTreeItemID aItem);
       
   471 
       
   472 protected:
       
   473 
       
   474 // from base class CCoeControl
       
   475 
       
   476     /**
       
   477      * From CCoeControl.
       
   478      * Handles focus change.
       
   479      *
       
   480      * @param aDrawNow @c EDrawNow to redraw the list.
       
   481      */
       
   482     void FocusChanged( TDrawNow aDrawNow );
       
   483 
       
   484     /**
       
   485      * From CCoeControl.
       
   486      * Responds to changes to the size and position of this control.
       
   487      */
       
   488     void SizeChanged();
       
   489 
       
   490     /**
       
   491      * From CCoeControl.
       
   492      * Responds to changes in the position of this control.
       
   493      */
       
   494     void PositionChanged();
       
   495 
       
   496     /**
       
   497      * From CCoeControl.
       
   498      * Retrieves an object of the same type as that encapsulated in aId.
       
   499      *
       
   500      * @param aId An encapsulated object type ID.
       
   501      *
       
   502      * @return Encapsulates the pointer to the object provided. Note that the
       
   503      *      encapsulated pointer may be NULL
       
   504      */
       
   505     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   506     
       
   507 private:
       
   508 
       
   509     /**
       
   510      * C++ constructor.
       
   511      *
       
   512      * @param aTree Reference to the tree structure.
       
   513      */
       
   514     CAknTreeListView( CAknTree& aTree, CAknTreeList& aList );
       
   515 
       
   516     /**
       
   517      * Second phase constructor.
       
   518      *
       
   519      * @param aContainer Container for the view.
       
   520      */
       
   521     void ConstructL( const CCoeControl& aContainer );
       
   522 
       
   523     /**
       
   524      * Handes an addition of item to the tree structure.
       
   525      *
       
   526      * @param aItem Pointer to the added tree item.
       
   527      */
       
   528     void HandleItemAddedEvent( CAknTreeItem* aItem, TBool aDrawNow );
       
   529 
       
   530     /**
       
   531      * Handles a movement of tree item.
       
   532      *
       
   533      * @param aItem Pointer to the moved item.
       
   534      */
       
   535     void HandleItemMovedEvent( CAknTreeItem* aItem );
       
   536 
       
   537     /**
       
   538      * Handles a removal of item from the tree structure.
       
   539      *
       
   540      * @param aItem Pointer to the removed tree item.
       
   541      */
       
   542     void PrepareForItemRemoval( CAknTreeItem* aItem, TBool aDrawNow );
       
   543 
       
   544     /**
       
   545      * Handles a removal of item from the tree structure.
       
   546      *
       
   547      * @param aItem Pointer to the removed tree item.
       
   548      */
       
   549     void HandleItemRemovedEvent( CAknTreeItem* aItem, TBool aDrawNow );
       
   550 
       
   551     /**
       
   552      * Handles an expansion of a tree node.
       
   553      *
       
   554      * @param aNode Pointer to the expanded tree node.
       
   555      */
       
   556     void HandleNodeExpandedEvent( CAknTreeNode* aNode );
       
   557 
       
   558     /**
       
   559      * Handles a collapse of a tree node.
       
   560      *
       
   561      * @param aNode Pointer to the collapsed tree node.
       
   562      */
       
   563     void HandleNodeCollapsedEvent( CAknTreeNode* aNode );
       
   564 
       
   565     /**
       
   566      * Handles change in tree item.
       
   567      *
       
   568      * @param aItem Pointer to the modified tree item.
       
   569      */
       
   570     void HandleItemModifiedEvent( CAknTreeItem* aItem );
       
   571 
       
   572     /**
       
   573      * Handles tree sorting.
       
   574      */
       
   575     void HandleTreeSortedEvent( TBool aDrawNow );
       
   576 
       
   577     /**
       
   578      * Updates the set of tree items in the view.
       
   579      */
       
   580     void UpdateVisibleItems();
       
   581 
       
   582     /**
       
   583      * Updates the set of tree items in the view so, that the given item is
       
   584      * set at the given position of the view.
       
   585      *
       
   586      * @param aIndex Position of the given index in the view.
       
   587      *
       
   588      * @param aItem Tree items to be set to the given view position.
       
   589      */
       
   590     void UpdateVisibleItems( TInt aIndex, CAknTreeItem* aItem );
       
   591 
       
   592     /**
       
   593      * Selects the focused item. When the focused item is a leaf, the selection
       
   594      * event is passed to the list client, and when the focused item is a node,
       
   595      * the node is either expanded or collapsed.
       
   596      */
       
   597     void HandleSelectionKeyEvent();
       
   598 
       
   599     /**
       
   600      * Handles right arrow key event.
       
   601      */
       
   602     void HandleRightArrowKeyEvent();
       
   603 
       
   604     /**
       
   605      * Handles left arrow key event.
       
   606      */
       
   607     void HandleLeftArrowKeyEvent();
       
   608 
       
   609     /**
       
   610      * Moves the focus upwards and changes the set of visible items so that
       
   611      * the focused item becomes visible.
       
   612      */
       
   613     void HandleUpArrowKeyEvent();
       
   614 
       
   615     /**
       
   616      * Moves the focus downwards and changes the set of visible items so that
       
   617      * the focused item becomes visible. 
       
   618      */
       
   619     void HandleDownArrowKeyEvent();
       
   620 
       
   621     /**
       
   622      * Moves the focus deeper in the tree structure. If the focused item is
       
   623      * a collapsed node, this method expands the node. If the focused item is
       
   624      * a non-empty, expanded node, the focus is moved to the first item in
       
   625      * the node.
       
   626      */
       
   627     void DescendFocus();
       
   628 
       
   629     /**
       
   630      * Moves the focus higher in the tree structure. If the focused item is
       
   631      * an expanded node, this method collapses the node. Otherwise, the focus
       
   632      * is moved to the parent node.
       
   633      */
       
   634     void AscendFocus();
       
   635 
       
   636     /**
       
   637      * Returns whether the list view is empty.
       
   638      */
       
   639     TBool IsEmpty() const;
       
   640 
       
   641     /**
       
   642      * Sets the layout for the view from the layout data.
       
   643      */
       
   644     void LayoutView();
       
   645 
       
   646     /**
       
   647      * Updates scrollbars.
       
   648      */
       
   649     void UpdateScrollbars();
       
   650 
       
   651     /**
       
   652      * Updates the horizontal position of the view so that the beginning of
       
   653      * the currently focused item can be seen. If the focused item is not in
       
   654      * the set of visible items, this method has no effect.
       
   655      */
       
   656     void UpdateViewLevel();
       
   657 
       
   658     /**
       
   659      * Updates the highlight animation by setting the correct size and
       
   660      * background for the animation.
       
   661      *
       
   662      * @return @c ETrue, if animation is successfully updated, or there is
       
   663      *      no need to update it. Otherwise, @c EFalse is returned.
       
   664      */
       
   665     TBool UpdateAnimation() const;
       
   666 
       
   667     /**
       
   668      * Updates the highlight animation by setting the correct size and
       
   669      * background for the animation based on the given rectangle.
       
   670      *
       
   671      * @param aRect Rectangle specifying the size and position of the
       
   672      *      highlight animation.
       
   673      *
       
   674      * @return @c ETrue, if animation is successfully updated, or there is
       
   675      *      no need to update it. Otherwise, @c EFalse is returned.
       
   676      */
       
   677     TBool UpdateAnimation( const TRect& aRect ) const;
       
   678 
       
   679     /**
       
   680      * Sets the specified item focused.
       
   681      *
       
   682      * @param aFocusedItem Item to be focused. @c NULL, if no item is focused.
       
   683      */
       
   684     void SetFocusedItem( CAknTreeItem* aFocusedItem );
       
   685 
       
   686     /**
       
   687      * Checks whether the focused item is in the set of visible items.
       
   688      *
       
   689      * @return @c ETrue, if focused item is visible.
       
   690      */
       
   691     TBool FocusedItemVisible() const;
       
   692 
       
   693     /**
       
   694      * Sets the position of focused item in the view. Any negative number can
       
   695      * be used to indicate that focused item is not one of the visible items.
       
   696      *
       
   697      * @param aIndex Index specifying the position of the focused item in the
       
   698      *      set of visible items.
       
   699      */
       
   700     void SetFocusIndex( TInt aIndex );
       
   701 
       
   702     /**
       
   703      * Returns the position of focused item in the view.
       
   704      *
       
   705      * @return Index specifiying the focused item's position.
       
   706      */
       
   707     TInt FocusIndex() const;
       
   708 
       
   709     /**
       
   710      * Creates highlight animation for the view from currently active skin.
       
   711      * Existing animation is deleted before the new is created.
       
   712      */
       
   713     void CreateAnimationL();
       
   714 
       
   715     /**
       
   716      * Draws highligt animation background to given graphic context.
       
   717      *
       
   718      * @param aGc Graphic context to which highlight background is drawn.
       
   719      *
       
   720      * @return @c ETrue, if background is drawn successfully.
       
   721      */
       
   722     TBool DrawHighlightBackground( CFbsBitGc& aGc ) const;
       
   723 
       
   724     /**
       
   725      * Changes the highlight animation size to the specified.
       
   726      *
       
   727      * @param aHighlightSize New size for the highlight animation.
       
   728      *
       
   729      * @param aAboutToStart If animation is about to be started or continued
       
   730      *      after layer configuration this should be set to @c ETrue (to keep
       
   731      *      input layers). Otherwise, @c EFalse should be used.
       
   732      */
       
   733     void ResizeAnimationL( const TSize& aHighlightSize,
       
   734         TBool aAboutToStart ) const;
       
   735 
       
   736     /**
       
   737      * Draws the highlight animation of given size and position to the given
       
   738      * graphic context. The size and background of current animation is
       
   739      * updated when necessary, but to avoid flickering, they should be
       
   740      * done already before drawing sequence with UpdateAnimation() method.
       
   741      *
       
   742      * @param aGc Graphic context.
       
   743      *
       
   744      * @param aRect Size and poistion of the highlight animation.
       
   745      *
       
   746      * @return @c ETrue, if highlight animation was updated and drawn
       
   747      *      successfully. Otherwise, @c EFalse is returned.
       
   748      */
       
   749     TBool DrawAnimation( CBitmapContext& aGc, const TRect& aRect ) const;
       
   750 
       
   751     /**
       
   752      * Draws the highlight of given size and position to the given graphic
       
   753      * context.
       
   754      *
       
   755      * @param aGc Graphic context.
       
   756      *
       
   757      * @param aRect Rectangle specifying the size and position of the
       
   758      *      highlight to be drawn.
       
   759      *
       
   760      * @param aPressedDown @c EFalse, to draw normal highlight. @c ETrue, to 
       
   761      * draw a pressed down state.
       
   762      */
       
   763     void DrawHighlight( CWindowGc& aGc, const TRect& aRect, TBool aPressedDown = EFalse ) const;
       
   764     
       
   765 
       
   766     /**
       
   767      * Handles selection of specified item, by expanding the item, if it is
       
   768      * a collapsed node; collapsing the item, if it is an expanded node; or
       
   769      * selecting the item, if it is a leaf.
       
   770      *
       
   771      * @param aItem Item to be selected.
       
   772      * @param aKeyPressed Indicates that selection key has been pressed
       
   773      */
       
   774     void SelectItem( CAknTreeItem* aItem, bool aKeyPressed );
       
   775 
       
   776     /**
       
   777      * Begins marking. The marking begins immediately after the user
       
   778      * presses any of the the marking modifier keys (shift, ctrl, edit,
       
   779      * or hash key). This method registers view to observe MSK commands,
       
   780      * and start the timer for entering marking mode.
       
   781      */
       
   782     void BeginMarkingL();
       
   783 
       
   784     /**
       
   785      * Ends marking.
       
   786      */
       
   787     void EndMarking();
       
   788 
       
   789     /**
       
   790      * Checks whether marking is currently ongoing.
       
   791      *
       
   792      * @return @c ETrue, if list items are beign marked.
       
   793      */ 
       
   794     TBool MarkingOngoing() const;
       
   795 
       
   796     /**
       
   797      * Starts the long press timer.
       
   798      */
       
   799     void StartLongPressTimerL();
       
   800 
       
   801     /**
       
   802      * Callback method for long press timer.
       
   803      *
       
   804      * @param aThis Pointer to an instance of @c CAknTreeListView class.
       
   805      *
       
   806      * @return @c NULL, as function is intended to be called only once.
       
   807      */
       
   808     static TInt ReportLongPressL( TAny* aThis );
       
   809 
       
   810     /**
       
   811      * Handles long press. Called from ReportLongPressL() method for the
       
   812      * view object given as parameter.
       
   813      */
       
   814     void DoHandleLongPressL();
       
   815 
       
   816     /**
       
   817      * Enters marking mode. When in marking mode, the list controls the MSK
       
   818      * commands depending on whether the currently focused item is marked or
       
   819      * unmarked. Marking mode is entered after specified timeout, when user
       
   820      * keeps one of the marking modifier keys pressed.
       
   821      *
       
   822      * Notifications of the beginning and ending of marking mode is sent to
       
   823      * list observers, so that they would not update the MSK commands, when
       
   824      * they are handled by the list.
       
   825      */
       
   826     void EnterMarkingMode();
       
   827 
       
   828     /**
       
   829      * Exits marking mode. Marking mode is exited when user releases
       
   830      * all the marking modifier keys. After that, the list no longer
       
   831      * handles the MSK commands.
       
   832      */
       
   833     void ExitMarkingMode();
       
   834 
       
   835     /**
       
   836      * Updates correct mark/unmark command to MSK depending on the marking
       
   837      * of current focused item.
       
   838      */
       
   839     void UpdateMSKCommand();
       
   840 
       
   841     /**
       
   842      * Draws the items when physics is enabled.
       
   843      *
       
   844      * @param aRect Drawing rect.
       
   845      */
       
   846     void DrawItemsWithPhysics( const TRect& aRect ) const;
       
   847 
       
   848     /**
       
   849      * Returns first visible item index.
       
   850      *
       
   851      * @return First visible item index.
       
   852      */
       
   853     TInt FirstVisibleItemIndex() const;
       
   854 
       
   855     /**
       
   856      * Returns last visible item index.
       
   857      *
       
   858      * @return Last visible item index.
       
   859      */
       
   860     TInt LastVisibleItemIndex() const;
       
   861 
       
   862     /**
       
   863      * Updates view items so that aItem is visible.
       
   864      *
       
   865      * @param aItem Tree item that should be visible.
       
   866      */
       
   867     void UpdateViewItemAsVisible( CAknTreeItem* aItem );
       
   868 
       
   869 // from base class CCoeControl
       
   870 
       
   871     /**
       
   872      * From CCoeControl.
       
   873      * Draws the tree list view.
       
   874      *
       
   875      * @param aRect Area that needs to be redrawn.
       
   876      */
       
   877     void Draw( const TRect& aRect ) const;
       
   878 
       
   879 // Single click functions
       
   880 public:    
       
   881     /**
       
   882      * Is single click enabled
       
   883      * 
       
   884      * @return ETrue if single click is enabled
       
   885      */
       
   886     TBool SingleClickEnabled() const;
       
   887     
       
   888     /**
       
   889      * Enables or disables highlight
       
   890      * 
       
   891      * @param ETrue to enable highlight, EFalse to disable
       
   892      */
       
   893     void EnableHighlight( TBool aEnabled );
       
   894 
       
   895     /**
       
   896      * Is highlight enabled
       
   897      * 
       
   898      * @return ETrue if highlight is enabled
       
   899      */
       
   900     TBool HighlightEnabled() const;    
       
   901     
       
   902     /**
       
   903      * Pointer event to long tap detector
       
   904      * 
       
   905      * @param aPointerEvent Pointer event
       
   906      */
       
   907     void LongTapPointerEventL( const TPointerEvent& aPointerEvent );
       
   908 
       
   909     /**
       
   910      * Cancel long tap detection
       
   911      * 
       
   912      */
       
   913     void CancelLongTapDetectorL();
       
   914 
       
   915     /**
       
   916      * Has list marked items
       
   917      * 
       
   918      * @return ETrue if list has marked items
       
   919      */    
       
   920     TBool HasMarkedItemsL();    
       
   921     
       
   922 // From MAknCollection
       
   923     /**
       
   924      * Returns the collection state. The state is combination of
       
   925      * flags defined in MAknCollection::TStateFlag. 
       
   926      *
       
   927      * @return  Collection state.
       
   928      */
       
   929     TUint CollectionState() const;
       
   930 
       
   931     /**
       
   932      * Notifies that item action menu (CAknItemActionMenu)
       
   933      * was closed. 
       
   934      */
       
   935     void ItemActionMenuClosed();
       
   936     
       
   937     /** 
       
   938      * Extension function.
       
   939      *
       
   940      * @param  aExtensionId  Extension id. 
       
   941      * @param  a0            First extension method parameter.
       
   942      * @param  a1            Second extension method parameter.
       
   943      */    
       
   944     TInt CollectionExtension( TUint aExtensionId, TAny*& a0, TAny* a1 );    
       
   945 
       
   946 // From MAknLongTapDetectorCallBack
       
   947     /**
       
   948      * Long tap detector callback 
       
   949      *
       
   950      * @param aPenEventLocation Long tap event location relative to parent control.
       
   951      * @param aPenEventScreenLocation Long tap event location relative to screen.
       
   952      */
       
   953     void HandleLongTapEventL( const TPoint& aPenEventLocation,
       
   954                                   const TPoint& aPenEventScreenLocation );
       
   955     
       
   956     
       
   957 private: // data
       
   958 
       
   959     /**
       
   960      * Tree structure.
       
   961      */
       
   962     CAknTree& iTree;
       
   963 
       
   964     /**
       
   965      * List interface.
       
   966      */
       
   967     CAknTreeList& iList;
       
   968 
       
   969     /**
       
   970      * Array for visible view items.
       
   971      */
       
   972     RArray<TAknTreeListViewItem> iItems;
       
   973 
       
   974     /**
       
   975      * Pointer to currently focused list item.
       
   976      * Not own.
       
   977      */
       
   978     CAknTreeItem* iFocusedItem;
       
   979 
       
   980     /**
       
   981      * Position of focused item in the view. The focused item can be outside
       
   982      * of the view as well. In which case, the index can be outside the scope
       
   983      * of valid indices to the @c iItems array.
       
   984      */
       
   985     TInt iFocusedItemIndex;
       
   986 
       
   987     /**
       
   988      * View level. This defines the views horizontal position from which the
       
   989      * tree items are drawn.
       
   990      */
       
   991     TInt iViewLevel;
       
   992 
       
   993     /**
       
   994      * Maximum view level. Depends on the depth of the tree structure.
       
   995      */
       
   996     TInt iMaxViewLevel;
       
   997 
       
   998     /**
       
   999      * Horizontal view span defines how many tree levels of tree items with
       
  1000      * minimum width can be displayed simultaneously. This value is updated
       
  1001      * from the layout data on layout changes.
       
  1002      */
       
  1003     TInt iHorizontalViewSpan;
       
  1004 
       
  1005     /**
       
  1006      * Text for empty list.
       
  1007      * Own.
       
  1008      */
       
  1009     HBufC* iEmptyListText;
       
  1010 
       
  1011     /**
       
  1012      * Scrollbar frame.
       
  1013      * Own.
       
  1014      */
       
  1015     CEikScrollBarFrame* iScrollbarFrame;
       
  1016 
       
  1017     /**
       
  1018      * Index of the item, which received the stylus down event.
       
  1019      */
       
  1020     TInt iStylusDownItemIndex;
       
  1021 
       
  1022     /**
       
  1023      * Animation skin item ID used for highlight animation.
       
  1024      */
       
  1025     TAknsItemID iAnimationIID;
       
  1026 
       
  1027     /**
       
  1028      * Long press timer.
       
  1029      * Own.
       
  1030      */
       
  1031     CPeriodic* iLongPressTimer;
       
  1032 
       
  1033     /**
       
  1034      * Highlight animation.
       
  1035      * Own.
       
  1036      */
       
  1037     mutable CAknsEffectAnim* iAnimation;
       
  1038 
       
  1039     /**
       
  1040      * Flags for the view.
       
  1041      */
       
  1042     mutable TBitFlags32 iFlags;
       
  1043 
       
  1044     /**
       
  1045      * Width of single indention step.
       
  1046      */
       
  1047     TInt iIndentionWidth;
       
  1048     
       
  1049      /**
       
  1050      * Pointer to the list item that was focused before EButton1Down event.
       
  1051      * Not own.
       
  1052      */
       
  1053     CAknTreeItem* iPreviouslyFocusedItem;
       
  1054 
       
  1055     TBool iIsPressedDownState;
       
  1056     
       
  1057     TBool iIsDragged;
       
  1058     
       
  1059     /**
       
  1060      * Physics handler. Used only when physics feature is enabled.
       
  1061      * Own.
       
  1062      */
       
  1063     CAknTreeListPhysicsHandler* iPhysicsHandler;
       
  1064 
       
  1065     /**
       
  1066      * ETrue if physics view should be adjusted according to top item.
       
  1067      */
       
  1068     TBool iScrollPhysicsTop;
       
  1069 
       
  1070     /**
       
  1071     * Pointer to tfx redirect gc for effects
       
  1072     *
       
  1073     */
       
  1074     CWindowGc* iGc;
       
  1075     
       
  1076     /**
       
  1077      * Pointer to item action menu.
       
  1078      * Not own.
       
  1079      */
       
  1080     CAknItemActionMenu* iItemActionMenu;    
       
  1081     
       
  1082    /**
       
  1083     * Long tap detector
       
  1084     */
       
  1085     CAknLongTapDetector* iLongTapDetector;
       
  1086     };
       
  1087 
       
  1088 
       
  1089 #endif // C_AKNTREELISTVIEW_H