uifw/EikStd/coctlinc/aknstyluspopupmenuphysicshandler.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 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:   AknTreeListView physics handler
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_AKNSTYLUSPOPUPMENUPHYSICSHANDLER_H
       
    21 #define C_AKNSTYLUSPOPUPMENUPHYSICSHANDLER_H
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 #include <w32std.h>
       
    26 #include <aknphysicsobserveriface.h>
       
    27 
       
    28 class CAknPhysics;
       
    29 class CAknStylusPopUpMenuContent;
       
    30 
       
    31 /**
       
    32  *  StylusPopUpmenu physics handler.
       
    33  *
       
    34  *  @lib aknhlist
       
    35  *  @since S60 v5.0
       
    36  */
       
    37 NONSHARABLE_CLASS( CAknStylusPopUpMenuPhysicsHandler ) : public CBase,
       
    38     public MAknPhysicsObserver
       
    39     {
       
    40 
       
    41 public:
       
    42 
       
    43     /**
       
    44      * Two-phased constructor.
       
    45      */
       
    46     static CAknStylusPopUpMenuPhysicsHandler* NewL( CAknStylusPopUpMenuContent* aPopUpMenuContent );
       
    47 
       
    48     /**
       
    49      * Two-phased constructor.
       
    50      */
       
    51     static CAknStylusPopUpMenuPhysicsHandler* NewLC( CAknStylusPopUpMenuContent* aPopUpMenuContent );
       
    52     /**
       
    53      * Destructor.
       
    54      */
       
    55     virtual ~CAknStylusPopUpMenuPhysicsHandler();
       
    56     
       
    57 public:
       
    58 
       
    59     /**
       
    60      * Handles the pointer event received by AknStylusPopUpMenuContent
       
    61      *
       
    62      * @param aPointerEvent Pointer event to handle.
       
    63      */
       
    64     void HandlePointerEventL( const TPointerEvent& aPointerEvent );                      
       
    65     
       
    66     /**
       
    67      * Sets view rect.
       
    68      *
       
    69      * @param aRect New view rect.
       
    70      */
       
    71     void SetViewRect( const TRect& aRect );
       
    72 
       
    73     /**
       
    74      * Sets item height.
       
    75      *
       
    76      * @param aItemHeight New item height.
       
    77      */
       
    78     void SetItemHeight( TInt aItemHeight );
       
    79     
       
    80     /**
       
    81      * Sets world height.
       
    82      *
       
    83      * @param aWorldHeight New world height.
       
    84      */
       
    85     void SetWorldHeight( TInt aWorldHeight );
       
    86 
       
    87     /**
       
    88      * Returns offset. Used to draw partial items.
       
    89      */
       
    90     TInt Offset() const;
       
    91     
       
    92     /**
       
    93      * Initializes physics.
       
    94      */
       
    95     void InitPhysicsL();
       
    96     
       
    97     /**
       
    98      * Scrolls the view to new position.
       
    99      *
       
   100      * @param aNewScrollIndex New view position.
       
   101      */
       
   102     void HandleScrollEvent( TInt aNewScrollIndex );
       
   103 
       
   104     /**
       
   105      * Resets physics so that location is set to world's top position.
       
   106      * 
       
   107      * @since S60 5.2
       
   108      */
       
   109     void Reset();
       
   110     
       
   111 public: // From base class MAknPhysicsObserver.
       
   112 
       
   113     /**
       
   114      * Called when view position changes.
       
   115      *
       
   116      * @param  aNewPosition  The new position of the view.
       
   117      * @param  aDrawNow      @c ETrue if the screen is to be redrawn,
       
   118      *                       otherwise @c EFalse.
       
   119      * @param  aFlags        Additional flags, not used currently.
       
   120      */
       
   121     virtual void ViewPositionChanged( const TPoint& aNewPosition,
       
   122                                       TBool aDrawNow = ETrue,
       
   123                                       TUint aFlags = 0 );
       
   124     
       
   125     /**
       
   126      * Called when emulation has ended.
       
   127      */
       
   128     virtual void PhysicEmulationEnded();
       
   129 
       
   130     /**
       
   131      * Returns the observer's view position.
       
   132      *
       
   133      * @return Physics observer's view position.
       
   134      */
       
   135     virtual TPoint ViewPosition() const;
       
   136 
       
   137 private:
       
   138 
       
   139     /**
       
   140      * C++ constructor.
       
   141      */
       
   142     CAknStylusPopUpMenuPhysicsHandler( CAknStylusPopUpMenuContent* aPopUpMenuContent );
       
   143 
       
   144     /**
       
   145      * Symbian second-phase constructor.
       
   146      */
       
   147     void ConstructL();
       
   148     
       
   149     /**
       
   150      * Returns drag threshold.
       
   151      *
       
   152      * @return drag threshold.
       
   153      */
       
   154     TInt DragThreshold();
       
   155     
       
   156     /**
       
   157      * Sets highlight to item.
       
   158      * 
       
   159      * @param aItem Item to be highlighted.
       
   160      */
       
   161     void SetHighlight( TInt aItem );
       
   162 
       
   163     /**
       
   164      * Moves view to correct position.
       
   165      * 
       
   166      * @param  aDrawNow  Whether or not the view is drawn. If @c EFalse,
       
   167      *                   then only the logical state is updated.
       
   168      */
       
   169     void ScrollView( TBool aDrawNow = ETrue );
       
   170     
       
   171     /**
       
   172      * Stops physics.
       
   173      */
       
   174     void StopPhysics();
       
   175 
       
   176 
       
   177 private: // data
       
   178 
       
   179     /**
       
   180      * PopUpMenuContent
       
   181      * Not own.
       
   182      */
       
   183     CAknStylusPopUpMenuContent* iPopUpMenuContent;
       
   184 
       
   185     /**
       
   186      * Scroll index.
       
   187      */
       
   188     TInt iScrollIndex;
       
   189     
       
   190     /**
       
   191      * Height of one item.
       
   192      */
       
   193     TInt iItemHeight;
       
   194     
       
   195     /**
       
   196      * Height of world.
       
   197      */
       
   198     TInt iWorldHeight;
       
   199 
       
   200     /**
       
   201      * Current pointer position.
       
   202      */   
       
   203     TPoint iPosition;
       
   204     
       
   205     /**
       
   206      * Start (pointer down) position.
       
   207      */
       
   208     TPoint iStartPosition;
       
   209     
       
   210     /**
       
   211      * View rect.
       
   212      */
       
   213     TRect iViewRect;
       
   214     
       
   215     /**
       
   216      *  ETrue if pointer down event received but pointer up not.
       
   217      */
       
   218     TBool iPressedDown;
       
   219     
       
   220     /**
       
   221      * ETrue if panning functionality is activated.
       
   222      */
       
   223     TBool iPanningActivated;
       
   224     
       
   225     /**
       
   226      * Pointer down start time.
       
   227      */
       
   228     TTime iStartTime;
       
   229     
       
   230     
       
   231     /**
       
   232      * Physics. 
       
   233      * Own.
       
   234      */
       
   235     CAknPhysics *iPhysics;
       
   236     
       
   237     
       
   238     /**
       
   239      * Physics handler flags.
       
   240      */
       
   241     TBitFlags iFlags;
       
   242     
       
   243     /**
       
   244      * Previous offset.
       
   245      */
       
   246     TInt iPrevOffset;
       
   247     
       
   248     /**
       
   249      * Previous topmost item
       
   250      */
       
   251     TInt iPrevTopmostItem;
       
   252     
       
   253     /**
       
   254      * count of offset item
       
   255      */
       
   256     TInt iOffsetItemCount;
       
   257     
       
   258     };
       
   259 
       
   260 
       
   261 #endif // C_AKNSTYLUSPOPUPMENUPHYSICSHANDLER_H