camerauis/activepalette/Inc/CActivePalettePluginBase.h
branchRCL_3
changeset 24 bac7acad7cb3
parent 0 1ddebce53859
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     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:  Active Palette plugin base class*
       
    15 */
       
    16 
       
    17 
       
    18 /**
       
    19  * @file CActivePalettePluginBase.h
       
    20  * Active Palette plugin base class
       
    21  */
       
    22 
       
    23 #ifndef CACTIVEPALETTEPLUGINBASE_H
       
    24 #define CACTIVEPALETTEPLUGINBASE_H
       
    25 
       
    26 //  INCLUDES
       
    27 #include <e32std.h>
       
    28 #include <e32base.h>
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CActivePalettePluginBase;
       
    32 class CGulIcon;
       
    33 class CFbsBitmap;
       
    34 class CFbsBitmapDevice;
       
    35 class CBitmapContext;
       
    36 
       
    37 // CLASS DECLARATIONS
       
    38 
       
    39 /**
       
    40  * Plugin observer class.
       
    41  * Plugins should use this to communicate with the Active Palette.
       
    42  */
       
    43 class MActivePalettePluginObserver
       
    44     {
       
    45     public:
       
    46         /**
       
    47          * Notifies of the creation of the plugin
       
    48          * @param aPlugin A pointer to the plugin
       
    49          */
       
    50     	virtual void NotifyPluginCreated(CActivePalettePluginBase* aPlugin) = 0;
       
    51 
       
    52         /**
       
    53          * Notifies of the destruction of the plugin
       
    54          * @param aPlugin A pointer to the plugin
       
    55          */
       
    56     	virtual void NotifyPluginDestroyed(CActivePalettePluginBase* aPlugin) = 0;
       
    57 
       
    58         /** 
       
    59          * Assign icon for plugin obect's item
       
    60          * @param aIcon A pointer to the icon
       
    61          * @param aOnwershipTransfer Whether to transfer ownership
       
    62          */
       
    63     	virtual void SetItemIcon(CGulIcon* aIcon, TBool aOnwershipTransfer) = 0;
       
    64     	
       
    65     	/**
       
    66     	 * Assign tool tip for plugin obect's item
       
    67     	 * @param aTooltipText A descriptor containing the new tooltip text
       
    68     	 */
       
    69     	virtual void SetItemTooltipL(const TDesC& aTooltipText) = 0;
       
    70     	
       
    71     	/**
       
    72     	 * Assign icon and tooltip for plugin obect's item
       
    73     	 * @param aIcon The new icon
       
    74     	 * @param aOnwershipTransfer Whether the AP should take ownership of the icon
       
    75     	 * @param aTooltipText The new tooltip text
       
    76     	 */
       
    77     	virtual void SetItemIconAndTooltipL(CGulIcon* aIcon, 
       
    78     										TBool aOnwershipTransfer,
       
    79     										const TDesC& aTooltipText) = 0;
       
    80 
       
    81     	/**
       
    82     	 * Notify comletion of handling of user's item selection
       
    83     	 * @param aDataDes Data descriptor
       
    84     	 */
       
    85     	virtual void NotifyItemComplete(const TDesC8& aDataDes) = 0;
       
    86 
       
    87     	/**
       
    88     	 * Notify comletion of handling of user's item selection
       
    89     	 * @param aDataInt Data integer
       
    90     	 */
       
    91     	virtual void NotifyItemComplete(TInt aDataInt) = 0;
       
    92     	
       
    93     	/**
       
    94     	 * Send message to application
       
    95     	 * @param aMessageID The message ID
       
    96     	 * @param aDataDes Data descriptor
       
    97     	 */
       
    98     	virtual void SendMessage(TInt aMessageID, const TDesC8& aDataDes) = 0;
       
    99 
       
   100     	/**
       
   101     	 * Send message to application
       
   102     	 * @param aMessageID The message ID
       
   103     	 * @param aDataInt Data integer
       
   104     	 */
       
   105     	virtual void SendMessage(TInt aMessageID, TInt aDataInt) = 0;
       
   106     };
       
   107 
       
   108 /**
       
   109  * Namespace for the plugin factory
       
   110  */
       
   111 namespace NActivePalettePluginFactory
       
   112     {
       
   113     /**
       
   114      * Definition for data that PLUGIN gets upon its creation
       
   115      */
       
   116     class TPluginCreationParams
       
   117         {
       
   118         public:
       
   119             /**
       
   120              * Return a reference to the observer
       
   121              * @return A reference to the observer
       
   122              */
       
   123         	IMPORT_C MActivePalettePluginObserver& PluginObserver(void) const; 
       
   124 
       
   125             /**
       
   126              * Return the dimensions
       
   127              * @return The dimensions
       
   128              */
       
   129         	IMPORT_C TSize Dimensions(void) const;
       
   130         	
       
   131             /**
       
   132              * Constructor
       
   133              * @param aObserver A reference to the observer
       
   134              * @param aDimensions The dimensions
       
   135              */
       
   136         	IMPORT_C TPluginCreationParams(MActivePalettePluginObserver &aObserver,
       
   137         						  const TSize& aDimensions); 
       
   138 
       
   139         private:
       
   140             /// The observer
       
   141         	MActivePalettePluginObserver& 	iObserver;
       
   142         	/// Size of the icons used
       
   143         	TSize 							iDimensions;
       
   144         };
       
   145 
       
   146     /**
       
   147      * Prototype for plugin DLL factory function
       
   148      */
       
   149     typedef CActivePalettePluginBase * (* TInstantiatePluginLFunc)(const TUid& aPluginUid, 
       
   150     															   const TPluginCreationParams& aCreationParams);
       
   151 
       
   152     /// Entry ordinal to use for plugin creation
       
   153     const TInt KFactoryEntryOrdinal = 1;
       
   154     }
       
   155 
       
   156 
       
   157 /**
       
   158  * Animation helper for plugins.
       
   159  * Contains default icon animation (shrinks, then returns to normal)
       
   160  */
       
   161 class CAnimationHelper : public CBase
       
   162     {
       
   163     private:
       
   164         /**
       
   165          * Constructor
       
   166          */
       
   167     	CAnimationHelper();
       
   168 
       
   169         /**
       
   170          * Symbian leaving constructor
       
   171          * @param aSize Size
       
   172          * @param aMaskNeeded Indicates if a mask is needed or not
       
   173          */
       
   174     	void ConstructL(const TSize aSize, const TBool aMaskNeeded);
       
   175     	
       
   176     public:
       
   177         /**
       
   178          * Destructor
       
   179          */
       
   180     	~CAnimationHelper();
       
   181     	
       
   182         /**
       
   183          * Constructor
       
   184          * @param aSize Size
       
   185          * @param aMaskNeeded Indicates if a mask is needed or not
       
   186          */
       
   187     	static CAnimationHelper* NewL(const TSize aSize, const TBool aMaskNeeded);
       
   188 
       
   189     public:
       
   190         /// Current frame bitmap.
       
   191     	CFbsBitmap*         iFrame; 
       
   192         /// Current frame device.
       
   193     	CFbsBitmapDevice*   iFrameDevice;
       
   194         /// Current frame context.
       
   195     	CBitmapContext*    iFrameGc;
       
   196  
       
   197         /// Current frame mask bitmap.
       
   198     	CFbsBitmap*         iFrameMask; 
       
   199         /// Current frame mask device.
       
   200     	CFbsBitmapDevice*   iFrameMaskDevice;
       
   201         /// Current frame mask context.
       
   202     	CBitmapContext*     iFrameMaskGc;
       
   203     };
       
   204 
       
   205 /**
       
   206  * Plugin base class
       
   207  */
       
   208 class CActivePalettePluginBase : public CBase
       
   209     {
       
   210     public:
       
   211         /**
       
   212          * Reserved for internal use in this version
       
   213          */
       
   214     	class TPluginAnimationInfo
       
   215         	{
       
   216         	public:
       
   217         	    /// Number of frames in animation
       
   218         		TInt 	iNofFrames;
       
   219         		/// Interval between frames
       
   220         		TInt	iFrameTimeGapMs;
       
   221         		/// Dimensions of icons
       
   222         		TSize   iFrameSize;
       
   223         	};
       
   224 
       
   225         /**
       
   226          * The type of animation to perform
       
   227          */
       
   228     	enum TPluginAnimationType
       
   229         	{
       
   230     		EAniInvalid,     ///< Invalid animation
       
   231     		EAniFocused = 2  ///< Focus animation
       
   232         	};
       
   233 
       
   234     protected:
       
   235 
       
   236         /**
       
   237          * Constructor
       
   238          */
       
   239     	IMPORT_C CActivePalettePluginBase(const NActivePalettePluginFactory::TPluginCreationParams& aCreationParams);
       
   240 
       
   241         /**
       
   242          * Returns a reference to the plugin observer
       
   243          * @return A reference to the plugin observer
       
   244          */
       
   245     	inline MActivePalettePluginObserver& PluginObserver(void) const;
       
   246 
       
   247     public:
       
   248 
       
   249         /**
       
   250          * Destructor
       
   251          */
       
   252     	IMPORT_C virtual ~CActivePalettePluginBase(void);
       
   253     	
       
   254     	/** 
       
   255     	 * Handling of user's item selection
       
   256     	 * @warning MUST BE IMPLEMENTED BY PLUGIN
       
   257     	 */
       
   258     	IMPORT_C virtual void HandleItemSelectedL(void) = 0;
       
   259     	
       
   260     	/**
       
   261     	 * Handling of message from application
       
   262     	 * @warning SHOULD BE IMPLEMENTED BY PLUGIN
       
   263     	 * @param aMessageID The message ID
       
   264     	 * @param aDataDes Data descriptor
       
   265     	 * @param aDataInt Data integer
       
   266     	 */
       
   267     	IMPORT_C virtual void HandleMessageL(TInt aMessageID,
       
   268     	                                     const TDesC8& aDataDes,
       
   269     	                                     TInt aDataInt);
       
   270     	
       
   271     	/**
       
   272     	 * 2nd phase constructor
       
   273     	 * @warning MUST BE IMPLEMENTED BY PLUGIN
       
   274     	 * @param aCreationParams A reference to the construction parameter class to use
       
   275     	 * @param aCustomDataDes Data descriptor
       
   276     	 * @param aCustomDataInt Data integer
       
   277     	 */
       
   278     	IMPORT_C virtual void ConstructL(const NActivePalettePluginFactory::TPluginCreationParams& aCreationParams, 
       
   279                                          const TDesC8& aCustomDataDes,
       
   280                                          TInt aCustomDataInt);
       
   281     	
       
   282     	/**
       
   283     	 * Resource destruction 
       
   284     	 * @warning MAY BE IMPLEMENTED BY PLUGIN
       
   285     	 * (possible to use AP services)
       
   286     	 */
       
   287     	IMPORT_C virtual void Shutdown(void);
       
   288 
       
   289     	/** 
       
   290     	 * Reserved for internal use in this version
       
   291     	 * @param aAniType
       
   292     	 * @param aAniInfo
       
   293     	 * @param aDefaultAniInfo
       
   294     	 * @param aItemIcon
       
   295     	 * @param aItemIconMask
       
   296     	 */
       
   297     	IMPORT_C virtual void PrepareAniFramesL(TInt aAniType,				
       
   298                                                 TPluginAnimationInfo& aAniInfo,
       
   299                                                 const TPluginAnimationInfo& aDefaultAniInfo,
       
   300                                                 const CFbsBitmap & aItemIcon,
       
   301                                                 const CFbsBitmap * aItemIconMask);
       
   302     								  
       
   303     	/** 
       
   304     	 * Release the frames used in the animation
       
   305     	 * @param aAniType
       
   306     	 */
       
   307     	IMPORT_C virtual void ReleaseAniFrames(TInt aAniType);
       
   308     	
       
   309     	/**
       
   310     	 * Produces an animation frame
       
   311     	 * @param aAniType
       
   312     	 * @param aFrameNo
       
   313     	 * @param aAniInfo
       
   314     	 * @param aItemIcon
       
   315     	 * @param aItemIconMask
       
   316     	 * @param aFrame
       
   317     	 * @param aFrameMask
       
   318     	 * @param aOwnershipTransferForFrame
       
   319     	 * @param aOwnershipTransferForMask
       
   320          */
       
   321     	IMPORT_C virtual void ProduceAniFrame(TInt aAniType,
       
   322                                               TInt aFrameNo,
       
   323                                               const TPluginAnimationInfo& aAniInfo,
       
   324                                               const CFbsBitmap & aItemIcon,
       
   325                                               const CFbsBitmap * aItemIconMask,
       
   326                                               CFbsBitmap** aFrame,
       
   327                                               CFbsBitmap** aFrameMask,
       
   328                                               TBool& aOwnershipTransferForFrame,
       
   329                                               TBool& aOwnershipTransferForMask);
       
   330     				      		  				      		  						      		  		
       
   331     private:
       
   332         /// The plugin observer
       
   333         MActivePalettePluginObserver& iPluginObserver;
       
   334         
       
   335         /// The animation helper
       
   336         CBase*						  iAnimationHelper;
       
   337     }; 
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CActivePalettePluginBase::PluginObserver()
       
   341 // -----------------------------------------------------------------------------
       
   342 //
       
   343 inline MActivePalettePluginObserver & CActivePalettePluginBase::PluginObserver(void) const
       
   344     {
       
   345 	return iPluginObserver;
       
   346     };
       
   347 
       
   348 #endif // CACTIVEPALETTEPLUGINBASE_H
       
   349 
       
   350 // End of File