|
1 /* |
|
2 * Copyright (c) 2002-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: Xuikon Bitmap Plugin. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "xnnodepluginif.h" |
|
20 #include "xndomproperty.h" |
|
21 #include "xnproperty.h" |
|
22 #include "xncontroladapter.h" |
|
23 |
|
24 #include "xnbitmapadapter.h" |
|
25 |
|
26 _LIT(KSkin, "skin("); |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CXnBitmapAdapter::NewL |
|
32 // Symbian static 1st phase constructor |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CXnBitmapAdapter* CXnBitmapAdapter::NewL(CXnNodePluginIf& aNode) |
|
36 { |
|
37 CXnBitmapAdapter* self = new( ELeave ) CXnBitmapAdapter( aNode ); |
|
38 |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL( aNode ); |
|
41 CleanupStack::Pop(); |
|
42 |
|
43 return self; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CXnBitmapAdapter::ConstructL |
|
48 // Symbian 2nd phase constructor can leave. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CXnBitmapAdapter::ConstructL(CXnNodePluginIf& aNode) |
|
52 { |
|
53 CXnControlAdapter::ConstructL( aNode ); |
|
54 |
|
55 iAreBitmapsLoaded = EFalse; |
|
56 |
|
57 iFallbackPathChange = ETrue; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CXnBitmapAdapter::CXnBitmapAdapter |
|
62 // C++ default constructor |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CXnBitmapAdapter::CXnBitmapAdapter(CXnNodePluginIf& aNode) : iNode( aNode ) |
|
66 { |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CXnBitmapAdapter::~CXnBitmapAdapter |
|
71 // C++ destructor |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CXnBitmapAdapter::~CXnBitmapAdapter() |
|
75 { |
|
76 delete iPath; |
|
77 delete iFallbackPath; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CXnBitmapAdapter::SetContentBitmaps |
|
82 // ----------------------------------------------------------------------------- |
|
83 // |
|
84 void CXnBitmapAdapter::SetContentBitmaps(CFbsBitmap* aBitmap, CFbsBitmap* aMask) |
|
85 { |
|
86 CXnControlAdapter::SetContentBitmaps( aBitmap, aMask ); |
|
87 |
|
88 iAreBitmapsSet = ETrue; |
|
89 |
|
90 TRAP_IGNORE( iNode.SetDirtyL() ); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CXnBitmapAdapter::ContentBitmaps |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CXnBitmapAdapter::ContentBitmaps(CFbsBitmap*& aBitmap, CFbsBitmap*& aMask) |
|
98 { |
|
99 CXnControlAdapter::ContentBitmaps( aBitmap, aMask ); |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CXnBitmapAdapter::Draw |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CXnBitmapAdapter::Draw(const TRect& aRect) const |
|
107 { |
|
108 CXnControlAdapter::Draw( aRect ); |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CXnBitmapAdapter::SizeChanged |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 void CXnBitmapAdapter::SizeChanged() |
|
116 { |
|
117 CXnControlAdapter::SizeChanged(); |
|
118 |
|
119 if ( !iAreBitmapsSet ) |
|
120 { |
|
121 TSize size( Rect().Size() ); |
|
122 |
|
123 if( size != iBitmapSize ) |
|
124 { |
|
125 iBitmapSize = size; |
|
126 |
|
127 iAreBitmapsLoaded = EFalse; |
|
128 |
|
129 TRAP_IGNORE( InitializeBitmapsL() ); |
|
130 } |
|
131 } |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CXnBitmapAdapter::HandlePropertyChangeL |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CXnBitmapAdapter::DoHandlePropertyChangeL( CXnProperty* aProperty ) |
|
139 { |
|
140 TBool reConstruct( ETrue ); |
|
141 |
|
142 if( aProperty ) |
|
143 { |
|
144 const TDesC8& name( aProperty->Property()->Name( ) ); |
|
145 |
|
146 //If display changed no need to reconstruct |
|
147 if( name == XnPropertyNames::style::common::KDisplay( ) ) |
|
148 { |
|
149 reConstruct = EFalse; |
|
150 } |
|
151 // Visibility changed, no need to do anything. |
|
152 else if( name == XnPropertyNames::style::common::KVisibility( ) ) |
|
153 { |
|
154 return; |
|
155 } |
|
156 else if( name == XnPropertyNames::appearance::common::KFallBackImage ) |
|
157 { |
|
158 HBufC* fallbackPath( aProperty->StringValueL( ) ); |
|
159 |
|
160 if( fallbackPath ) |
|
161 { |
|
162 CleanupStack::PushL( fallbackPath ); |
|
163 |
|
164 if( iFallbackPath ) |
|
165 { |
|
166 if( ( *fallbackPath ).Compare( *iFallbackPath ) ) |
|
167 { |
|
168 delete iFallbackPath; |
|
169 iFallbackPath = NULL; |
|
170 iFallbackPath = fallbackPath->AllocL( ); |
|
171 iFallbackPathChange = ETrue; |
|
172 } |
|
173 } |
|
174 else |
|
175 { |
|
176 iFallbackPath = fallbackPath->AllocL( ); |
|
177 iFallbackPathChange = ETrue; |
|
178 } |
|
179 |
|
180 CleanupStack::PopAndDestroy( fallbackPath ); |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 //If data API has been used don't load new bitmaps. |
|
186 if( !iAreBitmapsSet && reConstruct ) |
|
187 { |
|
188 InitializeBitmapsL(); |
|
189 } |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CXnTextAdapter::HandleResourceChange |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CXnBitmapAdapter::HandleScreenDeviceChangedL( ) |
|
197 { |
|
198 CXnControlAdapter::HandleScreenDeviceChangedL(); |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CXnBitmapAdapter::HandlePointerEventL |
|
203 // (other items were commented in a header). |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 void CXnBitmapAdapter::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
207 { |
|
208 CXnControlAdapter::HandlePointerEventL( aPointerEvent ); |
|
209 } |
|
210 |
|
211 // ----------------------------------------------------------------------------- |
|
212 // CXnBitmapAdapter::SkinChanged |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CXnBitmapAdapter::SkinChanged() |
|
216 { |
|
217 CXnControlAdapter::SkinChanged(); |
|
218 |
|
219 if( iPath ) |
|
220 { |
|
221 TInt pos( iPath->FindF( KSkin ) ); |
|
222 |
|
223 if( pos != KErrNotFound ) |
|
224 { |
|
225 iBitmapSize = Rect().Size(); |
|
226 |
|
227 iAreBitmapsLoaded = EFalse; |
|
228 |
|
229 TRAP_IGNORE( InitializeBitmapsL() ); |
|
230 } |
|
231 } |
|
232 } |
|
233 |
|
234 // ----------------------------------------------------------------------------- |
|
235 // CXnBitmapAdapter::InitializeBitmapsL |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 void CXnBitmapAdapter::InitializeBitmapsL( ) |
|
239 { |
|
240 TBool pathChanged( EFalse ); |
|
241 |
|
242 CXnProperty* pathProperty( iNode.PathL( ) ); |
|
243 CXnProperty* maskPathProperty( iNode.MaskPathL( ) ); |
|
244 |
|
245 if ( !pathProperty ) |
|
246 { |
|
247 return; |
|
248 } |
|
249 |
|
250 HBufC* path( pathProperty->StringValueL( ) ); |
|
251 |
|
252 if( !path ) |
|
253 { |
|
254 return; |
|
255 } |
|
256 |
|
257 CleanupStack::PushL( path ); |
|
258 |
|
259 HBufC* maskPath( NULL ); |
|
260 |
|
261 if( maskPathProperty ) |
|
262 { |
|
263 maskPath = maskPathProperty->StringValueL( ); |
|
264 } |
|
265 |
|
266 CleanupStack::PushL( maskPath ); |
|
267 |
|
268 if( !iPath ) |
|
269 { |
|
270 iPath = path->AllocL( ); |
|
271 } |
|
272 |
|
273 if( path->Des( ) != iPath->Des( ) ) |
|
274 { |
|
275 pathChanged = ETrue; |
|
276 } |
|
277 |
|
278 if( !iAreBitmapsLoaded || pathChanged || iFallbackPathChange ) |
|
279 { |
|
280 delete iPath; |
|
281 iPath = NULL; |
|
282 iPath = path->AllocL( ); |
|
283 |
|
284 CXnControlAdapter::SetContentBitmaps( *path, ( maskPath ) |
|
285 ? maskPath->Des( ) : KNullDesC() ); |
|
286 |
|
287 iAreBitmapsLoaded = ETrue; |
|
288 iFallbackPathChange = EFalse; |
|
289 |
|
290 iNode.SetDirtyL(); |
|
291 } |
|
292 |
|
293 CleanupStack::PopAndDestroy( 2, path ); |
|
294 } |
|
295 |
|
296 // End of File |
|
297 |