35
|
1 |
/*
|
|
2 |
* Copyright (c) 2004 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: Implementation of the CVtUiBitmapManager class.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
#include "CVtUiBitmapManager.h"
|
|
22 |
#include "VtUiLayout.h"
|
|
23 |
#include "VtUiPanic.h"
|
|
24 |
|
|
25 |
#include <AknsUtils.h>
|
|
26 |
#include <AknIconUtils.h>
|
|
27 |
#include <fbs.h>
|
|
28 |
|
|
29 |
// CONSTANTS
|
|
30 |
|
|
31 |
// Granularity of bitmap manager array.
|
|
32 |
const TInt KVtUiBitmapManagerGranularity = 16;
|
|
33 |
|
|
34 |
// MODULE DATA STRUCTURES
|
|
35 |
|
|
36 |
/**
|
|
37 |
* CBitmapInfo instances hold information of a bitmap and its mask.
|
|
38 |
* @since Series 60 2.8
|
|
39 |
*/
|
|
40 |
class CVtUiBitmapManager::CBitmapInfo
|
|
41 |
: public CBase
|
|
42 |
{
|
|
43 |
public: // Constructors and destructor
|
|
44 |
|
|
45 |
/**
|
|
46 |
* Constructor.
|
|
47 |
*/
|
|
48 |
inline CBitmapInfo(
|
|
49 |
TVtUiBitmapPoolId aId );
|
|
50 |
|
|
51 |
/**
|
|
52 |
* Destructor.
|
|
53 |
*/
|
|
54 |
~CBitmapInfo();
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Sets bitmap identifiers.
|
|
58 |
* @param aBitmapId bitmap identifier.
|
|
59 |
* @param aBitmapMaskId bitmap mask identifier.
|
|
60 |
*/
|
|
61 |
inline void SetBitmaps(
|
|
62 |
TVtUiBitmapId aBitmapId,
|
|
63 |
TVtUiBitmapId aBitmapMaskId );
|
|
64 |
|
|
65 |
/**
|
|
66 |
* Sets bitmap identifier.
|
|
67 |
* @param aBitmapId bitmap identifier.
|
|
68 |
*/
|
|
69 |
inline void SetBitmap(
|
|
70 |
TVtUiBitmapId aBitmapId );
|
|
71 |
|
|
72 |
/**
|
|
73 |
* Sets size.
|
|
74 |
* @param aSize size of the bitmaps.
|
|
75 |
*/
|
|
76 |
inline void SetSize( const TSize& aSize );
|
|
77 |
|
|
78 |
/**
|
|
79 |
* Sets aspect ratio preservation.
|
|
80 |
* @param aPreserve ETrue if aspect ratio preserved.
|
|
81 |
*/
|
|
82 |
inline void SetAspectRatio( TBool aPreserve );
|
|
83 |
|
|
84 |
/**
|
|
85 |
* Sets default color required / not required for this bitmap.
|
|
86 |
* By default, default color is not required.
|
|
87 |
* @param aRequireDefaultColor ETrue if default color is required,
|
|
88 |
* EFalse otherwise.
|
|
89 |
*/
|
|
90 |
inline void SetDefaultColorRequired(
|
|
91 |
TBool aRequireDefaultColor );
|
|
92 |
|
|
93 |
/**
|
|
94 |
* Sets default color.
|
|
95 |
* @param aDefaultColor default color.
|
|
96 |
*/
|
|
97 |
inline void SetDefaultColor( const TRgb& aDefaultColor );
|
|
98 |
|
|
99 |
/**
|
|
100 |
* Returns bitmap pool identifier.
|
|
101 |
* @return bitmap pool identifier.
|
|
102 |
*/
|
|
103 |
inline TVtUiBitmapPoolId BitmapPoolId() const;
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Gets a bitmap and its mask.
|
|
107 |
* @param aBitmap bitmap.
|
|
108 |
* @param aBitmapMask bitmap mask.
|
|
109 |
*/
|
|
110 |
inline void GetBitmap(
|
|
111 |
CFbsBitmap*& aBitmap,
|
|
112 |
CFbsBitmap*& aBitmapMask );
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Resets bitmap information.
|
|
116 |
*/
|
|
117 |
void Reset();
|
|
118 |
|
|
119 |
/**
|
|
120 |
* Constructs bitmap as far as possible.
|
|
121 |
* @param aTmpFileName temporary file name,
|
|
122 |
*/
|
|
123 |
void Require( TFileName& aTmpFileName );
|
|
124 |
|
|
125 |
private:
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Creates bitmaps using AVKON methods.
|
|
129 |
* @param aTmpFileName temporary file name,
|
|
130 |
*/
|
|
131 |
void DoCreateBitmapsL( TFileName& aTmpFileName );
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Sets size to the bitmap using AVKON method.
|
|
135 |
*/
|
|
136 |
void DoSetSize();
|
|
137 |
|
|
138 |
private:
|
|
139 |
|
|
140 |
// Bitmap pool identifier.
|
|
141 |
TVtUiBitmapPoolId iBitmapPoolId;
|
|
142 |
|
|
143 |
// Size has been defined.
|
|
144 |
TBool iHasSize;
|
|
145 |
|
|
146 |
// Size of the bitmap has been changed.
|
|
147 |
TBool iSizeChanged;
|
|
148 |
|
|
149 |
// Size of the bitmaps.
|
|
150 |
TSize iSize;
|
|
151 |
|
|
152 |
// ETrue if default color required.
|
|
153 |
TBool iRequireDefaultColor;
|
|
154 |
|
|
155 |
// Default color has been defined.
|
|
156 |
TBool iHasDefaultColor;
|
|
157 |
|
|
158 |
// Default color.
|
|
159 |
TRgb iDefaultColor;
|
|
160 |
|
|
161 |
// Bitmap identifier.
|
|
162 |
TVtUiBitmapId iBitmapId;
|
|
163 |
|
|
164 |
// Owned bitmap instance.
|
|
165 |
CFbsBitmap* iBitmap;
|
|
166 |
|
|
167 |
// Bitmap mask identifier.
|
|
168 |
TVtUiBitmapId iBitmapMaskId;
|
|
169 |
|
|
170 |
// Owned bitmap mask instance.
|
|
171 |
CFbsBitmap* iBitmapMask;
|
|
172 |
|
|
173 |
// ETrue if bitmaps have been created.
|
|
174 |
TBool iDoCreateBitmaps;
|
|
175 |
|
|
176 |
// ETrue if size has been set.
|
|
177 |
TBool iDoSetSize;
|
|
178 |
|
|
179 |
// ETrue if aspect ratio preservation has been updated.
|
|
180 |
TBool iHasAspectRatioPreserve;
|
|
181 |
|
|
182 |
// ETrue if aspect ratio should be preserved.
|
|
183 |
TBool iAspectRatioPreserve;
|
|
184 |
|
|
185 |
};
|
|
186 |
|
|
187 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
188 |
|
|
189 |
// -----------------------------------------------------------------------------
|
|
190 |
// CVtUiBitmapManager::CVtUiBitmapManager
|
|
191 |
// -----------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
CVtUiBitmapManager::CVtUiBitmapManager()
|
|
194 |
: iBitmapArray( KVtUiBitmapManagerGranularity )
|
|
195 |
{
|
|
196 |
}
|
|
197 |
|
|
198 |
// -----------------------------------------------------------------------------
|
|
199 |
// CVtUiBitmapManager::~CVtUiBitmapManager
|
|
200 |
// -----------------------------------------------------------------------------
|
|
201 |
//
|
|
202 |
CVtUiBitmapManager::~CVtUiBitmapManager()
|
|
203 |
{
|
|
204 |
iBitmapArray.ResetAndDestroy();
|
|
205 |
iBitmapArray.Close();
|
|
206 |
}
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
// CVtUiBitmapManager::AddBitmapsL
|
|
210 |
// -----------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
TVtUiBitmapPoolId CVtUiBitmapManager::AddBitmapsL(
|
|
213 |
TVtUiBitmapId aBitmapId,
|
|
214 |
TVtUiBitmapId aBitmapMaskId,
|
|
215 |
TBool aExpectDefaultColor )
|
|
216 |
{
|
|
217 |
iBitmapId++;
|
|
218 |
CBitmapInfo* bitmapInfo = new ( ELeave ) CBitmapInfo( iBitmapId );
|
|
219 |
CleanupStack::PushL( bitmapInfo );
|
|
220 |
bitmapInfo->SetBitmaps( aBitmapId, aBitmapMaskId );
|
|
221 |
bitmapInfo->SetDefaultColorRequired( aExpectDefaultColor );
|
|
222 |
bitmapInfo->Require( iTmpFileName );
|
|
223 |
|
|
224 |
User::LeaveIfError( iBitmapArray.Append( bitmapInfo ) );
|
|
225 |
CleanupStack::Pop( bitmapInfo );
|
|
226 |
return iBitmapId;
|
|
227 |
}
|
|
228 |
|
|
229 |
// -----------------------------------------------------------------------------
|
|
230 |
// CVtUiBitmapManager::AddBitmapL
|
|
231 |
// -----------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
TVtUiBitmapPoolId CVtUiBitmapManager::AddBitmapL(
|
|
234 |
TVtUiBitmapId aBitmapId,
|
|
235 |
TBool aExpectDefaultColor )
|
|
236 |
{
|
|
237 |
iBitmapId++;
|
|
238 |
CBitmapInfo* bitmapInfo = new ( ELeave ) CBitmapInfo( iBitmapId );
|
|
239 |
CleanupStack::PushL( bitmapInfo );
|
|
240 |
bitmapInfo->SetBitmap( aBitmapId );
|
|
241 |
bitmapInfo->SetDefaultColorRequired( aExpectDefaultColor );
|
|
242 |
bitmapInfo->Require( iTmpFileName );
|
|
243 |
|
|
244 |
User::LeaveIfError( iBitmapArray.Append( bitmapInfo ) );
|
|
245 |
CleanupStack::Pop( bitmapInfo );
|
|
246 |
return iBitmapId;
|
|
247 |
}
|
|
248 |
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
// CVtUiBitmapManager::RemoveBitmap
|
|
251 |
// -----------------------------------------------------------------------------
|
|
252 |
//
|
|
253 |
void CVtUiBitmapManager::RemoveBitmap(
|
|
254 |
TVtUiBitmapPoolId aId )
|
|
255 |
{
|
|
256 |
const TInt pos = Find( aId );
|
|
257 |
if ( pos != KErrNotFound )
|
|
258 |
{
|
|
259 |
CBitmapInfo* bitmapInfo = iBitmapArray[ pos ];
|
|
260 |
iBitmapArray.Remove( pos );
|
|
261 |
delete bitmapInfo;
|
|
262 |
}
|
|
263 |
}
|
|
264 |
|
|
265 |
// -----------------------------------------------------------------------------
|
|
266 |
// CVtUiBitmapManager::SetSize
|
|
267 |
// -----------------------------------------------------------------------------
|
|
268 |
//
|
|
269 |
void CVtUiBitmapManager::SetSize(
|
|
270 |
TVtUiBitmapPoolId aId,
|
|
271 |
const TSize& aSize )
|
|
272 |
{
|
|
273 |
const TInt pos = Find( aId );
|
|
274 |
if ( pos != KErrNotFound )
|
|
275 |
{
|
|
276 |
CBitmapInfo* bitmapInfo = iBitmapArray[ pos ];
|
|
277 |
bitmapInfo->SetSize( aSize );
|
|
278 |
bitmapInfo->Require( iTmpFileName );
|
|
279 |
}
|
|
280 |
}
|
|
281 |
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
// CVtUiBitmapManager::SetAspectRatio
|
|
284 |
// -----------------------------------------------------------------------------
|
|
285 |
//
|
|
286 |
void CVtUiBitmapManager::SetAspectRatio(
|
|
287 |
TVtUiBitmapPoolId aId,
|
|
288 |
TBool aPreserve )
|
|
289 |
{
|
|
290 |
const TInt pos = Find( aId );
|
|
291 |
if ( pos != KErrNotFound )
|
|
292 |
{
|
|
293 |
CBitmapInfo* bitmapInfo = iBitmapArray[ pos ];
|
|
294 |
bitmapInfo->SetAspectRatio( aPreserve );
|
|
295 |
}
|
|
296 |
}
|
|
297 |
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
// CVtUiBitmapManager::SetSizeAndColor
|
|
300 |
// -----------------------------------------------------------------------------
|
|
301 |
//
|
|
302 |
void CVtUiBitmapManager::SetSizeAndColor(
|
|
303 |
TVtUiBitmapPoolId aId,
|
|
304 |
const TSize& aSize,
|
|
305 |
const TRgb& aDefaultColor )
|
|
306 |
{
|
|
307 |
const TInt pos = Find( aId );
|
|
308 |
if ( pos != KErrNotFound )
|
|
309 |
{
|
|
310 |
CBitmapInfo* bitmapInfo = iBitmapArray[ pos ];
|
|
311 |
bitmapInfo->SetSize( aSize );
|
|
312 |
bitmapInfo->SetDefaultColor( aDefaultColor );
|
|
313 |
bitmapInfo->Require( iTmpFileName );
|
|
314 |
}
|
|
315 |
}
|
|
316 |
|
|
317 |
// -----------------------------------------------------------------------------
|
|
318 |
// CVtUiBitmapManager::RequireBitmap
|
|
319 |
// -----------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
void CVtUiBitmapManager::RequireBitmap( TVtUiBitmapPoolId aId )
|
|
322 |
{
|
|
323 |
const TInt pos = Find( aId );
|
|
324 |
if ( pos != KErrNotFound )
|
|
325 |
{
|
|
326 |
CBitmapInfo* bitmapInfo = iBitmapArray[ pos ];
|
|
327 |
bitmapInfo->Require( iTmpFileName );
|
|
328 |
}
|
|
329 |
}
|
|
330 |
|
|
331 |
// -----------------------------------------------------------------------------
|
|
332 |
// CVtUiBitmapManager::GetBitmaps
|
|
333 |
// -----------------------------------------------------------------------------
|
|
334 |
//
|
|
335 |
void CVtUiBitmapManager::GetBitmaps(
|
|
336 |
TVtUiBitmapPoolId aId,
|
|
337 |
CFbsBitmap*& aBitmap,
|
|
338 |
CFbsBitmap*& aBitmapMask )
|
|
339 |
{
|
|
340 |
aBitmap = NULL;
|
|
341 |
aBitmapMask = NULL;
|
|
342 |
|
|
343 |
const TInt pos = Find( aId );
|
|
344 |
if ( pos != KErrNotFound )
|
|
345 |
{
|
|
346 |
CBitmapInfo* bitmapInfo = iBitmapArray[ pos ];
|
|
347 |
bitmapInfo->GetBitmap( aBitmap, aBitmapMask );
|
|
348 |
}
|
|
349 |
}
|
|
350 |
|
|
351 |
// -----------------------------------------------------------------------------
|
|
352 |
// CVtUiBitmapManager::GetBitmap
|
|
353 |
// -----------------------------------------------------------------------------
|
|
354 |
//
|
|
355 |
void CVtUiBitmapManager::GetBitmap(
|
|
356 |
TVtUiBitmapPoolId aId,
|
|
357 |
CFbsBitmap*& aBitmap )
|
|
358 |
{
|
|
359 |
CFbsBitmap* dummy = NULL;
|
|
360 |
GetBitmaps( aId, aBitmap, dummy );
|
|
361 |
}
|
|
362 |
|
|
363 |
// -----------------------------------------------------------------------------
|
|
364 |
// CVtUiBitmapManager::InvalidateBitmaps
|
|
365 |
// -----------------------------------------------------------------------------
|
|
366 |
//
|
|
367 |
void CVtUiBitmapManager::InvalidateBitmaps()
|
|
368 |
{
|
|
369 |
const TInt count = iBitmapArray.Count();
|
|
370 |
for ( TInt index = 0; index < count; index++ )
|
|
371 |
{
|
|
372 |
CBitmapInfo* bitmapInfo = iBitmapArray[ index ];
|
|
373 |
bitmapInfo->Reset();
|
|
374 |
}
|
|
375 |
}
|
|
376 |
|
|
377 |
// -----------------------------------------------------------------------------
|
|
378 |
// CVtUiBitmapManager::Find
|
|
379 |
// -----------------------------------------------------------------------------
|
|
380 |
//
|
|
381 |
TInt CVtUiBitmapManager::Find( TVtUiBitmapPoolId aId ) const
|
|
382 |
{
|
|
383 |
TInt result = KErrNotFound;
|
|
384 |
const TInt count = iBitmapArray.Count();
|
|
385 |
for ( TInt index = 0; index < count; index++ )
|
|
386 |
{
|
|
387 |
CBitmapInfo* bitmapInfo = iBitmapArray[ index ];
|
|
388 |
if ( bitmapInfo->BitmapPoolId() == aId )
|
|
389 |
{
|
|
390 |
result = index;
|
|
391 |
index = count; // out of the loop
|
|
392 |
}
|
|
393 |
}
|
|
394 |
|
|
395 |
return result;
|
|
396 |
}
|
|
397 |
|
|
398 |
// Implementation of CBitmapInfo:
|
|
399 |
|
|
400 |
// -----------------------------------------------------------------------------
|
|
401 |
// CVtUiBitmapManager::CBitmapInfo::CBitmapInfo
|
|
402 |
// -----------------------------------------------------------------------------
|
|
403 |
//
|
|
404 |
inline CVtUiBitmapManager::CBitmapInfo::CBitmapInfo(
|
|
405 |
TVtUiBitmapPoolId aId )
|
|
406 |
: iBitmapPoolId( aId ),
|
|
407 |
iBitmapId( EVtUiBitmapNone ),
|
|
408 |
iBitmapMaskId( EVtUiBitmapNone )
|
|
409 |
{
|
|
410 |
}
|
|
411 |
|
|
412 |
// -----------------------------------------------------------------------------
|
|
413 |
// CVtUiBitmapManager::CBitmapInfo::~CBitmapInfo
|
|
414 |
// -----------------------------------------------------------------------------
|
|
415 |
//
|
|
416 |
CVtUiBitmapManager::CBitmapInfo::~CBitmapInfo()
|
|
417 |
{
|
|
418 |
delete iBitmap;
|
|
419 |
delete iBitmapMask;
|
|
420 |
}
|
|
421 |
|
|
422 |
// -----------------------------------------------------------------------------
|
|
423 |
// CVtUiBitmapManager::CBitmapInfo::SetBitmaps
|
|
424 |
// -----------------------------------------------------------------------------
|
|
425 |
//
|
|
426 |
inline void CVtUiBitmapManager::CBitmapInfo::SetBitmaps(
|
|
427 |
TVtUiBitmapId aBitmapId,
|
|
428 |
TVtUiBitmapId aBitmapMaskId )
|
|
429 |
{
|
|
430 |
iBitmapId = aBitmapId;
|
|
431 |
iBitmapMaskId = aBitmapMaskId;
|
|
432 |
}
|
|
433 |
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
// CVtUiBitmapManager::CBitmapInfo::SetBitmap
|
|
436 |
// -----------------------------------------------------------------------------
|
|
437 |
//
|
|
438 |
inline void CVtUiBitmapManager::CBitmapInfo::SetBitmap(
|
|
439 |
TVtUiBitmapId aBitmapId )
|
|
440 |
{
|
|
441 |
iBitmapId = aBitmapId;
|
|
442 |
iBitmapMaskId = EVtUiBitmapNone;
|
|
443 |
}
|
|
444 |
|
|
445 |
// -----------------------------------------------------------------------------
|
|
446 |
// CVtUiBitmapManager::CBitmapInfo::SetSize
|
|
447 |
// -----------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
inline void CVtUiBitmapManager::CBitmapInfo::SetSize(
|
|
450 |
const TSize& aSize )
|
|
451 |
{
|
|
452 |
if ( iHasSize )
|
|
453 |
{
|
|
454 |
iSizeChanged = ( iSize != aSize );
|
|
455 |
}
|
|
456 |
|
|
457 |
iHasSize = ETrue;
|
|
458 |
iSize = aSize;
|
|
459 |
}
|
|
460 |
|
|
461 |
// -----------------------------------------------------------------------------
|
|
462 |
// CVtUiBitmapManager::CBitmapInfo::SetAspectRatio
|
|
463 |
// -----------------------------------------------------------------------------
|
|
464 |
//
|
|
465 |
inline void CVtUiBitmapManager::CBitmapInfo::SetAspectRatio( TBool aPreserve )
|
|
466 |
{
|
|
467 |
iHasAspectRatioPreserve = ETrue;
|
|
468 |
iAspectRatioPreserve = aPreserve;
|
|
469 |
}
|
|
470 |
|
|
471 |
// -----------------------------------------------------------------------------
|
|
472 |
// CVtUiBitmapManager::CBitmapInfo::SetDefaultColorRequired
|
|
473 |
// -----------------------------------------------------------------------------
|
|
474 |
//
|
|
475 |
inline void CVtUiBitmapManager::CBitmapInfo::SetDefaultColorRequired(
|
|
476 |
TBool aRequireDefaultColor )
|
|
477 |
{
|
|
478 |
iRequireDefaultColor = aRequireDefaultColor;
|
|
479 |
}
|
|
480 |
|
|
481 |
// -----------------------------------------------------------------------------
|
|
482 |
// CVtUiBitmapManager::CBitmapInfo::SetDefaultColor
|
|
483 |
// -----------------------------------------------------------------------------
|
|
484 |
//
|
|
485 |
inline void CVtUiBitmapManager::CBitmapInfo::SetDefaultColor(
|
|
486 |
const TRgb& aDefaultColor )
|
|
487 |
{
|
|
488 |
__ASSERT_DEBUG( iRequireDefaultColor,
|
|
489 |
VtUiPanic::Panic( EVtUiPanicDefaultColorRequireMismatch ) );
|
|
490 |
iHasDefaultColor = ETrue;
|
|
491 |
iDefaultColor = aDefaultColor;
|
|
492 |
}
|
|
493 |
|
|
494 |
// -----------------------------------------------------------------------------
|
|
495 |
// CVtUiBitmapManager::CBitmapInfo::BitmapPoolId
|
|
496 |
// -----------------------------------------------------------------------------
|
|
497 |
//
|
|
498 |
inline TVtUiBitmapPoolId CVtUiBitmapManager::CBitmapInfo::BitmapPoolId() const
|
|
499 |
{
|
|
500 |
return iBitmapPoolId;
|
|
501 |
}
|
|
502 |
|
|
503 |
// -----------------------------------------------------------------------------
|
|
504 |
// CVtUiBitmapManager::CBitmapInfo::GetBitmap
|
|
505 |
// -----------------------------------------------------------------------------
|
|
506 |
//
|
|
507 |
inline void CVtUiBitmapManager::CBitmapInfo::GetBitmap(
|
|
508 |
CFbsBitmap*& aBitmap,
|
|
509 |
CFbsBitmap*& aBitmapMask )
|
|
510 |
{
|
|
511 |
if ( iDoCreateBitmaps && iDoSetSize )
|
|
512 |
{
|
|
513 |
aBitmap = iBitmap;
|
|
514 |
aBitmapMask = iBitmapMask;
|
|
515 |
}
|
|
516 |
else
|
|
517 |
{
|
|
518 |
aBitmap = NULL;
|
|
519 |
aBitmapMask = NULL;
|
|
520 |
}
|
|
521 |
}
|
|
522 |
|
|
523 |
// -----------------------------------------------------------------------------
|
|
524 |
// CVtUiBitmapManager::CBitmapInfo::Reset
|
|
525 |
// -----------------------------------------------------------------------------
|
|
526 |
//
|
|
527 |
void CVtUiBitmapManager::CBitmapInfo::Reset()
|
|
528 |
{
|
|
529 |
delete iBitmap;
|
|
530 |
iBitmap = NULL;
|
|
531 |
|
|
532 |
delete iBitmapMask;
|
|
533 |
iBitmapMask = NULL;
|
|
534 |
|
|
535 |
iSize = TSize();
|
|
536 |
iHasSize = EFalse;
|
|
537 |
iSizeChanged = EFalse;
|
|
538 |
iHasDefaultColor = EFalse;
|
|
539 |
iDefaultColor = TRgb();
|
|
540 |
iDoCreateBitmaps = EFalse;
|
|
541 |
iDoSetSize = EFalse;
|
|
542 |
}
|
|
543 |
|
|
544 |
// -----------------------------------------------------------------------------
|
|
545 |
// CVtUiBitmapManager::CBitmapInfo::Require
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
void CVtUiBitmapManager::CBitmapInfo::Require( TFileName& aTmpFileName )
|
|
549 |
{
|
|
550 |
// Bitmap can be created when the following has been satisfied
|
|
551 |
// a) It has not been created yet and default color is not required,
|
|
552 |
// b) It has not been created yet and default color is required and
|
|
553 |
// default color is available.
|
|
554 |
if ( !iDoCreateBitmaps && !( iRequireDefaultColor && !iHasDefaultColor ) )
|
|
555 |
{
|
|
556 |
TRAP_IGNORE( DoCreateBitmapsL( aTmpFileName ) );
|
|
557 |
}
|
|
558 |
|
|
559 |
DoSetSize();
|
|
560 |
}
|
|
561 |
|
|
562 |
// -----------------------------------------------------------------------------
|
|
563 |
// CVtUiBitmapManager::CBitmapInfo::DoCreateBitmapsL
|
|
564 |
// -----------------------------------------------------------------------------
|
|
565 |
//
|
|
566 |
void CVtUiBitmapManager::CBitmapInfo::DoCreateBitmapsL(
|
|
567 |
TFileName& aTmpFileName )
|
|
568 |
{
|
|
569 |
if ( !iDoCreateBitmaps )
|
|
570 |
{
|
|
571 |
TInt bitmapIndex = KErrNotFound;
|
|
572 |
|
|
573 |
VtUiLayout::Resolve( iBitmapId, aTmpFileName, bitmapIndex );
|
|
574 |
|
|
575 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
576 |
TAknsItemID skinId = VtUiLayout::MapBitmapToSkinId( iBitmapId );
|
|
577 |
|
|
578 |
TAknsItemID colorId = KAknsIIDNone;
|
|
579 |
TInt colorIndex = KErrNotFound;
|
|
580 |
TBool colorAvailable = EFalse;
|
|
581 |
if ( iHasDefaultColor )
|
|
582 |
{
|
|
583 |
colorAvailable =
|
|
584 |
VtUiLayout::MapBitmapToColorId(
|
|
585 |
iBitmapId, colorId, colorIndex );
|
|
586 |
}
|
|
587 |
|
|
588 |
if ( iBitmapMaskId != EVtUiBitmapNone )
|
|
589 |
{
|
|
590 |
TInt bitmapMaskIndex = KErrNotFound;
|
|
591 |
#ifdef _DEBUG
|
|
592 |
TFileName fileName;
|
|
593 |
VtUiLayout::Resolve( iBitmapMaskId, fileName, bitmapMaskIndex );
|
|
594 |
__ASSERT_ALWAYS( aTmpFileName == fileName,
|
|
595 |
VtUiPanic::Panic( EVtUiPanicMismatchInBitmapFileNames ) );
|
|
596 |
#else
|
|
597 |
VtUiLayout::Resolve( iBitmapMaskId, aTmpFileName, bitmapMaskIndex );
|
|
598 |
#endif
|
|
599 |
if ( colorAvailable )
|
|
600 |
{
|
|
601 |
AknsUtils::CreateColorIconL(
|
|
602 |
skin, skinId,
|
|
603 |
colorId, colorIndex,
|
|
604 |
iBitmap, iBitmapMask,
|
|
605 |
aTmpFileName,
|
|
606 |
bitmapIndex,
|
|
607 |
bitmapMaskIndex,
|
|
608 |
iDefaultColor );
|
|
609 |
}
|
|
610 |
else
|
|
611 |
{
|
|
612 |
AknsUtils::CreateIconL(
|
|
613 |
skin, skinId,
|
|
614 |
iBitmap, iBitmapMask,
|
|
615 |
aTmpFileName,
|
|
616 |
bitmapIndex,
|
|
617 |
bitmapMaskIndex );
|
|
618 |
}
|
|
619 |
}
|
|
620 |
else
|
|
621 |
{
|
|
622 |
// Only normal skinning for these.
|
|
623 |
AknsUtils::CreateIconL(
|
|
624 |
skin,
|
|
625 |
skinId,
|
|
626 |
iBitmap,
|
|
627 |
aTmpFileName,
|
|
628 |
bitmapIndex );
|
|
629 |
}
|
|
630 |
|
|
631 |
iDoCreateBitmaps = ETrue;
|
|
632 |
}
|
|
633 |
}
|
|
634 |
|
|
635 |
// -----------------------------------------------------------------------------
|
|
636 |
// CVtUiBitmapManager::CBitmapInfo::DoSetSize
|
|
637 |
// -----------------------------------------------------------------------------
|
|
638 |
//
|
|
639 |
void CVtUiBitmapManager::CBitmapInfo::DoSetSize()
|
|
640 |
{
|
|
641 |
if ( iDoCreateBitmaps && iHasSize && ( !iDoSetSize || iSizeChanged ) )
|
|
642 |
{
|
|
643 |
iSizeChanged = EFalse;
|
|
644 |
TInt retBitmap = KErrNone;
|
|
645 |
if ( !iHasAspectRatioPreserve )
|
|
646 |
{
|
|
647 |
retBitmap = AknIconUtils::SetSize( iBitmap, iSize );
|
|
648 |
}
|
|
649 |
else
|
|
650 |
{
|
|
651 |
TScaleMode scaleMode =
|
|
652 |
iAspectRatioPreserve ?
|
|
653 |
EAspectRatioPreserved :
|
|
654 |
EAspectRatioNotPreserved;
|
|
655 |
retBitmap = AknIconUtils::SetSize( iBitmap, iSize, scaleMode );
|
|
656 |
}
|
|
657 |
|
|
658 |
iDoSetSize = ( retBitmap == KErrNone );
|
|
659 |
}
|
|
660 |
}
|
|
661 |
|
|
662 |
// End of File
|