|
1 /* |
|
2 * Copyright (c) 2002 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 class CAknBitmap. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "AknBitmap.h" |
|
23 #include "AknIconSrvDef.h" |
|
24 #include "AknIconSrvTlsData.h" |
|
25 #include "AknIconPanic.h" |
|
26 #include "AknIconManager.h" |
|
27 |
|
28 // CONSTANTS |
|
29 |
|
30 // bit flags |
|
31 |
|
32 const TInt KFlagSharedByIconSrv = 0x0001; // Initialized and shared by AknIconSrv |
|
33 const TInt KFlagMaskDestroyed = 0x0002; // Mask has been destroyed for the bitmap |
|
34 const TInt KFlagIsAppIcon = 0x0004; |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CAknBitmap::CAknBitmap |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CAknBitmap::CAknBitmap() |
|
45 { |
|
46 } |
|
47 |
|
48 CAknBitmap* CAknBitmap::NewL( CAknIconManager& aManager ) |
|
49 { |
|
50 CAknBitmap* bitmap = new( ELeave ) CAknBitmap(); |
|
51 CleanupStack::PushL( bitmap ); |
|
52 bitmap->ConstructL( aManager ); |
|
53 CleanupStack::Pop(); |
|
54 return bitmap; |
|
55 } |
|
56 |
|
57 void CAknBitmap::ConstructL( CAknIconManager& aManager ) |
|
58 { |
|
59 AddToPointerListL(); |
|
60 |
|
61 // This needs to be done in the end of ConstructL. |
|
62 iManager = &aManager; |
|
63 iManager->Ref(); |
|
64 } |
|
65 |
|
66 TInt CAknBitmap::Extension_(TUint aExtensionId, TAny*& a0, TAny* a1) |
|
67 { |
|
68 if(aExtensionId == KExtensionId) |
|
69 { |
|
70 return KErrNone; |
|
71 } |
|
72 return CFbsBitmap::Extension_(aExtensionId, a0, a1); |
|
73 } |
|
74 |
|
75 // Destructor |
|
76 CAknBitmap::~CAknBitmap() |
|
77 { |
|
78 Reset(); |
|
79 |
|
80 if ( iManager ) |
|
81 { |
|
82 iManager->Unref(*this); |
|
83 } |
|
84 |
|
85 RemoveFromPointerList(); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAknBitmap::AddToPointerListL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CAknBitmap::AddToPointerListL() |
|
93 { |
|
94 // Add this pointer to the list of CAknBitmaps |
|
95 CAknIconSrvTlsData* data = static_cast<CAknIconSrvTlsData*>( Dll::Tls() ); |
|
96 |
|
97 __ASSERT_ALWAYS( data, |
|
98 User::Panic( KAknIconPanicCategory, EClientSessionNotConnected ) ); |
|
99 |
|
100 User::LeaveIfError( |
|
101 data->iPointers.InsertInOrder( |
|
102 reinterpret_cast<TInt>( static_cast<CFbsBitmap*>( this ) ) ) ); |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CAknBitmap::RemoveFromPointerList |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CAknBitmap::RemoveFromPointerList() |
|
110 { |
|
111 // Remove this pointer to the list of CAknBitmaps |
|
112 CAknIconSrvTlsData* data = static_cast<CAknIconSrvTlsData*>( Dll::Tls() ); |
|
113 |
|
114 __ASSERT_ALWAYS( data, |
|
115 User::Panic( KAknIconPanicCategory, EClientSessionNotConnected ) ); |
|
116 |
|
117 TInt index = data->iPointers.FindInOrder( |
|
118 reinterpret_cast<TInt>( static_cast<CFbsBitmap*>( this ) ) ); |
|
119 |
|
120 if ( index >= 0 ) |
|
121 { |
|
122 data->iPointers.Remove( index ); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CAknBitmap::SharedByIconSrv |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TBool CAknBitmap::SharedByIconSrv() |
|
131 { |
|
132 return iFlags & KFlagSharedByIconSrv; |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CAknBitmap::SetSharedByIconSrv |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CAknBitmap::SetSharedByIconSrv() |
|
140 { |
|
141 iFlags |= KFlagSharedByIconSrv; |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CAknBitmap::MaskDestroyed |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 TBool CAknBitmap::MaskDestroyed() |
|
149 { |
|
150 return iFlags & KFlagMaskDestroyed; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CAknBitmap::SetMaskDestroyed |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CAknBitmap::SetMaskDestroyed() |
|
158 { |
|
159 iFlags |= KFlagMaskDestroyed; |
|
160 } |
|
161 |
|
162 TBool CAknBitmap::IsAppIcon() const |
|
163 { |
|
164 return iFlags & KFlagIsAppIcon; |
|
165 } |
|
166 |
|
167 void CAknBitmap::SetAppIcon() |
|
168 { |
|
169 iFlags |= KFlagIsAppIcon; |
|
170 } |
|
171 |
|
172 void CAknBitmap::SetEnsuredSize(const TSize& aSize) |
|
173 { |
|
174 iEnsuredSize = aSize; |
|
175 } |
|
176 |
|
177 TBool CAknBitmap::IsEnsuredSize(const TSize& aSize) const |
|
178 { |
|
179 return iEnsuredSize == aSize; |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CAknBitmap::Reset |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CAknBitmap::Reset() |
|
187 { |
|
188 if ( iFlags & KFlagSharedByIconSrv ) |
|
189 { |
|
190 RAknIconSrvClient* client = RAknIconSrvClient::GetSession(); |
|
191 client->FreeBitmap( *this ); |
|
192 } |
|
193 |
|
194 CFbsBitmap::Reset(); |
|
195 |
|
196 iFlags &= ~(KFlagSharedByIconSrv|KFlagMaskDestroyed); |
|
197 } |
|
198 |
|
199 // End of File |