sl@0: // Copyright (c) 2006-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: // CWsSprite and associated classes definitions sl@0: // sl@0: // sl@0: sl@0: #ifndef __SPRITE_H__ sl@0: #define __SPRITE_H__ sl@0: sl@0: #include "server.h" sl@0: #include "window.h" sl@0: #include sl@0: #include sl@0: sl@0: // sl@0: // CWsSpriteMember sl@0: // sl@0: class CWsSpriteMember : public CBase sl@0: { sl@0: public: sl@0: CWsSpriteMember(); sl@0: ~CWsSpriteMember(); sl@0: TBool SetL(const TCmdSpriteMember &aCmdSpriteMember); sl@0: public: sl@0: CFbsBitmap *iBitmap; sl@0: CFbsBitmap *iMaskBitmap; sl@0: TBool iInvertMask; sl@0: CGraphicsContext::TDrawMode iDrawMode; sl@0: TPoint iOffset; sl@0: TTimeIntervalMicroSeconds32 iInterval; sl@0: }; sl@0: sl@0: // sl@0: // CWsSpriteBase sl@0: // sl@0: class CWsSpriteBase : public CWsScreenObject, public MWsWindowTreeNode, public MWsSprite sl@0: { sl@0: protected: sl@0: enum {ENoChildPriorityBoost=1,EPointerPriorityBoost=2}; sl@0: public: sl@0: friend class CWsSpriteTimer; sl@0: friend class CWsAnim; sl@0: friend class TCursorSprite; sl@0: public: sl@0: static void InitStaticsL(); sl@0: static void DeleteStatics(); sl@0: sl@0: CWsSpriteBase(CWsClient *aOwner, WH_HANDLES aType); sl@0: ~CWsSpriteBase(); sl@0: sl@0: //from MWsSprite sl@0: TRect Rect() const; sl@0: TSpriteType SpriteType() const; sl@0: sl@0: TPoint Pos() const; sl@0: void SetPos(const TPoint &Pos); sl@0: void Deactivate(); sl@0: void DisconnectGroupWin(); sl@0: void TimerExpired(); sl@0: void Activate(); sl@0: inline TBool IsActive() const; sl@0: inline TBool IsFlashingEnabled() const; sl@0: inline TBool AdvancedPointersEnabled() const; sl@0: TBool CanBeSeen() const; sl@0: CWsSpriteBase * Next() { return iNext; } sl@0: void SetNext(CWsSpriteBase * aNext) { iNext = aNext; } sl@0: void CalcRedrawRegion(const TRegion& aSourceRegion, TRegion& aTarget) const; sl@0: void Redraw(MWsGraphicsContext * aGc, const TRegion& aRegion); sl@0: void ForceRedraw(); sl@0: inline const CWsWindow* Win() const; sl@0: inline CWsWindow* Win(); sl@0: TBool IsActivated() const; sl@0: inline TBool HasSpriteMember() const { return iMembers->Count(); } sl@0: void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const; sl@0: sl@0: public: // 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: protected: sl@0: void ConstructL(TUint aFlags, CWsWindow *aWindow); sl@0: void CommandL(TInt aOpcode, const TAny *aCmdData); sl@0: void AppendMemberL(const TCmdSpriteMember &aCmdSpriteMember); sl@0: virtual void CompleteL(); sl@0: void SetMember(TInt aIndex); sl@0: void CheckSizesL(); sl@0: TBool UpdateMemberL(CWsSpriteMember *aMember, const TCmdSpriteMember &aCmdSpriteMember); sl@0: void QueueDeltaTimer(); sl@0: void NotifyExtentChanged() const; sl@0: enum TInternalFlags sl@0: { sl@0: EFloating, sl@0: EClipSprite, sl@0: EHasAnimation, sl@0: EDirty sl@0: }; sl@0: inline void SetIsFloating(TBool aIsFloating); sl@0: inline TBool IsFloating() const; sl@0: inline void SetClipSprite(TBool aClipSprite); sl@0: inline TBool ClipSprite() const; sl@0: public: sl@0: inline void SetHasAnimation(TBool aValue); sl@0: inline TBool HasAnimation() const; sl@0: inline void SetDirty(TBool aValue); sl@0: inline TBool IsDirty() const; sl@0: sl@0: protected: sl@0: CWsWindow *iWin; sl@0: CWsWindowGroup *iGroupWin; sl@0: TPoint iBasePos; sl@0: TPoint iPos; // Combined position and offset sl@0: TSize iMaxSize; sl@0: TSize iSize; sl@0: TUint iFlags; sl@0: TRect iClipRect; sl@0: CArrayPtrFlat *iMembers; sl@0: TInt iCurIndex; sl@0: TWsDeltaTimerEntry iDeltaTimerEntry; sl@0: TDisplayMode iDisplayMode; sl@0: TPoint iClipOffset; sl@0: TSize iClipSize; sl@0: CWsSpriteBase * iNext; // linked list per window sl@0: TBitFlags iInternalFlags; sl@0: // sl@0: // Static data sl@0: // sl@0: static CWsDeltaTimer *iDeltaTimer; sl@0: }; sl@0: sl@0: /** Sprite flags. sl@0: sl@0: These can be combined with each other and TSpriteFlags using a bit-wise OR operation. sl@0: sl@0: @internalComponent sl@0: @released sl@0: @see RWsPointerCursor::Construct() sl@0: @see RWsSprite::Construct() */ sl@0: enum TSystemSpriteFlags sl@0: { sl@0: ESpriteNonSystemFlags=0x0000FFFF, sl@0: ESpriteSystemFlags= 0xFFFF0000, sl@0: ESpritePointer=0x10000, sl@0: ESpriteOOM=0x20000, sl@0: ESpriteDisabled=0x40000, sl@0: ESpriteActive=0x80000, sl@0: ESpriteDirty=0x100000 sl@0: }; sl@0: sl@0: // sl@0: // CWsSpriteBase inlines sl@0: // sl@0: inline TBool CWsSpriteBase::IsActive() const sl@0: { sl@0: return (iFlags&ESpriteActive); sl@0: } sl@0: inline TBool CWsSpriteBase::IsFlashingEnabled() const sl@0: { sl@0: return (iFlags&ESpriteFlash); sl@0: } sl@0: inline const CWsWindow* CWsSpriteBase::Win() const sl@0: { sl@0: return iWin; sl@0: } sl@0: inline CWsWindow* CWsSpriteBase::Win() sl@0: { sl@0: return iWin; sl@0: } sl@0: /* sl@0: @return ETrue if this sprite belongs to window which has Advanced Pointer Support enabled. sl@0: */ sl@0: inline TBool CWsSpriteBase::AdvancedPointersEnabled() const sl@0: { sl@0: return iWin ? iWin->AdvancedPointersEnabled() : EFalse; sl@0: } sl@0: sl@0: inline void CWsSpriteBase::SetIsFloating(TBool aIsFloating) sl@0: { sl@0: iInternalFlags.Assign(EFloating, aIsFloating); } sl@0: sl@0: inline TBool CWsSpriteBase::IsFloating() const sl@0: { sl@0: return iInternalFlags.IsSet(EFloating); sl@0: } sl@0: sl@0: inline void CWsSpriteBase::SetClipSprite(TBool aClipSprite) sl@0: { sl@0: iInternalFlags.Assign(EClipSprite, aClipSprite); sl@0: } sl@0: sl@0: inline TBool CWsSpriteBase::ClipSprite() const sl@0: { sl@0: return iInternalFlags.IsSet(EClipSprite); sl@0: } sl@0: sl@0: inline void CWsSpriteBase::SetHasAnimation(TBool aValue) sl@0: { sl@0: iInternalFlags.Assign(EHasAnimation, aValue); sl@0: } sl@0: sl@0: inline TBool CWsSpriteBase::HasAnimation() const sl@0: { sl@0: return iInternalFlags.IsSet(EHasAnimation); sl@0: } sl@0: sl@0: inline void CWsSpriteBase::SetDirty(TBool aValue) sl@0: { sl@0: iInternalFlags.Assign(EDirty, aValue); sl@0: } sl@0: sl@0: inline TBool CWsSpriteBase::IsDirty() const sl@0: { sl@0: return iInternalFlags.IsSet(EDirty); sl@0: } sl@0: sl@0: sl@0: // sl@0: // CWsSprite sl@0: // sl@0: class CWsSprite : public CWsSpriteBase sl@0: { sl@0: public: sl@0: CWsSprite(CWsClient *aOwner); sl@0: ~CWsSprite(); sl@0: void ConstructL(const TWsClCmdCreateSprite &aParams); sl@0: void CommandL(TInt aOpcode, const TAny *aCmdData); sl@0: void CompleteL(); sl@0: void Update(TInt aMember,TRect aRect,TBool aFullUpdate); sl@0: public: sl@0: CWsAnim *iAnim; // The AnimDLL on this sprite if there is one. sl@0: }; sl@0: sl@0: // sl@0: // CWsSpriteManager sl@0: // sl@0: class CWsSpriteManager : public CBase sl@0: { sl@0: public: sl@0: ~CWsSpriteManager(); sl@0: static CWsSpriteManager* NewL(); sl@0: void DrawFloatingSprites(MWsGraphicsContext* aGc,const TRegion& aRegion); sl@0: void AddFloatingSprite(CWsSpriteBase* aSprite); sl@0: void RemoveFloatingSprite(CWsSpriteBase* aSprite); sl@0: void Schedule(CWsSpriteBase* aSprite, TRect* aRect = 0); sl@0: TFlashState CurrentSpriteFlashState(const CWsSpriteBase* aSprite) const; sl@0: TInt SpriteCount() const { return iFloatingSprites.Count(); } sl@0: TTimeIntervalMicroSeconds NextCursorFlashStateChange() const; sl@0: void CalcFloatingSpriteRgn( TRegion& aResultRgn, const TRect& aDefaultRect ); sl@0: void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const; sl@0: private: sl@0: CWsSpriteManager(); sl@0: void ConstructL(); sl@0: TTimeIntervalMicroSeconds NextSpriteFlashStateChange(const CWsSpriteBase* aSprite) const; sl@0: TTimeIntervalMicroSeconds CalculateTimeToNextFlash(TTimeIntervalMicroSeconds aTime) const; sl@0: private: sl@0: RPointerArray iFloatingSprites; sl@0: }; sl@0: #endif