menufw/menufwui/mmwidgets/inc/mmlistboxview.h
changeset 0 f72a12da539e
child 38 79311d856354
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 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:  
       
    15 *  Version     : %version: MM_12.1.6 % << Don't touch! Updated by Synergy at check-out.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef MMLISTBOXVIEW_H
       
    21 #define MMLISTBOXVIEW_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <e32std.h>
       
    25 #include <e32base.h>
       
    26 #include <eikfrlb.h> 
       
    27 
       
    28 // CLASS DECLARATION
       
    29 
       
    30 /**
       
    31  *  Multimedia Menu Listbox view.
       
    32  *  
       
    33  *  @code
       
    34  *  @endcode
       
    35  *  @lib mmwidgets
       
    36  *  @since S60 v3.0
       
    37  *  @ingroup group_mmwidgets
       
    38  */
       
    39 NONSHARABLE_CLASS( CMmListBoxView ) : public CFormattedCellListBoxView 
       
    40     {
       
    41 public:
       
    42     // Constructors and destructor
       
    43 
       
    44     /**
       
    45      * Destructor.
       
    46      */
       
    47     ~CMmListBoxView();
       
    48 
       
    49     /**
       
    50      * Two-phased constructor.
       
    51      */
       
    52     static CMmListBoxView* NewL();
       
    53 
       
    54     /**
       
    55      * Two-phased constructor.
       
    56      */
       
    57     static CMmListBoxView* NewLC();
       
    58 	
       
    59 	/**
       
    60 	 * Calculate the bottom item index.
       
    61 	 * 
       
    62 	 * @since S60 v3.0
       
    63 	 */
       
    64     void CalcBottomItemIndex();
       
    65 	
       
    66 	/**
       
    67 	 * Draw the view.
       
    68 	 * 
       
    69 	 * @since S60 v3.0
       
    70 	 * @param clipRect Clipping rectangle.
       
    71 	 */
       
    72     void Draw(const TRect* clipRect) const;
       
    73     
       
    74 	/**
       
    75 	 * Draws the listbox within the given clipping rect.
       
    76 	 * 
       
    77 	 * @since S60 v3.0
       
    78 	 * @param clipRect Clipping rectangle.
       
    79 	 */
       
    80     void DoDraw(const TRect* aClipRect) const;
       
    81     
       
    82 	/**
       
    83 	 * Draw item in view. It is possible that it
       
    84 	 * calls drawing of more than one item.
       
    85 	 * 
       
    86 	 * @since S60 v3.0
       
    87 	 * @param aItemIndex Item index.
       
    88 	 */
       
    89     void DrawItem(TInt aItemIndex) const;
       
    90     
       
    91 	/**
       
    92 	 * Draw a single item in view.
       
    93 	 * 
       
    94 	 * @since S60 v3.0
       
    95 	 * @param aItemIndex Item index.
       
    96 	 */
       
    97     void DrawSingleItem (TInt aItemIndex) const;
       
    98     
       
    99 	/**
       
   100 	 * Get the number of items that fit in rectangle.
       
   101 	 * 
       
   102 	 * @since S60 v3.0
       
   103 	 * @param aRect Clipping rectangle.
       
   104 	 * @return Number of items that fit in rectangle.
       
   105 	 */
       
   106     TInt NumberOfItemsThatFitInRect(const TRect& aRect) const;
       
   107 	
       
   108 	/**
       
   109 	 * Get the number of items that fit in rectangle (with option to include
       
   110 	 * partial item at bottom of view).
       
   111 	 * 
       
   112 	 * @since S60 v3.0
       
   113 	 * @param aRect Rect for calculations.
       
   114 	 * @param aIncludePartialItem Should partial item be included.
       
   115 	 * @return Number of items that fit in rectangle.
       
   116 	 */
       
   117     TInt GetNumberOfItemsThatFitInRect (const TRect& aRect, TBool aIncludePartialItem ) const;
       
   118 	
       
   119 	/**
       
   120 	 * Get item size.
       
   121 	 * 
       
   122 	 * @since S60 v3.0
       
   123 	 * @param aItemIndex Item index.
       
   124 	 * @return Size of item.
       
   125 	 */
       
   126     TSize ItemSize(TInt aItemIndex) const;
       
   127 	
       
   128 	/**
       
   129 	 * Sets aItemIndex to the index of the item whose bounding box contains aPosition.
       
   130 	 * 
       
   131 	 * @since S60 v3.0
       
   132 	 * @param aPosition Item position.
       
   133 	 * @param aItemIndex Item index.
       
   134 	 * @return Was item found.
       
   135 	 */
       
   136     TBool XYPosToItemIndex(TPoint aPosition, TInt& aItemIndex) const;
       
   137     
       
   138 	/**
       
   139 	 * Gets item position.
       
   140 	 * 
       
   141 	 * @since S60 v3.0
       
   142 	 * @param aItemIndex Item index.
       
   143 	 * @return Item position.
       
   144 	 */
       
   145     TPoint ItemPos(TInt aItemIndex) const;
       
   146 	
       
   147 	/**
       
   148 	 * Sets item height.
       
   149 	 * 
       
   150 	 * @since S60 v3.0
       
   151 	 * @param aItemHeight Item height.
       
   152 	 */
       
   153     void SetItemHeight(TInt aItemHeight);
       
   154 	
       
   155 	/**
       
   156 	 * Calculates new top item index so item is visible.
       
   157 	 * 
       
   158 	 * @since S60 v3.0
       
   159 	 * @param aItemIndex Item to be visible.
       
   160 	 * @return New top item index.
       
   161 	 */
       
   162     TInt CalcNewTopItemIndexSoItemIsVisible(TInt aItemIndex) const;
       
   163 	
       
   164 	/**
       
   165 	 * Draw background between rects.
       
   166 	 * 
       
   167 	 * @since S60 v3.0
       
   168 	 * @param aUsedPortionOfViewRect Inner rect.
       
   169 	 * @param aSmallerViewRect Outer rect.
       
   170 	 */
       
   171     void RedrawBackground( TRect aUsedPortionOfViewRect, TRect aSmallerViewRect) const;
       
   172 	
       
   173 	/**
       
   174 	 * Draws background in list which is not covered by vivible items.
       
   175 	 * 
       
   176 	 * @since S60 v3.0
       
   177 	 */
       
   178     void RedrawBackground() const;
       
   179 	
       
   180 	/**
       
   181 	 * Gets total height of items within range.
       
   182 	 * 
       
   183 	 * @since S60 v3.0
       
   184 	 * @param aStartIndex Start item index.
       
   185 	 * @param aEndIndex End item index.
       
   186 	 * @return Total height of items starting from aStartIndex, ending with aEndIndex.
       
   187 	 */
       
   188     TInt GetTotalHeight( TInt aStartIndex, TInt aEndIndex ) const;
       
   189 
       
   190     /**
       
   191      * Gets the current widget vertical item offset.
       
   192      * 
       
   193      * @since S60 v5.0
       
   194      * @return The current widget vertical item offset.
       
   195      */
       
   196     TInt VerticalItemOffset() const;
       
   197     
       
   198     /**
       
   199      * Overridden to allow for disabling this method in certain situations.
       
   200      * 
       
   201      * @param aItemIndex Item index.
       
   202      */
       
   203     TBool ScrollToMakeItemVisible(TInt aItemIndex);
       
   204 
       
   205     /**
       
   206      * Disables ScrollToMakeItemVisible.
       
   207      * When disabled, ScrollToMakeItemVisible does nothing.
       
   208      * 
       
   209      * @param aDisable Self-explanatory.
       
   210      */
       
   211     void DisableScrollToItem( TBool aDisable );
       
   212 
       
   213 private:
       
   214 
       
   215     /**
       
   216      * Constructor for performing 1st stage construction.
       
   217      */
       
   218     CMmListBoxView();
       
   219 
       
   220     /**
       
   221      * Default symbian 2nd stage constructor.
       
   222      */
       
   223     void ConstructL();
       
   224 
       
   225 	/**
       
   226 	 * Updates average item height.
       
   227 	 * 
       
   228 	 * @since S60 v3.0
       
   229 	 */
       
   230    	void UpdateAverageItemHeight();
       
   231 
       
   232 	/**
       
   233 	 * Gets last item index depending on height.
       
   234 	 * 
       
   235 	 * @since S60 v3.0
       
   236 	 * @param aStartIndex Start item index.
       
   237 	 * @param aHeight Height of area.
       
   238 	 * @return Last item index.
       
   239 	 */
       
   240     TInt GetLastIndexInHeight( const TInt aStartIndex, TInt aHeight ) const;
       
   241     
       
   242 	/**
       
   243 	 * Sets the previously drawn current item index.
       
   244 	 * 
       
   245 	 * @since S60 v3.0
       
   246 	 * @param aIndex Current Item index.
       
   247 	 */
       
   248     void SetPreviouslyDrawnCurrentItemIndex( TBool aIndex );
       
   249     
       
   250 private:
       
   251 
       
   252 	/**
       
   253 	 * Scrollbar visibility flag.
       
   254 	 */
       
   255 	TBool iScrollbarIsVisible;
       
   256 	
       
   257 	/**
       
   258 	 * iCurrentItemIndex
       
   259 	 */
       
   260 	TInt iPreviouslyDrawnCurrentItemIndex;
       
   261 	
       
   262 	/**
       
   263 	 * When ETrue, disables ScrollToMakeItemVisible method.
       
   264 	 */
       
   265 	TBool iScrollToItemDisabled;
       
   266     };
       
   267 
       
   268 #endif // MMLISTBOXVIEW_H