1 /* |
|
2 * Copyright (c) 2007 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: Active Palette 2 Generic Plugin* |
|
15 */ |
|
16 |
|
17 |
|
18 /** |
|
19 * @file ActivePalette2GenericPlugin.cpp |
|
20 * Active Palette 2 Generic Plugin |
|
21 */ |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include "ActivePalette2GenericPlugin.h" |
|
25 #include "ActivePalette2Const.h" |
|
26 #include "ActivePalette2Cfg.h" |
|
27 |
|
28 #include <gulicon.h> |
|
29 #include <AknIconUtils.h> |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // TAPGenericPluginParams::TAPGenericPluginParams() |
|
35 // C++ Constructor |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 TAP2GenericPluginParams::TAP2GenericPluginParams() : |
|
39 iResFileType(EGenericStdResFile), |
|
40 iGraphicsFileName(KNullDesC), |
|
41 iIconId(0), |
|
42 iMaskId(0), |
|
43 iTooltipText(KNullDesC), |
|
44 iMessageId(KActivePaletteNoDataInt), |
|
45 iMsgCustomParam(KActivePaletteNoDataInt) |
|
46 { |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // TAPGenericPluginParams::TAPGenericPluginParams() |
|
51 // C++ Constructor |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 EXPORT_C TAP2GenericPluginParams::TAP2GenericPluginParams(const TInt aResFileType, |
|
55 const TDesC& aGraphicsFileName, |
|
56 const TInt aIconId, |
|
57 const TInt aMaskId, |
|
58 const TDesC& aTooltipText, |
|
59 const TInt aMessageId, |
|
60 const TInt aMsgCustomParam): |
|
61 iResFileType(aResFileType), |
|
62 iGraphicsFileName(aGraphicsFileName), |
|
63 iIconId(aIconId), |
|
64 iMaskId(aMaskId), |
|
65 iTooltipText(aTooltipText), |
|
66 iMessageId(aMessageId), |
|
67 iMsgCustomParam(aMsgCustomParam) |
|
68 { |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // TAPGenericPluginIcon::TAPGenericPluginIcon() |
|
73 // C++ Constructor |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TAP2GenericPluginIcon::TAP2GenericPluginIcon() : |
|
77 iIconId(0), |
|
78 iMaskId(0) |
|
79 { |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // TAPGenericPluginIcon::TAPGenericPluginIcon() |
|
84 // C++ Constructor |
|
85 // ----------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C TAP2GenericPluginIcon::TAP2GenericPluginIcon(const TInt aIconId, |
|
88 const TInt aMaskId): |
|
89 iIconId(aIconId), |
|
90 iMaskId(aMaskId) |
|
91 { |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CAP2GenericPlugin::CAP2GenericPlugin() |
|
96 // C++ Constructor |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CAP2GenericPlugin::CAP2GenericPlugin(const NActivePalettePluginFactory::TPluginCreationParams& aCreationParams): |
|
100 CActivePalettePluginBase(aCreationParams) |
|
101 { |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CAP2GenericPlugin::CAP2GenericPlugin() |
|
106 // Destructor |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 CAP2GenericPlugin::~CAP2GenericPlugin() |
|
110 { |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CAP2GenericPlugin::HandleItemSelectedL() |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CAP2GenericPlugin::HandleItemSelectedL(void) |
|
118 { |
|
119 PluginObserver().SendMessage(iMessageId,iMsgCustomParam); |
|
120 PluginObserver().NotifyItemComplete(KActivePaletteNoDataInt); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CAP2GenericPlugin::ConstructL() |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CAP2GenericPlugin::ConstructL(const NActivePalettePluginFactory::TPluginCreationParams& aCreationParams, |
|
128 const TDesC8& aCustomDataDes, const TInt aCustomDataInt) |
|
129 { |
|
130 CActivePalettePluginBase::ConstructL(aCreationParams, aCustomDataDes, aCustomDataInt); |
|
131 |
|
132 iDimensions = aCreationParams.Dimensions(); |
|
133 |
|
134 // unpack creation params |
|
135 TAP2GenericPluginParams params; |
|
136 TPckg<TAP2GenericPluginParams> paramsPckg(params); |
|
137 if (aCustomDataDes.Length()) |
|
138 { |
|
139 paramsPckg.Copy(aCustomDataDes); |
|
140 SetIconAndTooltipL(params); |
|
141 } |
|
142 } |
|
143 |
|
144 // ----------------------------------------------------------------------------- |
|
145 // CAP2GenericPlugin::SetIconAndTooltipL() |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CAP2GenericPlugin::SetIconAndTooltipL(TAP2GenericPluginParams& aParams) |
|
149 { |
|
150 iMessageId = aParams.iMessageId; |
|
151 iMsgCustomParam = aParams.iMsgCustomParam; |
|
152 |
|
153 iGraphicsFileName = aParams.iGraphicsFileName; |
|
154 |
|
155 CGulIcon* icon = CreateIconL(aParams.iIconId, aParams.iMaskId); |
|
156 CleanupStack::PushL(icon); |
|
157 |
|
158 // Don't need to worry about the CGulIcon object from now on |
|
159 // as we are transferring ownership of it to the active palette. |
|
160 PluginObserver().SetItemIconAndTooltipL(icon, ETrue, aParams.iTooltipText); |
|
161 |
|
162 CleanupStack::Pop(icon); |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CAP2GenericPlugin::CreateIconL() |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 CGulIcon* CAP2GenericPlugin::CreateIconL(TInt aIconId, TInt aMaskId) |
|
170 { |
|
171 CFbsBitmap* picture; |
|
172 CFbsBitmap* mask; |
|
173 |
|
174 AknIconUtils::CreateIconLC(picture, mask, iGraphicsFileName, aIconId, aMaskId); |
|
175 AknIconUtils::SetSize(picture, iDimensions); |
|
176 AknIconUtils::SetSize(mask, iDimensions); |
|
177 |
|
178 CGulIcon* icon = CGulIcon::NewL(picture,mask); |
|
179 |
|
180 // Can now take the bitmaps off the cleanup stack as we have |
|
181 // transferred ownership to the CGulIcon object |
|
182 CleanupStack::Pop(mask); |
|
183 CleanupStack::Pop(picture); |
|
184 |
|
185 return icon; |
|
186 } |
|
187 |
|
188 // ----------------------------------------------------------------------------- |
|
189 // CAP2GenericPlugin::HandleMessageL() |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CAP2GenericPlugin::HandleMessageL(const TInt aMessageID, const TDesC8& aDataDes, const TInt /* aDataInt */) |
|
193 { |
|
194 switch (aMessageID) |
|
195 { |
|
196 case EAPGenericPluginChangeIcon: |
|
197 { |
|
198 TAP2GenericPluginIcon iconParams; |
|
199 TPckg<TAP2GenericPluginIcon> iconParamsPckg(iconParams); |
|
200 if (aDataDes.Length()) |
|
201 { |
|
202 iconParamsPckg.Copy(aDataDes); |
|
203 CGulIcon* icon = CreateIconL(iconParams.iIconId, iconParams.iMaskId); |
|
204 // Ownership of icon is transferred to the Active Palette |
|
205 PluginObserver().SetItemIcon(icon, ETrue); |
|
206 } |
|
207 } |
|
208 break; |
|
209 |
|
210 case EAPGenericPluginChangeParams: |
|
211 { |
|
212 TAP2GenericPluginParams params; |
|
213 TPckg<TAP2GenericPluginParams> paramsPckg(params); |
|
214 if (aDataDes.Length()) |
|
215 { |
|
216 paramsPckg.Copy(aDataDes); |
|
217 SetIconAndTooltipL(params); |
|
218 } |
|
219 break; |
|
220 } |
|
221 |
|
222 default: |
|
223 break; |
|
224 } |
|
225 } |
|
226 |
|
227 // ----------------------------------------------------------------------------- |
|
228 // InstantiateGenericPluginL() |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 CActivePalettePluginBase* InstantiateGenericPluginL( |
|
232 const TUid& aPluginUid, |
|
233 const NActivePalettePluginFactory::TPluginCreationParams& aCreationParams) |
|
234 { |
|
235 if (TUid::Uid(KActivePalette2GenericPluginUID) != aPluginUid) |
|
236 { |
|
237 User::Leave(KErrNotSupported); |
|
238 } |
|
239 |
|
240 CActivePalettePluginBase* self = new (ELeave) CAP2GenericPlugin(aCreationParams); |
|
241 return self; |
|
242 } |
|
243 |
|
244 // End of File |
|