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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // Definition of classes related to Anim DLL's
26 class CWsAnimDll : public CWsObject
29 static void InitStaticsL();
30 static void DeleteStatics();
32 CWsAnimDll(CWsClient *owner);
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;
42 TInt doCreateInstanceL(CWsAnim *aInstance, TInt aType, TAny *aArgs, TBool aIsWindow);
44 static CObjectConIx *AnimObjectConIx;
46 CObjectCon *iInstanceCon;
47 CObjectIx *iInstanceIndex;
57 class CWsAnim : public CObject, public MAnimGeneralFunctions, public MAnimGeneralFunctionsWindowExtension,
58 public MAnimFreeTimerWindowFunctions, public MAnimSpriteFunctions, public MAnimGeneralFunctionsEventExtension
61 static void InitStaticsL();
62 static void DeleteStatics();
64 CWsAnim(CWsAnimDll *aDll);
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
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);
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
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
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
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
134 inline CWsAnim * Next();
136 inline CWindowAnim* WindowAnim() {return STATIC_CAST(CWindowAnim*,iAnim);}
138 static CWsAnimGc *WsAnimGc;
141 TTimeIntervalMicroSeconds iInterval;
143 CWsAnim *iNextWin; // Linked list of animated objects attached to a window
145 CWsAnimDll *iAnimDll;
146 CWsClientWindow *iWindow;
149 const RMessagePtr2* iMessage;
150 TWindowInfo::TRegionPair* iRedrawRegionPair;
151 friend class CWsAnimDll;
152 friend class DllAnimator;
153 mutable TBool iAnimAddedInHandler;
161 class CWsAnimGc : public CAnimGc
163 friend class CWsAnim;
167 void Activate(CWsClientWindow *aWindow, CWsAnim *aWsAnim, const TRegion *aRegion, CFbsBitGc * aGc);
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);
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);
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);
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;
254 inline CAnim *CWsAnim::Anim() const
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()