sl@0: // Copyright (c) 1999-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // Definition of classes related to Anim DLL's sl@0: // sl@0: // sl@0: sl@0: #ifndef __ANIM_H__ sl@0: #define __ANIM_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include "server.h" sl@0: #include "sprite.h" sl@0: sl@0: class CWsAnimDll : public CWsObject sl@0: { sl@0: public: sl@0: static void InitStaticsL(); sl@0: static void DeleteStatics(); sl@0: public: sl@0: CWsAnimDll(CWsClient *owner); sl@0: ~CWsAnimDll(); sl@0: TInt CreateInstanceL(TUint32 aHandle, TInt aType, TAny *aArgs, TBool aIsWindow); sl@0: void LoadL(const TDesC &aDllName); sl@0: void CommandL(TInt aOpcode, const TAny *aCmdData); sl@0: void Remove(TInt aHandle); sl@0: inline TInt AnimObjectHandle(CWsAnim *aAnimObject) const; sl@0: inline CWsAnim* AnimObjectL(TInt aAnimHandle) const; sl@0: sl@0: private: sl@0: TInt doCreateInstanceL(CWsAnim *aInstance, TInt aType, TAny *aArgs, TBool aIsWindow); sl@0: private: sl@0: static CObjectConIx *AnimObjectConIx; sl@0: private: sl@0: CObjectCon *iInstanceCon; sl@0: CObjectIx *iInstanceIndex; sl@0: CAnimDll *iAnimDll; sl@0: RLibrary iAnimLib; sl@0: sl@0: public: sl@0: TSglQueLink iQue; sl@0: }; sl@0: sl@0: class CWsAnimGc; sl@0: sl@0: class CWsAnim : public CObject, public MAnimGeneralFunctions, public MAnimGeneralFunctionsWindowExtension, sl@0: public MAnimFreeTimerWindowFunctions, public MAnimSpriteFunctions, public MAnimGeneralFunctionsEventExtension, sl@0: public MWsWindowTreeNode sl@0: { sl@0: public: sl@0: ~CWsAnim(); sl@0: void RedrawWindowAnimL(const TTime& aTimeNow, MWsGraphicsContext* aGc, const TRegion* aRegion); sl@0: void AnimateSpriteAnimL(const TTime& aTimeNow); sl@0: void UserDeactivateAnimGc(); sl@0: static void WindowClosing(CWsAnim *aWsAnim); sl@0: static void CloseAnim(CWsAnim *aWsAnim); sl@0: TRect BestRect() const; sl@0: void FocusChanged(TBool aNewFocusState); sl@0: void SetMessage(const RMessagePtr2* aMessage); sl@0: TInt CommandReply(TInt aOpcode, TAny* aArgs); sl@0: void SessionPanic() const; sl@0: void Panic() const; sl@0: void Panic(TClientPanic aPanic) const; sl@0: inline CWsAnim * Next(); sl@0: inline CWsClientWindow* ClientWindow() const; sl@0: void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const; sl@0: sl@0: private: sl@0: CWsAnim(CWsAnimDll *aDll); sl@0: void Connect(CWsClientWindow *aWindow); sl@0: void Connect(CWsSprite *aSprite); sl@0: void ConstructL(CAnim *aAnim, TAny *aArgs, CWsAnimDll *aAnimDll, TBool aIsWindow); sl@0: inline CAnim *Anim() const; sl@0: const TRect& Rect() const; sl@0: sl@0: // Functions from MAnimGeneralFunctions sl@0: TDateTime SystemTime() const; sl@0: TBool FlashStateOn() const; // Return ETrue if in the on part of the flash cycle sl@0: sl@0: const CFbsScreenDevice *ScreenDevice(); // Pointer to screen device sl@0: CFbsBitmap *DuplicateBitmapL(TInt aHandle); sl@0: CFbsFont *DuplicateFontL(TInt aHandle); sl@0: void CloseFont(CFbsFont *); sl@0: TAnimSync Sync() const; // Return the current sync mode sl@0: void Animate(TDateTime *aDateTime); // Trigger a call to the DLL's Animate function sl@0: void SetSync(TAnimSync aSyncMode); sl@0: void SetInterval(TInt aInterval); // Set the regular repeat interval, does not affect the current countdown sl@0: void SetNextInterval(TInt aInterval); // Sets the interval to the next Animate, after that it will fall back to the usual rate sl@0: const RThread &Client(); // Return a reference to the calling clients thread sl@0: void ReplyBuf(const TDesC8 &aDes); sl@0: void ReplyBuf(const TDesC16 &aDes); sl@0: void GetRawEvents(TBool aGetEvents) const; // Raw events are passed to CAnim::OfferRawEventL sl@0: void PostRawEvent(const TRawEvent &aRawEvent) const; sl@0: void PostKeyEvent(const TKeyEvent &aRawEvent) const; sl@0: const RMessagePtr2* Message(); sl@0: TAny* ExtendedInterface(TInt aInterface); sl@0: TInt RegisterForNotifications(TUint32 aNotifications); sl@0: sl@0: // Functions from MAnimGeneralFunctionsWindowExtension sl@0: TInt Screens() const; sl@0: TInt FocusScreens() const; sl@0: void SetFocusScreen(TInt aScreenNo); sl@0: TInt WindowGroups(TInt aScreen) const; sl@0: TBool WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aWindowGroup) const; sl@0: TBool WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aWindowGroup) const; sl@0: TInt SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority); sl@0: void WindowConfig(TWindowConfig& aWindowConfig) const; sl@0: // Functions from MAnimWindowFunctions sl@0: void ActivateGc(); // Activate the GC to enable drawing in a command or animate function sl@0: void Invalidate(const TRect &aRect); sl@0: void Parameters(TWindowInfo &aData); sl@0: void VisibleRegion(TRegion& aRegion); sl@0: TSize WindowSize() const; // Return the window size sl@0: TBool IsHidden(); sl@0: void SetVisible(TBool aState); sl@0: void SetRect(const TRect &aRect); // Sets the rect that this instance wants to draw to. sl@0: // Functions from MAnimFreeTimerWindowFunctions sl@0: void DeactivateGc(); // Deactivate the GC after drawing from our own RunL sl@0: void Update(); sl@0: // Functions from MAnimSpriteFunctions sl@0: TSpriteMember *GetSpriteMember(TInt aMember) const; //Returns sprite member data sl@0: void UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate); //redraw of part of a sprite sl@0: void Activate(TBool aActive); // Turn sprite on or off sl@0: void SizeChangedL(); sl@0: void SetPosition(const TPoint &aPos); //Change the positon of the sprite sl@0: TBool SpriteCanBeSeen() const; sl@0: // Functions from MAnimGeneralFunctionsEventExtension sl@0: void PostKeyEvent(const TKeyEvent& aRawEvent,TInt aRepeats) const; //Repeated key events sl@0: // Functions from MWsWindowTreeNode sl@0: MWsWindowTreeNode::TType NodeType() const; sl@0: const MWsWindow* Window() const; sl@0: const MWsSprite* Sprite() const; sl@0: const MWsStandardTextCursor* StandardTextCursor() const; sl@0: const MWsWindowGroup* WindowGroup() const; sl@0: const MWsWindowTreeNode* ParentNode() const; sl@0: sl@0: void ScheduleSelf(const TTimeIntervalMicroSeconds& aFrom); sl@0: void AnimateL(const TTime& aTimeNow, TInt& aFrame, TInt64& aAdjustedStart); sl@0: void RedrawWindowAnimL(MWsGraphicsContext* aGc, const TRegion* aRegion); sl@0: void ReSchedule(const TTime& aTimeNow, const TInt& aFrame, const TInt64& aAdjustedStart); sl@0: sl@0: private: sl@0: CWsClient *iClient; sl@0: TTimeIntervalMicroSeconds iInterval; sl@0: TAnimSync iAnimSync; sl@0: /* Linked list of animated objects attached to a window */ sl@0: CWsAnim *iNextWin; sl@0: union sl@0: { sl@0: CWindowAnim* iWindowAnim; sl@0: CSpriteAnim* iSpriteAnim; sl@0: } iAnim; sl@0: CWsAnimGc *iAnimGc; sl@0: CWsAnimDll *iAnimDll; sl@0: CWsClientWindow *iWindow; sl@0: TRect iRect; sl@0: CWsSprite *iSprite; sl@0: const RMessagePtr2* iMessage; sl@0: TWindowInfo::TRegionPair* iRedrawRegionPair; sl@0: friend class CWsAnimDll; sl@0: friend class DllAnimator; sl@0: mutable TBool iAnimAddedInHandler; sl@0: TTime iStartTime; sl@0: TInt iLastFrame; sl@0: enum TFlags sl@0: { sl@0: /** ETrue if this anim accepts advanced pointer events sl@0: (TRawEvents with pointer number, pointer pressure and proximity info) */ sl@0: EAdvancedPointersEnabled, sl@0: EFlashOn, sl@0: EWinAnimConstructed, sl@0: /** This flag is set when this anim is called in the context of CScreenRedraw::OnAnimation sl@0: i.e. when the screen is in the process of sending a new frame to the display hardware. */ sl@0: EInRedraw, sl@0: }; sl@0: TBitFlags iBitFlags; sl@0: }; sl@0: sl@0: class CAnimFbsFont; sl@0: sl@0: class CWsAnimGc : public CAnimGc sl@0: { sl@0: public: sl@0: CWsAnimGc(CWsAnim& aWsAnim); sl@0: ~CWsAnimGc(); sl@0: // sl@0: void Activate(const TRegion* aRegion, MWsGraphicsContext* aGc); sl@0: void Deactivate(); sl@0: TBool IsActive() const; sl@0: void UserActivate(); sl@0: void UserDeactivate(); sl@0: // From CGraphicsContext sl@0: virtual CGraphicsDevice* Device() const; sl@0: virtual void SetDrawMode(TDrawMode aDrawingMode); sl@0: virtual void SetClippingRect(const TRect& aRect); sl@0: virtual void CancelClippingRect(); sl@0: virtual void CancelClippingRegion(); sl@0: virtual void UseFont(const CFont *aFont); sl@0: virtual void DiscardFont(); sl@0: virtual void SetUnderlineStyle(TFontUnderline aUnderlineStyle); sl@0: virtual void SetStrikethroughStyle(TFontStrikethrough aStrikethroughStyle); sl@0: virtual void SetWordJustification(TInt aExcessWidth,TInt aNumGaps); sl@0: virtual void SetCharJustification(TInt aExcessWidth,TInt aNumChars); sl@0: virtual void SetPenColor(const TRgb &aColor); sl@0: virtual void SetPenStyle(TPenStyle aPenStyle); sl@0: virtual void SetPenSize(const TSize& aSize); sl@0: virtual void SetBrushColor(const TRgb &aColor); sl@0: virtual void SetBrushStyle(TBrushStyle aBrushStyle); sl@0: virtual void SetBrushOrigin(const TPoint &aOrigin); sl@0: virtual void UseBrushPattern(const CFbsBitmap *aBitmap); sl@0: virtual void DiscardBrushPattern(); sl@0: virtual void DrawArc(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd); sl@0: virtual void DrawLine(const TPoint &aPoint1,const TPoint &aPoint2); sl@0: virtual void DrawLineTo(const TPoint &aPoint); sl@0: virtual void DrawLineBy(const TPoint &aPoint); sl@0: virtual void DrawPolyLine(const CArrayFix *aPointList); sl@0: virtual void DrawPolyLine(const TPoint* aPointList,TInt aNumPoints); sl@0: virtual void DrawPie(const TRect &aRect,const TPoint &aStart,const TPoint &aEnd); sl@0: virtual void DrawEllipse(const TRect &aRect); sl@0: virtual void DrawRect(const TRect &aRect); sl@0: virtual void DrawRoundRect(const TRect &aRect,const TSize &aCornerSize); sl@0: virtual void Clear(const TRect &aRect); sl@0: virtual void Clear(); sl@0: virtual TInt DrawPolygon(const CArrayFix *aPointList,TFillRule aFillRule); sl@0: virtual TInt DrawPolygon(const TPoint* aPointList,TInt aNumPoints,TFillRule aFillRule=EAlternate); sl@0: virtual void DrawBitmap(const TPoint &aTopLeft, const CFbsBitmap *aSource); sl@0: virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource); sl@0: virtual void DrawBitmap(const TRect &aDestRect, const CFbsBitmap *aSource, const TRect &aSourceRect); sl@0: virtual void DrawBitmapMasked(const TRect &aDestRect, const CFbsBitmap *aBitmap, const TRect &aSrcRect, const CFbsBitmap* aMaskBitmap, TBool aInvertMask); sl@0: virtual void DrawText(const TDesC &aString,const TPoint &aPosition); sl@0: virtual void DrawText(const TDesC &aString,const TRect &aBox,TInt aBaselineOffset,TTextAlign aHoriz=ELeft,TInt aLeftMrg=0); sl@0: virtual void MoveTo(const TPoint &aPoint); sl@0: virtual void MoveBy(const TPoint &aPoint); sl@0: virtual void Plot(const TPoint &aPoint); sl@0: virtual void SetOrigin(const TPoint &aPoint); sl@0: virtual void BitBlt(const TPoint &,const CFbsBitmap *aBitmap); sl@0: virtual void BitBlt(const TPoint &,const CFbsBitmap *aBitmap,const TRect &); sl@0: virtual void BitBltMasked(const TPoint& aPoint,const CFbsBitmap* aBitmap,const TRect& aSourceRect,const CFbsBitmap* aMaskBitmap,TBool aInvertMask); sl@0: virtual void CopyRect(const TPoint& aOffset,const TRect& aRect); sl@0: virtual void Reset(); sl@0: // Extra command defined in CBitmapContext sl@0: virtual void SetFaded(TBool aFaded); sl@0: virtual void SetFadingParameters(TUint8 aBlackMap,TUint8 aWhiteMap); sl@0: sl@0: virtual TInt SetClippingRegion(const TRegion &aRegion); sl@0: virtual TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CFbsBitmap* aSrcBmp, const TRect& aSrcRect, const CFbsBitmap* aAlphaBmp, const TPoint& aAlphaPt); sl@0: virtual void MapColors(const TRect &aRect,const TRgb *aColors,TInt aNumPairs,TBool aMapForwards); sl@0: virtual void DrawTextVertical(const TDesC& aText,const TPoint& aPos,TBool aUp); sl@0: virtual void DrawTextVertical(const TDesC& aText,const TRect& aBox,TInt aBaselineOffset,TBool aUp,TTextAlign aVert=ELeft,TInt aMargin=0); sl@0: sl@0: private: sl@0: void CloseCurrentFont(); sl@0: virtual void DrawBitmapMasked(const TRect& /*aDestRect*/,const CWsBitmap* /*aBitmap*/,const TRect& /*aSrcRect*/,const CWsBitmap* /*aMaskBitmap*/, TBool /*aInvertMask*/); sl@0: TInt AlphaBlendBitmaps(const TPoint& aDestPt, const CWsBitmap* aSrcBmp, const TRect& aSrcRect, const CWsBitmap* aAlphaBmp, const TPoint& aAlphaPt); sl@0: private: sl@0: CWsAnim& iOwningWsAnim; sl@0: MWsGraphicsContext* iGc; sl@0: TBool iUserActive; sl@0: const TRegion *iBaseRegion; // Base clipping region provided on activation sl@0: TBool iUseDrawingRegion; // Indicates that the user has set a drawing region sl@0: RWsRegion iDrawingRegion; // Drawing region provided by the user (in screen coordinates) sl@0: TRect iClippingRect; // Clipping rectangle (in screen coordinates) sl@0: CAnimFbsFont *iFont; sl@0: }; sl@0: sl@0: // sl@0: // inlines // sl@0: // sl@0: sl@0: inline CAnim *CWsAnim::Anim() const sl@0: { sl@0: if(iWindow) sl@0: return iAnim.iWindowAnim; sl@0: else sl@0: return iAnim.iSpriteAnim; sl@0: } sl@0: inline TInt CWsAnimDll::AnimObjectHandle(CWsAnim *aAnimObject) const sl@0: {return(iInstanceIndex->At(aAnimObject));} sl@0: inline CWsAnim* CWsAnimDll::AnimObjectL(TInt aAnimHandle) const sl@0: {return STATIC_CAST(CWsAnim*,iInstanceIndex->AtL(aAnimHandle));} sl@0: inline CWsAnim* CWsAnim::Next() sl@0: {return iNextWin;} sl@0: inline CWsClientWindow* CWsAnim::ClientWindow() const sl@0: {return iWindow;} sl@0: #endif