mpxplugins/viewplugins/views/commoncontainer/inc/mpxcommoncontaineravkonimp.h
changeset 0 ff3acec5bc43
child 21 a1247965635c
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  MPX common container definition for AVKON platform.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CMPXCOMMONCONTAINERAVKONIMP_H
       
    21 #define CMPXCOMMONCONTAINERAVKONIMP_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include "mpxcommoncontainer.h"
       
    26 
       
    27 
       
    28 // FORWARD DECLARATIONS
       
    29 class CAknSearchField;
       
    30 class CAknListBoxFilterItems;
       
    31 class CMPXLbxExtendedFeatures;
       
    32 class MEikCommandObserver;
       
    33 class CEikMenuPane;
       
    34 class CEikTextListBox;
       
    35 class MEikListBoxObserver;
       
    36 class CAknIconArray;
       
    37 class CMPXCommonListBoxArrayBase;
       
    38 
       
    39 // CLASS DECLARATION
       
    40 
       
    41 /**
       
    42  *  Container class for AVKON common container.
       
    43  *  The view class should implement the following virtual function
       
    44  *  from MEikCommandObserver 
       
    45  *
       
    46  *  virtual void ProcessCommandL(TInt aCommandId);
       
    47  *
       
    48  *  common container uses this to pass commands back to the view class
       
    49  *  the commands supported are defined in mpxcommoncontainer.hrh
       
    50  *
       
    51  *  view container class owns this class to access List box commands, receive
       
    52  *  CoeControl events and GetHelpContext(). The view container class should
       
    53  *  implement the following virtual functions from MViewContainer
       
    54  *
       
    55  *  virtual void HandleKeyEvent();
       
    56  *  virtual void HandleHelpContent();
       
    57  *
       
    58  *  common container uses this to pass CoeControl events back to the view
       
    59  *  container class. 
       
    60  *
       
    61  *  view class should handle the following commands in ProcessCommandL
       
    62  *  from MEikCommandObserver: 
       
    63  *  
       
    64  *  EMPXCmdCommonDelete  // delete key pressed
       
    65  *  EMPXCmdCommonResourceChange  // resource change
       
    66  *
       
    67  *  @lib mpxcommoncontainer.lib
       
    68  *  @since S60 v3.1
       
    69  */
       
    70 NONSHARABLE_CLASS( CMPXCommonContainerAvkonImp )
       
    71     : public CCoeControl
       
    72     , public MMPXCommonContainer
       
    73     {
       
    74 public:
       
    75 
       
    76     /**
       
    77      * default C++ constructor.
       
    78      */
       
    79     CMPXCommonContainerAvkonImp();
       
    80     
       
    81     /**
       
    82      * Destructor.
       
    83      */
       
    84     virtual ~CMPXCommonContainerAvkonImp();
       
    85 
       
    86 
       
    87 // from base class MMPXCommonContainer
       
    88 
       
    89     /**
       
    90      * Return Coe Control
       
    91      *
       
    92      * @since 3.2
       
    93      */
       
    94     CCoeControl* CoeControl();
       
    95 
       
    96     /**
       
    97      * Set View Container
       
    98      *
       
    99      * @since 3.2
       
   100      */
       
   101     void SetViewContainer( MMPXViewContainer* aViewContainer );
       
   102 
       
   103     /**
       
   104      * Set command observer for container
       
   105      *
       
   106      * @since 3.2
       
   107      */
       
   108     void SetCommandObserver( MEikCommandObserver* aCommandObserver );
       
   109 
       
   110     /**
       
   111      * Set list box observer for container
       
   112      *
       
   113      * @since 3.2
       
   114      */
       
   115     void SetListBoxObserver( MEikListBoxObserver* aObserver );
       
   116 
       
   117     /**
       
   118      * Set layout for all elements and set sizes for icons.
       
   119      *
       
   120      * @since 3.1
       
   121      */
       
   122     void UpdateLayout();
       
   123 
       
   124     /**
       
   125      * Returns list box array, ownership not transfered
       
   126      *
       
   127      * @since 3.1
       
   128      * @return A pointer to the list box array
       
   129      */
       
   130     CMPXCommonListBoxArrayBase* ListBoxArray() const;
       
   131     
       
   132     /**
       
   133      * Sets up the listbox array, ownership not transferred
       
   134      */
       
   135     void SetListBoxArrayL( CMPXCommonListBoxArrayBase* aListBoxArray );
       
   136 
       
   137     /**
       
   138      * Return number of listbox items shown in the current listbox.
       
   139      *
       
   140      * @since 3.1
       
   141      * @return The number of items shown in the list box
       
   142      */
       
   143     TInt CurrentListItemCount() const;
       
   144 
       
   145     /**
       
   146      * Return total number of listbox items in the listbox.
       
   147      *
       
   148      * @since 3.1
       
   149      * @return Total items in the list box
       
   150      */
       
   151     TInt TotalListItemCount() const;
       
   152 
       
   153     /**
       
   154      * Gets top listbox item index (relative to the original listbox).
       
   155      * @return Top listbox item index
       
   156      *
       
   157      * @since 3.1
       
   158      */
       
   159     TInt TopLbxItemIndex() const;
       
   160     
       
   161     /**
       
   162      * Gets bottom listbox item index (relative to the original listbox).
       
   163      * @return Bottom listbox item index
       
   164      *
       
   165      * @since 3.1
       
   166      */
       
   167     TInt BottomLbxItemIndex() const;
       
   168 
       
   169     /**
       
   170      * Gets current listbox item index (relative to the original listbox).
       
   171      * @return Current listbox item index
       
   172      *
       
   173      * @since 3.1
       
   174      */
       
   175     TInt CurrentLbxItemIndex() const;
       
   176 
       
   177     /**
       
   178      * Get current selected listbox items indices (relative to the original
       
   179      * listbox). Ownership not transferred.
       
   180      *
       
   181      * @since 3.1
       
   182      * @return Current listbox item indices
       
   183      */
       
   184     const CArrayFix<TInt>* CurrentSelectionIndicesL() const;
       
   185     
       
   186     /**
       
   187      * Sewt current selected listbox items indices
       
   188      *
       
   189      * @since 3.1
       
   190      * @param aIndices Array of selection indices, ownership not transfered
       
   191      */
       
   192     void SetCurrentSelectionIndicesL( CArrayFix<TInt>* aIndices ) const;
       
   193 
       
   194     /**
       
   195      * Set top listbox item index.
       
   196      *
       
   197      * @since 3.1
       
   198      * @param aIndex Actual listbox index.
       
   199      */
       
   200     void SetLbxTopItemIndex( TInt aIndex );
       
   201 
       
   202     /**
       
   203      * Set current listbox item index.
       
   204      *
       
   205      * @since 3.1
       
   206      * @param aIndex Actual listbox index.
       
   207      */
       
   208     void SetLbxCurrentItemIndex( TInt aIndex );
       
   209 
       
   210     /**
       
   211      * Set current listbox item index and highlight it.
       
   212      *
       
   213      * @since 3.1
       
   214      * @param aIndex Actual listbox index.
       
   215      */
       
   216     void SetLbxCurrentItemIndexAndDraw( TInt aIndex );
       
   217 
       
   218     /**
       
   219      * Clear listbox selection.
       
   220      *
       
   221      * @since 3.1
       
   222      */
       
   223     void ClearLbxSelection();
       
   224 
       
   225     /**
       
   226      * Sets list box backround text. This text is visible if the list box 
       
   227      * has no items.
       
   228      *
       
   229      * @param aText The text for the empty list box background.
       
   230      * @since 3.2
       
   231      */
       
   232 	void SetLbxEmptyTextL( const TDesC& aText );
       
   233 
       
   234     /**
       
   235      * Draws list box item index
       
   236      *
       
   237      * @since 3.2
       
   238      */
       
   239     void DrawLbxItem( TInt aIndex );
       
   240     
       
   241     /**
       
   242      * Set Find box's focus.
       
   243      *
       
   244      * @since 3.1
       
   245      * @param aFocus ETrue if set focus on FindBox. Otherwise, EFalse.
       
   246      */
       
   247     void SetFindBoxFocus( TBool aFocus );
       
   248 
       
   249     /**
       
   250      * Handle listbox item addition.
       
   251      *
       
   252      * @since 3.1
       
   253      */
       
   254     void HandleLbxItemAdditionL();
       
   255     
       
   256     /**
       
   257      * Handle listbox item addition, preserving the current display index.
       
   258      *
       
   259      * @since 3.1
       
   260      */
       
   261     void HandleLbxItemAdditionPreserveIndexL();
       
   262     
       
   263     /**
       
   264      * Handle listbox item removal.
       
   265      *
       
   266      * @since 3.1
       
   267      */
       
   268     void HandleLbxItemRemovalL();
       
   269 
       
   270     /**
       
   271      * Show/hide find box
       
   272      *
       
   273      * @since 3.1
       
   274      * @param aIsVisible ETrue to set findbox visible. Otherwise, EFalse
       
   275      */
       
   276     void SetFindBoxVisibilityL( TBool aIsVisible );
       
   277 
       
   278     /**
       
   279      * Determine find box visibility
       
   280      *
       
   281      * @since 3.1
       
   282      * @return ETrue if find box is currently visible, EFalse otherwise
       
   283      */
       
   284     TBool FindBoxVisibility();
       
   285 
       
   286     /**
       
   287      * Restore the PopupCBA of find box
       
   288      */
       
   289     void RestoreFindBoxPopupCBA();
       
   290     
       
   291     /**
       
   292      * Calculate the top index of the visible items
       
   293      *
       
   294      * @since 3.1
       
   295      * @param aBottomIndex the bottom index of the visible items
       
   296      * @return top index
       
   297      */
       
   298     TInt CalculateTopIndex( TInt aBottomIndex );
       
   299 
       
   300     /**
       
   301      * Creates the container
       
   302      *
       
   303      * @since 3.1
       
   304      * @param aCollectionType collection type
       
   305      */
       
   306     void ConstructContainerL( TMPXCommonContainerCollectionType aCollectionType );
       
   307 
       
   308     /**
       
   309      * Enable/disable find box     
       
   310      * 
       
   311      * @since 3.1
       
   312      * @aEnable ETrue to enable find box, EFalse to disable
       
   313      */
       
   314     void EnableFindBox( TBool aEnable );
       
   315     
       
   316     /**
       
   317      * Enable/disable marking     
       
   318      * 
       
   319      * @since 3.1
       
   320      * @aEnable ETrue to enable marking, EFalse to disable
       
   321      */
       
   322     void EnableMarking( TBool aEnable );
       
   323 
       
   324     /**
       
   325      * Custom handling of commands for markable lists.
       
   326      */
       
   327     void HandleMarkableListProcessCommandL( TInt aCommand );
       
   328 
       
   329     /**
       
   330      * Custom handling of menu pane for markable lists
       
   331      */
       
   332     void HandleMarkableListDynInitMenuPane(
       
   333         TInt aResourceId,
       
   334         CEikMenuPane* aMenuPane );
       
   335         
       
   336     /**
       
   337      * Handle listbox array events
       
   338      *
       
   339      *  @param aEvent list box event
       
   340      */
       
   341     void HandleListBoxArrayEventL( 
       
   342         MMPXCommonListBoxArrayObserver::TMPXCommonListBoxArrayEvents aEvent );
       
   343 
       
   344     /**
       
   345      * Handles key events.
       
   346      *
       
   347      * @param aKeyEvent The key event.
       
   348      * @param aType The type of key event.
       
   349      */
       
   350     TKeyResponse HandleKeyEventL(
       
   351         const TKeyEvent& aKeyEvent,
       
   352         TEventCode aType );
       
   353     
       
   354     /**
       
   355      * Activate the container
       
   356      */
       
   357     void ActivateContainerL();
       
   358 
       
   359     /**
       
   360      * Deactivate the container
       
   361      */
       
   362     void DeactivateContainerL();
       
   363 
       
   364     /**
       
   365      * Checks whether the container is active
       
   366      */
       
   367     TBool IsContainerActive();
       
   368 
       
   369 // from base class CCoeControl
       
   370 
       
   371     /**
       
   372      * From CCoeControl.
       
   373      * Handles key events.
       
   374      *
       
   375      * @param aKeyEvent The key event.
       
   376      * @param aType The type of key event.
       
   377      */
       
   378     TKeyResponse OfferKeyEventL(
       
   379         const TKeyEvent& aKeyEvent,
       
   380         TEventCode aType );
       
   381     
       
   382     /**
       
   383      * From CCoeControl.
       
   384      * Gets the control's help context.
       
   385      *
       
   386      * @param aContext The control's help context.
       
   387      */
       
   388     void GetHelpContext( TCoeHelpContext& aContext ) const;
       
   389     
       
   390     /**
       
   391      * From CCoeControl.
       
   392      * Responds to changes to the size and position of the contents of this 
       
   393      * control.
       
   394      */
       
   395     void SizeChanged();
       
   396 
       
   397     /**
       
   398      * From CCoeControl.
       
   399      * Gets the number of controls contained in a compound control.
       
   400      *
       
   401      * @return The number of component controls contained by this control.
       
   402      */
       
   403     TInt CountComponentControls() const;
       
   404 
       
   405     /**
       
   406      * From CCoeControl.
       
   407      * Gets an indexed component of a compound control.
       
   408      *
       
   409      * @param aIndex The index of the control.
       
   410      * @return The component control with an index of aIndex.
       
   411      */
       
   412     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   413 
       
   414     /**
       
   415      * From CoeControl.
       
   416      * Handles a change to the control's resources.
       
   417      *
       
   418      * @param aType A message UID value.
       
   419      */
       
   420     void HandleResourceChange( TInt aType );
       
   421     
       
   422 private:
       
   423 
       
   424     /**
       
   425      * Create list box 
       
   426      */
       
   427     void CreateListBoxL();
       
   428     
       
   429     /**
       
   430      * Constructs Find box.
       
   431      *
       
   432      * @param aIsFindPopup ETrue if findbox is a popup type.
       
   433      *                     EFalse if finsbox is a fixed type.
       
   434      */
       
   435     void ConstructFindBoxL( TBool aIsFindPopup );
       
   436 
       
   437     /**
       
   438      * Creates icon array, populates iIconArray to be used by listbox
       
   439      */   
       
   440     void CreateIconArrayL();
       
   441     
       
   442 protected: // data
       
   443 
       
   444     CAknIconArray*              iIconArray;  
       
   445 
       
   446     MMPXViewContainer*          iViewContainer;    // not owned
       
   447     MEikCommandObserver*        iView;          // not owned
       
   448     MEikListBoxObserver*        iListBoxObserver; // not owned
       
   449     CEikTextListBox*            iListBox;       // owned
       
   450     CMPXLbxExtendedFeatures*    iLbxExtFeat;    // owned    
       
   451     CMPXCommonListBoxArrayBase* iListBoxArray;  // not owned
       
   452     
       
   453     CAknSearchField*            iFindBox;  // owned
       
   454     CAknListBoxFilterItems*     iFindBoxFilterItems; // not owned
       
   455     TBool                       iIsFindPopup;    
       
   456     TBool                       iIsFindEnabled;
       
   457     TBool                       iIsMarkingEnabled;
       
   458     TInt                        iResourceOffset; // must be freed
       
   459     TBool                       iContainerActive;
       
   460     };
       
   461 
       
   462 #endif  // CMPXCOMMONCONTAINERAVKONIMP_H
       
   463 
       
   464 // End of File