|
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: |
|
15 * Methods for Class which loads Phonebook's icon into context pane. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPbkContextPaneIcon.h" // This class |
|
22 #include "PbkUID.h" |
|
23 #include <barsread.h> // TResourceReader |
|
24 #include <eikspane.h> // CEikStatusPane |
|
25 #include <avkon.hrh> // Status pane control UIDs |
|
26 #include <eikimage.h> // CEikImage |
|
27 #include <akncontext.h> // CAknContextPane |
|
28 #include <PbkView.rsg> // Phonebook view dll resource IDs |
|
29 #include <AknsSkinInstance.h> |
|
30 #include <AknUtils.h> |
|
31 #include <AknsUtils.h> |
|
32 #include <AknsControlContext.h> |
|
33 #include <aknconsts.h> // Context pane bitmap size |
|
34 #include <layoutmetadata.cdl.h> |
|
35 |
|
36 #include "PbkIconInfo.h" |
|
37 |
|
38 /// Unnamed namespace for local definitions |
|
39 namespace { |
|
40 |
|
41 static CEikImage* CopyL(const CEikImage& aSrc) |
|
42 { |
|
43 CEikImage* copy = new(ELeave) CEikImage; |
|
44 CleanupStack::PushL(copy); |
|
45 copy->SetPictureOwnedExternally(EFalse); |
|
46 CFbsBitmap* bitmap = new(ELeave) CFbsBitmap; |
|
47 copy->SetBitmap(bitmap); |
|
48 |
|
49 const CFbsBitmap* sourceBitmap = aSrc.Bitmap(); |
|
50 const CFbsBitmap* sourceMask = aSrc.Mask(); |
|
51 if (sourceBitmap) |
|
52 { |
|
53 User::LeaveIfError(bitmap->Duplicate(sourceBitmap->Handle())); |
|
54 } |
|
55 if (sourceMask) |
|
56 { |
|
57 CFbsBitmap* mask = new(ELeave) CFbsBitmap; |
|
58 // Null mask is not be copied. |
|
59 copy->SetMask(mask); |
|
60 User::LeaveIfError(mask->Duplicate(sourceMask->Handle())); |
|
61 } |
|
62 CleanupStack::Pop(); // copy |
|
63 return copy; |
|
64 } |
|
65 |
|
66 |
|
67 } // namespace |
|
68 |
|
69 // ================= MEMBER FUNCTIONS ======================= |
|
70 |
|
71 inline CPbkContextPaneIcon::CPbkContextPaneIcon() |
|
72 { |
|
73 } |
|
74 |
|
75 CPbkContextPaneIcon* CPbkContextPaneIcon::NewL(CEikonEnv& aEikonEnv) |
|
76 { |
|
77 CPbkContextPaneIcon* self = new(ELeave) CPbkContextPaneIcon; |
|
78 CleanupStack::PushL(self); |
|
79 self->StoreContextPaneIconL(aEikonEnv); |
|
80 self->SetPhonebookContextPaneIconL(); |
|
81 CleanupStack::Pop(self); |
|
82 return self; |
|
83 } |
|
84 |
|
85 CPbkContextPaneIcon::~CPbkContextPaneIcon() |
|
86 { |
|
87 RestoreContextPaneIcon(); |
|
88 } |
|
89 |
|
90 void CPbkContextPaneIcon::StoreContextPaneIconL(CEikonEnv& aEikonEnv) |
|
91 { |
|
92 CEikStatusPane* statusPane = aEikonEnv.AppUiFactory()->StatusPane(); |
|
93 if (statusPane && |
|
94 statusPane->PaneCapabilities(TUid::Uid(EEikStatusPaneUidContext)).IsPresent() && |
|
95 !Layout_Meta_Data::IsLandscapeOrientation()) |
|
96 { |
|
97 iContextPane = static_cast<CAknContextPane*> |
|
98 (statusPane->ControlL(TUid::Uid(EEikStatusPaneUidContext))); |
|
99 const CEikImage& picture = iContextPane->Picture(); |
|
100 if (picture.Bitmap() && |
|
101 picture.Bitmap()->Handle()) |
|
102 { |
|
103 iPreviousContextPaneIcon = CopyL(picture); |
|
104 } |
|
105 } |
|
106 } |
|
107 |
|
108 void CPbkContextPaneIcon::SetPhonebookContextPaneIconL() |
|
109 { |
|
110 if (iContextPane) |
|
111 { |
|
112 CFbsBitmap* bitmap = NULL; |
|
113 CFbsBitmap* mask = NULL; |
|
114 |
|
115 AknsUtils::CreateAppIconLC( AknsUtils::SkinInstance(), |
|
116 TUid::Uid(KPbkUID3), EAknsAppIconTypeContext, |
|
117 bitmap, mask ); |
|
118 |
|
119 CleanupStack::Pop(2); // bitmap, mask |
|
120 iContextPane->SetPicture(bitmap, mask); |
|
121 iContextPane->DrawNow(); |
|
122 } |
|
123 } |
|
124 |
|
125 void CPbkContextPaneIcon::RestoreContextPaneIcon() |
|
126 { |
|
127 if (iPreviousContextPaneIcon) |
|
128 { |
|
129 iContextPane->SetPicture(iPreviousContextPaneIcon); |
|
130 iPreviousContextPaneIcon = NULL; |
|
131 } |
|
132 } |
|
133 |
|
134 // End of File |