widgetmodel/alfwidgetmodel/inc/alfrecyclinggridelementimpl.h
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     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:   Class for private implementation for AlfRecyclingGridElement.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef ALFRECYCLINGGRIDELEMENTIMPL_H
       
    20 #define ALFRECYCLINGGRIDELEMENTIMPL_H
       
    21 
       
    22 #include "alf/alfrecyclinggridelement.h"
       
    23 #include <osn/osndefines.h>
       
    24 
       
    25 class CAlfVisual;
       
    26 class CAlfLayout;
       
    27 class TAlfEvent;
       
    28 
       
    29 namespace Alf
       
    30     {
       
    31 class CAlfWidgetControl;
       
    32 class IAlfVariantType;
       
    33 class IAlfBranch;
       
    34 class IAlfElement;
       
    35 
       
    36 /**
       
    37  *  Implementation class used with the implPtr paradigm.
       
    38  */
       
    39 OSN_NONSHARABLE_CLASS( AlfRecyclingGridElementImpl )
       
    40     {
       
    41 public:
       
    42     /**
       
    43         * Gets the unit.
       
    44         *
       
    45         * @since S60 ?S60_version
       
    46         * @return The unit.
       
    47         */
       
    48     AlfRecyclingGridElementImpl(
       
    49         AlfRecyclingGridElement& aOwner,
       
    50         int aNumColumns,
       
    51         int aNumRows);
       
    52     /**
       
    53         * Gets the unit.
       
    54         *
       
    55         * @since S60 ?S60_version
       
    56         * @return The unit.
       
    57         */
       
    58     ~AlfRecyclingGridElementImpl();
       
    59     /**
       
    60         * setFillStyle.
       
    61         *
       
    62         * @since S60 ?S60_version
       
    63         * @return The unit.
       
    64         */
       
    65     void setFillStyle(AlfRecyclingGridElement::FillStyle aFillStyle, int aFillStyleParam);
       
    66 
       
    67     /**
       
    68      * setAnimationTimes.
       
    69      *
       
    70      * @since S60 ?S60_version
       
    71      * @return The unit.
       
    72      */
       
    73     void setAnimationTimes( int aScrollingTime,
       
    74                             int aFadeInTime, int aFadeInDelay,
       
    75                             int aFadeOutTime, int aFadeOutDelay );
       
    76     /**
       
    77      * createVisualTree.
       
    78      *
       
    79      * @since S60 ?S60_version
       
    80      * @return The unit.
       
    81      */
       
    82     CAlfVisual* createVisualTree(
       
    83         IAlfVariantType& aData, uint aDataID,
       
    84         CAlfLayout* aParentLayout, int aLayoutIndex );
       
    85     /**
       
    86      * accept.
       
    87      *
       
    88      * @since S60 ?S60_version
       
    89      * @return The unit.
       
    90      */
       
    91     bool accept( CAlfWidgetControl& aControl, const TAlfEvent& aEvent ) const;
       
    92     /**
       
    93      * offerEvent.
       
    94      *
       
    95      * @since S60 ?S60_version
       
    96      * @return The unit.
       
    97      */
       
    98     bool offerEvent( CAlfWidgetControl& aControl, const TAlfEvent& aEvent );
       
    99     /**
       
   100      * setActiveStates.
       
   101      *
       
   102      * @since S60 ?S60_version
       
   103      * @return The unit.
       
   104      */
       
   105     void setActiveStates( unsigned int aStates );
       
   106     /**
       
   107      * Sets AlfWidgetEventHandlerInitData to event handler.
       
   108      *
       
   109      * @param aData A data structure which contains for example id of the event
       
   110      * handler.
       
   111      */
       
   112     void setEventHandlerData( const AlfWidgetEventHandlerInitData& /*aData*/ ) { }
       
   113     
       
   114     /**
       
   115      * Returns AlfWidgetEventHandlerInitData.
       
   116      *
       
   117      * @return  A pointer to AlfWidgetEventHandlerInitData structure which contains
       
   118      * for example id of the event handler.
       
   119      */
       
   120     AlfWidgetEventHandlerInitData* eventHandlerData() { return NULL; }
       
   121     /**
       
   122      * createChildVisualTree.
       
   123      *
       
   124      * @since S60 ?S60_version
       
   125      * @return The unit.
       
   126      */
       
   127     void createChildVisualTree( IAlfElement* aElement,
       
   128                                 IAlfVariantType& aChildData,
       
   129                                 IAlfBranch& aData,
       
   130                                 int aIndex, uint aDataID );
       
   131     /**
       
   132      * removeChildVisualTree.
       
   133      *
       
   134      * @since S60 ?S60_version
       
   135      * @return The unit.
       
   136      */
       
   137     void removeChildVisualTree( IAlfElement* aElement, IAlfBranch& aData, int aIndex, uint aDataID );
       
   138     /**
       
   139      * removeAndDestroyVisuals.
       
   140      *
       
   141      * @since S60 ?S60_version
       
   142      * @return The unit.
       
   143      */
       
   144     void removeAndDestroyVisuals( int aTimeMilliseconds );
       
   145 
       
   146 private:
       
   147 
       
   148     /**
       
   149      * Api to naviagte by a single row or column.
       
   150      * @since S60 ?S60_version
       
   151      * @param aControl - Widget Control
       
   152      * @param aPageUp  - indicates the direction either a page up or page down
       
   153      */
       
   154     bool moveSingleRowOrColumn( CAlfWidgetControl& aControl, bool aPageUp);
       
   155 
       
   156     /**
       
   157      * APi to find the point in the grid for a given index in the visual array on the recycle grid  .
       
   158      * @since S60 ?S60_version
       
   159      * @param aInd - index of the element
       
   160      * @return  TPoint - Point or cordinates
       
   161      */
       
   162     TPoint calculateChildPos(int aInd) const;
       
   163 
       
   164     /**
       
   165      * APi to find the index for a given point
       
   166      * @since S60 ?S60_version
       
   167      * @param aPos- position for whom the index needs to be found out
       
   168      * @return  int  - Index of the cordinate
       
   169      */
       
   170     int calculateChildInd(TPoint aPos) const;
       
   171 
       
   172     /**
       
   173      * Internal APi to do the index calcuation for navigation and recycling
       
   174     */
       
   175     void doPositioningAndScrolling( CAlfWidgetControl& aControl,uint aEventID);
       
   176 
       
   177 private:
       
   178 
       
   179     AlfRecyclingGridElement& mOwner;
       
   180 
       
   181     //class Data
       
   182     /**
       
   183      * The number of visible rows and columns.
       
   184      */
       
   185     int mNumVisibleColumns, mNumVisibleRows;
       
   186 
       
   187     /**
       
   188      * The number of rows and columns in the grid layout.
       
   189      */
       
   190     int mNumColumns, mNumRows;
       
   191 
       
   192     /**
       
   193      * The strategy for adding new items to the grid
       
   194      */
       
   195     AlfRecyclingGridElement::FillStyle mFillStyle;
       
   196 
       
   197     /**
       
   198      * The maximum number of items used with EColumnsFirst and ERowsFirst fill styles
       
   199      */
       
   200     int mFillStyleParam;
       
   201 
       
   202 
       
   203     /**
       
   204      * Duration of the scrolling animation
       
   205      */
       
   206     int mScrollingTime;
       
   207 
       
   208     /**
       
   209      * Duration of the fade in animation
       
   210      */
       
   211     int mFadeInTime;
       
   212 
       
   213     /**
       
   214      * Delay before the fade in animation
       
   215      */
       
   216     int mFadeInDelay;
       
   217 
       
   218     /**
       
   219      * Duration of the fade out animation
       
   220      */
       
   221     int mFadeOutTime;
       
   222 
       
   223     /**
       
   224      * Delay before the fade out animation
       
   225      */
       
   226     int mFadeOutDelay;
       
   227 
       
   228     /**
       
   229      * The logical scrolling offset.
       
   230      */
       
   231     TPoint  mScrollOffset;
       
   232 
       
   233     bool    mHorizontalOffset;
       
   234     bool    mVerticalOffset;
       
   235     unsigned int mActiveStates;
       
   236     };
       
   237 
       
   238     } // namespace Alf
       
   239 
       
   240 #endif // C_ALFWIDGETEVENTHANDLERIMPL_H