|
1 /* |
|
2 * Copyright (c) 2007-2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "cmrimage.h" |
|
19 #include "esmrhelper.h" |
|
20 #include <esmrgui.mbg> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <aknsconstants.h> |
|
23 |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 // --------------------------------------------------------------------------- |
|
28 // CMRImage::~CMRImage |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CMRImage* CMRImage::NewL( |
|
32 NMRBitmapManager::TMRBitmapId aBitmapId, |
|
33 TBool aIsMaskIcon, |
|
34 TScaleMode aScaleMode ) |
|
35 { |
|
36 CMRImage* self = new (ELeave) CMRImage( aScaleMode ); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL( aBitmapId, aIsMaskIcon ); |
|
39 CleanupStack::Pop( self ); |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CMRImage::~CMRImage |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 EXPORT_C CMRImage::~CMRImage() |
|
48 { |
|
49 // Do nothing |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CMRImage::SizeChanged |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void CMRImage::SizeChanged() |
|
57 { |
|
58 TSize sz = Rect().Size(); |
|
59 const CFbsBitmap* bitmap = Bitmap(); |
|
60 AknIconUtils::SetSize( const_cast< CFbsBitmap* >( bitmap ), sz, iScaleMode ); |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // CMRImage::CMRImage |
|
65 // --------------------------------------------------------------------------- |
|
66 // |
|
67 CMRImage::CMRImage( TScaleMode aScaleMode ) |
|
68 : iScaleMode( aScaleMode ) |
|
69 { |
|
70 // Do nothing |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // CMRImage::ConstructL |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CMRImage::ConstructL( NMRBitmapManager::TMRBitmapId aBitmapId, |
|
78 TBool aIsMaskIcon ) |
|
79 { |
|
80 if( aIsMaskIcon ) |
|
81 { |
|
82 CreateMaskIconL( aBitmapId ); |
|
83 } |
|
84 else |
|
85 { |
|
86 CreateIconL( aBitmapId ); |
|
87 } |
|
88 } |
|
89 |
|
90 // --------------------------------------------------------------------------- |
|
91 // CMRImage::CreateIconL |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CMRImage::CreateIconL( NMRBitmapManager::TMRBitmapId aBitmapId ) |
|
95 { |
|
96 CFbsBitmap* bitMap( NULL ); |
|
97 CFbsBitmap* bitMapMask( NULL ); |
|
98 TSize sz( Rect().Size() ); |
|
99 User::LeaveIfError( |
|
100 NMRBitmapManager::GetSkinBasedBitmap( |
|
101 aBitmapId, |
|
102 bitMap, bitMapMask, sz ) ); |
|
103 |
|
104 if( bitMap && bitMapMask ) |
|
105 { |
|
106 SetPictureOwnedExternally( EFalse ); |
|
107 SetBrushStyle( CWindowGc::ENullBrush ); |
|
108 SetPicture( bitMap, bitMapMask ); |
|
109 } |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CMRImage::CreateMaskIconL |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CMRImage::CreateMaskIconL( NMRBitmapManager::TMRBitmapId aBitmapId ) |
|
117 { |
|
118 CFbsBitmap* bitMap( NULL ); |
|
119 CFbsBitmap* bitMapMask( NULL ); |
|
120 TSize sz( Rect().Size() ); |
|
121 User::LeaveIfError( |
|
122 NMRBitmapManager::GetMaskIconBitmap( |
|
123 aBitmapId, |
|
124 bitMap, bitMapMask, |
|
125 EAknsCIQsnIconColorsCG13, |
|
126 sz ) ); |
|
127 |
|
128 if( bitMap && bitMapMask ) |
|
129 { |
|
130 SetPictureOwnedExternally( EFalse ); |
|
131 SetBrushStyle( CWindowGc::ENullBrush ); |
|
132 SetPicture( bitMap, bitMapMask ); |
|
133 } |
|
134 } |
|
135 |
|
136 // EOF |