|
1 /* |
|
2 * Copyright (c) 2004 - 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __CLIENTIMAGE_COMMANDER_H__ |
|
20 #define __CLIENTIMAGE_COMMANDER_H__ |
|
21 |
|
22 // INCLUDES |
|
23 #include <w32adll.h> |
|
24 |
|
25 #include "pointmsgqueue.h" |
|
26 // CLASS DECLARATION |
|
27 |
|
28 #define KWakeUpNeeded (5) |
|
29 |
|
30 class CPointQueue; |
|
31 |
|
32 class MPointHandler |
|
33 { |
|
34 public: |
|
35 /** |
|
36 * Handle Points from AnimDll |
|
37 */ |
|
38 virtual void HandlePointL(const TPoint& aPoint) = 0; |
|
39 virtual void SendEventL(TPointerEvent::TType aEventType) = 0; |
|
40 }; |
|
41 |
|
42 /** |
|
43 * RImageCommander |
|
44 * An instance of RImageCommander is an Animation Client Commander which |
|
45 * sends commands to the Animation Server |
|
46 */ |
|
47 class RImageCommander : public RAnim, public MPointHandler |
|
48 { |
|
49 public: |
|
50 // Constructors |
|
51 |
|
52 /** |
|
53 * RImageCommander. |
|
54 * Construct an Animation Client object for Animation Client DLL aAnimDll |
|
55 * @param aAnimDll the Animation Client DLL to use |
|
56 */ |
|
57 IMPORT_C RImageCommander(RAnimDll& aAnimDll, RWsSession& aWsSession); |
|
58 |
|
59 /** |
|
60 * ImageConstruct. |
|
61 * Complete Animation Client construction |
|
62 */ |
|
63 IMPORT_C void ImageConstructL(RWindowGroup& aWindowGroup, TSize aSize); |
|
64 |
|
65 /** |
|
66 * ~RImageCommander |
|
67 */ |
|
68 IMPORT_C ~RImageCommander(); |
|
69 |
|
70 public: |
|
71 // from MPointHandler |
|
72 |
|
73 void HandlePointL(const TPoint& aPoint); |
|
74 void SendEventL(TPointerEvent::TType aEventType); |
|
75 private: |
|
76 TInt SendPointerEvent(TPointerEvent::TType aEventType); |
|
77 TRawEvent::TType PointerEventToRawEvent(TPointerEvent::TType aEventType); |
|
78 void CreateSpriteL(TSize aSize, RWindowGroup& aGroup); |
|
79 void FillInSpriteMember(TSpriteMember& aMember, CFbsBitmap* icon, |
|
80 CFbsBitmap* iconMask); |
|
81 TBool CheckCurrentPoint(); |
|
82 TInt SendWakeUp(); |
|
83 TBool RestrictPos(); |
|
84 |
|
85 public: |
|
86 // New functions |
|
87 |
|
88 /** |
|
89 * ImageCommand. |
|
90 * Send aCommand to the Animation Server object; |
|
91 * aCommand == KChangeCursor implies "change animation cursor". |
|
92 * Note! Because there is no way to return an error from the server side |
|
93 * using this method, it is important that any server side code for these |
|
94 * commands should not be able to fail or leave. |
|
95 * This command is also buffered and may not be performed immediately. |
|
96 * @param aCommand the enumerated code for the option selected |
|
97 */ |
|
98 IMPORT_C void ImageCommand(TInt aCommand); |
|
99 |
|
100 public: |
|
101 // Enumerations |
|
102 |
|
103 /** |
|
104 * KAnimationTypes. |
|
105 * Constant used to indicate the animation of a bouncing square should |
|
106 * be created, enumeration can be expanded |
|
107 */ |
|
108 enum KAnimationTypes |
|
109 { |
|
110 KAnimationSquare = 1 |
|
111 }; |
|
112 |
|
113 |
|
114 private: |
|
115 |
|
116 RWsSession& iSession; |
|
117 RWsSprite iSprite; |
|
118 CFbsBitmap* iBaseBitmap; |
|
119 CFbsBitmap* iBaseMaskBitmap; |
|
120 |
|
121 TPoint iCurrentPoint; |
|
122 CPointQueue* iPointBufferQueue; |
|
123 TBool iMouseButtonPressed; |
|
124 TInt iWakeUpCalculator; |
|
125 }; |
|
126 |
|
127 /** |
|
128 * Class CPointQueue |
|
129 * Event message queue. It's an active object. |
|
130 * |
|
131 * @since S60 v4.0 |
|
132 */ |
|
133 |
|
134 class CPointQueue : public CActive |
|
135 { |
|
136 public: |
|
137 /** |
|
138 * factory constructor. |
|
139 * |
|
140 * @since S60 v4.0 |
|
141 * @param aHandler The event handler. |
|
142 * @param aName The event queue global name |
|
143 * @return The created messge queue object |
|
144 */ |
|
145 static CPointQueue* NewL(MPointHandler* aHandler, const TDesC& aName); |
|
146 /** |
|
147 * desstructor. |
|
148 * |
|
149 * @since S60 v4.0 |
|
150 */ |
|
151 ~CPointQueue(); |
|
152 |
|
153 /** |
|
154 * Request event. |
|
155 * |
|
156 * @since S60 v4.0 |
|
157 */ |
|
158 void GetPoint(); |
|
159 |
|
160 protected: |
|
161 /** |
|
162 * 2nd phase constructor. |
|
163 * |
|
164 * @since S60 v4.0 |
|
165 * @aName The message queue name |
|
166 */ |
|
167 void ConstructL(const TDesC& aName); |
|
168 /** |
|
169 * Default construcotr. |
|
170 * |
|
171 * @since S60 v4.0 |
|
172 * @aHandler The event handler |
|
173 */ |
|
174 CPointQueue(MPointHandler* aHandler); |
|
175 |
|
176 //From CActive |
|
177 /** |
|
178 * From CActive |
|
179 * Called when there is event in the queue |
|
180 * |
|
181 * @since S60 v4.0 |
|
182 */ |
|
183 void RunL(); |
|
184 |
|
185 /** |
|
186 * From CActive |
|
187 * will be called if RunL leaves |
|
188 * |
|
189 * @since S60 v4.0 |
|
190 * @param aError The error number |
|
191 */ |
|
192 TInt RunError(TInt aError); |
|
193 |
|
194 /** |
|
195 * From CActive |
|
196 * will be called when Cancel is issued |
|
197 * |
|
198 * @since S60 v4.0 |
|
199 */ |
|
200 void DoCancel(); |
|
201 |
|
202 private: |
|
203 /** |
|
204 * Message buffer queue |
|
205 */ |
|
206 RMsgQueue<TPointBuffer> iPointBufQueue; |
|
207 |
|
208 /** |
|
209 * Event handler |
|
210 */ |
|
211 MPointHandler* iHandler; |
|
212 }; |
|
213 |
|
214 #endif // __CLIENTIMAGE_COMMANDER_H__ |
|
215 // End of File |