|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // CWsSprite and associated classes definitions |
|
15 // |
|
16 // |
|
17 |
|
18 #ifndef __SPRITE_H__ |
|
19 #define __SPRITE_H__ |
|
20 |
|
21 #include "server.h" |
|
22 |
|
23 // |
|
24 // CWsSpriteMember |
|
25 // |
|
26 class CWsSpriteMember : public CBase |
|
27 { |
|
28 public: |
|
29 CWsSpriteMember(); |
|
30 ~CWsSpriteMember(); |
|
31 TBool SetL(const TCmdSpriteMember &aCmdSpriteMember); |
|
32 public: |
|
33 CFbsBitmap *iBitmap; |
|
34 CFbsBitmap *iMaskBitmap; |
|
35 TBool iInvertMask; |
|
36 CGraphicsContext::TDrawMode iDrawMode; |
|
37 TPoint iOffset; |
|
38 TTimeIntervalMicroSeconds32 iInterval; |
|
39 }; |
|
40 |
|
41 // |
|
42 // CWsSpriteBase |
|
43 // |
|
44 class CWsSpriteBase : public CWsScreenObject |
|
45 { |
|
46 protected: |
|
47 enum {ENoChildPriorityBoost=1,EPointerPriorityBoost=2}; |
|
48 public: |
|
49 friend class CWsSpriteTimer; |
|
50 friend class CWsAnim; |
|
51 friend class TCursorSprite; |
|
52 public: |
|
53 static void InitStaticsL(); |
|
54 static void DeleteStatics(); |
|
55 |
|
56 CWsSpriteBase(CWsClient *aOwner, WH_HANDLES aType); |
|
57 ~CWsSpriteBase(); |
|
58 |
|
59 TRect Rect() const; |
|
60 TPoint Pos() const; |
|
61 |
|
62 void SetPos(const TPoint &Pos); |
|
63 void Deactivate(); |
|
64 void TimerExpired(); |
|
65 void Activate(); |
|
66 inline TBool IsActive(); |
|
67 inline TBool IsFlashingEnabled(); |
|
68 TBool CanBeSeen() const; |
|
69 |
|
70 CWsSpriteBase * Next() { return iNext; } |
|
71 void SetNext(CWsSpriteBase * aNext) { iNext = aNext; } |
|
72 void Redraw(CFbsBitGc * aGc, const TRegion& aRegion); |
|
73 void ForceRedraw(); |
|
74 inline const CWsWindow* Win(); |
|
75 TBool IsActivated() const; |
|
76 TBool HasSpriteMember() const { return iMembers->Count(); } |
|
77 protected: |
|
78 void ConstructL(TUint aFlags, CWsWindow *aWindow); |
|
79 void CommandL(TInt aOpcode, const TAny *aCmdData); |
|
80 void AppendMemberL(const TCmdSpriteMember &aCmdSpriteMember); |
|
81 virtual void CompleteL(); |
|
82 void SetMember(TInt aIndex); |
|
83 void CheckSizesL(); |
|
84 TBool UpdateMemberL(CWsSpriteMember *aMember, const TCmdSpriteMember &aCmdSpriteMember); |
|
85 void QueueDeltaTimer(); |
|
86 protected: |
|
87 CWsWindow *iWin; |
|
88 CWsWindowGroup *iGroupWin; |
|
89 TPoint iBasePos; |
|
90 TPoint iPos; // Combined position and offset |
|
91 TSize iMaxSize; |
|
92 TSize iSize; |
|
93 TUint iFlags; |
|
94 TRect iClipRect; |
|
95 CArrayPtrFlat<CWsSpriteMember> *iMembers; |
|
96 TInt iCurIndex; |
|
97 TWsDeltaTimerEntry iDeltaTimerEntry; |
|
98 TDisplayMode iDisplayMode; |
|
99 TBool iClipSprite; |
|
100 TPoint iClipOffset; |
|
101 TSize iClipSize; |
|
102 CWsSpriteBase * iNext; // linked list per window |
|
103 TBool iFloating; |
|
104 // |
|
105 // Static data |
|
106 // |
|
107 static CWsDeltaTimer *iDeltaTimer; |
|
108 }; |
|
109 |
|
110 /** Sprite flags. |
|
111 |
|
112 These can be combined with each other and TSpriteFlags using a bit-wise OR operation. |
|
113 |
|
114 @internalComponent |
|
115 @released |
|
116 @see RWsPointerCursor::Construct() |
|
117 @see RWsSprite::Construct() */ |
|
118 enum TSystemSpriteFlags |
|
119 { |
|
120 ESpriteNonSystemFlags=0x0000FFFF, |
|
121 ESpriteSystemFlags= 0xFFFF0000, |
|
122 ESpritePointer=0x10000, |
|
123 ESpriteOOM=0x20000, |
|
124 ESpriteDisabled=0x40000, |
|
125 ESpriteActive=0x80000, |
|
126 ESpriteDirty=0x100000 |
|
127 }; |
|
128 |
|
129 // |
|
130 // CWsSpriteBase inlines |
|
131 // |
|
132 inline TBool CWsSpriteBase::IsActive() |
|
133 { |
|
134 return iNext != NULL; |
|
135 } |
|
136 inline TBool CWsSpriteBase::IsFlashingEnabled() |
|
137 { |
|
138 return (iFlags&ESpriteFlash); |
|
139 } |
|
140 inline const CWsWindow* CWsSpriteBase::Win() |
|
141 { |
|
142 return iWin; |
|
143 } |
|
144 |
|
145 // |
|
146 // CWsSprite |
|
147 // |
|
148 class CWsSprite : public CWsSpriteBase |
|
149 { |
|
150 public: |
|
151 CWsSprite(CWsClient *aOwner); |
|
152 ~CWsSprite(); |
|
153 void ConstructL(const TWsClCmdCreateSprite &aParams); |
|
154 void CommandL(TInt aOpcode, const TAny *aCmdData); |
|
155 void CompleteL(); |
|
156 void Update(TInt aMember,TRect aRect,TBool aFullUpdate); |
|
157 public: |
|
158 CWsAnim *iAnim; // The AnimDLL on this sprite if there is one. |
|
159 }; |
|
160 |
|
161 // |
|
162 // CWsSpriteManager |
|
163 // |
|
164 class CWsSpriteManager : public CBase |
|
165 { |
|
166 public: |
|
167 ~CWsSpriteManager(); |
|
168 static CWsSpriteManager* NewL(); |
|
169 void DrawFloatingSprites(CFbsBitGc* aGc,const TRegion& aRegion); |
|
170 void AddFloatingSprite(CWsSpriteBase* aSprite); |
|
171 void RemoveFloatingSprite(CWsSpriteBase* aSprite); |
|
172 void Schedule(CWsSpriteBase* aSprite, TRect* aRect = 0); |
|
173 TFlashState CurrentSpriteFlashState(const CWsSpriteBase* aSprite) const; |
|
174 TFlashState CurrentCursorFlashState() const; |
|
175 TInt SpriteCount() const { return iFloatingSprites.Count(); } |
|
176 TTimeIntervalMicroSeconds NextCursorFlashStateChange() const; |
|
177 void CalcFloatingSpriteRgn( TRegion& aResultRgn, const TRect& aDefaultRect ); |
|
178 private: |
|
179 CWsSpriteManager(); |
|
180 void ConstructL(); |
|
181 TTimeIntervalMicroSeconds NextSpriteFlashStateChange(const CWsSpriteBase* aSprite) const; |
|
182 TTimeIntervalMicroSeconds CalculateTimeToNextFlash(TTimeIntervalMicroSeconds aTime) const; |
|
183 private: |
|
184 RPointerArray<CWsSpriteBase> iFloatingSprites; |
|
185 }; |
|
186 #endif |