|
1 /* |
|
2 * Copyright (c) 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: Call status indicator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "BMBubbleManager.h" |
|
20 #include "BMMainPaneControl.h" |
|
21 #include "BMCustomManager.h" |
|
22 #include "BMBubbleHeader.h" |
|
23 #include "BMUtils.h" |
|
24 #include "BMCallObjectManager.h" |
|
25 #include "BMBubbleImageManager.h" |
|
26 |
|
27 #include <telbubblecallimage.h> |
|
28 #include <AknIconUtils.h> |
|
29 #include <layoutmetadata.cdl.h> |
|
30 |
|
31 // --------------------------------------------------------------------------- |
|
32 // C++ constructor |
|
33 // --------------------------------------------------------------------------- |
|
34 // |
|
35 CBubbleMainPaneControl::CBubbleMainPaneControl( |
|
36 CBubbleManager& aBubbleManager, |
|
37 CBubbleCallObjectManager& aCallObjectManager ) : |
|
38 iBubbleManager( aBubbleManager ), |
|
39 iCallObjectManager ( aCallObjectManager ) |
|
40 { |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // ConstructL |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 void CBubbleMainPaneControl::ConstructL() |
|
48 { |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // NewL |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CBubbleMainPaneControl* CBubbleMainPaneControl::NewL( |
|
56 CBubbleManager& aBubbleManager, |
|
57 CBubbleCallObjectManager& aCallObjectManager ) |
|
58 { |
|
59 CBubbleMainPaneControl* self = |
|
60 new( ELeave ) CBubbleMainPaneControl( aBubbleManager, |
|
61 aCallObjectManager ); |
|
62 CleanupStack::PushL( self ); |
|
63 self->ConstructL(); |
|
64 CleanupStack::Pop( self ); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // Destructor |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CBubbleMainPaneControl::~CBubbleMainPaneControl() |
|
74 { |
|
75 } |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // ReadBubbleHeader |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CBubbleMainPaneControl::ReadBubbleHeader( |
|
82 const CBubbleHeader& aHeader ) |
|
83 { |
|
84 iBubble = aHeader.BubbleId(); |
|
85 iBitmap = aHeader.CallObjectImage(); |
|
86 iMask = aHeader.CallObjectImageMask(); |
|
87 iThreeLinedBubble = ( aHeader.CNAP().Length() > 0 ); |
|
88 |
|
89 if ( iBitmap ) |
|
90 { |
|
91 CFbsBitmap* bitmap; |
|
92 CFbsBitmap* mask; |
|
93 TBool bitmapOwnership; |
|
94 TBool maskOwnership; |
|
95 |
|
96 TRAPD(err, PrepareBitmapsL( bitmap, |
|
97 bitmapOwnership, |
|
98 mask, |
|
99 maskOwnership, |
|
100 aHeader.CallObjectImageType() == |
|
101 CBubbleHeader::EThemeImage ) ); |
|
102 |
|
103 if ( err ) |
|
104 { |
|
105 return; |
|
106 } |
|
107 |
|
108 iCallImage = iBubbleManager.CustomManager().ReserveCustomElement( |
|
109 aHeader, CTelBubbleCustomElement::ECallImage ); |
|
110 SizeChanged(); |
|
111 |
|
112 if ( iCallImage->ControlType() == |
|
113 CTelBubbleCustomElement::EBubbleCallImage ) |
|
114 { |
|
115 CTelBubbleCallImage* image = |
|
116 static_cast<CTelBubbleCallImage*> ( iCallImage->Control() ); |
|
117 image->SetImage( bitmap, EFalse, mask, maskOwnership ); |
|
118 } |
|
119 |
|
120 iIsUsed = ETrue; |
|
121 MakeVisible( ETrue ); |
|
122 } |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // PrepareBitmapsL |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CBubbleMainPaneControl::PrepareBitmapsL( |
|
130 CFbsBitmap*& aBitmap, |
|
131 TBool& aBitmapOwnership, |
|
132 CFbsBitmap*& aMask, |
|
133 TBool& aMaskOwnership, |
|
134 TBool aIsScalable ) |
|
135 { |
|
136 aBitmap = iBitmap; |
|
137 aMask = iMask; |
|
138 aBitmapOwnership = EFalse; |
|
139 aMaskOwnership = EFalse; |
|
140 |
|
141 if ( aIsScalable ) |
|
142 { |
|
143 // Switch to preloaded image when available |
|
144 if ( iCallObjectManager.CallThemeImageIcon() ) |
|
145 { |
|
146 aBitmap = iCallObjectManager.CallThemeImageIcon()->Bitmap(); |
|
147 aMask = iCallObjectManager.CallThemeImageIcon()->Mask(); |
|
148 } |
|
149 |
|
150 // Secure that SVG image is initialized |
|
151 User::LeaveIfError( AknIconUtils::SetSize( aBitmap, |
|
152 iBubbleManager.MainPaneImageRect().Size(), |
|
153 EAspectRatioPreservedSlice ) != KErrNone ); |
|
154 } |
|
155 |
|
156 TSize imageSize = aBitmap->SizeInPixels(); |
|
157 TSize tinyImageSize( iBubbleManager.MainPaneImageRect( ETrue ).Size() ); |
|
158 TBool fullScreen = !( ( imageSize.iWidth <= tinyImageSize.iWidth ) && |
|
159 ( imageSize.iHeight <= tinyImageSize.iHeight ) ); |
|
160 |
|
161 if ( iBubbleManager.IsTouchCallHandling() && |
|
162 fullScreen ) |
|
163 { |
|
164 // Attach display mask to image. |
|
165 CEikImage* displayMask = new( ELeave ) CEikImage; |
|
166 CleanupStack::PushL( displayMask ); |
|
167 |
|
168 TBMIcons maskId = |
|
169 Layout_Meta_Data::IsLandscapeOrientation() ? |
|
170 EQgn_indi_call4_image_mask_lsc : |
|
171 EQgn_indi_call4_image_mask_prt; |
|
172 |
|
173 iBubbleManager.ImageManager().SetBitmapToImage( |
|
174 displayMask, |
|
175 maskId ); |
|
176 |
|
177 User::LeaveIfError( AknIconUtils::SetSize( |
|
178 const_cast<CFbsBitmap*> (displayMask->Bitmap()), |
|
179 imageSize, |
|
180 EAspectRatioNotPreserved ) ); |
|
181 |
|
182 if ( aMask ) |
|
183 { |
|
184 // Combine display mask and image mask. |
|
185 CFbsBitmap* combinedMask = |
|
186 BubbleUtils::CreateCombinedMaskL( |
|
187 displayMask->Bitmap(), |
|
188 aMask ); |
|
189 aMask = combinedMask; |
|
190 } |
|
191 else |
|
192 { |
|
193 aMask = |
|
194 const_cast<CFbsBitmap*> ( displayMask->Bitmap()); |
|
195 displayMask->SetPictureOwnedExternally( ETrue ); |
|
196 } |
|
197 |
|
198 aMaskOwnership = ETrue; |
|
199 CleanupStack::PopAndDestroy( displayMask ); |
|
200 } |
|
201 } |
|
202 |
|
203 // --------------------------------------------------------------------------- |
|
204 // Reset |
|
205 // --------------------------------------------------------------------------- |
|
206 // |
|
207 void CBubbleMainPaneControl::Reset() |
|
208 { |
|
209 if ( iIsUsed ) |
|
210 { |
|
211 iIsUsed = EFalse; |
|
212 MakeVisible( EFalse ); |
|
213 iBubble = KErrNotFound; |
|
214 |
|
215 if ( iCallImage && |
|
216 iCallImage->ControlType() == |
|
217 CTelBubbleCustomElement::EBubbleCallImage ) |
|
218 { |
|
219 CTelBubbleCallImage* image = |
|
220 static_cast<CTelBubbleCallImage*> ( iCallImage->Control() ); |
|
221 image->SetImage( NULL, EFalse, NULL, EFalse ); |
|
222 } |
|
223 |
|
224 iBubbleManager.CustomManager().ReleaseCustomElement( iCallImage ); |
|
225 } |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // DrawBitmaps |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 void CBubbleMainPaneControl::DrawBitmaps( const TRect& aRect ) const |
|
233 { |
|
234 if ( iCallImage ) |
|
235 { |
|
236 // ToDo: propagate to components |
|
237 iCallImage->Control()->DrawForeground( aRect ); |
|
238 } |
|
239 } |
|
240 |
|
241 // --------------------------------------------------------------------------- |
|
242 // BubbleId |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 CBubbleManager::TBubbleId CBubbleMainPaneControl::BubbleId() const |
|
246 { |
|
247 return iBubble; |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // IsUsed |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 TBool CBubbleMainPaneControl::IsUsed() const |
|
255 { |
|
256 return iIsUsed; |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // SizeChanged |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 void CBubbleMainPaneControl::SizeChanged() |
|
264 { |
|
265 if ( iCallImage ) |
|
266 { |
|
267 iCallImage->Control()->SetRect( Rect() ); |
|
268 if ( iCallImage->ControlType() == |
|
269 CTelBubbleCustomElement::EBubbleCallImage ) |
|
270 { |
|
271 CTelBubbleCallImage* image = |
|
272 static_cast<CTelBubbleCallImage*> ( iCallImage->Control() ); |
|
273 TRect imageArea( iBubbleManager.MainPaneImageRect( |
|
274 ETrue, iThreeLinedBubble ) ); |
|
275 |
|
276 image->SetImagePlacingArea( imageArea ); |
|
277 } |
|
278 } |
|
279 } |
|
280 |
|
281 // END OF FILE |
|
282 |