idlehomescreen/examples/carouselwidgetexample/renderer/inc/carouselwidget.h
branchRCL_3
changeset 102 ba63c83f4716
parent 93 b01126ce0bec
child 103 966d119a7e67
equal deleted inserted replaced
93:b01126ce0bec 102:ba63c83f4716
     1 /*
       
     2  * Copyright (c) 2010 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:  Carousel widget for Symbian Homescreen
       
    15  *
       
    16  */
       
    17 
       
    18 #ifndef _CCAROUSELWIDGET_H
       
    19 #define _CCAROUSELWIDGET_H
       
    20 
       
    21 //  INCLUDES
       
    22 #include <xnextrenderingpluginadapter.h>
       
    23 #include <aknphysicsobserveriface.h>
       
    24 
       
    25 class MXnExtEventHandler;
       
    26 class CCarouselItem;
       
    27 class CAknPhysics;
       
    28 
       
    29 // Class declaration
       
    30 NONSHARABLE_CLASS( CCarouselItem ) : public CBase  
       
    31     {
       
    32 public:
       
    33 
       
    34     // Constructors
       
    35         
       
    36     /**
       
    37      * C++ default constructor.
       
    38      */
       
    39 CCarouselItem(/* CCarouselEditor& aEditor,*/ CFbsBitmap* aBitmap, CFbsBitmap* aMask);
       
    40     
       
    41     /**
       
    42      * Destructor.
       
    43      */
       
    44     ~CCarouselItem();
       
    45     
       
    46     void SetTextL( const TDesC& aText );
       
    47 
       
    48     CFbsBitmap* iBitmap;
       
    49     CFbsBitmap* iMask;
       
    50 private:
       
    51    
       
    52     HBufC* iText;
       
    53     };
       
    54 
       
    55 // CLASS DECLARATION
       
    56 
       
    57 /**
       
    58 *  
       
    59 */
       
    60 class CCarouselWidget : public CXnExtRenderingPluginAdapter, 
       
    61     public MAknPhysicsObserver
       
    62     {
       
    63 
       
    64 public:  // Constructors and destructor
       
    65         
       
    66     /**
       
    67     * Two-phased constructor.
       
    68     */
       
    69     static CCarouselWidget* NewL();
       
    70     
       
    71     /**
       
    72     * Destructor.
       
    73     */
       
    74     virtual ~CCarouselWidget();
       
    75 
       
    76 public: // from base classes
       
    77 
       
    78     /**
       
    79     * From CCoeControl Handles key events.
       
    80     * @since Series 60 3.1
       
    81     * @param aKeyEvent Key event.
       
    82     * @param aType Event type.
       
    83     * @return Key response
       
    84     */
       
    85     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
    86         TEventCode aType );
       
    87 
       
    88     /**
       
    89     * From CCoeControl
       
    90     */
       
    91     void SetContainerWindowL( const CCoeControl &aContainer );
       
    92 
       
    93     /**
       
    94     * See CCoeControl documentation
       
    95     */
       
    96     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
    97 
       
    98     /**
       
    99     * From CCoeControl, CountComponentControls
       
   100     * @return Number of component controls
       
   101     */
       
   102     TInt CountComponentControls() const;
       
   103 
       
   104     /**
       
   105     * From CCoeControl, ComponentControl
       
   106     * @param aIndex index of component control
       
   107     * @return pointer to the specified control
       
   108     */
       
   109     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   110 
       
   111     /**
       
   112     * Skin change notification.
       
   113     * See CXnControlAdapter documentation
       
   114     * @since Series 60 3.1
       
   115     */
       
   116     void SkinChanged();
       
   117 
       
   118     /**
       
   119     * See CXnControlAdapter documentation
       
   120     */
       
   121     void EnterPowerSaveModeL();
       
   122 
       
   123     /**
       
   124     * See CXnControlAdapter documentation
       
   125     */
       
   126     void ExitPowerSaveModeL();
       
   127 
       
   128     // From MAknPhysicsObserver
       
   129     /**
       
   130      * Physics emulation has moved the view.
       
   131      */
       
   132     void ViewPositionChanged( const TPoint& aNewPosition, 
       
   133                 TBool aDrawNow, TUint aFlags );
       
   134 
       
   135     /**
       
   136      * Called when emulation ended.
       
   137      */
       
   138     void PhysicEmulationEnded();
       
   139 
       
   140     /**
       
   141      * Returns the observer view position.
       
   142      *
       
   143      * @return Physics observer view position.
       
   144      */
       
   145     TPoint ViewPosition() const;
       
   146 
       
   147 protected: // from base classes
       
   148 
       
   149     /**
       
   150     * From CCoeControl
       
   151     * Called if focus changes
       
   152     */
       
   153     void FocusChanged( TDrawNow aDrawNow );
       
   154 
       
   155     /**
       
   156     * From CCoeControl
       
   157     * Called if position or size changes
       
   158     */
       
   159     void SizeChanged();
       
   160     
       
   161     /**
       
   162      * Sets the external event handler interface.
       
   163      *
       
   164      * @since Series 60 5.2
       
   165      * @param aEventHandler Event handler interface.
       
   166      */
       
   167     void SetEventHandler( MXnExtEventHandler* aEventHandler );
       
   168     
       
   169     /**
       
   170      * Routes the data stream for the external rendering plugin.
       
   171      *
       
   172      * @since Series 60 5.2
       
   173      * @param aData Data stream.
       
   174      * @param aType Type of the stream.
       
   175      * @param aIndex Index of the data.
       
   176      */
       
   177     void SetDataL( const TDesC8& aData, const TDesC& aType, TInt aIndex );
       
   178 
       
   179 private: // from base classes
       
   180 
       
   181     /**
       
   182     * From CCoeControl, Draw
       
   183     * See CCoeControl documentation
       
   184     */
       
   185     void Draw( const TRect& aRect ) const;
       
   186 
       
   187 public:
       
   188 
       
   189     /**
       
   190     * C++ default constructor.
       
   191     */
       
   192     CCarouselWidget();
       
   193 
       
   194     /**
       
   195     * By default Symbian 2nd phase constructor is private.
       
   196     */
       
   197     void ConstructL();
       
   198     
       
   199     TRect ViewPort() {return iViewPort; };
       
   200 
       
   201 private:
       
   202     void InitPhysicEngineL();
       
   203     
       
   204     TInt ItemIndex( TPoint& aPoint );
       
   205     
       
   206     void LaunchItemL( TPoint& aPosition );
       
   207     
       
   208 private: // Member data
       
   209     /**
       
   210      * Physics. 
       
   211      * Own.
       
   212      */
       
   213     CAknPhysics*        iPhysics;
       
   214     
       
   215     MXnExtEventHandler* iEventHandler; // not own
       
   216     
       
   217     /**
       
   218      * Pointer down start time.
       
   219      */
       
   220     TTime               iStartTime;
       
   221 
       
   222     /**
       
   223      * Start (pointer down) position.
       
   224      */
       
   225     TPoint              iStartPosition;
       
   226     
       
   227     /**
       
   228      * Current pointer position.
       
   229      */   
       
   230     TPoint              iStylusPosition;
       
   231     
       
   232     /**
       
   233      * Current view position.
       
   234      */
       
   235     TPoint              iCurrentPosition;
       
   236     
       
   237     /**
       
   238      * Adjusted view position
       
   239      */
       
   240     TPoint iViewPosition;
       
   241     
       
   242     /**
       
   243      * Visible area, i.e. area of the scollable control that is to be drawn.
       
   244      */          
       
   245     TRect                           iViewPort;
       
   246     
       
   247     RPointerArray<CCarouselItem>    iStripeItems;
       
   248     
       
   249     TBool                           iDrawHighlight;
       
   250     };
       
   251 
       
   252 #endif      // _CCAROUSELWIDGET_H
       
   253 // End of File