windowing/windowserver/inc/Graphics/WSGRAPHICDRAWER.H
changeset 0 5d03bc08d59c
equal deleted inserted replaced
-1:000000000000 0:5d03bc08d59c
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Server-side base-classes for graphic drawer plugins
       
    15 // 
       
    16 //
       
    17 
       
    18 #ifndef __WSGRAPHICDRAWER_H__
       
    19 #define __WSGRAPHICDRAWER_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <e32std.h>
       
    23 
       
    24 #include <graphics/wsgraphicdrawerinterface.h>
       
    25 
       
    26 class CFbsBitGc;
       
    27 class TSurfaceId;
       
    28 
       
    29 NONSHARABLE_STRUCT(TGraphicDrawerId)
       
    30 /** Represents a graphic drawer on the window-server side
       
    31 A much-abridged version of TWsGraphicId, with trivial constructor
       
    32 @publishedPartner
       
    33 @released
       
    34 */	{
       
    35 	TInt iId;
       
    36 	TBool iIsUid;
       
    37 	IMPORT_C TInt Compare(const TGraphicDrawerId& aOther) const;
       
    38 	IMPORT_C static TInt Compare(const TGraphicDrawerId& aFirst,const TGraphicDrawerId& aSecond);
       
    39 	};
       
    40 
       
    41 /** Wserv event representation to plugin side
       
    42 
       
    43 @publishedPartner
       
    44 @released
       
    45 */
       
    46 NONSHARABLE_STRUCT(TWservCrEvent)
       
    47 	{
       
    48 public:
       
    49 	/** Type of wserv events which plugin can listen to. It is a mask that can be combined
       
    50 	when subscribing to notification. */
       
    51 	enum
       
    52 		{
       
    53 		EScreenSizeModeChanged		= 0x00000001,
       
    54 		EWindowVisibilityChanged 	= 0x00000002,
       
    55 		EDsaDrawingBegin			= 0x00000004,
       
    56 		EDsaDrawingEnd				= 0x00000008,
       
    57 		EScreenSizeModeAboutToChange= 0x00000010,
       
    58 		EScreenUpdated				= 0x00000020,
       
    59 		EScreenDrawing				= 0x00000040,
       
    60 		EWindowGroupChanged			= 0x00000080,
       
    61 		EScreenOrientationChanged	= 0x00000100,
       
    62 		EDeviceOrientationChanged	= 0x00000200,
       
    63 		EWindowClosing              = 0x00000400,
       
    64 		ESurfaceUnreferenced		= 0x00000800,
       
    65 		};
       
    66 public:
       
    67 	IMPORT_C TWservCrEvent(TUint32 aType);
       
    68 	IMPORT_C TWservCrEvent(TUint32 aType, TUint32 aInfo);
       
    69 	IMPORT_C TWservCrEvent(TUint32 aType, TUint32 aInfo, TAny* aData);
       
    70 	IMPORT_C TWservCrEvent(TUint32 aType, TUint32 aInfo, TAny* aData, MWsWindow* aWindow);
       
    71 
       
    72 	/** Returns wserv event type */
       
    73 	IMPORT_C TUint32 Type() const;
       
    74 	/** Returns current wserv screen size mode as the result of event EScreenSizeModeChanged.
       
    75 	Screen mode is 0,1,2,...
       
    76 	*/
       
    77 	IMPORT_C TInt SizeMode() const;
       
    78 	/** Returns visibile region as the result of event EWindowVisibilityChanged, this region represents
       
    79 	full or some part of window which is changing visibility. NULL if window is becoming not visible
       
    80 	completely.
       
    81 	*/
       
    82 	IMPORT_C const RRegion* VisibleRegion() const;
       
    83 	/** Returns screen number where a DSA, screen updated or window group changed event occurs
       
    84 	*/
       
    85 	IMPORT_C TInt ScreenNumber() const;
       
    86 	/** Returns the drawing region which is referred to by an EScreenDrawing
       
    87 	*/
       
    88 	IMPORT_C const TRegion* DrawingRegion() const;
       
    89 	/** Returns the new window group identifier where a window group changed event occurs
       
    90 	*/
       
    91 	IMPORT_C TInt WindowGroupIdentifier() const;
       
    92 	/** Returns the new window server display oriention
       
    93 	*/
       
    94 	IMPORT_C CFbsBitGc::TGraphicsOrientation Orientation() const;
       
    95 	/** Returns whether or not a window was already visible before a visibility event occurred
       
    96 	*/
       
    97 	IMPORT_C TBool WasVisible() const;
       
    98 	/** Returns the window this event is for.  This may be null.
       
    99 	@prototype
       
   100 	*/
       
   101 	IMPORT_C MWsWindow* Window() const;	
       
   102 	/** Returns the released surface ID
       
   103 	*/
       
   104 	IMPORT_C const TSurfaceId* SurfaceId() const;
       
   105 
       
   106 private:
       
   107 	TWservCrEvent() {}
       
   108 	
       
   109 private:
       
   110 	TUint32 iType;
       
   111 	TUint32 iInfo;
       
   112 	TAny* iData;
       
   113 	MWsWindow* iWindow;
       
   114 	TInt iReserved[7];
       
   115 	};
       
   116 
       
   117 /** Event notification callback. Need to be implemented to allow CWsGraphicDrawer to listen to
       
   118 wserv events.
       
   119 
       
   120 @publishedPartner
       
   121 @released
       
   122 */
       
   123 class MWsEventHandler
       
   124 	{
       
   125 public:
       
   126 	/** Plugin event handler, will be called once for each event.
       
   127 	*/
       
   128 	virtual void DoHandleEvent(const TWservCrEvent& aEvent) = 0;
       
   129 	};
       
   130 
       
   131 /**
       
   132 Implementing this interface will give a callback notification wheater a
       
   133 graphic message which was sent has either failed or succeded.
       
   134 @publishedPartner
       
   135 @prototype
       
   136 */
       
   137 class MWsGraphicMessageCallback : public MWsObjectProvider
       
   138  	{
       
   139 public:
       
   140  	DECLARE_WS_TYPE_ID(KWsGraphicMessageCallbackInterfaceId)
       
   141 
       
   142 public:
       
   143  	/**
       
   144  	Called with unique ID of the message, aError will be set to KErrNone if message delivery is
       
   145  	successful, otherwise one of the system-wide error code.
       
   146  	*/
       
   147  	virtual void HandleMessageDelivery(TInt aMessageId, TInt aError) = 0;
       
   148  	};
       
   149 
       
   150 /**
       
   151 Implementing this interface will give you the possibility to send synchron messages with a returnvalue to the client.
       
   152 @publishedPartner
       
   153 @prototype
       
   154 */
       
   155 class MWsGraphicHandleSynchronMessage: public MWsObjectProvider
       
   156  	{
       
   157 public:
       
   158  	DECLARE_WS_TYPE_ID(KWsGraphicHandleSynchronMessageId)
       
   159 
       
   160 public:
       
   161  	/**
       
   162 	Synchron handlemessage method.
       
   163 	*/
       
   164 	virtual TInt HandleSynchronMessage(const TDesC8& aData) = 0;
       
   165 	};
       
   166 
       
   167 
       
   168 class CWsGraphicDrawer: public CBase, public MWsObjectProvider
       
   169 /** A window-server-side peer to a CWsGraphic
       
   170 @publishedPartner
       
   171 @released
       
   172 */	{
       
   173 public:
       
   174 	/** This function should be overriden by all derived classes.  The first call the implementation of this function
       
   175 		should make is to BaseConstructL().
       
   176 		@param aEnv the environment this drawer exists in
       
   177 		@param aId the ID of this drawer
       
   178 		@param aOwner the client session that owns this drawer
       
   179 		@param aData arbitrary data for constructing this instance, sent from the client.
       
   180 	*/
       
   181 	virtual void ConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner,const TDesC8& aData) = 0;
       
   182 	IMPORT_C ~CWsGraphicDrawer();
       
   183 	IMPORT_C const TGraphicDrawerId& Id() const;
       
   184 	IMPORT_C const MWsClient& Owner() const;
       
   185 	IMPORT_C TBool IsSharedWith(TSecureId aClientId) const;
       
   186 	IMPORT_C TInt ShareGlobally();
       
   187 	IMPORT_C TInt UnShareGlobally();
       
   188 	IMPORT_C TInt Share(TSecureId aClientId);
       
   189 	IMPORT_C TInt UnShare(TSecureId aClientId);
       
   190 	IMPORT_C void Draw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const;
       
   191 	IMPORT_C TBool Contains(const TArray<TGraphicDrawerId>& aIds) const;
       
   192 	virtual void HandleMessage(const TDesC8& aData) = 0;
       
   193 	IMPORT_C void HandleEvent(const TWservCrEvent& aEvent);
       
   194 	IMPORT_C void SetEventHandler(MWsEventHandler* aHandler);
       
   195 	IMPORT_C TBool HasEventHandler() const;
       
   196 protected:
       
   197 	IMPORT_C CWsGraphicDrawer();
       
   198 	IMPORT_C void BaseConstructL(MWsGraphicDrawerEnvironment& aEnv,const TGraphicDrawerId& aId,MWsClient& aOwner);
       
   199 	IMPORT_C MWsGraphicDrawerEnvironment& Env();
       
   200 	IMPORT_C const MWsGraphicDrawerEnvironment& Env() const;
       
   201 	IMPORT_C TInt SendMessage(const TDesC8& aData);
       
   202 	IMPORT_C TInt SendMessage(CWsMessageData& aData);
       
   203 	IMPORT_C void Invalidate();
       
   204 private:
       
   205 	IMPORT_C virtual TBool HasAsChild(const TArray<TGraphicDrawerId>& aIds) const;
       
   206 	virtual void DoDraw(MWsGc& aGc,const TRect& aRect,const TDesC8& aData) const = 0;
       
   207 private:
       
   208 	class CPimpl;
       
   209 	friend class CPimpl;
       
   210 	CPimpl* iPimpl;
       
   211 	TInt iWsGraphicDrawerSpare[3];
       
   212 private:
       
   213 	friend class WsGraphicDrawer;
       
   214 	TUid iDtor_ID_Key;
       
   215 	};
       
   216 
       
   217 
       
   218 #endif //#ifndef __WSGRAPHICDRAWER_H__