|
1 // Copyright (c) 2001-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 // |
|
15 |
|
16 #if !defined(__GULSPRITE_H__) |
|
17 #define __GULSPRITE_H__ |
|
18 |
|
19 #include <w32std.h> |
|
20 #include <gulicon.h> |
|
21 |
|
22 class CWindowToBitmapMappingGc; |
|
23 |
|
24 class CSpriteSet : public CBase |
|
25 /** |
|
26 The CSpriteSet class allows a window server sprite to be drawn to a window. The class |
|
27 supports storage of any number of bitmap/mask pairs, though allowing only one of these |
|
28 bitmap/mask members to be displayed at any one time. The client of this class should |
|
29 provide the source bitmap/mask pairs which can be resized to fit a specified rectangle. |
|
30 Also provided for at runtime is the ability to draw onto the sprite as though it were a |
|
31 regular CWindowGc and using the same coordinate offsets as the window it exists in. |
|
32 |
|
33 @publishedPartner |
|
34 @released |
|
35 */ |
|
36 { |
|
37 public: |
|
38 enum TSpriteResizeMode |
|
39 { |
|
40 ENoResizing, |
|
41 EResizeHorizToFit, |
|
42 EResizeVertToFit, |
|
43 EResizeHorizAndVertToFit |
|
44 }; |
|
45 public: |
|
46 // methods for creation of the sprite set |
|
47 IMPORT_C static CSpriteSet* NewL(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice, CGulIcon* aSpriteSetMember, TBool aInvertMask); |
|
48 IMPORT_C static CSpriteSet* NewLC(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice, CGulIcon* aSpriteSetMember, TBool aInvertMask); |
|
49 IMPORT_C void AddMemberL(CGulIcon* aSpriteSetMember); |
|
50 IMPORT_C void RemoveMember(TInt aSpriteSetMemberIndex); |
|
51 // methods for preparing and using a sprite in the set |
|
52 IMPORT_C void PrepareSpriteForDisplayL(TInt aSpriteType, const TPoint& aSpritePos, const TSize& aSpriteSize, TSpriteResizeMode aSpriteResizeMode); |
|
53 IMPORT_C void StartDisplayingSpriteL(); |
|
54 IMPORT_C void StopDisplayingSprite(); |
|
55 IMPORT_C CWindowGc* SpriteGc() const; |
|
56 IMPORT_C void TranslateSpritePosition(const TPoint& aSpritePos); |
|
57 IMPORT_C void SetClippingRect(const TRect& aRect); |
|
58 public: |
|
59 ~CSpriteSet(); |
|
60 private: |
|
61 enum TInternalSpriteResizeMode |
|
62 { |
|
63 EHSameVSame, |
|
64 EHSameVShrink, |
|
65 EHSameVStretch, |
|
66 EHShrinkVSame, |
|
67 EHShrinkVShrink, |
|
68 EHShrinkVStretch, |
|
69 EHStretchVSame, |
|
70 EHStretchVShrink, |
|
71 EHStretchVStretch |
|
72 }; |
|
73 private: |
|
74 CSpriteSet(TBool aInvertMask); |
|
75 void ConstructL(RWindowTreeNode& aWindow, RWsSession& aWs, CWsScreenDevice& aDevice); |
|
76 void CreateSpriteMember(); |
|
77 void AdjustSpriteSizeAccordingToResizeMode(TSize& aTargetSize, const TSize& aSourceSize, TSpriteResizeMode aSpriteResizeMode) const; |
|
78 void ComputeInternalResizeMode(TInternalSpriteResizeMode& aInternalSpriteResizeMode, TSpriteResizeMode aSpriteResizeMode, const TSize& aSourceSize, const TSize& aSpriteSize) const; |
|
79 void RenderSprite(TInt aSpriteType, TInternalSpriteResizeMode aInternalSpriteResizeMode, const TSize& aSourceSize, const TSize& aSpriteSize); |
|
80 private: |
|
81 enum TFlags |
|
82 { |
|
83 EMaskIsInverted =0x01, |
|
84 ESpriteIsCurrentlyDisplayed =0x02 |
|
85 }; |
|
86 private: |
|
87 RPointerArray<CGulIcon> iSourceMembers; |
|
88 CWsBitmap* iTargetBitmap; |
|
89 CWsBitmap* iTargetMaskBitmap; |
|
90 RWsSprite iSprite; |
|
91 TSpriteMember iSpriteMember; |
|
92 CWindowToBitmapMappingGc* iWindowToBitmapMappingGc; |
|
93 CFbsBitGc* iMainFbsBitGc; |
|
94 CFbsBitGc* iMaskFbsBitGc; |
|
95 CFbsBitmapDevice* iMainBmpDevice; |
|
96 CFbsBitmapDevice* iMaskBmpDevice; |
|
97 TPoint iSpritePosition; |
|
98 TRect iClippingRect; |
|
99 TInt iFlags; |
|
100 }; |
|
101 |
|
102 #endif |