|
1 // Copyright (c) 1995-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 // Header for writing animated DLL add ons |
|
15 // |
|
16 // |
|
17 |
|
18 #if !defined(__W32ADLL_H__) |
|
19 #define __W32ADLL_H__ |
|
20 |
|
21 #if !defined(__W32STD_H__) |
|
22 #include <w32std.h> |
|
23 #endif |
|
24 |
|
25 #if !defined(__BITSTD_H__) |
|
26 #include <bitstd.h> |
|
27 #endif |
|
28 |
|
29 /** |
|
30 @publishedAll |
|
31 @deprecated |
|
32 */ |
|
33 const TUint KWservAnimDllUidValue8=268435858; |
|
34 |
|
35 /** |
|
36 @publishedAll |
|
37 @deprecated |
|
38 */ |
|
39 const TUid KWservAnimDllUid8={KWservAnimDllUidValue8}; |
|
40 |
|
41 /** |
|
42 @publishedAll |
|
43 @released |
|
44 */ |
|
45 const TUint KWservAnimDllUidValue16=268450594; |
|
46 |
|
47 /** |
|
48 @publishedAll |
|
49 @released |
|
50 */ |
|
51 const TUid KWservAnimDllUid16={KWservAnimDllUidValue16}; |
|
52 |
|
53 /** |
|
54 @publishedAll |
|
55 @released |
|
56 */ |
|
57 const TUint KWservAnimDllUidValue=KWservAnimDllUidValue16; |
|
58 |
|
59 /** |
|
60 @publishedAll |
|
61 @released |
|
62 */ |
|
63 const TUid KWservAnimDllUid={KWservAnimDllUidValue}; |
|
64 |
|
65 // |
|
66 // Contains functions callable from animated DLLs |
|
67 // |
|
68 |
|
69 |
|
70 class TWindowInfo |
|
71 /** Animation window information. |
|
72 |
|
73 Stores the window position and display mode for the animation. |
|
74 During a redraw of the animation window, the redraw regions |
|
75 can be retrieved by calling GetRedrawRegionAndRedrawShadowRegion(). |
|
76 |
|
77 @publishedAll |
|
78 @released |
|
79 @see TWindowInfo::GetRedrawRegionAndRedrawShadowRegion() */ |
|
80 { |
|
81 public: |
|
82 /** The screen position. */ |
|
83 TRect iScreenPos; |
|
84 /** The display mode. |
|
85 |
|
86 This is the minimum display mode that the screen has to be in to display this window. */ |
|
87 TDisplayMode iMode; |
|
88 public: |
|
89 /** Constructs an animation window information object. */ |
|
90 inline TWindowInfo() : iRegionPair(NULL) {} |
|
91 public: |
|
92 /** Stores a pair of region pointers. */ |
|
93 struct TRegionPair |
|
94 { |
|
95 const TRegion* iRegion1; |
|
96 const TRegion* iRegion2; |
|
97 }; |
|
98 /** Returns the current redraw region and redraw shadow region. |
|
99 This function must only be called from an override of CWindowAnim's pure virtual Redraw function. |
|
100 The region pointers retrieved must not be used beyond the end of the Redraw override. |
|
101 @param aRedrawRegion The redraw region in screen coordinates. |
|
102 @param aRedrawShadowRegion The redraw shadow region in screen coordinates. */ |
|
103 inline void GetRedrawRegionAndRedrawShadowRegion(const TRegion*& aRedrawRegion, const TRegion*& aRedrawShadowRegion) const |
|
104 { |
|
105 if (iRegionPair) |
|
106 { |
|
107 aRedrawRegion=iRegionPair->iRegion1; |
|
108 aRedrawShadowRegion=iRegionPair->iRegion2; |
|
109 iRegionPair=NULL; |
|
110 } |
|
111 else |
|
112 { |
|
113 aRedrawRegion=NULL; |
|
114 aRedrawShadowRegion=NULL; |
|
115 } |
|
116 } |
|
117 private: |
|
118 mutable const TRegionPair* iRegionPair; |
|
119 TAny *iFree2; |
|
120 friend class CWsAnim; |
|
121 }; |
|
122 |
|
123 |
|
124 class MEventHandler |
|
125 /** Event handler interface. |
|
126 |
|
127 The interface provides a function to handle raw events, e.g. key presses, |
|
128 pen events, power buttons etc. Raw events are passed to the OfferRawEvent() |
|
129 function when the MAnimGeneralFunctions::GetRawEvents() function has been |
|
130 called. |
|
131 |
|
132 @publishedAll |
|
133 @released */ |
|
134 { |
|
135 public: |
|
136 /** Handles raw events. |
|
137 |
|
138 If the incoming event can be handled, the function should |
|
139 process it and then return true. If it cannot be processed the function should |
|
140 return false, and the event will be passed to other event handling code. |
|
141 |
|
142 This function must be implemented in every animation DLL. If event |
|
143 handling is not required, the function should simply return false. |
|
144 |
|
145 @param aRawEvent The raw event to be processed |
|
146 @return ETrue if the raw event is handled by this function, EFalse if the function |
|
147 chooses not to process it. */ |
|
148 virtual TBool OfferRawEvent(const TRawEvent &aRawEvent)=0; |
|
149 }; |
|
150 |
|
151 enum TAnimNotifications |
|
152 /** Bit flags to be used by anims when registering for notifications */ |
|
153 { |
|
154 /** Notify when direct screen access begins or ends.*/ |
|
155 EDirectScreenAccess = 0x0001, |
|
156 /** Notify when the wserv heartbeat timer starts or stops. */ |
|
157 EHeartbeatTimer = 0x0002, |
|
158 /** Notify when screen device changes.*/ |
|
159 EScreenDeviceChange = 0x0004 |
|
160 }; |
|
161 //Forward Declaration. |
|
162 class MAnimGeneralFunctionsWindowExtension; |
|
163 class MAnimGeneralFunctionsEventExtension ; |
|
164 |
|
165 class MAnimGeneralFunctions |
|
166 /** General animation utility functions interface. |
|
167 |
|
168 The interface provides functions to set the animation timing, |
|
169 event functions, and other general functions. |
|
170 |
|
171 You do not have to create an object of this type. The class is implemented |
|
172 by the window server and provides utility functions to all CAnim-derived |
|
173 classes via the CAnim::iFunctions pointer. |
|
174 |
|
175 It is not intended for user derivation. |
|
176 |
|
177 @publishedAll |
|
178 @released */ |
|
179 { |
|
180 public: |
|
181 /** Animation synchronisation flags. |
|
182 |
|
183 The animation can be synchronised to any of these values; |
|
184 the Animate() call will take place at the start of the new unit (day, hour, etc...). */ |
|
185 enum TAnimSync |
|
186 { |
|
187 /** Not synchronised. Animate() is called after some number of flash cycles - |
|
188 set by SetSync(). */ |
|
189 ESyncNone, |
|
190 /** Animate() every flash tick. This occurs twice a second, on the second and after |
|
191 7/12ths of a second, e.g. the function is called in a flash-on (7/12 seconds) - |
|
192 flash-off (5/12 seconds) cycle. */ |
|
193 ESyncFlash, |
|
194 /** Animate() called as soon after every second as system activity allows. */ |
|
195 ESyncSecond, |
|
196 /** Animate() called as soon after every minute as system activity allows. */ |
|
197 ESyncMinute, |
|
198 /** Animate() called as soon after midnight every day as system activity allows. */ |
|
199 ESyncDay, |
|
200 }; |
|
201 enum |
|
202 { |
|
203 ENumberOfExtendedInterfaces=0, |
|
204 EWindowExtensionInterface, |
|
205 EEventExtentionInterface, |
|
206 EInterfaceCount, // Always keep at the end. |
|
207 }; |
|
208 //Timing functions |
|
209 /** Calls the DLL's Animate() function then deactivates the graphics context. |
|
210 |
|
211 This allows users to do drawing from their own active object. |
|
212 |
|
213 Note: |
|
214 |
|
215 If the user calls the CAnim-derived classes' Animate() function directly, |
|
216 or otherwise does drawing from their own active object, then this will not |
|
217 deactivate the graphics context. This causes the window server to panic the |
|
218 client. |
|
219 |
|
220 Alternatively, use CFreeTimerWindowAnim, which allows you to deactivate the |
|
221 graphics context yourself. |
|
222 |
|
223 @param aDateTime The parameter passed into the animation DLL's Animate() |
|
224 function. */ |
|
225 virtual void Animate(TDateTime *aDateTime)=0; |
|
226 /** Sets the synchronisation mode. |
|
227 |
|
228 This determines the time intervals between calls to the Animate() function. |
|
229 |
|
230 @param aSyncMode The synchronisation mode. */ |
|
231 virtual void SetSync(TAnimSync aSyncMode)=0; |
|
232 /** Sets the repeat interval. |
|
233 |
|
234 If the synchronisation mode is TAnimSync::ESyncNone, then the Animate() function |
|
235 is called at intervals defined by some number of flash ticks. There are two |
|
236 flash ticks a second, with a 7/12 second - 5/12 second cycle. If the function |
|
237 is called when the synchronisation mode is not TAnimSync::ESyncNone, then |
|
238 the window server panics the client. |
|
239 |
|
240 If the new interval is greater than the current countdown, then the call does |
|
241 not affect the current countdown. For example, if the countdown has 10 flash |
|
242 ticks remaining, and the interval is set to 20, the new interval does not |
|
243 apply until the current countdown is complete. |
|
244 |
|
245 However if the new interval is less the current countdown, then the new interval |
|
246 applies immediately i.e. the countdown is reset to the interval value. |
|
247 |
|
248 If the interval is set to zero the countdown stops, and the Animate() function |
|
249 is no longer called. |
|
250 |
|
251 @param aInterval The number of flash ticks between calls to the Animate() |
|
252 function. */ |
|
253 virtual void SetInterval(TInt aInterval)=0; |
|
254 /** Sets the next interval. |
|
255 |
|
256 This function immediately resets the current countdown to the specified number |
|
257 of flash ticks, irrespective of its current value. After the countdown expires, |
|
258 the interval returns to its usual rate. Note that this may be zero (i.e. |
|
259 not at all). |
|
260 |
|
261 To call this function, the synchronisation mode must be TAnimSync::ESyncNone, |
|
262 otherwise the window server panics the client. |
|
263 |
|
264 Note: there are two flash ticks a second, with a 7/12 second - 5/12 second cycle. |
|
265 |
|
266 @param aInterval The interval to the next Animate(). If the value is less |
|
267 than 1, it automatically gets set to 1. |
|
268 @see SetInterval() */ |
|
269 virtual void SetNextInterval(TInt aInterval)=0; |
|
270 /** Gets the system time as it was when Animate() was last called. |
|
271 |
|
272 @return The system time when Animate() was last called. */ |
|
273 virtual TDateTime SystemTime() const=0; |
|
274 /** Tests the flash cycle state. |
|
275 |
|
276 The flash cycle has 2 states: on (7/12 second) or off (5/12 second). |
|
277 |
|
278 @return ETrue if in the on part of the flash cycle, otherwise EFalse. */ |
|
279 virtual TBool FlashStateOn() const=0; |
|
280 /** Gets the current synchronisation mode. |
|
281 |
|
282 @return The current sync mode. */ |
|
283 virtual TAnimSync Sync() const=0; |
|
284 //Other functions generally useful |
|
285 /** Gets a pointer to the screen device. |
|
286 |
|
287 For example, this might be used to gain access to twips to pixel conversion functions. |
|
288 |
|
289 @return A pointer to the screen device. */ |
|
290 virtual const CFbsScreenDevice *ScreenDevice()=0; |
|
291 /** Creates and duplicates a bitmap from a handle. |
|
292 |
|
293 This function might be used to duplicate client side bitmaps on the server side. |
|
294 |
|
295 @param aHandle A handle to the bitmap to be duplicated. |
|
296 @return A pointer to the duplicate bitmap. */ |
|
297 virtual CFbsBitmap *DuplicateBitmapL(TInt aHandle)=0; |
|
298 /** Creates and duplicates a font from a handle. |
|
299 |
|
300 This function might be used to duplicate client side fonts on the server side. |
|
301 |
|
302 @param aHandle A handle to the font to be duplicated. |
|
303 @return A pointer to the duplicate font. */ |
|
304 virtual CFbsFont *DuplicateFontL(TInt aHandle)=0; |
|
305 /** Closes a duplicate font. |
|
306 |
|
307 @param Pointer to the duplicate font. |
|
308 @see DuplicateFontL() */ |
|
309 virtual void CloseFont(CFbsFont *)=0; |
|
310 /** Gets a reference to the calling client's thread. |
|
311 |
|
312 @return A reference to the calling client's thread. */ |
|
313 virtual const RThread &Client()=0; |
|
314 /** Send a reply to the client process in response to a request |
|
315 from the client. |
|
316 |
|
317 @see RAnim::CommandReply() |
|
318 |
|
319 @param aDes The data to be sent back to the client |
|
320 */ |
|
321 virtual void ReplyBuf(const TDesC8 &aDes)=0; |
|
322 /** Send a reply to the client process in response to a request |
|
323 from the client. |
|
324 |
|
325 @see RAnim::CommandReply() |
|
326 |
|
327 @param aDes The data to be sent back to the client |
|
328 */ |
|
329 virtual void ReplyBuf(const TDesC16 &aDes)=0; |
|
330 /** Panics the client. |
|
331 |
|
332 This will result in the client thread being destroyed. */ |
|
333 virtual void Panic() const=0; |
|
334 |
|
335 //Event functions |
|
336 |
|
337 /** Switches animation raw event handling on and off. |
|
338 |
|
339 If raw event handling is switched on, then raw events, e.g. pointer, key, or power events |
|
340 are all offered to the animation event handling code's MEventHandler::OfferRawEvent(). |
|
341 |
|
342 If Animation works in a window for which advanced pointers have been enabled, |
|
343 then after switching on raw event handling it will receive pointer events from all |
|
344 detected pointers. Otherwise it will receive events only from one emulated pointer. |
|
345 |
|
346 @param aGetEvents If ETrue, raw events are passed to the animation |
|
347 event handling code. If EFalse, events are not passed to the animation. |
|
348 @see RWindowBase::EnableAdvancedPointers() */ |
|
349 virtual void GetRawEvents(TBool aGetEvents) const=0; |
|
350 /** Posts a raw event, just as if it had come from the kernel. |
|
351 |
|
352 If aRawEvent has pointer-related type (move, switch on, down, up or out of range), |
|
353 then its Z coordinate and iPointerNumber fields will be validated and may be |
|
354 overwritten by WSERV in order to guarantee correct behaviour depending on: |
|
355 1. Pointer Pressure and Proximity support on current platform. |
|
356 2. Multiple pointers support on current platform. |
|
357 3. Animation's awareness of these fields. If Animation works in a window |
|
358 for which advanced pointers have been enabled, it is assumed that it has |
|
359 initialized these fields. Otherwise WSERV will assume that these fields have |
|
360 not been provided and may overwrite them with most appropriate values. |
|
361 For more information about event validation, please refer to System Documentation. |
|
362 |
|
363 @param aRawEvent The raw event |
|
364 @see RWindowBase::EnableAdvancedPointers() */ |
|
365 virtual void PostRawEvent(const TRawEvent &aRawEvent) const=0; |
|
366 /** Posts a key event. |
|
367 |
|
368 The function is similar to PostRawEvent() but should be |
|
369 used for posting key events. |
|
370 |
|
371 @param aRawEvent The key event. */ |
|
372 virtual void PostKeyEvent(const TKeyEvent &aRawEvent) const=0; |
|
373 /** Get the address of an object which can retrieve information from and send |
|
374 information to the client-side. |
|
375 |
|
376 @return A pointer to RMessagePtr2. Complete must be called on the returned object (or a |
|
377 copy of it) if and only if Message is called from an override of CAnim's CommandReplyL which |
|
378 has been caused by a client-side RAnim::AsyncCommandReply call. If Message is called outside |
|
379 an override of CAnim's CommandReplyL or outside an override of CWindowAnim's ConstructL or |
|
380 CSpriteAnim's ConstructL, the it returns NULL. |
|
381 @see RMessagePtr2 */ |
|
382 virtual const RMessagePtr2* Message()=0; // replaces Reserved1 |
|
383 /**Returns an extension interface, maybe extended further in the future. |
|
384 @param aInterfaceId The ID of the interface to return. |
|
385 @return A pointer to the extension interface. |
|
386 When aInterface=0 (ENumberOfExtendedInterfaces), the number of interfaces is returned (currently 2). |
|
387 When aInterface=1 (EWindowExtensionInterface), a pointer to the Window Extension interface is returned. |
|
388 When aInterface=2 (EEventExtentionInterface), a pointer to the Event Extension interface is returned. |
|
389 */ |
|
390 virtual TAny* ExtendedInterface(TInt aInterface)=0; // replaces Reserved2 |
|
391 |
|
392 /** Register to receive notifications. |
|
393 @param aNotifications A bitset of TAnimNotifications values indicating which notifications are required |
|
394 @return One of the system wide error codes |
|
395 */ |
|
396 virtual TInt RegisterForNotifications(TUint32 aNotifications)=0; |
|
397 /* |
|
398 Return number of ExtendedInterfaces. */ |
|
399 inline TInt NumberOfExtendedInterfaces() |
|
400 { |
|
401 return reinterpret_cast<TInt>(ExtendedInterface(ENumberOfExtendedInterfaces)); |
|
402 } |
|
403 /** Gets access to Window Extension utility functions. |
|
404 @return A pointer to a class containing functions for working with Window. */ |
|
405 inline MAnimGeneralFunctionsWindowExtension* WindowExtension() |
|
406 { |
|
407 return static_cast<MAnimGeneralFunctionsWindowExtension*>(ExtendedInterface(EWindowExtensionInterface)); |
|
408 } |
|
409 /** Gets access to EventExtension utility functions. |
|
410 @return A pointer to a class containing functions for working with Event. */ |
|
411 inline MAnimGeneralFunctionsEventExtension* EventExtension() |
|
412 { |
|
413 return static_cast<MAnimGeneralFunctionsEventExtension*>(ExtendedInterface(EEventExtentionInterface)); |
|
414 } |
|
415 private: |
|
416 virtual void Reserved1() const; |
|
417 virtual void Reserved2() const; |
|
418 virtual void Reserved3() const; |
|
419 }; |
|
420 |
|
421 /* Structure for passing window configuration information. Currently transparancey |
|
422 related configuration information is supported, though this may be added to, as |
|
423 apprioriate. |
|
424 |
|
425 @publishedAll |
|
426 @released |
|
427 */ |
|
428 class TWindowConfig |
|
429 { |
|
430 public: |
|
431 /** Transparency flags. |
|
432 |
|
433 Used to represent transparency configuration of the window. */ |
|
434 enum |
|
435 { |
|
436 /** Transparency is enabled on the window. */ |
|
437 ETransparencyEnabled=0x0001, |
|
438 /** Window transparency uses alpha blending channel. */ |
|
439 EAlphaBlendedTransparency=0x0002, |
|
440 }; |
|
441 public: |
|
442 /** Indicate configuration of window, using enumerations defined within this class. */ |
|
443 TInt iFlags; |
|
444 private: |
|
445 TInt iReserved0; |
|
446 TInt iReserved1; |
|
447 TInt iReserved2; |
|
448 }; |
|
449 |
|
450 class MAnimGeneralFunctionsWindowExtension |
|
451 /** General Window utility functions interface. |
|
452 |
|
453 The member functions define the interface for querying and manipulating |
|
454 the window and screen attributes. |
|
455 |
|
456 You obtain one by calling: iFunctions->ExtendedInterface(MAnimGeneralFunctions::EWindowExtensionInterface) |
|
457 and casting the result. |
|
458 |
|
459 It is not intended for user derivation. |
|
460 |
|
461 @publishedAll |
|
462 @released */ |
|
463 { |
|
464 public: |
|
465 /** Class contains the information pertaining to a window group: name, priority, |
|
466 focusability. */ |
|
467 class TWindowGroupInfo |
|
468 { |
|
469 public: |
|
470 enum |
|
471 { |
|
472 /** Window is focusable flag. */ |
|
473 EIsFocusable=0x0001, |
|
474 }; |
|
475 public: |
|
476 /** Returns whether or not the window is focusable. |
|
477 @return ETrue if focusable, else returns EFalse. */ |
|
478 inline TBool IsFocusable() const {return iFlags&EIsFocusable;} |
|
479 public: |
|
480 /* Window group attributes. */ |
|
481 TInt iId; |
|
482 TUint32 iFlags; |
|
483 TInt iOrdinalPriority; |
|
484 TInt iNameLength; |
|
485 TInt iParentId; |
|
486 }; |
|
487 public: |
|
488 /** Returns the total number of screens. |
|
489 @return The total number of screens. */ |
|
490 virtual TInt Screens() const=0; |
|
491 |
|
492 /** Returns the number of the screen which is currently in focus. |
|
493 @return The number of the screen which is currently in focus.*/ |
|
494 virtual TInt FocusScreens() const=0; |
|
495 |
|
496 /** Changes the focused screen. |
|
497 @param aScreenNo New screen number. */ |
|
498 virtual void SetFocusScreen(TInt aScreenNo)=0; |
|
499 |
|
500 /** Returns the number of window groups available for the specified screen. |
|
501 |
|
502 @param aScreen The screen number. |
|
503 @return The number of window groups. */ |
|
504 virtual TInt WindowGroups(TInt aScreen) const=0; |
|
505 |
|
506 /** Takes a screen number and an ordinal position and returns the complete window |
|
507 group information of the specified window. If the window group does not exist, the |
|
508 function returns EFalse. |
|
509 |
|
510 Note: the ordinal position specified should be the total or full ordinal position |
|
511 of all group windows of all priorities on that screen. |
|
512 |
|
513 @param aInfo on return, complete window information. |
|
514 @param aScreen Screen number. |
|
515 @param aFullOrdinalPosition Ordinal position of the window. |
|
516 @return ETrue if window group information exists, EFalse otherwise. */ |
|
517 virtual TBool WindowGroupInfo(TWindowGroupInfo& aInfo,TInt aScreen,TInt aFullOrdinalPosition) const=0; |
|
518 |
|
519 /** Takes a screen number and an ordinal position and returns the window group name. |
|
520 If the window group does not exist, the function returns false. |
|
521 |
|
522 Note: the ordinal position specified should be the total or full ordinal position of |
|
523 all group windows of all priorities on that screen. |
|
524 |
|
525 Note: if the name does not fit into the descriptor provided then it will be truncated. |
|
526 |
|
527 @param aWindowName On return, the window group name. |
|
528 @param aScreen The screen number. |
|
529 @param aFullOrdinalPosition The ordinal position of the window. |
|
530 @return ETrue if the window group name exists, EFalse otherwise. */ |
|
531 virtual TBool WindowGroupName(TPtrC& aWindowName,TInt aScreen,TInt aFullOrdinalPosition) const=0; |
|
532 |
|
533 /** Changes the ordinal position and priority of the window group with the specified ID. |
|
534 |
|
535 @param aWindowGroupId The window group ID. |
|
536 @param aPos The ordinal position to move the window to. |
|
537 @param aOrdinalPriority The new ordinal priority of the window. |
|
538 @return KErrNotFound if there is no window group with the specified ID, KErrNone otherwise. */ |
|
539 virtual TInt SetOrdinalPosition(TInt aWindowGroupId,TInt aPos,TInt aOrdinalPriority)=0; |
|
540 |
|
541 /** Accessor for window configuration. |
|
542 |
|
543 @param aWindowConfig Gets filled in with window configuration details. */ |
|
544 virtual void WindowConfig(TWindowConfig& aWindowConfig) const=0; |
|
545 private: |
|
546 virtual void Reserved1() const; |
|
547 virtual void Reserved2() const; |
|
548 virtual void Reserved3() const; |
|
549 }; |
|
550 |
|
551 class MAnimGeneralFunctionsEventExtension |
|
552 /** Event utility functions interface. |
|
553 |
|
554 The member functions define the interface for generate repeated key events . |
|
555 |
|
556 It is not intended for user derivation. |
|
557 */ |
|
558 { |
|
559 public: |
|
560 /** Posts a key event. |
|
561 |
|
562 The function is similar to PostKeyEvent() but should be |
|
563 used for posting repeated key events. |
|
564 |
|
565 @param aRawEvent The key event. |
|
566 @param aRepeats value */ |
|
567 virtual void PostKeyEvent(const TKeyEvent& aRawEvent, TInt aRepeats) const=0; |
|
568 |
|
569 private: |
|
570 virtual void Reserved1() const; |
|
571 virtual void Reserved2() const; |
|
572 }; |
|
573 |
|
574 class MAnimWindowFunctions |
|
575 /** Window utility functions interface. |
|
576 |
|
577 The member functions define the interface for querying and manipulating |
|
578 the window in which the animation takes place. |
|
579 |
|
580 You do not have to create an object of this type. The class is implemented |
|
581 by the window server, and provides these utility functions to all CWindowAnim |
|
582 and CFreeTimerWindowAnim derived classes via the iWindowFunctions pointer. |
|
583 |
|
584 It is not intended for user derivation. |
|
585 |
|
586 @publishedAll |
|
587 @released */ |
|
588 { |
|
589 public: |
|
590 /** Activates the graphics context. |
|
591 |
|
592 This function should be called to enable drawing in the CAnim-derived classes' |
|
593 Command(), CommandReplyL(), Animate(), or FocusChanged() functions. |
|
594 |
|
595 Note: this function is called automatically by the animation DLL framework in the |
|
596 Redraw() function. */ |
|
597 virtual void ActivateGc()=0; |
|
598 /** Sets the rectangle that this animation will draw to. |
|
599 |
|
600 This function must be called as part of the initialisation/construction of |
|
601 the CAnim-derived object, i.e. in CAnim::ConstructL(). This is so that the |
|
602 window server knows which area the animation is operating in. Anything that |
|
603 is drawn by the animation outside this rectangle may not be redrawn correctly |
|
604 as the window server uses this rectangle to decide when the animation should |
|
605 be redrawn. |
|
606 |
|
607 @param aRect The rectangle to be drawn to. */ |
|
608 virtual void SetRect(const TRect &aRect)=0; |
|
609 /** Gets the window size. |
|
610 |
|
611 @return The window size, in pixels. */ |
|
612 virtual TSize WindowSize() const=0; |
|
613 /** Tests whether to draw the animation. |
|
614 |
|
615 If the window is completely hidden, there is normally no need to draw |
|
616 the animation. However in some conditions the animation should be drawn even |
|
617 if it is obscured. The window server is aware of these cases, and returns |
|
618 ETrue if it is not safe to draw the animation. |
|
619 |
|
620 @return True if the window is completely hidden and there is no requirement |
|
621 to continue drawing the animation, otherwise false. */ |
|
622 virtual TBool IsHidden()=0; |
|
623 /** Sets the visibility of the window the animation is drawing to. |
|
624 |
|
625 This does the same as RWindowBase::SetVisible(). |
|
626 |
|
627 @param aState True for visible, false otherwise. */ |
|
628 virtual void SetVisible(TBool aState)=0; |
|
629 /** Forces a redraw of a rectangular part of the window. |
|
630 |
|
631 The function causes a redraw message on the part of the window specified, |
|
632 which provides a non-immediate way to do drawing. |
|
633 |
|
634 It can be used to redraw the whole of the window, not just the part used by |
|
635 the animation. |
|
636 |
|
637 @param aRect The rectangle to be redrawn. These co-ordinates are relative |
|
638 to the origin of the window. */ |
|
639 virtual void Invalidate(const TRect &aRect)=0; |
|
640 /** Gets window information. |
|
641 |
|
642 @param aData The window information. */ |
|
643 virtual void Parameters(TWindowInfo &aData)=0; |
|
644 /** Gets the visible region. |
|
645 |
|
646 This region is the area of the visible window which |
|
647 is currently unshadowed. If there is not enough memory to calculate this region |
|
648 then aRegion's error flag is set. |
|
649 |
|
650 @param aRegion The visible region. */ |
|
651 virtual void VisibleRegion(TRegion& aRegion)=0; |
|
652 //virtual void CopyScreen(CFbsBitGc *aBitmapGc,TRect aRect)=0; |
|
653 private: |
|
654 virtual void Reserved() const; |
|
655 virtual void Reserved1() const; |
|
656 virtual void Reserved2() const; |
|
657 virtual void Reserved3() const; |
|
658 }; |
|
659 |
|
660 |
|
661 class MAnimFreeTimerWindowFunctions : public MAnimWindowFunctions |
|
662 /** Free timer animation utility functions interface. |
|
663 |
|
664 The class inherits functions from MAnimWindowFunctions, and defines the additional |
|
665 interface required for window operations which support animations with their |
|
666 own timers. |
|
667 |
|
668 You do NOT have to create an object of this type. The class is implemented |
|
669 by the window server, and provides utility functions to all CFreeTimerWindowAnim |
|
670 derived classes via the WindowFunctions() member. |
|
671 |
|
672 It is not intended for user derivation. |
|
673 |
|
674 @publishedAll |
|
675 @released */ |
|
676 { |
|
677 public: |
|
678 /** Deactivates the graphics context. |
|
679 |
|
680 This function is used in the context of a CFreeTimerWindowAnim derived class |
|
681 when writing animation DLLs with their own timer. Within the timer's RunL(), |
|
682 the ActivateGc() function should be called prior to drawing to the window. |
|
683 DeactivateGc() should be called after drawing is finished. */ |
|
684 virtual void DeactivateGc()=0; |
|
685 /** Forces the screen to update. */ |
|
686 virtual void Update()=0; |
|
687 private: |
|
688 virtual void Reserved3() const; |
|
689 }; |
|
690 |
|
691 class MAnimSpriteFunctions |
|
692 /** Sprite animation utility functions interface. |
|
693 |
|
694 The interface includes functions for querying and manipulating a sprite. |
|
695 |
|
696 You do NOT have to create an object of this type. The class is implemented |
|
697 by the window server, and provides utility functions to all CSpriteAnim derived |
|
698 classes via the CSpriteAnim::iSpriteFunctions pointer. |
|
699 |
|
700 It is not intended for user derivation. |
|
701 |
|
702 @publishedAll |
|
703 @released */ |
|
704 { |
|
705 public: |
|
706 /** Gets sprite member data. |
|
707 |
|
708 Each member of the sprite is effectively a bitmap, which is displayed for a |
|
709 different amount of time. |
|
710 |
|
711 @param aMember The index of the sprite member for which information is required. |
|
712 @return A pointer to the sprite member. */ |
|
713 virtual TSpriteMember *GetSpriteMember(TInt aMember) const=0; |
|
714 /** Redraws part of a sprite. |
|
715 Updates a sprite on the screen, possibly after the bitmap for a particular |
|
716 sprite member has been changed. |
|
717 |
|
718 Use the aRect parameter to specify the (small) part of the sprite which has been changed, |
|
719 then any flicker will only occur in this rectangle. |
|
720 |
|
721 A full update used to be required if you had removed pixels from the mask, i.e. made |
|
722 pixels in the sprite transparent when they were not before. If drawing is |
|
723 additive, e.g. you are using a mask or the draw mode is EDrawModePEN, a partial |
|
724 update used to be possible. But current versions of the window-server always do full back to front rendering. |
|
725 |
|
726 Note: if the sprite member aMember is not visible then there is no need for a change |
|
727 to the display, so the aRect and aFullUpdate parameters are ignored. |
|
728 |
|
729 @param aMember The index of the sprite member that is to be updated. |
|
730 @param aRect The part of the sprite member which has changed. |
|
731 @param aFullUpdate Not used. Wserv now always do full back to front rendering. */ |
|
732 virtual void UpdateMember(TInt aMember,const TRect& aRect,TBool aFullUpdate)=0; |
|
733 /** Turns a sprite on or off. |
|
734 |
|
735 In effect this makes the sprite bitmap visible. |
|
736 |
|
737 @param aActive ETrue to turn sprite on. EFalse to turn it off. */ |
|
738 virtual void Activate(TBool aActive)=0; |
|
739 /** Finishes constructing the sprite. |
|
740 |
|
741 It also sets the currently displayed sprite member to zero. |
|
742 |
|
743 This function must be called after members change size. */ |
|
744 virtual void SizeChangedL()=0; |
|
745 /** Set the sprite's position. |
|
746 |
|
747 @param aPos The new position of the sprite. */ |
|
748 virtual void SetPosition(const TPoint &aPos)=0; |
|
749 private: |
|
750 virtual void Reserved() const; |
|
751 public: |
|
752 /** Returns the visibility of the sprite. |
|
753 |
|
754 A sprite can be seen if it is neither obscured by another window nor hidden. |
|
755 |
|
756 @return ETrue if the sprite can be seen, EFalse otherwise. */ |
|
757 virtual TBool SpriteCanBeSeen() const = 0; |
|
758 private: |
|
759 virtual void Reserved2() const; |
|
760 virtual void Reserved3() const; |
|
761 virtual void Reserved4() const; |
|
762 }; |
|
763 |
|
764 |
|
765 class CAnimGc : public CBitmapContext |
|
766 /** Animation graphics context. |
|
767 |
|
768 An object of this type is linked into CAnim by the window server, which allows |
|
769 you to draw to the animation window. The object's functions allow you to set |
|
770 and cancel the clipping region, and to draw to the visible window using |
|
771 the inherited CBitmapContext functions. |
|
772 |
|
773 @publishedAll |
|
774 @released */ |
|
775 { |
|
776 public: |
|
777 /** Sets the clipping region. |
|
778 |
|
779 Only the parts of the animation which are within the clipping region are drawn. |
|
780 |
|
781 @param aRegion The clipping region. */ |
|
782 virtual TInt SetClippingRegion(const TRegion &aRegion)=0; |
|
783 /** Cancels the clipping region. |
|
784 |
|
785 @see SetClippingRegion() */ |
|
786 virtual void CancelClippingRegion()=0; |
|
787 }; |
|
788 |
|
789 class CWsAnim; // Forward ref for friend declaration |
|
790 |
|
791 |
|
792 class CAnim : public CBase , public MEventHandler |
|
793 /** Server side animated object base interface. |
|
794 |
|
795 Animations implement this interface, which is called by the window server |
|
796 to pass commands from clients, perform a step in the animation, or to pass |
|
797 window server events (if required) so that the animation can handle them |
|
798 before the application. |
|
799 |
|
800 The functions are all pure virtual, and must be implemented in |
|
801 the derived class to provide server side behaviour. The functions will be |
|
802 called by the window server with optional arguments passed in from the client |
|
803 side animation class RAnim. |
|
804 |
|
805 You should derive from CWindowAnim, CFreeTimerWindowAnim or CSpriteAnim, |
|
806 depending on whether the animation is to draw to a sprite or a window, |
|
807 rather than directly from this class. |
|
808 |
|
809 The derived class is constructed in the DLL factory class CAnimDll::CreateInstanceL() |
|
810 function. |
|
811 |
|
812 The operation to perform an animation step is called by the window server |
|
813 on a timer. The timing properties are set through an MAnimGeneralFunctions |
|
814 member, which also provides other utility functions. |
|
815 |
|
816 @publishedAll |
|
817 @released */ |
|
818 { |
|
819 public: |
|
820 /** Implements client-side initiated commands, returning a value. |
|
821 |
|
822 The window server calls this function in response to application calls to |
|
823 the client side command function RAnim::CommandReplyL(). The arguments passed |
|
824 to the function by the window server are the same as were used on the client |
|
825 side function call. |
|
826 |
|
827 This function returns values to the client side, and should be used to return |
|
828 error codes for commands which might leave. |
|
829 |
|
830 @param aOpcode Opcode understood by the class. |
|
831 @param aArgs Arguments packaged on the client side, for example as a struct |
|
832 of a type determined by the aOpcode argument. These mirror the aArgs argument |
|
833 passed in to RAnim::CommandReply(). |
|
834 @return Value passed back to client side function when this function completes. |
|
835 Typically this would be KErrNone or another of the system-wide error codes. |
|
836 However any value may be returned to the client side. |
|
837 @see RAnim */ |
|
838 virtual TInt CommandReplyL(TInt aOpcode, TAny *aArgs)=0; |
|
839 /** Implements client-side initiated commands. |
|
840 |
|
841 The window server calls this function in response to application calls to |
|
842 the client side command function RAnim::Command(). The arguments passed to |
|
843 the function by the window server are the same as were used on the client |
|
844 side function call. |
|
845 |
|
846 Because this function does not return errors, it is not safe for commands |
|
847 which might leave. |
|
848 |
|
849 @param aOpcode Opcode understood by the class |
|
850 @param aArgs Arguments packaged on the client side, for example as a struct |
|
851 of a type determined by the aOpcode argument. These mirror the aArgs argument |
|
852 passed in to RAnim::Command(). |
|
853 @see RAnim */ |
|
854 virtual void Command(TInt aOpcode, TAny *aArgs)=0; |
|
855 /** Main animation function, called by the window server. |
|
856 |
|
857 The drawing code which implements a given animation should be provided here. |
|
858 |
|
859 This function is called at a frequency determined by the SetSync() helper |
|
860 function. Note that if sync is not set, then this function will never be |
|
861 called. This effect can be exploited to use the animation framework, with |
|
862 its server side speed, for what are strictly not animations, e.g. for streaming |
|
863 video images. |
|
864 |
|
865 The aDateTime parameter will be null if the current time (as determined by |
|
866 the window server) matches the time implied by the sync period, modulo normalisation, |
|
867 otherwise it will contain a valid (non-normalised) time. |
|
868 |
|
869 Normalisation is to some specified granularity, for example if one minute |
|
870 is specified as the animation frequency, then in effect the window server |
|
871 will decide whether the implied time is correct to the minute, but not to |
|
872 the second. |
|
873 |
|
874 Implied time is the time implied by the (normalised) actual time of the previous |
|
875 animation call plus the sync interval. For example if the last call was at |
|
876 time 't' and the sync interval is 1 second then if the time at this call |
|
877 is t + 1 second, then actual time and implied time match and the value placed |
|
878 into aDateTime will be NULL. |
|
879 |
|
880 Cases in which the two may not match include, for example, system time having |
|
881 been reset between animation calls (perhaps British Summer Time or other daylight |
|
882 saving time has just come into effect). The intention is that when system |
|
883 time changes, a mechanism is provided to alert the animation code and allow |
|
884 it to reset itself. The assumption is that somewhere in its initialisation |
|
885 code, the animation will have performed a CAnimFunctions utility call to set |
|
886 a base time, which is then implicitly tracked by incrementing by a suitable |
|
887 interval; when aDateTime is non-NULL after a call to Animate(), base time |
|
888 should be reset. |
|
889 |
|
890 @param aDateTime Null if the current time w.r.t. the window server matches |
|
891 the time implied by the synch period. Otherwise a valid (non-normalised) time. */ |
|
892 virtual void Animate(TDateTime *aDateTime)=0; |
|
893 virtual void HandleNotification(const TWsEvent& /*aEvent*/) {}; |
|
894 private: |
|
895 inline CAnim() {} |
|
896 virtual void Reserved1() const {}; |
|
897 virtual void Reserved2() const {}; |
|
898 virtual void Reserved3() const {}; |
|
899 protected: |
|
900 /** Pointer to a class containing functions implemented by the window server. |
|
901 |
|
902 These are available to any CAnim derived class. |
|
903 |
|
904 Note that this value is automatically set for you by the animation framework. |
|
905 You do not need to assign a value to this pointer. |
|
906 @publishedAll |
|
907 @released */ |
|
908 MAnimGeneralFunctions *iFunctions; |
|
909 friend class CWsAnim; |
|
910 friend class CWindowAnim; |
|
911 friend class CSpriteAnim; |
|
912 }; |
|
913 |
|
914 |
|
915 class CWindowAnim : public CAnim |
|
916 /** Window animation interface. |
|
917 |
|
918 This interface is provided to create animations other than sprites. A window |
|
919 animation can be provided by deriving from this class. |
|
920 |
|
921 The interface inherits from CAnim and has access to its functions. It additionally |
|
922 can access an interface for querying and manipulating the window in which |
|
923 the animation takes place, using its iWindowFunctions member. |
|
924 |
|
925 The derived class is constructed in the DLL factory class CAnimDll::CreateInstanceL(). |
|
926 |
|
927 @publishedAll |
|
928 @released |
|
929 @see CFreeTimerWindowAnim |
|
930 @see CSpriteAnim */ |
|
931 { |
|
932 public: |
|
933 /** Server side construction and initialisation of an animation class. |
|
934 |
|
935 Note: the aHasFocus argument allows the animation to start in a known focus state. |
|
936 For example, an animation may or may not have focus, depending on how it was |
|
937 started. Together with the FocusChanged() function, this allows an animation |
|
938 to always know its focus state. |
|
939 |
|
940 @param aArgs Packaged arguments which may be required during construction. |
|
941 These are transferred from the aParams argument of the client side constructor's |
|
942 RAnim::Construct(). |
|
943 @param aHasFocus Specifies whether or not the animation has window server focus. */ |
|
944 virtual void ConstructL(TAny *aArgs, TBool aHasFocus)=0; |
|
945 /** Redraws the objects. |
|
946 |
|
947 The function is called by the window server when it needs to redraw the object. |
|
948 The object must provide all the low level drawing code. */ |
|
949 virtual void Redraw()=0; |
|
950 /** Notifies change of focus. |
|
951 |
|
952 The function is called by the window server to notify a change of focus, |
|
953 allowing the animation code to track whether it does or does not have focus, |
|
954 and to change its appearance accordingly. |
|
955 |
|
956 @param aState Indicates whether the focus has or has not changed. */ |
|
957 virtual void FocusChanged(TBool aState)=0; |
|
958 protected: |
|
959 /** Protected constructor. |
|
960 |
|
961 Prevents objects of this class being directly constructed. */ |
|
962 inline CWindowAnim() {} |
|
963 private: |
|
964 virtual void ReservedW1() const {}; |
|
965 virtual void ReservedW2() const {}; |
|
966 protected: |
|
967 /** Pointer to a class containing functions implemented by the window server. |
|
968 |
|
969 These are available to any CWindowAnim-derived class. |
|
970 |
|
971 Note that this and the iGc pointer are automatically set for you by the |
|
972 animation framework - you do not need to assign a value to them.*/ |
|
973 MAnimWindowFunctions *iWindowFunctions; |
|
974 /** Pointer to the graphics context. */ |
|
975 CAnimGc *iGc; |
|
976 friend class CWsAnim; |
|
977 }; |
|
978 |
|
979 |
|
980 class CFreeTimerWindowAnim : public CWindowAnim |
|
981 /** Free timer animation interface. |
|
982 |
|
983 This interface allows animations to have their own timers or other active |
|
984 objects, and to draw to the window when the timer completes. The implication |
|
985 of this is that animations derived from this class can have an extremely short |
|
986 user-defined time between calls to the Animate() function, unlike the |
|
987 other animation classes, which are tied to the (approximately) half second |
|
988 flash cycle. |
|
989 |
|
990 The interface inherits from CWindowAnim and has access to its functions. It |
|
991 additionally can access functions declared in the MAnimFreeTimerWindowFunctions |
|
992 interface, using WindowFunctions(). |
|
993 |
|
994 In order to draw to the window inside the RunL() of your own timer, you will |
|
995 need call the ActivateGc() function before doing any drawing, and the DeactivateGc() |
|
996 function after finishing the drawing. |
|
997 |
|
998 @publishedAll |
|
999 @released |
|
1000 @see CSpriteAnim */ |
|
1001 { |
|
1002 protected: |
|
1003 inline MAnimFreeTimerWindowFunctions* WindowFunctions() |
|
1004 /** Gets the free timer utility functions. |
|
1005 |
|
1006 These functions include all the MAnimWindowFunctions, |
|
1007 and additional functions to deactivate the graphics context and to force the |
|
1008 screen to update. |
|
1009 |
|
1010 @return A pointer to the free timer utility functions. */ |
|
1011 {return STATIC_CAST(MAnimFreeTimerWindowFunctions*,iWindowFunctions);} |
|
1012 private: |
|
1013 virtual void ReservedF1() const {}; |
|
1014 }; |
|
1015 |
|
1016 |
|
1017 class CSpriteAnim : public CAnim |
|
1018 /** Sprite animation interface. |
|
1019 |
|
1020 Sprites are bitmaps that can overlay a window or the screen. A sprite animation |
|
1021 can be provided by deriving from this class. |
|
1022 |
|
1023 The interface inherits from CAnim and has access to its functions. It additionally |
|
1024 can access an interface for querying and manipulating a sprite, using its |
|
1025 iSpriteFunctions member. |
|
1026 |
|
1027 The derived class is constructed in the DLL factory class CAnimDll::CreateInstanceL() |
|
1028 function. |
|
1029 |
|
1030 @publishedAll |
|
1031 @released |
|
1032 @see CFreeTimerWindowAnim |
|
1033 @see CWindowAnim */ |
|
1034 { |
|
1035 public: |
|
1036 /** Server side construction and initialisation of an animation class. |
|
1037 |
|
1038 @param aArgs Packaged arguments which may be required during construction. |
|
1039 These are transferred from the aParams argument of the client side constructor's |
|
1040 RAnim::Construct(). */ |
|
1041 virtual void ConstructL(TAny *aArgs)=0; |
|
1042 protected: |
|
1043 inline CSpriteAnim() |
|
1044 /** Protected constructor. |
|
1045 |
|
1046 Ensures that only derived classes can be constructed. */ |
|
1047 {} |
|
1048 private: |
|
1049 virtual void ReservedS1() const {}; |
|
1050 virtual void ReservedS2() const {}; |
|
1051 protected: |
|
1052 /** Pointer to a class containing functions implemented by the window server. |
|
1053 |
|
1054 These are available to any CSpriteAnim-derived class. |
|
1055 |
|
1056 Note that this value is automatically set for you by the animation framework. |
|
1057 You do not need to assign a value to this pointer. */ |
|
1058 MAnimSpriteFunctions *iSpriteFunctions; |
|
1059 friend class CWsAnim; |
|
1060 }; |
|
1061 |
|
1062 |
|
1063 class CAnimDll : public CBase |
|
1064 /** Animation DLL factory interface. |
|
1065 |
|
1066 An animation DLL class must be a derived class of CAnimDll, and can be thought |
|
1067 of as a server side factory class. CAnimDll consists of a single pure virtual |
|
1068 factory function, CreateInstanceL(TInt aType), which is used to create new |
|
1069 instances of animation objects of type CAnim contained in the DLL. Animation |
|
1070 DLL objects are created by the CreateCAnimDllL() function, which is called |
|
1071 by the window server at the request of the client. |
|
1072 |
|
1073 For efficiency reasons, it makes sense to collect multiple animation classes |
|
1074 into a single DLL, even if they are otherwise logically quite separate classes. |
|
1075 |
|
1076 @publishedAll |
|
1077 @released */ |
|
1078 { |
|
1079 public: |
|
1080 /** Factory function for animation DLLs. |
|
1081 |
|
1082 It must be provided in the derived class. |
|
1083 |
|
1084 The parameter can be used to differentiate between multiple animation |
|
1085 classes contained in the same animation DLL. |
|
1086 |
|
1087 @param aType Identifies an animation class to be constructed. This is the |
|
1088 same value as the aType argument of the client side animation constructor |
|
1089 RAnim::Construct(). It is passed from the client side by the animation framework. |
|
1090 @return Pointer to a CAnim-derived animation class object. */ |
|
1091 virtual CAnim *CreateInstanceL(TInt aType)=0; |
|
1092 }; |
|
1093 |
|
1094 #endif |