|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Layered background control context with mask bitmap. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "AknsCppPreface.h" |
|
19 #include "AknsMaskedLayerBackgroundControlContext.h" |
|
20 |
|
21 #include <AknsUtils.h> |
|
22 #include "AknsBackgroundLayout.h" |
|
23 #include "AknsDebug.h" |
|
24 |
|
25 #include "AknIconUtils.h" |
|
26 #include <AknsDrawUtils.h> |
|
27 #include "AknsAppSkinInstance.h" |
|
28 |
|
29 // ======== MEMBER FUNCTIONS ======== |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CAknsMaskedLayerBackgroundControlContext::CAknsMaskedLayerBackgroundControlContext |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CAknsMaskedLayerBackgroundControlContext::CAknsMaskedLayerBackgroundControlContext() : |
|
37 CAknsLayeredBackgroundControlContext() |
|
38 // CBase initializes: iLayoutArray(NULL), iLayoutArraySize(0) |
|
39 { |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CAknsMaskedLayerBackgroundControlContext::ConstructL |
|
44 // Symbian 2nd phase constructor can leave. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 void CAknsMaskedLayerBackgroundControlContext::ConstructL( |
|
48 const TRect& aRect, const TBool aParentAbsolute, |
|
49 const TAknsItemID& aImageID, const TInt aNumberOfLayers ) |
|
50 { |
|
51 CAknsLayeredBackgroundControlContext::ConstructL( aRect, aParentAbsolute, |
|
52 aImageID, aNumberOfLayers ); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CAknsMaskedLayerBackgroundControlContext::NewL |
|
57 // Two-phased constructor. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 AKNS_EXPORTED_METHOD(CAknsMaskedLayerBackgroundControlContext::NewL) |
|
61 EXPORT_C CAknsMaskedLayerBackgroundControlContext* |
|
62 CAknsMaskedLayerBackgroundControlContext::NewL( |
|
63 const TAknsItemID& aImageID, const TRect& aRect, |
|
64 const TBool aParentAbsolute, const TInt aNumberOfLayers ) |
|
65 { |
|
66 #ifndef RD_FULLSCREEN_WALLPAPER |
|
67 User::Leave( KErrNotSupported ); |
|
68 #endif //RD_FULLSCREEN_WALLPAPER |
|
69 CAknsMaskedLayerBackgroundControlContext* self = |
|
70 new( ELeave ) CAknsMaskedLayerBackgroundControlContext(); |
|
71 |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL( aRect, aParentAbsolute, aImageID, aNumberOfLayers ); |
|
74 CleanupStack::Pop( self ); |
|
75 |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Destructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CAknsMaskedLayerBackgroundControlContext::~CAknsMaskedLayerBackgroundControlContext() |
|
84 { |
|
85 #ifndef RD_FULLSCREEN_WALLPAPER |
|
86 return; |
|
87 #else |
|
88 delete iOffScreenDevice; |
|
89 delete iOffScreenGc; |
|
90 delete iOffScreenBmp; |
|
91 delete iLayerMask; |
|
92 #endif //RD_FULLSCREEN_WALLPAPER |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CAknsMaskedLayerBackgroundControlContext::SetLayerImage |
|
97 // (other items were commented in a header). |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 AKNS_EXPORTED_METHOD(CAknsMaskedLayerBackgroundControlContext::SetLayerImage) |
|
101 EXPORT_C void CAknsMaskedLayerBackgroundControlContext::SetLayerImage( |
|
102 const TInt aLayer, const TAknsItemID& aID ) |
|
103 { |
|
104 #ifndef RD_FULLSCREEN_WALLPAPER |
|
105 return; |
|
106 #else |
|
107 CAknsLayeredBackgroundControlContext::SetLayerImage( |
|
108 aLayer, |
|
109 aID ); |
|
110 #endif //RD_FULLSCREEN_WALLPAPER |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CAknsMaskedLayerBackgroundControlContext::SetLayerRect |
|
115 // (other items were commented in a header). |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 AKNS_EXPORTED_METHOD(CAknsMaskedLayerBackgroundControlContext::SetLayerRect) |
|
119 EXPORT_C void CAknsMaskedLayerBackgroundControlContext::SetLayerRect( |
|
120 const TInt aLayer, const TRect& aRect ) |
|
121 { |
|
122 #ifndef RD_FULLSCREEN_WALLPAPER |
|
123 return; |
|
124 #else |
|
125 CAknsLayeredBackgroundControlContext::SetLayerRect( |
|
126 aLayer, |
|
127 aRect ); |
|
128 #endif //RD_FULLSCREEN_WALLPAPER |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CAknsMaskedLayerBackgroundControlContext::SetLayerMaskAndSizeL |
|
133 // (other items were commented in a header). |
|
134 // By default layer depth is set to one. |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 AKNS_EXPORTED_METHOD(CAknsMaskedLayerBackgroundControlContext::SetLayerMaskAndSizeL) |
|
138 EXPORT_C void CAknsMaskedLayerBackgroundControlContext::SetLayerMaskAndSizeL( |
|
139 const TAknsItemID& aIID, const TRect& aMaskRect ) |
|
140 { |
|
141 #ifndef RD_FULLSCREEN_WALLPAPER |
|
142 User::Leave( KErrNotSupported ); |
|
143 return; |
|
144 #else |
|
145 if ( iOffScreenDevice ) |
|
146 { |
|
147 delete iOffScreenDevice; |
|
148 iOffScreenDevice = NULL; |
|
149 } |
|
150 |
|
151 if ( iOffScreenGc ) |
|
152 { |
|
153 delete iOffScreenGc; |
|
154 iOffScreenGc = NULL; |
|
155 } |
|
156 |
|
157 if ( iLayerMask ) |
|
158 { |
|
159 delete iLayerMask; |
|
160 iLayerMask = NULL; |
|
161 } |
|
162 |
|
163 if ( iOffScreenBmp ) |
|
164 { |
|
165 delete iOffScreenBmp; |
|
166 iOffScreenBmp = NULL; |
|
167 } |
|
168 |
|
169 // Client did not set mask - previous mask & offscreen bitmap |
|
170 // deleted, just return. |
|
171 if ( aIID == KAknsIIDNone ) |
|
172 { |
|
173 return; |
|
174 } |
|
175 |
|
176 // Only do this if layer 0 is actually available. |
|
177 CAknsItemData* itemData = NULL; |
|
178 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
179 if ( skinInstance ) |
|
180 { |
|
181 TRAP_IGNORE( |
|
182 itemData = skinInstance->CreateUncachedItemDataL( |
|
183 iLayout->iImageID, EAknsITUnknown ) ); |
|
184 } |
|
185 |
|
186 if ( itemData ) |
|
187 { |
|
188 // Create layer mask item. |
|
189 AknsUtils::CreateIconL(AknsUtils::SkinInstance(), aIID, iLayerMask, KNullDesC, 0); |
|
190 User::LeaveIfError(AknIconUtils::SetSize(iLayerMask, aMaskRect.Size(),EAspectRatioNotPreserved)); |
|
191 |
|
192 // Create offscreen bitmap. |
|
193 iOffScreenBmp = new (ELeave) CFbsBitmap; |
|
194 |
|
195 CAknsAppSkinInstance* appInstance = |
|
196 static_cast<CAknsAppSkinInstance*>(skinInstance); |
|
197 |
|
198 if ( appInstance && appInstance->AnimBackgroundState() ) |
|
199 iOffScreenBmp->Create(aMaskRect.Size(), EColor16MA); |
|
200 else |
|
201 iOffScreenBmp->Create(aMaskRect.Size(), EColor64K); |
|
202 |
|
203 iOffScreenDevice = CFbsBitmapDevice::NewL(iOffScreenBmp); |
|
204 User::LeaveIfError(iOffScreenDevice->CreateContext(iOffScreenGc)); |
|
205 TPoint myPoint( 0, 0 ); |
|
206 |
|
207 // Draw the upper layers to offscreen bitmap. |
|
208 AknsDrawUtils::DrawBackground( |
|
209 AknsUtils::SkinInstance(), |
|
210 this, |
|
211 NULL, |
|
212 *iOffScreenGc, |
|
213 myPoint, |
|
214 aMaskRect, |
|
215 KAknsDrawParamIgnoreLayerMask ); |
|
216 } |
|
217 |
|
218 if (itemData) |
|
219 { |
|
220 delete itemData; |
|
221 } |
|
222 #endif //RD_FULLSCREEN_WALLPAPER |
|
223 } |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // CAknsMaskedLayerBackgroundControlContext::IsCompatibleWithType |
|
227 // (other items were commented in a header). |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 TBool CAknsMaskedLayerBackgroundControlContext::IsCompatibleWithType( |
|
231 const TAknsControlContextType aType ) const |
|
232 { |
|
233 #ifndef RD_FULLSCREEN_WALLPAPER |
|
234 return EFalse; |
|
235 #else |
|
236 if ( aType == EAknsControlContextTypeMasked ) |
|
237 { |
|
238 return ETrue; |
|
239 } |
|
240 return EFalse; |
|
241 #endif //RD_FULLSCREEN_WALLPAPER |
|
242 } |
|
243 |
|
244 // End of file |