menufw/menufwui/mmwidgets/inc/mmgridview.h
changeset 0 f72a12da539e
child 4 4d54b72983ae
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c)  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:  CMmGridView declaration
       
    15 *  Version     : %version: MM_24.1.7 % << Don't touch! Updated by Synergy at check-out.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef C_MMGRIDVIEW_H
       
    21 #define C_MMGRIDVIEW_H
       
    22 
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <AknGridView.h> 
       
    26 
       
    27 /**
       
    28  *  Multimedia Menu Grid View.
       
    29  *
       
    30  *  @code
       
    31  *  @endcode
       
    32  *  @lib mmwidgets
       
    33  *  @since S60 v3.0
       
    34  *  @ingroup group_mmwidgets
       
    35  */
       
    36 NONSHARABLE_CLASS( CMmGridView ) : public CAknGridView
       
    37     {
       
    38 public:
       
    39     /**
       
    40      * Two-phased constructor.
       
    41      * 
       
    42      * @since S60 v3.0
       
    43      */
       
    44     static CMmGridView* NewL();
       
    45     
       
    46     /**
       
    47      * Two-phased constructor.
       
    48      * 
       
    49      * @since S60 v3.0
       
    50      */
       
    51     static CMmGridView* NewLC();
       
    52 
       
    53     /**
       
    54      * Destructor.
       
    55      * 
       
    56      * @since S60 v3.0
       
    57      */
       
    58     virtual ~CMmGridView();
       
    59     
       
    60     /**
       
    61      * Draws the grid within the given clipping rectangle.
       
    62      *
       
    63      * @since S60 v3.0
       
    64      * @param aClipRect Clipping rectangle.
       
    65      */
       
    66 	void Draw( const TRect* aClipRect ) const;
       
    67 	
       
    68 	/**
       
    69      * Draws item definied by index.
       
    70      *
       
    71      * @since S60 v3.0
       
    72      * @param aItemIndex Item index which should be draw.
       
    73      */
       
    74 	void DrawItem(TInt aItemIndex) const;
       
    75 	
       
    76 	/**
       
    77      * Gets item position.
       
    78      * 
       
    79      * This fuction from @c CAknGridView is overridden so that it
       
    80      * returns 'mirrored' item positions when mirrored layout is
       
    81      * used. 
       
    82      * 
       
    83      * @since S60 v3.0
       
    84      * @param aItemIndex Item index.
       
    85      * @return Item position.
       
    86      */
       
    87     TPoint ItemPos( TInt aItemIndex ) const;
       
    88     
       
    89     /**
       
    90      * Converts an (x, y) pixel position to an item index.
       
    91      * 
       
    92      * This fuction from @c CAknGridView has been overridden in order
       
    93      * to make it work properly when mirrored layout is used.
       
    94      * 
       
    95      * @param aPosition Pixel position in the viewing rectangle.
       
    96      * @param aItemIndex Reference to the item index.
       
    97      * @return Whether there was an item at aPosition.
       
    98      */  
       
    99     TBool XYPosToItemIndex(TPoint aPosition, TInt& aItemIndex) const;
       
   100 	
       
   101 	/**
       
   102 	 * Returns this view's gc.
       
   103 	 * 
       
   104 	 * @return pointer to gc
       
   105 	 */
       
   106 	CWindowGc* Gc();
       
   107 	
       
   108     /**
       
   109      * @see CAknGridView::UpdateSelectionL
       
   110      * 
       
   111      * This method of CAknGridView is overriden to so that
       
   112      * correct effects are displayed when moving highlight with 
       
   113      * rocker key in mirrored layout.
       
   114      * Please note that it is necessary because of the hackish
       
   115      * solution used to draw items in mirrored layout.
       
   116      */
       
   117     void UpdateSelectionL( TSelectionMode aSelectionMode );
       
   118 
       
   119 	/**
       
   120 	 * @see CAknGridView::MoveCursorL
       
   121 	 * 
       
   122 	 * This method of CAknGridView is overriden to so that
       
   123 	 * correct effects are displayed when moving highlight with 
       
   124 	 * rocker key in mirrored layout.
       
   125      * Please note that it is necessary because of the hackish
       
   126      * solution used to draw items in mirrored layout.
       
   127 	 */
       
   128     void MoveCursorL( TCursorMovement aCursorMovement,
       
   129             TSelectionMode aSelectionMode );
       
   130 
       
   131     /**
       
   132      * Gets the current widget vertical item offset.
       
   133      * 
       
   134      * @since S60 v5.0
       
   135      * @return The current widget vertical item offset.
       
   136      */
       
   137     TInt VerticalItemOffset() const;
       
   138     
       
   139 	/**
       
   140 	* This function sets item height in pixels.
       
   141 	* @param aItemHeight New height in pixels for this view’s items.
       
   142 	*/	
       
   143     void SetItemHeight(TInt aItemHeight);
       
   144 
       
   145 private:
       
   146 	
       
   147     /**
       
   148      * Default constructor.
       
   149      * 
       
   150      * @since S60 v3.0 
       
   151      */
       
   152     CMmGridView();
       
   153 
       
   154     /**
       
   155      * 2nd phase constructor.
       
   156      * 
       
   157      * @since S60 v3.0 
       
   158      */
       
   159     void ConstructL();
       
   160     
       
   161     /**
       
   162      * Draws the grid within the given clipping rectangle.
       
   163      *
       
   164      * @since S60 v3.0
       
   165      * @param aClipRect Clipping rectangle.
       
   166      */
       
   167     void DoDraw( const TRect* aClipRect ) const;
       
   168     
       
   169     /**
       
   170      * Gets item position.
       
   171      * 
       
   172      * AVKON implementation of ItemPos method does not always work properly.
       
   173      * It fails when:
       
   174      *   aItemIndex < TopItemIndex() - NumberOfColsInView()
       
   175      * Because of that problem this method was created. It is now used in
       
   176      * CMmGridView::ItemPos in place where base class (AVKON) implementation
       
   177      * was used previously.
       
   178      * 
       
   179      * @param aItemIndex Item index.
       
   180      * @return Item position.
       
   181      */
       
   182     TPoint CorrectItemPos( TInt aItemIndex ) const;
       
   183 
       
   184 private:
       
   185 
       
   186     /**
       
   187      * Stores cursor movement flag during CMmGridView::MoveCursorL execution.
       
   188      * 
       
   189      * When CMmGridView::MoveCursorL is not executing this member variable is
       
   190      * always set to ECursorFirstItem. This is part of the hack that allows
       
   191      * for correct effects to be displayed when using rocker key in mirrored
       
   192      * layout.
       
   193      */
       
   194     TCursorMovement iLastCurMove;
       
   195     
       
   196     /**
       
   197      * Stores previosly highlighted item index during CMmGridView::MoveCursorL
       
   198      * execution.
       
   199      * 
       
   200      * When CMmGridView::MoveCursorL is not executing this member variable is
       
   201      * always set to KErrNotFound. This is part of the hack that allows
       
   202      * for correct effects to be displayed when using rocker key in mirrored
       
   203      * layout.
       
   204      */
       
   205     TInt iOldIndex;	
       
   206     };
       
   207 
       
   208 #endif // C_MMGRIDVIEW_H