os/graphics/windowing/windowserver/nonnga/SERVER/ANIM.H
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 1999-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 // Definition of classes related to Anim DLL's
    15 // 
    16 //
    17 
    18 #ifndef __ANIM_H__
    19 #define __ANIM_H__
    20 
    21 #include <e32std.h>
    22 #include <w32adll.h>
    23 #include "server.h"
    24 #include "sprite.h"
    25 
    26 class CWsAnimDll : public CWsObject
    27 	{
    28 public:
    29 	static void InitStaticsL();
    30 	static void DeleteStatics();
    31 public:
    32 	CWsAnimDll(CWsClient *owner);
    33 	~CWsAnimDll();
    34 	TInt CreateInstanceL(TUint32 aHandle, TInt aType, TAny *aArgs, TBool aIsWindow);
    35 	void LoadL(const TDesC &aDllName);
    36 	void CommandL(TInt aOpcode, const TAny *aCmdData);
    37 	void Remove(TInt aHandle);
    38 	inline TInt AnimObjectHandle(CWsAnim *aAnimObject) const;
    39 	inline CWsAnim* AnimObjectL(TInt aAnimHandle) const;
    40 	
    41 private:
    42 	TInt doCreateInstanceL(CWsAnim *aInstance, TInt aType, TAny *aArgs, TBool aIsWindow);
    43 private:
    44 	static CObjectConIx *AnimObjectConIx;
    45 private:
    46 	CObjectCon *iInstanceCon;
    47 	CObjectIx *iInstanceIndex;
    48 	CAnimDll *iAnimDll;
    49 	RLibrary iAnimLib;
    50 	
    51 public:
    52 	TSglQueLink iQue;
    53 	};
    54 	
    55 class CWsAnimGc;
    56 
    57 class CWsAnim : public CObject, public MAnimGeneralFunctions, public MAnimGeneralFunctionsWindowExtension,
    58 													public MAnimFreeTimerWindowFunctions, public MAnimSpriteFunctions, public MAnimGeneralFunctionsEventExtension
    59 	{
    60 public:
    61 	static void InitStaticsL();
    62 	static void DeleteStatics();
    63 public:
    64 	CWsAnim(CWsAnimDll *aDll);
    65 	~CWsAnim();
    66 	void Connect(CWsClientWindow *aWindow);
    67 	void Connect(CWsSprite *aSprite);
    68 	void ConstructL(CAnim *aAnim, TAny *aArgs, CWsAnimDll *aAnimDll, TBool aIsWindow);
    69 	void Redraw(CFbsBitGc * aGc, const TRegion *aRegion);
    70 	static void UserDeactivateAnimGc();
    71 	inline CAnim *Anim() const;
    72 	static void WindowClosing(CWsAnim *aWsAnim);
    73 	static void CloseAnim(CWsAnim *aWsAnim);
    74 	const TRect& Rect() const;
    75 	TRect BestRect() const;
    76 	void FocusChanged(TBool aNewFocusState);
    77 	void SetMessage(const RMessagePtr2* aMessage);
    78 	TInt CommandReply(TInt aOpcode, TAny* aArgs);
    79 // Functions from MAnimGeneralFunctions
    80 	TDateTime SystemTime() const;
    81 	TBool FlashStateOn() const;				// Return ETrue if in the on part of the flash cycle
    82 	void Panic() const;
    83 	void Panic(TClientPanic aPanic) const;
    84 	const CFbsScreenDevice *ScreenDevice();						// Pointer to screen device
    85 	CFbsBitmap *DuplicateBitmapL(TInt aHandle);
    86 	CFbsFont *DuplicateFontL(TInt aHandle);
    87 	void CloseFont(CFbsFont *);
    88 	TAnimSync Sync() const;					// Return the current sync mode
    89 	void Animate(TDateTime *aDateTime);		// Trigger a call to the DLL's Animate function
    90 	void SetSync(TAnimSync aSyncMode);
    91 	void SetInterval(TInt aInterval);		// Set the regular repeat interval, does not affect the current countdown
    92 	void SetNextInterval(TInt aInterval);	// Sets the interval to the next Animate, after that it will fall back to the usual rate
    93 	const RThread &Client();				// Return a reference to the calling clients thread
    94 	void ReplyBuf(const TDesC8 &aDes);
    95 	void ReplyBuf(const TDesC16 &aDes);
    96 	void GetRawEvents(TBool aGetEvents) const;	// Raw events are passed to CAnim::OfferRawEventL
    97 	void PostRawEvent(const TRawEvent &aRawEvent) const;
    98 	void PostKeyEvent(const TKeyEvent &aRawEvent) const;
    99 	const RMessagePtr2* Message();
   100 	TAny* ExtendedInterface(TInt aInterface);
   101 	TInt RegisterForNotifications(TUint32 aNotifications);
   102 
   103 // Functions from MAnimGeneralFunctionsWindowExtension
   104 	TInt Screens() const;
   105 	TInt FocusScreens() const;
   106 	void SetFocusScreen(TInt aScreenNo);
   107 	TInt WindowGroups(TInt aScreen) const;
   108 	TBool WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aWindowGroup) const;
   109 	TBool WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aWindowGroup) const;
   110 	TInt SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority);
   111 	void WindowConfig(TWindowConfig& aWindowConfig) const;	
   112 // Functions from MAnimWindowFunctions
   113 	void ActivateGc();	// Activate the GC to enable drawing in a command or animate function
   114 	void Invalidate(const TRect &aRect);
   115 	void Parameters(TWindowInfo &aData);
   116 	void VisibleRegion(TRegion& aRegion);
   117  	TSize WindowSize() const;				// Return the window size
   118 	TBool IsHidden();
   119 	void SetVisible(TBool aState);
   120 	void SetRect(const TRect &aRect);		// Sets the rect that this instance wants to draw to.
   121 // Functions from MAnimFreeTimerWindowFunctions
   122 	void DeactivateGc();					// Deactivate the GC after drawing from our own RunL
   123 	void Update();
   124 // Functions from MAnimSpriteFunctions
   125 	TSpriteMember *GetSpriteMember(TInt aMember) const;	//Returns sprite member data
   126 	void UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate);		//redraw of part of a sprite
   127 	void Activate(TBool aActive);		// Turn sprite on or off
   128 	void SizeChangedL();
   129 	void SetPosition(const TPoint &aPos);			//Change the positon of the sprite
   130 	TBool SpriteCanBeSeen() const;
   131 // Functions from MAnimGeneralFunctionsEventExtension
   132 	void PostKeyEvent(const TKeyEvent& aRawEvent,TInt aRepeats) const; //Repeated key events 
   133 public:
   134 	inline CWsAnim * Next();
   135 private:
   136 	inline CWindowAnim* WindowAnim() {return STATIC_CAST(CWindowAnim*,iAnim);}
   137 private:
   138 	static CWsAnimGc *WsAnimGc;
   139 private:
   140 	CWsClient *iClient;
   141 	TTimeIntervalMicroSeconds iInterval;
   142 	TAnimSync iAnimSync;
   143 	CWsAnim *iNextWin;	// Linked list of animated objects attached to a window
   144 	CAnim *iAnim;
   145 	CWsAnimDll *iAnimDll;
   146 	CWsClientWindow *iWindow;
   147 	TRect iRect;
   148 	CWsSprite *iSprite;
   149 	const RMessagePtr2* iMessage;
   150 	TWindowInfo::TRegionPair* iRedrawRegionPair;
   151 	friend class CWsAnimDll;
   152 	friend class DllAnimator;
   153 	mutable TBool iAnimAddedInHandler;
   154 	TTime iStartTime;
   155 	TInt iLastFrame;
   156 	TBool iFlashOn;
   157 	};
   158 
   159 class CAnimFbsFont;
   160 
   161 class CWsAnimGc : public CAnimGc
   162 	{
   163 	friend class CWsAnim;
   164 public:
   165 	CWsAnimGc();
   166 //
   167 	void Activate(CWsClientWindow *aWindow, CWsAnim *aWsAnim, const TRegion *aRegion, CFbsBitGc * aGc);
   168 	void Deactivate();
   169 	TBool IsActive() const;
   170 	void UserActivate(CWsClientWindow *aWindow, CWsAnim *aWsAnim);
   171 	void UserDeactivate();
   172 	void AnimDeleted(CWsAnim *aWsAnim);
   173 // From CGraphicsContext
   174 	virtual CGraphicsDevice* Device() const;
   175 	virtual void SetDrawMode(TDrawMode aDrawingMode);
   176 	virtual void SetClippingRect(const TRect& aRect);
   177 	virtual void CancelClippingRect();
   178 	virtual void CancelClippingRegion();
   179 	virtual void UseFont(const CFont *aFont);
   180 	virtual void DiscardFont();
   181 	virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle);
   182 	virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle);
   183 	virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps);
   184 	virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars);
   185 	virtual void SetPenColor(const TRgb &aColor);
   186 	virtual void SetPenStyle(TPenStyle aPenStyle);
   187 	virtual void SetPenSize(const TSize& aSize);
   188 	virtual void SetBrushColor(const TRgb &aColor);
   189 	virtual void SetBrushStyle(TBrushStyle aBrushStyle);
   190 	virtual void SetBrushOrigin(const TPoint &aOrigin);
   191 	virtual void UseBrushPattern(const CFbsBitmap *aBitmap);
   192 	virtual void DiscardBrushPattern();
   193 	virtual void DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);
   194 	virtual void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2);
   195 	virtual void DrawLineTo(const TPoint &aPoint);
   196 	virtual void DrawLineBy(const TPoint &aPoint);
   197 	virtual void DrawPolyLine(const CArrayFix<TPoint> *aPointList);
   198 	virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints);
   199 	virtual void DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);
   200 	virtual void DrawEllipse(const TRect &aRect);
   201 	virtual void DrawRect(const TRect &aRect);
   202 	virtual void DrawRoundRect(const TRect &aRect,const TSize &aCornerSize);
   203 	virtual void Clear(const TRect &aRect);
   204 	virtual void Clear();
   205 	virtual TInt DrawPolygon(const CArrayFix<TPoint> *aPointList,TFillRule aFillRule);
   206 	virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate);
   207 	virtual void DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aSource);
   208 	virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource);
   209 	virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource, const TRect &aSourceRect);
   210 	virtual void DrawBitmapMasked(const TRect &aDestRect, const CFbsBitmap *aBitmap, const TRect &aSrcRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask);
   211 	virtual void DrawText(const TDesC &aString,const TPoint &aPosition);
   212 	virtual void DrawText(const TDesC &aString,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz=ELeft,TInt aLeftMrg=0);
   213 	virtual void MoveTo(const TPoint &aPoint);
   214 	virtual void MoveBy(const TPoint &aPoint);
   215 	virtual void Plot(const TPoint &aPoint);
   216 	virtual void SetOrigin(const TPoint &aPoint);
   217 	virtual void BitBlt(const TPoint &,const CFbsBitmap *aBitmap);
   218 	virtual void BitBlt(const TPoint &,const CFbsBitmap *aBitmap,const TRect &);
   219 	virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask);
   220 	virtual void CopyRect(const TPoint& aOffset,const TRect& aRect);
   221 	virtual void Reset();
   222 // Extra command defined in CBitmapContext
   223 	virtual void SetFaded(TBool aFaded);
   224 	virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap);
   225 
   226 	virtual TInt SetClippingRegion(const TRegion &aRegion);	
   227 	virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp,	const TPoint& aAlphaPt);	
   228 	virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards);
   229 	virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp);
   230 	virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
   231 	
   232 private:
   233 	void SetDrawingRegions(const TRegion *aRegion);
   234 	void CloseCurrentFont();
   235 	virtual void DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSrcRect*/,const CWsBitmap* /*aMaskBitmap*/, TBool /*aInvertMask*/);
   236 	TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp,	const TRect& aSrcRect, const CWsBitmap* aAlphaBmp,	const TPoint& aAlphaPt);
   237 private:
   238 	CFbsBitGc* iGc;
   239 	TBool iUserActive;
   240 	const TRegion *iBaseRegion;	// Pointer to base clipping region
   241 	TBool iUseDrawingRegion; // If ETrue use iDrawingRegion instead of iBaseRegion
   242 	RWsRegion iDrawingRegion;	// Intersection of iBaseRegion and extra clipping
   243 	CWsClientWindow *iWin;
   244 	RWsRegion iAnimateRegion;
   245 	CWsAnim *iOwningWsAnim;
   246 	TRect iClippingRect;
   247 	CAnimFbsFont *iFont;
   248 	};
   249 
   250 //
   251 // inlines			//
   252 //
   253 
   254 inline CAnim *CWsAnim::Anim() const
   255 	{return(iAnim);}
   256 inline TInt CWsAnimDll::AnimObjectHandle(CWsAnim *aAnimObject) const
   257 	{return(iInstanceIndex->At(aAnimObject));}
   258 inline CWsAnim* CWsAnimDll::AnimObjectL(TInt aAnimHandle) const
   259 	{return STATIC_CAST(CWsAnim*,iInstanceIndex->AtL(aAnimHandle));}
   260 inline CWsAnim* CWsAnim::Next()
   261 	{return iNextWin;}
   262 #endif