Update contrib.
1 // Copyright (c) 2006-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 // CWsSprite and associated classes definitions
23 #include <graphics/wsgraphicscontext.h>
24 #include <babitflags.h>
29 class CWsSpriteMember : public CBase
34 TBool SetL(const TCmdSpriteMember &aCmdSpriteMember);
37 CFbsBitmap *iMaskBitmap;
39 CGraphicsContext::TDrawMode iDrawMode;
41 TTimeIntervalMicroSeconds32 iInterval;
47 class CWsSpriteBase : public CWsScreenObject, public MWsWindowTreeNode, public MWsSprite
50 enum {ENoChildPriorityBoost=1,EPointerPriorityBoost=2};
52 friend class CWsSpriteTimer;
54 friend class TCursorSprite;
56 static void InitStaticsL();
57 static void DeleteStatics();
59 CWsSpriteBase(CWsClient *aOwner, WH_HANDLES aType);
64 TSpriteType SpriteType() const;
67 void SetPos(const TPoint &Pos);
69 void DisconnectGroupWin();
72 inline TBool IsActive() const;
73 inline TBool IsFlashingEnabled() const;
74 inline TBool AdvancedPointersEnabled() const;
75 TBool CanBeSeen() const;
76 CWsSpriteBase * Next() { return iNext; }
77 void SetNext(CWsSpriteBase * aNext) { iNext = aNext; }
78 void CalcRedrawRegion(const TRegion& aSourceRegion, TRegion& aTarget) const;
79 void Redraw(MWsGraphicsContext * aGc, const TRegion& aRegion);
81 inline const CWsWindow* Win() const;
82 inline CWsWindow* Win();
83 TBool IsActivated() const;
84 inline TBool HasSpriteMember() const { return iMembers->Count(); }
85 void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const;
87 public: // from MWsWindowTreeNode
88 MWsWindowTreeNode::TType NodeType() const;
89 const MWsWindow* Window() const;
90 const MWsSprite* Sprite() const;
91 const MWsStandardTextCursor* StandardTextCursor() const;
92 const MWsWindowGroup* WindowGroup() const;
93 const MWsWindowTreeNode* ParentNode() const;
96 void ConstructL(TUint aFlags, CWsWindow *aWindow);
97 void CommandL(TInt aOpcode, const TAny *aCmdData);
98 void AppendMemberL(const TCmdSpriteMember &aCmdSpriteMember);
99 virtual void CompleteL();
100 void SetMember(TInt aIndex);
102 TBool UpdateMemberL(CWsSpriteMember *aMember, const TCmdSpriteMember &aCmdSpriteMember);
103 void QueueDeltaTimer();
104 void NotifyExtentChanged() const;
112 inline void SetIsFloating(TBool aIsFloating);
113 inline TBool IsFloating() const;
114 inline void SetClipSprite(TBool aClipSprite);
115 inline TBool ClipSprite() const;
117 inline void SetHasAnimation(TBool aValue);
118 inline TBool HasAnimation() const;
119 inline void SetDirty(TBool aValue);
120 inline TBool IsDirty() const;
124 CWsWindowGroup *iGroupWin;
126 TPoint iPos; // Combined position and offset
131 CArrayPtrFlat<CWsSpriteMember> *iMembers;
133 TWsDeltaTimerEntry iDeltaTimerEntry;
134 TDisplayMode iDisplayMode;
137 CWsSpriteBase * iNext; // linked list per window
138 TBitFlags iInternalFlags;
142 static CWsDeltaTimer *iDeltaTimer;
147 These can be combined with each other and TSpriteFlags using a bit-wise OR operation.
151 @see RWsPointerCursor::Construct()
152 @see RWsSprite::Construct() */
153 enum TSystemSpriteFlags
155 ESpriteNonSystemFlags=0x0000FFFF,
156 ESpriteSystemFlags= 0xFFFF0000,
157 ESpritePointer=0x10000,
159 ESpriteDisabled=0x40000,
160 ESpriteActive=0x80000,
161 ESpriteDirty=0x100000
165 // CWsSpriteBase inlines
167 inline TBool CWsSpriteBase::IsActive() const
169 return (iFlags&ESpriteActive);
171 inline TBool CWsSpriteBase::IsFlashingEnabled() const
173 return (iFlags&ESpriteFlash);
175 inline const CWsWindow* CWsSpriteBase::Win() const
179 inline CWsWindow* CWsSpriteBase::Win()
184 @return ETrue if this sprite belongs to window which has Advanced Pointer Support enabled.
186 inline TBool CWsSpriteBase::AdvancedPointersEnabled() const
188 return iWin ? iWin->AdvancedPointersEnabled() : EFalse;
191 inline void CWsSpriteBase::SetIsFloating(TBool aIsFloating)
193 iInternalFlags.Assign(EFloating, aIsFloating); }
195 inline TBool CWsSpriteBase::IsFloating() const
197 return iInternalFlags.IsSet(EFloating);
200 inline void CWsSpriteBase::SetClipSprite(TBool aClipSprite)
202 iInternalFlags.Assign(EClipSprite, aClipSprite);
205 inline TBool CWsSpriteBase::ClipSprite() const
207 return iInternalFlags.IsSet(EClipSprite);
210 inline void CWsSpriteBase::SetHasAnimation(TBool aValue)
212 iInternalFlags.Assign(EHasAnimation, aValue);
215 inline TBool CWsSpriteBase::HasAnimation() const
217 return iInternalFlags.IsSet(EHasAnimation);
220 inline void CWsSpriteBase::SetDirty(TBool aValue)
222 iInternalFlags.Assign(EDirty, aValue);
225 inline TBool CWsSpriteBase::IsDirty() const
227 return iInternalFlags.IsSet(EDirty);
234 class CWsSprite : public CWsSpriteBase
237 CWsSprite(CWsClient *aOwner);
239 void ConstructL(const TWsClCmdCreateSprite &aParams);
240 void CommandL(TInt aOpcode, const TAny *aCmdData);
242 void Update(TInt aMember,TRect aRect,TBool aFullUpdate);
244 CWsAnim *iAnim; // The AnimDLL on this sprite if there is one.
250 class CWsSpriteManager : public CBase
254 static CWsSpriteManager* NewL();
255 void DrawFloatingSprites(MWsGraphicsContext* aGc,const TRegion& aRegion);
256 void AddFloatingSprite(CWsSpriteBase* aSprite);
257 void RemoveFloatingSprite(CWsSpriteBase* aSprite);
258 void Schedule(CWsSpriteBase* aSprite, TRect* aRect = 0);
259 TFlashState CurrentSpriteFlashState(const CWsSpriteBase* aSprite) const;
260 TInt SpriteCount() const { return iFloatingSprites.Count(); }
261 TTimeIntervalMicroSeconds NextCursorFlashStateChange() const;
262 void CalcFloatingSpriteRgn( TRegion& aResultRgn, const TRect& aDefaultRect );
263 void SendState(MWsWindowTreeObserver& aWindowTreeObserver) const;
267 TTimeIntervalMicroSeconds NextSpriteFlashStateChange(const CWsSpriteBase* aSprite) const;
268 TTimeIntervalMicroSeconds CalculateTimeToNextFlash(TTimeIntervalMicroSeconds aTime) const;
270 RPointerArray<CWsSpriteBase> iFloatingSprites;