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,
59 public MWsWindowTreeNode
63 void RedrawWindowAnimL(const TTime& aTimeNow, MWsGraphicsContext* aGc, const TRegion* aRegion);
64 void AnimateSpriteAnimL(const TTime& aTimeNow);
65 void UserDeactivateAnimGc();
66 static void WindowClosing(CWsAnim *aWsAnim);
67 static void CloseAnim(CWsAnim *aWsAnim);
68 TRect BestRect() const;
69 void FocusChanged(TBool aNewFocusState);
70 void SetMessage(const RMessagePtr2* aMessage);
71 TInt CommandReply(TInt aOpcode, TAny* aArgs);
72 void SessionPanic() const;
74 void Panic(TClientPanic aPanic) const;
75 inline CWsAnim * Next();
76 inline CWsClientWindow* ClientWindow() const;
77 void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const;
80 CWsAnim(CWsAnimDll *aDll);
81 void Connect(CWsClientWindow *aWindow);
82 void Connect(CWsSprite *aSprite);
83 void ConstructL(CAnim *aAnim, TAny *aArgs, CWsAnimDll *aAnimDll, TBool aIsWindow);
84 inline CAnim *Anim() const;
85 const TRect& Rect() const;
87 // Functions from MAnimGeneralFunctions
88 TDateTime SystemTime() const;
89 TBool FlashStateOn() const; // Return ETrue if in the on part of the flash cycle
91 const CFbsScreenDevice *ScreenDevice(); // Pointer to screen device
92 CFbsBitmap *DuplicateBitmapL(TInt aHandle);
93 CFbsFont *DuplicateFontL(TInt aHandle);
94 void CloseFont(CFbsFont *);
95 TAnimSync Sync() const; // Return the current sync mode
96 void Animate(TDateTime *aDateTime); // Trigger a call to the DLL's Animate function
97 void SetSync(TAnimSync aSyncMode);
98 void SetInterval(TInt aInterval); // Set the regular repeat interval, does not affect the current countdown
99 void SetNextInterval(TInt aInterval); // Sets the interval to the next Animate, after that it will fall back to the usual rate
100 const RThread &Client(); // Return a reference to the calling clients thread
101 void ReplyBuf(const TDesC8 &aDes);
102 void ReplyBuf(const TDesC16 &aDes);
103 void GetRawEvents(TBool aGetEvents) const; // Raw events are passed to CAnim::OfferRawEventL
104 void PostRawEvent(const TRawEvent &aRawEvent) const;
105 void PostKeyEvent(const TKeyEvent &aRawEvent) const;
106 const RMessagePtr2* Message();
107 TAny* ExtendedInterface(TInt aInterface);
108 TInt RegisterForNotifications(TUint32 aNotifications);
110 // Functions from MAnimGeneralFunctionsWindowExtension
111 TInt Screens() const;
112 TInt FocusScreens() const;
113 void SetFocusScreen(TInt aScreenNo);
114 TInt WindowGroups(TInt aScreen) const;
115 TBool WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aWindowGroup) const;
116 TBool WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aWindowGroup) const;
117 TInt SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority);
118 void WindowConfig(TWindowConfig& aWindowConfig) const;
119 // Functions from MAnimWindowFunctions
120 void ActivateGc(); // Activate the GC to enable drawing in a command or animate function
121 void Invalidate(const TRect &aRect);
122 void Parameters(TWindowInfo &aData);
123 void VisibleRegion(TRegion& aRegion);
124 TSize WindowSize() const; // Return the window size
126 void SetVisible(TBool aState);
127 void SetRect(const TRect &aRect); // Sets the rect that this instance wants to draw to.
128 // Functions from MAnimFreeTimerWindowFunctions
129 void DeactivateGc(); // Deactivate the GC after drawing from our own RunL
131 // Functions from MAnimSpriteFunctions
132 TSpriteMember *GetSpriteMember(TInt aMember) const; //Returns sprite member data
133 void UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate); //redraw of part of a sprite
134 void Activate(TBool aActive); // Turn sprite on or off
136 void SetPosition(const TPoint &aPos); //Change the positon of the sprite
137 TBool SpriteCanBeSeen() const;
138 // Functions from MAnimGeneralFunctionsEventExtension
139 void PostKeyEvent(const TKeyEvent& aRawEvent,TInt aRepeats) const; //Repeated key events
140 // Functions from MWsWindowTreeNode
141 MWsWindowTreeNode::TType NodeType() const;
142 const MWsWindow* Window() const;
143 const MWsSprite* Sprite() const;
144 const MWsStandardTextCursor* StandardTextCursor() const;
145 const MWsWindowGroup* WindowGroup() const;
146 const MWsWindowTreeNode* ParentNode() const;
148 void ScheduleSelf(const TTimeIntervalMicroSeconds& aFrom);
149 void AnimateL(const TTime& aTimeNow, TInt& aFrame, TInt64& aAdjustedStart);
150 void RedrawWindowAnimL(MWsGraphicsContext* aGc, const TRegion* aRegion);
151 void ReSchedule(const TTime& aTimeNow, const TInt& aFrame, const TInt64& aAdjustedStart);
155 TTimeIntervalMicroSeconds iInterval;
157 /* Linked list of animated objects attached to a window */
161 CWindowAnim* iWindowAnim;
162 CSpriteAnim* iSpriteAnim;
165 CWsAnimDll *iAnimDll;
166 CWsClientWindow *iWindow;
169 const RMessagePtr2* iMessage;
170 TWindowInfo::TRegionPair* iRedrawRegionPair;
171 friend class CWsAnimDll;
172 friend class DllAnimator;
173 mutable TBool iAnimAddedInHandler;
178 /** ETrue if this anim accepts advanced pointer events
179 (TRawEvents with pointer number, pointer pressure and proximity info) */
180 EAdvancedPointersEnabled,
183 /** This flag is set when this anim is called in the context of CScreenRedraw::OnAnimation
184 i.e. when the screen is in the process of sending a new frame to the display hardware. */
192 class CWsAnimGc : public CAnimGc
195 CWsAnimGc(CWsAnim& aWsAnim);
198 void Activate(const TRegion* aRegion, MWsGraphicsContext* aGc);
200 TBool IsActive() const;
202 void UserDeactivate();
203 // From CGraphicsContext
204 virtual CGraphicsDevice* Device() const;
205 virtual void SetDrawMode(TDrawMode aDrawingMode);
206 virtual void SetClippingRect(const TRect& aRect);
207 virtual void CancelClippingRect();
208 virtual void CancelClippingRegion();
209 virtual void UseFont(const CFont *aFont);
210 virtual void DiscardFont();
211 virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle);
212 virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle);
213 virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps);
214 virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars);
215 virtual void SetPenColor(const TRgb &aColor);
216 virtual void SetPenStyle(TPenStyle aPenStyle);
217 virtual void SetPenSize(const TSize& aSize);
218 virtual void SetBrushColor(const TRgb &aColor);
219 virtual void SetBrushStyle(TBrushStyle aBrushStyle);
220 virtual void SetBrushOrigin(const TPoint &aOrigin);
221 virtual void UseBrushPattern(const CFbsBitmap *aBitmap);
222 virtual void DiscardBrushPattern();
223 virtual void DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);
224 virtual void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2);
225 virtual void DrawLineTo(const TPoint &aPoint);
226 virtual void DrawLineBy(const TPoint &aPoint);
227 virtual void DrawPolyLine(const CArrayFix<TPoint> *aPointList);
228 virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints);
229 virtual void DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd);
230 virtual void DrawEllipse(const TRect &aRect);
231 virtual void DrawRect(const TRect &aRect);
232 virtual void DrawRoundRect(const TRect &aRect,const TSize &aCornerSize);
233 virtual void Clear(const TRect &aRect);
234 virtual void Clear();
235 virtual TInt DrawPolygon(const CArrayFix<TPoint> *aPointList,TFillRule aFillRule);
236 virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate);
237 virtual void DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aSource);
238 virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource);
239 virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource, const TRect &aSourceRect);
240 virtual void DrawBitmapMasked(const TRect &aDestRect, const CFbsBitmap *aBitmap, const TRect &aSrcRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask);
241 virtual void DrawText(const TDesC &aString,const TPoint &aPosition);
242 virtual void DrawText(const TDesC &aString,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz=ELeft,TInt aLeftMrg=0);
243 virtual void MoveTo(const TPoint &aPoint);
244 virtual void MoveBy(const TPoint &aPoint);
245 virtual void Plot(const TPoint &aPoint);
246 virtual void SetOrigin(const TPoint &aPoint);
247 virtual void BitBlt(const TPoint &,const CFbsBitmap *aBitmap);
248 virtual void BitBlt(const TPoint &,const CFbsBitmap *aBitmap,const TRect &);
249 virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask);
250 virtual void CopyRect(const TPoint& aOffset,const TRect& aRect);
251 virtual void Reset();
252 // Extra command defined in CBitmapContext
253 virtual void SetFaded(TBool aFaded);
254 virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap);
256 virtual TInt SetClippingRegion(const TRegion &aRegion);
257 virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt);
258 virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards);
259 virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp);
260 virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0);
263 void CloseCurrentFont();
264 virtual void DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSrcRect*/,const CWsBitmap* /*aMaskBitmap*/, TBool /*aInvertMask*/);
265 TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt);
267 CWsAnim& iOwningWsAnim;
268 MWsGraphicsContext* iGc;
270 const TRegion *iBaseRegion; // Base clipping region provided on activation
271 TBool iUseDrawingRegion; // Indicates that the user has set a drawing region
272 RWsRegion iDrawingRegion; // Drawing region provided by the user (in screen coordinates)
273 TRect iClippingRect; // Clipping rectangle (in screen coordinates)
281 inline CAnim *CWsAnim::Anim() const
284 return iAnim.iWindowAnim;
286 return iAnim.iSpriteAnim;
288 inline TInt CWsAnimDll::AnimObjectHandle(CWsAnim *aAnimObject) const
289 {return(iInstanceIndex->At(aAnimObject));}
290 inline CWsAnim* CWsAnimDll::AnimObjectL(TInt aAnimHandle) const
291 {return STATIC_CAST(CWsAnim*,iInstanceIndex->AtL(aAnimHandle));}
292 inline CWsAnim* CWsAnim::Next()
294 inline CWsClientWindow* CWsAnim::ClientWindow() const