idlehomescreen/inc/xncontroladapter.h
changeset 0 f72a12da539e
child 9 f966699dea19
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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 * Xuikon control adapter header file
       
    16 *
       
    17 */
       
    18 
       
    19 #ifndef XNCONTROLADAPTER_H
       
    20 #define XNCONTROLADAPTER_H
       
    21 
       
    22 // System includes
       
    23 #include <e32base.h>
       
    24 #include <coecntrl.h>
       
    25 #include <aknappui.h>
       
    26 #include <aknlongtapdetector.h>
       
    27 
       
    28 // Forward declarations
       
    29 class CXnNodePluginIf;
       
    30 class CXnComponent;
       
    31 class CXnControlAdapterImpl;
       
    32 class CXnProperty;
       
    33 class CXnNode;
       
    34 
       
    35 // Class declaration
       
    36 /**
       
    37  * Control adapter interface class
       
    38  *
       
    39  * @ingroup group_xnlayoutengine
       
    40  * @lib xnlayoutengine.lib
       
    41  * @since Series 60 3.1
       
    42  */
       
    43 class CXnControlAdapter : public CCoeControl,
       
    44                           public MCoeControlObserver,
       
    45                           public MAknLongTapDetectorCallBack
       
    46     {
       
    47 public:
       
    48     // Data types
       
    49     enum TModeEvent
       
    50         {
       
    51         EEventNone = 0,
       
    52         EEventBackground,
       
    53         EEventLight,
       
    54         EEventDisplay,
       
    55         EEventVisibility
       
    56         };
       
    57 
       
    58     /**
       
    59      * Two-phased constructor.
       
    60      */
       
    61     IMPORT_C static CXnControlAdapter* NewL( CXnNodePluginIf& aNode );
       
    62 
       
    63     /**
       
    64      * Destructor.
       
    65      */
       
    66     IMPORT_C virtual ~CXnControlAdapter();
       
    67 
       
    68 public:
       
    69     // New functions
       
    70 
       
    71     /**
       
    72      * Sets component pointer.
       
    73      *
       
    74      * @since Series 60 3.1
       
    75      * @param aComponent Component pointer.
       
    76      */
       
    77     IMPORT_C void SetComponent( CXnComponent* aComponent );
       
    78 
       
    79     /**
       
    80      * Set component visibility
       
    81      *
       
    82      * @since Series 60 3.1
       
    83      * @param aVisible ETrue for making visible, EFalse for making invisible
       
    84      */
       
    85     IMPORT_C void SetVisible( TBool aVisible );
       
    86 
       
    87     /**
       
    88      * Gets the component pointer.
       
    89      *
       
    90      * @since Series 60 3.1
       
    91      * @return Component pointer.
       
    92      */
       
    93     IMPORT_C CXnComponent* Component();
       
    94 
       
    95     /**
       
    96      * Checks if the control should be drawn, according to visibility and
       
    97      * display properties.
       
    98      *
       
    99      * @since Series 60 3.1
       
   100      * @return ETrue if drawing is ok, EFalse otherwise
       
   101      */
       
   102     IMPORT_C TBool IsDrawingAllowed() const;
       
   103 
       
   104     /**
       
   105      * Gets content bitmaps. Ownership is not transferred.
       
   106      *
       
   107      * @since Series 60 3.1
       
   108      * @param aBitmap Bitmap to draw
       
   109      * @param aMask Mask to use
       
   110      */
       
   111     IMPORT_C void ContentBitmaps( CFbsBitmap*& aBitmap, CFbsBitmap*& aMask );
       
   112 
       
   113     /**
       
   114      * Sets content bitmaps. Ownership is transferred.
       
   115      *
       
   116      * @since Series 60 3.1
       
   117      * @param aBitmap Bitmap to draw
       
   118      * @param aMask Mask to use
       
   119      */
       
   120     IMPORT_C void SetContentBitmaps( CFbsBitmap* aBitmap, CFbsBitmap* aMask );
       
   121 
       
   122     /**
       
   123      * Sets content bitmaps. Ownership is transferred.
       
   124      *
       
   125      * @since Series 60 3.1
       
   126      * @param aBitmapUrl Url of the bitmap to draw
       
   127      * @param aMaskUrl Url of the bitmap mask to use
       
   128      */
       
   129     IMPORT_C void SetContentBitmaps( const TDesC& aBitmapUrl,
       
   130         const TDesC& aMaskUrl );
       
   131 
       
   132     /**
       
   133      * Load a bitmap from the server. Ownership is transferred.
       
   134      *
       
   135      * @since Series 60 3.1
       
   136      * @param aBitmapUrl Url of the bitmap to load
       
   137      * @return Bitmap
       
   138      */
       
   139     IMPORT_C CFbsBitmap* LoadBitmap( const TDesC& aBitmapUrl );
       
   140 
       
   141     /**
       
   142      * Load a bitmap and mask from the server. Ownership is transferred.
       
   143      *
       
   144      * @since Series 60 3.1
       
   145      * @param aBitmapUrl Url of the bitmap to load
       
   146      * @param aMaskUrl Url of the mask to load, if any
       
   147      * @param aBitmap  Fetched bitmap
       
   148      * @param aMask Fetched mask
       
   149      */
       
   150     IMPORT_C void GetBitmapAndMask(
       
   151         const TDesC& aBitmapUrl,
       
   152         const TDesC& aMaskUrl,
       
   153         CFbsBitmap*& aBitmap,
       
   154         CFbsBitmap*& aMask );
       
   155 
       
   156     /**
       
   157      * Skin change notification.
       
   158      *
       
   159      * @since Series 60 3.1
       
   160      */
       
   161     IMPORT_C virtual void SkinChanged();
       
   162 
       
   163     /**
       
   164      * Draws the control using a client-specified gc.
       
   165      *
       
   166      * @param aRect TRect to draw
       
   167      * @param aGc Gc used for drawing
       
   168      */
       
   169     IMPORT_C virtual void Draw( const TRect& aRect, CWindowGc& aGc ) const;
       
   170 
       
   171     /**
       
   172      * Enter power save mode. This is done when application goes to background
       
   173      * or lights go off.
       
   174      * Derived classes should override this function and stop animations, timers
       
   175      * etc. when the function is called.
       
   176      */
       
   177     IMPORT_C void EnterPowerSaveModeL( TModeEvent aEvent = EEventNone );
       
   178 
       
   179     /*
       
   180      * Template method, called by EnterPowerSaveModeL(). Additional
       
   181      * implementations are done in derived classes.
       
   182      */
       
   183     IMPORT_C virtual void DoEnterPowerSaveModeL( TModeEvent aEvent );
       
   184 
       
   185     /**
       
   186      * Exit power save mode. This is done when application comes to foreground
       
   187      * or lights go on.
       
   188      * Derived classes should override this function and restart animations,
       
   189      * timers etc. when the function is called.
       
   190      */
       
   191     IMPORT_C void ExitPowerSaveModeL( TModeEvent aEvent = EEventNone );
       
   192 
       
   193     /*
       
   194      * Template method, called by ExitPowerSaveModeL(). Additional
       
   195      * implementations are done in derived classes.
       
   196      */
       
   197     IMPORT_C virtual void DoExitPowerSaveModeL( TModeEvent aEvent );
       
   198 
       
   199     /**
       
   200      * Sets the application local zoom
       
   201      *
       
   202      * @param aZoom application local zoom
       
   203      * @since 3.1
       
   204      */
       
   205     IMPORT_C virtual void SetLocalUiZoomL( TAknUiZoom aZoom );
       
   206 
       
   207     /**
       
   208      * This called to measure adaptive content dimensions
       
   209      *
       
   210      * @since 3.2
       
   211      * @param aAvailableSize where the component's content must fit
       
   212      * @return The measure content dimensions
       
   213      */
       
   214     IMPORT_C virtual TSize MeasureAdaptiveContentL(
       
   215         const TSize& aAvailableSize );
       
   216 
       
   217 
       
   218     /**
       
   219      * Add a child adapter
       
   220      * @since Series 60 3.1
       
   221      * @param aChild Child adapter
       
   222      * @param aNode Child layout node.
       
   223      */
       
   224     void AppendChildL(CXnControlAdapter& aChild, CXnNode& aNode);
       
   225 
       
   226 
       
   227     /**
       
   228      * Resets the stylus state counter, so that the next tap causes 1st stylus
       
   229      * action.
       
   230      *
       
   231      * @since 3.2
       
   232      */
       
   233     IMPORT_C void ResetStylusCounter();
       
   234 
       
   235     /**
       
   236      * Sets the control blank
       
   237      *
       
   238      * @since S60 5.1
       
   239      * @param aBlank, ETrue sets blank, EFalse resets blank
       
   240      */
       
   241     IMPORT_C void SetBlank( TBool aBlank );
       
   242 
       
   243     /**
       
   244      * Gets the control's long tap detector
       
   245      *
       
   246      * @since 5.0
       
   247      */
       
   248     IMPORT_C CAknLongTapDetector* LongTapDetector() const;
       
   249 
       
   250     /**
       
   251      * Gets the control's associated window.
       
   252      *
       
   253      * @since 3.2
       
   254      */
       
   255     inline RWindow& Window() const;
       
   256 
       
   257     /**
       
   258      * Gets the component of this control which is grabbing the pointer.
       
   259      *
       
   260      * @since 5.0
       
   261      */
       
   262     inline CCoeControl* GrabbingComponent() const;
       
   263 
       
   264 public:
       
   265     /**
       
   266      * From CCoeControl.
       
   267      * Handles key events.
       
   268      *
       
   269      * @since Series 60 3.1
       
   270      * @param aKeyEvent Key event.
       
   271      * @param aType Event type.
       
   272      * @return Key response
       
   273      */
       
   274     IMPORT_C TKeyResponse OfferKeyEventL(
       
   275         const TKeyEvent& aKeyEvent,
       
   276         TEventCode aType );
       
   277 
       
   278     /**
       
   279      * From CCoeControl.
       
   280      * Handles control events.
       
   281      *
       
   282      * @since Series 60 3.1
       
   283      * @param aControl Control.
       
   284      * @param aEventType Event type.
       
   285      */
       
   286     IMPORT_C void HandleControlEventL(
       
   287         CCoeControl* aControl,
       
   288         TCoeEvent aEventType );
       
   289 
       
   290     /**
       
   291      * From CCoeControl.
       
   292      * Handles pointer events
       
   293      *
       
   294      * This method must always be called, even when it's overridden by derived
       
   295      * classes
       
   296      *
       
   297      * @param aPointerEvent pointer event
       
   298      */
       
   299     IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   300 
       
   301     /**
       
   302      * From CCoeControl.
       
   303      * Handles pointer events
       
   304      *
       
   305      * This method must always be called, even when it's overridden by derived
       
   306      * classes
       
   307      *
       
   308      * @param aDrawNow Contains the value that was passed to it by SetFocus().      
       
   309      */    
       
   310     IMPORT_C void FocusChanged( TDrawNow aDrawNow );
       
   311     
       
   312     /**
       
   313      * From MAknLongTapDetectorCallBack.
       
   314      * Handles the long tap events.
       
   315      *
       
   316      * @since Series 60 3.1
       
   317      * @param aPenEventLocation Long tap event location relative to parent
       
   318      *        control.
       
   319      * @param aPenEventScreenLocation Long tap event location relative to
       
   320      *        screen.
       
   321      */
       
   322     IMPORT_C void HandleLongTapEventL(
       
   323         const TPoint& aPenEventLocation,
       
   324         const TPoint& aPenEventScreenLocation );
       
   325 
       
   326 protected:
       
   327     // New functions
       
   328 
       
   329     /**
       
   330      * C++ default constructor.
       
   331      */
       
   332     IMPORT_C CXnControlAdapter();
       
   333 
       
   334     /**
       
   335      * Two-phased constructor.
       
   336      */
       
   337     IMPORT_C void ConstructL( CXnNodePluginIf& aNode );
       
   338 
       
   339     /**
       
   340      * Const-version of getting the component pointer.
       
   341      * For internal use only.
       
   342      *
       
   343      * @since Series 60 3.1
       
   344      * @return Component pointer.
       
   345      */
       
   346     CXnComponent* Component() const;
       
   347 
       
   348     /**
       
   349      * Draws content image.
       
   350      *
       
   351      * @since Series 60 3.1
       
   352      */
       
   353     IMPORT_C void DrawContentImage() const;
       
   354 
       
   355 protected:
       
   356     /**
       
   357      * From CCoeControl.
       
   358      * Draws the control.
       
   359      *
       
   360      * This method must always be called, even when it's overridden by derived
       
   361      * classes
       
   362      *
       
   363      * @param aRect TRect to draw
       
   364      */
       
   365     IMPORT_C virtual void Draw( const TRect& aRect ) const;
       
   366 
       
   367     /**
       
   368      * From CCoeControl.
       
   369      * Return a child control by index.
       
   370      *
       
   371      * This method must not be overridden by derived classes
       
   372      *
       
   373      * @param aIndex Index of the child to return
       
   374      * @return Control at the given index
       
   375      */
       
   376 
       
   377     IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const;
       
   378 
       
   379     /**
       
   380      * From CCoeControl.
       
   381      * Return count of children.
       
   382      *
       
   383      * This method must not be overridden by derived classes.
       
   384      *
       
   385      * @return Count of children
       
   386      */
       
   387     IMPORT_C TInt CountComponentControls() const;
       
   388 
       
   389     /**
       
   390      * From CCoeControl.
       
   391      * Size change notification
       
   392      */
       
   393     IMPORT_C virtual void SizeChanged();
       
   394 
       
   395 public:
       
   396     /**
       
   397      * From CCoeAppUiBase.
       
   398      * Informs the components about the screen layout switch.
       
   399      */
       
   400     IMPORT_C virtual void HandleScreenDeviceChangedL();
       
   401 
       
   402     /**
       
   403      * Informs the components about the property change.
       
   404      */
       
   405     IMPORT_C void HandlePropertyChangeL( CXnProperty* aProperty = NULL );
       
   406 
       
   407     /*
       
   408      * Template method, called by HandlePropertyChangeL().
       
   409      * Additional implementations are done in derived classes.
       
   410      */
       
   411     IMPORT_C virtual void DoHandlePropertyChangeL(
       
   412         CXnProperty* aProperty = NULL );
       
   413 
       
   414     /**
       
   415      * Sets the state of the long tap animation
       
   416      */
       
   417     IMPORT_C void EnableLongTapAnimation( const TBool aAnimation );
       
   418 
       
   419     /**
       
   420      * Remove all child adapters
       
   421      */
       
   422     void RemoveChildAdapters();
       
   423 
       
   424     /**
       
   425      * Get child adapter list i.e which are not window owning controls
       
   426      */
       
   427     RPointerArray< CXnControlAdapter >& ChildAdapters();
       
   428 
       
   429     /**
       
   430      * Determines wheter control refuses focus loss
       
   431      */            
       
   432     virtual TBool RefusesFocusLoss() const { return EFalse; };
       
   433         
       
   434 private:
       
   435     // Data
       
   436 
       
   437     /**
       
   438      * class implementation.
       
   439      * Own.
       
   440      */
       
   441     CXnControlAdapterImpl* iImpl;
       
   442 
       
   443     /**
       
   444      * Avkon long tap detector implementation.
       
   445      * Own.
       
   446      */
       
   447     CAknLongTapDetector* iLongTapDetector;
       
   448     };
       
   449 
       
   450 // Inline functions
       
   451 #include "xncontroladapter.inl"
       
   452 
       
   453 #endif