58 { |
58 { |
59 // Create the header image |
59 // Create the header image |
60 iImage = new (ELeave) CEikImage(); |
60 iImage = new (ELeave) CEikImage(); |
61 iImage->SetPictureOwnedExternally(ETrue); |
61 iImage->SetPictureOwnedExternally(ETrue); |
62 iImage->SetBrushStyle( CGraphicsContext::ENullBrush ); // transparent |
62 iImage->SetBrushStyle( CGraphicsContext::ENullBrush ); // transparent |
63 iImage->SetAlignment(EHCenterVCenter); |
63 iImage->SetAlignment(EHCenterVCenter); |
|
64 |
|
65 //Favorite Icon |
|
66 iFavContactIcon = new (ELeave) CEikImage(); |
|
67 iFavContactIcon->SetBrushStyle( CGraphicsContext::ENullBrush ); // transparent |
|
68 iFavContactIcon->SetAlignment(EHCenterVCenter); |
64 |
69 |
65 // Create the header labels |
70 // Create the header labels |
66 for (TInt i=0; i < KLabelLineCount; i++) |
71 for (TInt i=0; i < KLabelLineCount; i++) |
67 { |
72 { |
68 CEikLabel* label = new(ELeave) CEikLabel; |
73 CEikLabel* label = new(ELeave) CEikLabel; |
82 // Destructor |
87 // Destructor |
83 // --------------------------------------------------------------------------- |
88 // --------------------------------------------------------------------------- |
84 // |
89 // |
85 CCCAppCommLauncherHeaderControl::~CCCAppCommLauncherHeaderControl() |
90 CCCAppCommLauncherHeaderControl::~CCCAppCommLauncherHeaderControl() |
86 { |
91 { |
|
92 delete iFavContactIcon; |
87 delete iContactImageFullName; |
93 delete iContactImageFullName; |
88 delete iContactThumbnailData; |
94 delete iContactThumbnailData; |
|
95 if ( iStoreContactImageFullName ) |
|
96 { |
|
97 delete iStoreContactImageFullName; |
|
98 iStoreContactImageFullName = NULL; |
|
99 } |
89 |
100 |
90 iCmsContactFields.Close(); |
101 iCmsContactFields.Close(); |
91 iLabels.ResetAndDestroy(); |
102 iLabels.ResetAndDestroy(); |
92 if (iImage) |
103 if (iImage) |
93 { |
104 { |
126 // From CCoeControl, returns the number of child controls to the framework |
137 // From CCoeControl, returns the number of child controls to the framework |
127 // --------------------------------------------------------------------------- |
138 // --------------------------------------------------------------------------- |
128 // |
139 // |
129 TInt CCCAppCommLauncherHeaderControl::CountComponentControls() const |
140 TInt CCCAppCommLauncherHeaderControl::CountComponentControls() const |
130 { |
141 { |
131 return 1 + iLabels.Count(); |
142 return 2 + iLabels.Count(); // iImage, iFavContactIcon |
132 } |
143 } |
133 |
144 |
134 // --------------------------------------------------------------------------- |
145 // --------------------------------------------------------------------------- |
135 // From CCoeControl, returns the child controls to the framework by index |
146 // From CCoeControl, returns the child controls to the framework by index |
136 // --------------------------------------------------------------------------- |
147 // --------------------------------------------------------------------------- |
137 // |
148 // |
138 CCoeControl* CCCAppCommLauncherHeaderControl::ComponentControl(TInt aIndex) const |
149 CCoeControl* CCCAppCommLauncherHeaderControl::ComponentControl(TInt aIndex) const |
139 { |
150 { |
|
151 TInt imageControl = 2; // iImage, iFavContactIcon |
|
152 |
140 if (aIndex == 0) |
153 if (aIndex == 0) |
141 { |
154 { |
142 return iImage; |
155 return iImage; |
143 } |
156 } |
144 else if (aIndex - 1 < iLabels.Count()) |
157 else if (aIndex == 1) |
145 { |
158 { |
146 return iLabels[aIndex-1]; |
159 return iFavContactIcon; |
|
160 } |
|
161 else if (aIndex - imageControl < iLabels.Count()) |
|
162 { |
|
163 return iLabels[aIndex-imageControl]; |
147 } |
164 } |
148 else |
165 else |
149 { |
166 { |
150 return NULL; |
167 return NULL; |
151 } |
168 } |
154 // --------------------------------------------------------------------------- |
171 // --------------------------------------------------------------------------- |
155 // From CCoeControl, called when the control's size changes, handles portrait-landscape switch |
172 // From CCoeControl, called when the control's size changes, handles portrait-landscape switch |
156 // --------------------------------------------------------------------------- |
173 // --------------------------------------------------------------------------- |
157 // |
174 // |
158 void CCCAppCommLauncherHeaderControl::SizeChanged() |
175 void CCCAppCommLauncherHeaderControl::SizeChanged() |
159 { |
176 { |
160 const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
177 const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
161 const TRect rect(Rect()); |
178 const TRect rect(Rect()); |
162 |
179 |
163 /** |
180 /** |
164 * Option0 (w button, lsc) |
181 * Option0 (w button, lsc) |
233 // |
252 // |
234 void CCCAppCommLauncherHeaderControl::SetContainerWindowL(const CCoeControl& aContainer) |
253 void CCCAppCommLauncherHeaderControl::SetContainerWindowL(const CCoeControl& aContainer) |
235 { |
254 { |
236 CCoeControl::SetContainerWindowL(aContainer); |
255 CCoeControl::SetContainerWindowL(aContainer); |
237 iImage->SetContainerWindowL(aContainer); |
256 iImage->SetContainerWindowL(aContainer); |
|
257 iFavContactIcon->SetContainerWindowL(aContainer); |
|
258 |
238 for (TInt i=0; i < iLabels.Count(); i++) |
259 for (TInt i=0; i < iLabels.Count(); i++) |
239 { |
260 { |
240 iLabels[i]->SetContainerWindowL(aContainer); |
261 iLabels[i]->SetContainerWindowL(aContainer); |
241 } |
262 } |
242 } |
263 } |
268 if ( data.Length() > 0 ) |
289 if ( data.Length() > 0 ) |
269 { |
290 { |
270 delete iContactImageFullName; |
291 delete iContactImageFullName; |
271 iContactImageFullName = NULL; |
292 iContactImageFullName = NULL; |
272 iContactImageFullName = data.AllocL(); |
293 iContactImageFullName = data.AllocL(); |
|
294 |
|
295 if ( iStoreContactImageFullName ) |
|
296 { |
|
297 delete iStoreContactImageFullName; |
|
298 iStoreContactImageFullName = NULL; |
|
299 } |
|
300 iStoreContactImageFullName = data.AllocL(); |
273 } |
301 } |
274 } |
302 } |
275 else if ( aContactField.Type() == CCmsContactFieldItem::ECmsThumbnailPic ) |
303 else if ( aContactField.Type() == CCmsContactFieldItem::ECmsThumbnailPic ) |
276 { |
304 { |
277 TPtrC8 data( aContactField.ItemL( 0 ).BinaryData() ); |
305 TPtrC8 data( aContactField.ItemL( 0 ).BinaryData() ); |
314 } |
342 } |
315 for (TInt i = 0; i < iLabels.Count(); i++) |
343 for (TInt i = 0; i < iLabels.Count(); i++) |
316 { |
344 { |
317 iLabels[i]->SetTextL(iTextOrder->GetTextForRow(i)); |
345 iLabels[i]->SetTextL(iTextOrder->GetTextForRow(i)); |
318 } |
346 } |
|
347 |
|
348 //Find whether the Contact is a Favorite Contact |
|
349 if ( iPlugin.IsTopContactL() ) |
|
350 { |
|
351 //Create the Favorite Icon |
|
352 CFbsBitmap* bmp = NULL; |
|
353 CFbsBitmap* mask = NULL; |
|
354 |
|
355 AknIconUtils::CreateIconLC( |
|
356 bmp, mask, KPbk2ECEIconFileName, |
|
357 EMbmPhonebook2eceQgn_prop_pb_topc, EMbmPhonebook2eceQgn_prop_pb_topc_mask ); |
|
358 |
|
359 //Create the header image |
|
360 iFavContactIcon->SetPicture( bmp, mask ); |
|
361 CleanupStack::Pop( 2 ); // bmp, mask |
|
362 |
|
363 FavoriteIconSizeChanged(); |
|
364 } |
|
365 else |
|
366 { |
|
367 iFavContactIcon->SetPicture(NULL, NULL); |
|
368 } |
|
369 |
319 DrawDeferred(); |
370 DrawDeferred(); |
320 } |
371 } |
321 |
372 |
322 void CCCAppCommLauncherHeaderControl::BitmapReadyL( CFbsBitmap* aBitmap ) |
373 void CCCAppCommLauncherHeaderControl::BitmapReadyL( CFbsBitmap* aBitmap ) |
323 { |
374 { |
324 SetBitmap(aBitmap); |
375 SetBitmap(aBitmap); |
325 } |
376 } |
326 |
377 |
327 // --------------------------------------------------------------------------- |
378 // --------------------------------------------------------------------------- |
328 // Sets the bitmap shown in the header image |
379 // Sets the bitmap shown in the header image |
329 // --------------------------------------------------------------------------- |
380 // --------------------------------------------------------------------------- |
340 delete iMask; |
391 delete iMask; |
341 iMask = NULL; |
392 iMask = NULL; |
342 } |
393 } |
343 iBitmap = aBmp; |
394 iBitmap = aBmp; |
344 iImage->SetPicture(aBmp, NULL); |
395 iImage->SetPicture(aBmp, NULL); |
345 iImage->DrawDeferred(); |
396 iImage->DrawDeferred(); |
346 } |
397 } |
347 |
398 |
348 // --------------------------------------------------------------------------- |
399 // --------------------------------------------------------------------------- |
349 // Clears the header texts to blank |
400 // Clears the header texts to blank |
350 // --------------------------------------------------------------------------- |
401 // --------------------------------------------------------------------------- |
494 CleanupStack::PopAndDestroy(); // reader |
545 CleanupStack::PopAndDestroy(); // reader |
495 } |
546 } |
496 |
547 |
497 if( iHasContactImage ) |
548 if( iHasContactImage ) |
498 { |
549 { |
499 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusViewImageCmd, EFalse); |
|
500 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, EFalse); |
550 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, EFalse); |
501 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusRemoveImageCmd, EFalse); |
551 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusRemoveImageCmd, EFalse); |
502 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusAddImageCmd, ETrue); |
552 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusAddImageCmd, ETrue); |
|
553 |
|
554 // If the image has been deleted in the memory, "view image" should be hidden. |
|
555 RFs& fs( iCoeEnv->FsSession() ); |
|
556 TEntry entry; |
|
557 iImageSelectionPopup->SetItemDimmed( ECCAppCommLauncherStylusViewImageCmd, |
|
558 ( fs.Entry( *iStoreContactImageFullName , entry ) == KErrNone ) ? EFalse : ETrue ); |
503 } |
559 } |
504 else |
560 else |
505 { |
561 { |
506 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusViewImageCmd, ETrue); |
562 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusViewImageCmd, ETrue); |
507 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, ETrue); |
563 iImageSelectionPopup->SetItemDimmed(ECCAppCommLauncherStylusChangeImageCmd, ETrue); |
590 TBool ret = contactRelocator->IsPhoneMemoryInConfigurationL(); |
646 TBool ret = contactRelocator->IsPhoneMemoryInConfigurationL(); |
591 CleanupStack::PopAndDestroy( contactRelocator ); |
647 CleanupStack::PopAndDestroy( contactRelocator ); |
592 return ret; |
648 return ret; |
593 } |
649 } |
594 |
650 |
|
651 // -------------------------------------------------------------------------- |
|
652 // CCCAppCommLauncherHeaderControl::OfferKeyEventL |
|
653 // -------------------------------------------------------------------------- |
|
654 // |
595 TKeyResponse CCCAppCommLauncherHeaderControl::OfferKeyEventL( |
655 TKeyResponse CCCAppCommLauncherHeaderControl::OfferKeyEventL( |
596 const TKeyEvent& aKeyEvent, TEventCode /*aType*/) |
656 const TKeyEvent& aKeyEvent, TEventCode /*aType*/) |
597 { |
657 { |
598 TKeyResponse ret( EKeyWasNotConsumed ); |
658 TKeyResponse ret( EKeyWasNotConsumed ); |
599 |
659 |
608 } |
668 } |
609 } |
669 } |
610 return ret; |
670 return ret; |
611 } |
671 } |
612 |
672 |
|
673 // -------------------------------------------------------------------------- |
|
674 // CCCAppCommLauncherHeaderControl::ProcessContactImageDisplayL |
|
675 // -------------------------------------------------------------------------- |
|
676 // |
613 void CCCAppCommLauncherHeaderControl::ProcessContactImageDisplayL() |
677 void CCCAppCommLauncherHeaderControl::ProcessContactImageDisplayL() |
614 { |
678 { |
615 iHasContactImage = EFalse; |
679 iHasContactImage = EFalse; |
616 |
680 |
617 delete iImageDecoding; |
681 delete iImageDecoding; |
634 delete iContactImageFullName; |
698 delete iContactImageFullName; |
635 iContactImageFullName = NULL; |
699 iContactImageFullName = NULL; |
636 delete iContactThumbnailData; |
700 delete iContactThumbnailData; |
637 iContactThumbnailData = NULL; |
701 iContactThumbnailData = NULL; |
638 } |
702 } |
|
703 |
|
704 // -------------------------------------------------------------------------- |
|
705 // CCCAppCommLauncherHeaderControl::FavoriteIconSizeChanged |
|
706 // -------------------------------------------------------------------------- |
|
707 // |
|
708 void CCCAppCommLauncherHeaderControl::FavoriteIconSizeChanged() |
|
709 { |
|
710 //Set the size for the Favorite Icon |
|
711 //This code must be in Sync with SizeChanged() code |
|
712 const TInt isLandscape = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; |
|
713 const TRect rect(Rect()); |
|
714 |
|
715 // (w/o button) |
|
716 TInt option( isLandscape ? 2 : 1 ); |
|
717 if( iStatusButtonVisibility ) |
|
718 { |
|
719 // (w button) |
|
720 if( isLandscape ) |
|
721 { |
|
722 option = 0; |
|
723 } |
|
724 else |
|
725 { |
|
726 option = 0; |
|
727 } |
|
728 } |
|
729 |
|
730 AknLayoutUtils::LayoutImage( |
|
731 iFavContactIcon, rect, AknLayoutScalable_Apps::phob2_cc_data_pane_g2(option)); |
|
732 |
|
733 } |
|
734 |
|
735 //End of File |