|
1 /* |
|
2 * Copyright (c) 2009-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: Header UI control of the mycard plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ccappmycardheadercontrol.h" |
|
20 #include "ccappmycardcommon.h" |
|
21 #include <eikimage.h> |
|
22 #include <eiklabel.h> |
|
23 #include <AknIconUtils.h> |
|
24 #include <AknUtils.h> |
|
25 #include <avkon.mbg> |
|
26 #include <aknstyluspopupmenu.h> |
|
27 #include <ccappmycardpluginrsc.rsg> |
|
28 #include <barsread.h> |
|
29 #include <touchfeedback.h> |
|
30 #include "ccappmycardplugin.h" |
|
31 #include <aknlayoutscalable_apps.cdl.h> |
|
32 #include "spbcontentprovider.h" |
|
33 #include <CPbk2ApplicationServices.h> |
|
34 #include <featmgr.h> |
|
35 #include <AknIconUtils.h> |
|
36 #include "ccappstatuscontrol.h" |
|
37 #include <phonebook2ece.mbg> |
|
38 #include <gulicon.h> |
|
39 #include <layoutmetadata.cdl.h> |
|
40 |
|
41 namespace { |
|
42 /// Amount of child UI components |
|
43 const TInt KControlCount = 4; |
|
44 _LIT( KMyCardIconDefaultFileName, "\\resource\\apps\\phonebook2ece.mif" ); |
|
45 } |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // CCCAppMyCardHeaderControl::NewL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 CCCAppMyCardHeaderControl* CCCAppMyCardHeaderControl::NewL( |
|
52 MCCAStatusControlObserver& aObserver ) |
|
53 { |
|
54 CCCAppMyCardHeaderControl* self = new(ELeave) CCCAppMyCardHeaderControl(); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(aObserver); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CCCAppMyCardHeaderControl::CCCAppMyCardHeaderControl |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CCCAppMyCardHeaderControl::CCCAppMyCardHeaderControl() |
|
66 { |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CCCAppMyCardHeaderControl::ConstructL |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 void CCCAppMyCardHeaderControl::ConstructL( |
|
74 MCCAStatusControlObserver& aObserver ) |
|
75 { |
|
76 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardHeaderControl::ConstructL()")); |
|
77 |
|
78 iAppServices = CPbk2ApplicationServices::InstanceL(); |
|
79 CVPbkContactManager& contactManager = iAppServices->ContactManager(); |
|
80 |
|
81 FeatureManager::InitializeLibL(); |
|
82 if( FeatureManager::FeatureSupported( KFeatureIdFfContactsSocial ) ) |
|
83 { |
|
84 iProvider = CSpbContentProvider::NewL( contactManager, |
|
85 iAppServices->StoreManager(), |
|
86 CSpbContentProvider::EStatusMessage | CSpbContentProvider::EServiceIcon ); |
|
87 iStatusControl = CCCAppStatusControl::NewL( *iProvider, aObserver ); |
|
88 iStatusControl->SetContainerWindowL( *this ); |
|
89 iStatusControl->MakeVisible( EFalse ); |
|
90 |
|
91 CFbsBitmap* bmp = NULL; |
|
92 CFbsBitmap* bmpMask = NULL; |
|
93 |
|
94 AknIconUtils::CreateIconL( |
|
95 bmp, |
|
96 bmpMask, |
|
97 KMyCardIconDefaultFileName, |
|
98 EMbmPhonebook2eceQgn_prop_wml_bm_ovi, |
|
99 EMbmPhonebook2eceQgn_prop_wml_bm_ovi_mask ); |
|
100 |
|
101 CGulIcon* guiIcon = CGulIcon::NewL( bmp, bmpMask ); |
|
102 iStatusControl->SetDefaultStatusL( R_QTN_MYCARD_DEFAULT_STATUS, guiIcon ); |
|
103 } |
|
104 FeatureManager::UnInitializeLib(); |
|
105 |
|
106 |
|
107 // Create portrait image |
|
108 iPortraitImage = new(ELeave) CEikImage; |
|
109 iPortraitImage->SetAlignment(EHCenterVCenter); |
|
110 iPortraitImage->SetBrushStyle( CGraphicsContext::ENullBrush ); // transparent |
|
111 iPortraitImage->SetPictureOwnedExternally( ETrue ); |
|
112 |
|
113 // Create my name label |
|
114 iLabel1 = new(ELeave) CEikLabel; |
|
115 iLabel1->SetAlignment(EHLeftVCenter); |
|
116 iLabel1->SetTextL( KNullDesC ); // CEikLabel will panic without text |
|
117 iLabel2 = new(ELeave) CEikLabel; |
|
118 iLabel2->SetAlignment(EHLeftVCenter); |
|
119 iLabel2->SetTextL( KNullDesC ); |
|
120 |
|
121 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardHeaderControl::ConstructL()")); |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CCCAppMyCardHeaderControl::~CCCAppMyCardHeaderControl |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 CCCAppMyCardHeaderControl::~CCCAppMyCardHeaderControl() |
|
129 { |
|
130 delete iStatusControl; |
|
131 delete iProvider; |
|
132 Release( iAppServices ); |
|
133 delete iPortraitImage; |
|
134 delete iLabel1; |
|
135 delete iLabel2; |
|
136 delete iPortraitBitmap; |
|
137 delete iPortraitMask; |
|
138 iObserverArray.Reset(); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CCCAppMyCardHeaderControl::CountComponentControls |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 TInt CCCAppMyCardHeaderControl::CountComponentControls() const |
|
146 { |
|
147 if(iStatusControl) |
|
148 { |
|
149 return KControlCount; |
|
150 } |
|
151 else |
|
152 { |
|
153 return (KControlCount - 1); |
|
154 } |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CCCAppMyCardHeaderControl::ComponentControl |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 CCoeControl* CCCAppMyCardHeaderControl::ComponentControl( TInt aIndex ) const |
|
162 { |
|
163 switch( aIndex ) |
|
164 { |
|
165 case 0: |
|
166 { |
|
167 return iPortraitImage; |
|
168 } |
|
169 case 1: |
|
170 { |
|
171 return iLabel1; |
|
172 } |
|
173 case 2: |
|
174 { |
|
175 return iLabel2; |
|
176 } |
|
177 case 3: |
|
178 { |
|
179 return iStatusControl; |
|
180 } |
|
181 } |
|
182 return NULL; |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CCCAppMyCardHeaderControl::SizeChanged |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CCCAppMyCardHeaderControl::SizeChanged() |
|
190 { |
|
191 const TRect rect(Rect()); |
|
192 /** |
|
193 * Option0, Parent Variety :1 (w button, lsc) |
|
194 * Option2, Parent Variety :3 (w/o button, lsc) |
|
195 * Option0, Parent Variety :0 (w button, prt) |
|
196 * Option1, Parent Variety :2 (w/o button, prt) |
|
197 */ |
|
198 |
|
199 const TBool isLandscape( Layout_Meta_Data::IsLandscapeOrientation() ); |
|
200 |
|
201 // (w/o button) |
|
202 TInt option( isLandscape ? 2 : 1 ); |
|
203 if( iStatusControl && iStatusControl->IsVisible() ) |
|
204 { |
|
205 // (w button) |
|
206 if( isLandscape ) |
|
207 { |
|
208 option = 0; |
|
209 } |
|
210 else |
|
211 { |
|
212 option = 0; |
|
213 } |
|
214 |
|
215 TAknWindowComponentLayout statusPaneLayout( |
|
216 AknLayoutScalable_Apps::phob2_cc_button_pane( option ) ); |
|
217 |
|
218 TAknLayoutRect statusPaneLayoutRect; |
|
219 statusPaneLayoutRect.LayoutRect( rect, statusPaneLayout.LayoutLine() ); |
|
220 TRect statusPaneRect( statusPaneLayoutRect.Rect() ); |
|
221 iStatusControl->SetRect( statusPaneRect ); |
|
222 } |
|
223 |
|
224 |
|
225 // image |
|
226 TAknWindowComponentLayout imageLayout( |
|
227 AknLayoutScalable_Apps::phob2_cc_data_pane_g1( option ) ); |
|
228 |
|
229 TAknLayoutRect imageLayoutRect; |
|
230 imageLayoutRect.LayoutRect( rect, imageLayout.LayoutLine() ); |
|
231 TRect imageRect( imageLayoutRect.Rect() ); |
|
232 |
|
233 iPortraitImage->SetRect( imageRect ); |
|
234 iPortraitImageSize = imageRect.Size(); |
|
235 |
|
236 // label 1 |
|
237 AknLayoutUtils::LayoutLabel( |
|
238 iLabel1, |
|
239 rect, |
|
240 AknLayoutScalable_Apps::phob2_cc_data_pane_t1( option ) ); |
|
241 |
|
242 // label 2 |
|
243 AknLayoutUtils::LayoutLabel( |
|
244 iLabel2, |
|
245 rect, |
|
246 AknLayoutScalable_Apps::phob2_cc_data_pane_t2( option ) ); |
|
247 |
|
248 // resize images for new resolution |
|
249 if( iPortraitBitmap ) |
|
250 { |
|
251 AknIconUtils::SetSize( iPortraitBitmap, |
|
252 iPortraitImageSize, EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
253 } |
|
254 if( iPortraitMask ) |
|
255 { |
|
256 AknIconUtils::SetSize( iPortraitMask, |
|
257 iPortraitImageSize, EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
258 } |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CCCAppMyCardHeaderControl::HandlePointerEventL |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 void CCCAppMyCardHeaderControl::HandlePointerEventL( |
|
266 const TPointerEvent& aPointerEvent) |
|
267 { |
|
268 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
269 switch(aPointerEvent.iType) |
|
270 { |
|
271 case TPointerEvent::EButton1Down: |
|
272 |
|
273 // Image selection popup |
|
274 if ( iPortraitImage->Rect().Contains(aPointerEvent.iPosition) ) |
|
275 { |
|
276 // Show the feedback |
|
277 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
278 if ( feedback ) |
|
279 { |
|
280 feedback->InstantFeedback( ETouchFeedbackBasic ); |
|
281 } |
|
282 // check the pointer position so that menu can be opened |
|
283 // to the correct place |
|
284 NotifyObservers( aPointerEvent.iPosition ); |
|
285 } |
|
286 break; |
|
287 default: |
|
288 break; |
|
289 } |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // CCCAppMyCardHeaderControl::SetContainerWindowL |
|
294 // --------------------------------------------------------------------------- |
|
295 // |
|
296 void CCCAppMyCardHeaderControl::SetContainerWindowL( |
|
297 const CCoeControl& aContainer ) |
|
298 { |
|
299 CCoeControl::SetContainerWindowL( aContainer ); |
|
300 |
|
301 // Assign window for child controls too |
|
302 TInt childCount = CountComponentControls(); |
|
303 for( TInt i = 0; i < childCount; ++i ) |
|
304 { |
|
305 ComponentControl( i )->SetContainerWindowL( *this ); |
|
306 } |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CCCAppMyCardHeaderControl::SetPortraitIcon |
|
311 // --------------------------------------------------------------------------- |
|
312 // |
|
313 void CCCAppMyCardHeaderControl::SetPortraitIcon( |
|
314 CFbsBitmap* aImage, CFbsBitmap* aMask ) |
|
315 { |
|
316 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardHeaderControl::SetPortraitIcon()")); |
|
317 |
|
318 delete iPortraitBitmap; |
|
319 iPortraitBitmap = aImage; |
|
320 |
|
321 delete iPortraitMask; |
|
322 iPortraitMask = aMask; |
|
323 |
|
324 // resize and assign |
|
325 if( iPortraitImageSize != TSize() ) |
|
326 { |
|
327 AknIconUtils::SetSize( |
|
328 iPortraitBitmap, |
|
329 iPortraitImageSize, |
|
330 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
331 |
|
332 AknIconUtils::SetSize( |
|
333 iPortraitMask, |
|
334 iPortraitImageSize, |
|
335 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
336 } |
|
337 |
|
338 iPortraitImage->SetPicture( iPortraitBitmap, iPortraitMask ); |
|
339 iPortraitImage->DrawDeferred(); |
|
340 |
|
341 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardHeaderControl::SetPortraitIcon()")); |
|
342 } |
|
343 |
|
344 // --------------------------------------------------------------------------- |
|
345 // CCCAppMyCardHeaderControl::SetPortraitBitmapL |
|
346 // --------------------------------------------------------------------------- |
|
347 // |
|
348 void CCCAppMyCardHeaderControl::SetPortraitBitmapL( CFbsBitmap* aImage ) |
|
349 { |
|
350 CCA_DP(KMyCardLogFile, CCA_L("->CCCAppMyCardHeaderControl::SetPortraitBitmapL()")); |
|
351 |
|
352 // create scalable image |
|
353 aImage = AknIconUtils::CreateIconL( aImage ); |
|
354 delete iPortraitBitmap; |
|
355 iPortraitBitmap = aImage; |
|
356 |
|
357 delete iPortraitMask; |
|
358 iPortraitMask = NULL; |
|
359 |
|
360 // resize and assign |
|
361 if( iPortraitImageSize != TSize() ) |
|
362 { |
|
363 AknIconUtils::SetSize( |
|
364 iPortraitBitmap, |
|
365 iPortraitImageSize, |
|
366 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
367 |
|
368 } |
|
369 |
|
370 iPortraitImage->SetPicture( iPortraitBitmap ); |
|
371 iPortraitImage->DrawDeferred(); |
|
372 |
|
373 CCA_DP(KMyCardLogFile, CCA_L("<-CCCAppMyCardHeaderControl::SetPortraitBitmapL()")); |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------------------------- |
|
377 // CCCAppMyCardHeaderControl::SetNameTextL |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 void CCCAppMyCardHeaderControl::SetLabel1TextL( const TDesC& aTxt ) |
|
381 { |
|
382 iLabel1->SetTextL( aTxt ); |
|
383 iLabel1->CropText(); |
|
384 iLabel1->DrawDeferred(); |
|
385 } |
|
386 |
|
387 // --------------------------------------------------------------------------- |
|
388 // CCCAppMyCardHeaderControl::SetLabel2TextL |
|
389 // --------------------------------------------------------------------------- |
|
390 // |
|
391 void CCCAppMyCardHeaderControl::SetLabel2TextL( const TDesC& aTxt ) |
|
392 { |
|
393 iLabel2->SetTextL( aTxt ); |
|
394 iLabel2->CropText(); |
|
395 iLabel2->DrawDeferred(); |
|
396 } |
|
397 |
|
398 // --------------------------------------------------------------------------- |
|
399 // CCCAppMyCardHeaderControl::AddObserverL |
|
400 // --------------------------------------------------------------------------- |
|
401 // |
|
402 void CCCAppMyCardHeaderControl::AddObserverL( |
|
403 MMyCardHeaderControlObserver* aObserver ) |
|
404 { |
|
405 if( aObserver ) |
|
406 { |
|
407 iObserverArray.AppendL( aObserver ); |
|
408 } |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------------------------- |
|
412 // CCCAppMyCardHeaderControl::NotifyObservers |
|
413 // --------------------------------------------------------------------------- |
|
414 // |
|
415 void CCCAppMyCardHeaderControl::NotifyObservers( TPoint aPoint) |
|
416 { |
|
417 const TInt count(iObserverArray.Count()); |
|
418 for(TInt i = 0 ; i < count ; ++i) |
|
419 { |
|
420 TRAP_IGNORE( iObserverArray[i]->MyCardHeaderControlClickL( aPoint ) ); |
|
421 } |
|
422 } |
|
423 // End of file |