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: Implementation of CApSelectorListbox. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <eikclbd.h> |
|
22 #include <AknIconArray.h> |
|
23 //#include <EIKON.mbg> |
|
24 #include <avkon.mbg> |
|
25 #include <aknkeys.h> |
|
26 #include <apsetui.rsg> |
|
27 #include <featmgr.h> |
|
28 |
|
29 #include "ApSelectorListbox.h" |
|
30 #include "ApSelectorListBoxModel.h" |
|
31 #include "ApListItem.h" |
|
32 |
|
33 #include <AknsUtils.h> |
|
34 #include <apsettings.mbg> |
|
35 #include <data_caging_path_literals.hrh> |
|
36 |
|
37 #include "ApSettingsHandlerLogger.h" |
|
38 |
|
39 // CONSTANTS |
|
40 // Drive and file name of the MBM file containing icons for Protection |
|
41 _LIT( KFileIcons, "z:ApSettings.mbm" ); |
|
42 |
|
43 |
|
44 // ================= MEMBER FUNCTIONS ======================= |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CApSelectorListbox::NewL |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 CApSelectorListbox* CApSelectorListbox::NewL |
|
51 ( const CCoeControl* aParent ) |
|
52 { |
|
53 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::NewL") |
|
54 |
|
55 CApSelectorListbox* listbox = |
|
56 new ( ELeave ) CApSelectorListbox(); |
|
57 CleanupStack::PushL( listbox ); |
|
58 listbox->ConstructL( aParent, EAknListBoxSelectionList ); |
|
59 CleanupStack::Pop(); // listbox |
|
60 |
|
61 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::NewL") |
|
62 return listbox; |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------- |
|
67 // CApSelectorListbox::CApSelectorListbox |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 CApSelectorListbox::CApSelectorListbox() |
|
71 { |
|
72 } |
|
73 |
|
74 |
|
75 // --------------------------------------------------------- |
|
76 // CApSelectorListbox::~CApSelectorListbox |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CApSelectorListbox::~CApSelectorListbox() |
|
80 { |
|
81 |
|
82 } |
|
83 |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CApSelectorListbox::OfferKeyEventL |
|
87 // --------------------------------------------------------- |
|
88 // |
|
89 TKeyResponse CApSelectorListbox::OfferKeyEventL |
|
90 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
91 { |
|
92 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::OfferKeyEventL") |
|
93 |
|
94 TKeyResponse retval; |
|
95 if ( aKeyEvent.iCode == EKeyOK && |
|
96 !( aKeyEvent.iModifiers & EModifierShift ) |
|
97 ) |
|
98 { |
|
99 // Enter pressed (not Shift-Enter). This will report an |
|
100 // EEnterKeyPressed event sent to the observer (the view), which may |
|
101 // delete this listbox. The code which processes keypresses by |
|
102 // default, will continue (on the already deleted listbox), and |
|
103 // will crash. So we grab this keypress here, and generate the |
|
104 // same event, but after that, quit immediately! |
|
105 ReportListBoxEventL( MEikListBoxObserver::EEventEnterKeyPressed ); |
|
106 // By now the listbox may have been deleted! |
|
107 // Do not access it after this point! |
|
108 retval = EKeyWasConsumed; |
|
109 } |
|
110 else |
|
111 { |
|
112 retval = CAknSingleGraphicStyleListBox::OfferKeyEventL |
|
113 ( aKeyEvent, aType ); |
|
114 } |
|
115 |
|
116 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::OfferKeyEventL") |
|
117 return retval; |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CApSelectorListbox::FocusChanged |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CApSelectorListbox::FocusChanged( TDrawNow aDrawNow ) |
|
127 { |
|
128 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::FocusChanged") |
|
129 |
|
130 // Do nothing until the listbox is fully constructed |
|
131 // The dialogpage sets the focus before calling ConstructL |
|
132 if ( iView ) |
|
133 { |
|
134 CAknSingleGraphicStyleListBox::FocusChanged( aDrawNow ); |
|
135 } |
|
136 |
|
137 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::FocusChanged") |
|
138 } |
|
139 |
|
140 |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CApSelectorListbox::LoadIconsL |
|
144 // --------------------------------------------------------- |
|
145 // |
|
146 void CApSelectorListbox::LoadIconsL() |
|
147 { |
|
148 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::LoadIconsL") |
|
149 |
|
150 CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( KGranularity ); |
|
151 CleanupStack::PushL( icons ); |
|
152 |
|
153 MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); |
|
154 |
|
155 TParse mbmFile; |
|
156 User::LeaveIfError( mbmFile.Set( KFileIcons, &KDC_APP_BITMAP_DIR, NULL ) ); |
|
157 |
|
158 icons->AppendL( AknsUtils::CreateGulIconL( |
|
159 skinInstance, |
|
160 KAknsIIDQgnPropWmlGprs, |
|
161 mbmFile.FullName(), |
|
162 EMbmApsettingsQgn_prop_wml_gprs, |
|
163 EMbmApsettingsQgn_prop_wml_gprs_mask ) ); |
|
164 |
|
165 icons->AppendL( AknsUtils::CreateGulIconL( |
|
166 skinInstance, |
|
167 KAknsIIDQgnPropWmlCsd, |
|
168 mbmFile.FullName(), |
|
169 EMbmApsettingsQgn_prop_wml_csd, |
|
170 EMbmApsettingsQgn_prop_wml_csd_mask ) ); |
|
171 |
|
172 icons->AppendL( AknsUtils::CreateGulIconL( |
|
173 skinInstance, |
|
174 KAknsIIDQgnPropWmlHscsd, |
|
175 mbmFile.FullName(), |
|
176 EMbmApsettingsQgn_prop_wml_hscsd, |
|
177 EMbmApsettingsQgn_prop_wml_hscsd_mask ) ); |
|
178 |
|
179 icons->AppendL( AknsUtils::CreateGulIconL( |
|
180 skinInstance, |
|
181 KAknsIIDQgnPropWmlSms, |
|
182 mbmFile.FullName(), |
|
183 EMbmApsettingsQgn_prop_wml_sms, |
|
184 EMbmApsettingsQgn_prop_wml_sms_mask ) ); |
|
185 |
|
186 icons->AppendL( AknsUtils::CreateGulIconL( |
|
187 skinInstance, |
|
188 KAknsIIDQgnPropWlanBearer, |
|
189 mbmFile.FullName(), |
|
190 EMbmApsettingsQgn_prop_wlan_bearer, |
|
191 EMbmApsettingsQgn_prop_wlan_bearer_mask ) ); |
|
192 |
|
193 |
|
194 icons->AppendL( AknsUtils::CreateGulIconL( |
|
195 skinInstance, |
|
196 KAknsIIDQgnPropWlanBearer, |
|
197 mbmFile.FullName(), |
|
198 EMbmApsettingsQgn_prop_wlan_easy, |
|
199 EMbmApsettingsQgn_prop_wlan_easy_mask ) ); |
|
200 |
|
201 |
|
202 FeatureManager::InitializeLibL(); |
|
203 TBool protsupported = FeatureManager::FeatureSupported( |
|
204 KFeatureIdSettingsProtection ); |
|
205 FeatureManager::UnInitializeLib(); |
|
206 if ( protsupported ) |
|
207 { |
|
208 icons->AppendL( AknsUtils::CreateGulIconL( |
|
209 skinInstance, |
|
210 KAknsIIDQgnIndiSettProtectedAdd, |
|
211 mbmFile.FullName(), |
|
212 EMbmApsettingsQgn_indi_sett_protected_add, |
|
213 EMbmApsettingsQgn_indi_sett_protected_add_mask ) ); |
|
214 } |
|
215 |
|
216 ItemDrawer()->ColumnData()->SetIconArray( icons ); |
|
217 |
|
218 CleanupStack::Pop(); // icons |
|
219 |
|
220 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::LoadIconsL") |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------- |
|
225 // CApSelectorListbox::Uid4Item |
|
226 // --------------------------------------------------------- |
|
227 // |
|
228 TUint32 CApSelectorListbox::Uid4Item( TInt aItem ) const |
|
229 { |
|
230 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::Uid4Item<->") |
|
231 |
|
232 CApSelectorListboxModel* lbmodel = |
|
233 STATIC_CAST( CApSelectorListboxModel*, Model()->ItemTextArray() ); |
|
234 return lbmodel->At( aItem )->Uid(); |
|
235 } |
|
236 |
|
237 |
|
238 // --------------------------------------------------------- |
|
239 // CApSelectorListbox::CurrentItemUid |
|
240 // --------------------------------------------------------- |
|
241 // |
|
242 TUint32 CApSelectorListbox::CurrentItemUid() const |
|
243 { |
|
244 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::CurrentItemUid") |
|
245 |
|
246 CApSelectorListboxModel* lbmodel = |
|
247 STATIC_CAST( CApSelectorListboxModel*, Model()->ItemTextArray() ); |
|
248 TInt idx = CurrentItemIndex(); |
|
249 TUint32 retval( 0 ); |
|
250 if ( idx >= 0 ) |
|
251 { |
|
252 retval = lbmodel->At( idx )->Uid(); |
|
253 } |
|
254 |
|
255 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::CurrentItemUid") |
|
256 return retval; |
|
257 } |
|
258 |
|
259 |
|
260 |
|
261 // --------------------------------------------------------- |
|
262 // CApSelectorListbox::CurrentItemNameL |
|
263 // --------------------------------------------------------- |
|
264 // |
|
265 const TDesC& CApSelectorListbox::CurrentItemNameL() |
|
266 { |
|
267 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::CurrentItemNameL") |
|
268 |
|
269 CApSelectorListboxModel* lbmodel = new( ELeave )CApSelectorListboxModel; |
|
270 lbmodel = |
|
271 STATIC_CAST( CApSelectorListboxModel*, Model()->ItemTextArray() ); |
|
272 |
|
273 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::CurrentItemNameL") |
|
274 return lbmodel->At( CurrentItemIndex() )->Name(); |
|
275 } |
|
276 |
|
277 |
|
278 // --------------------------------------------------------- |
|
279 // CApSelectorListbox::HandleResourceChange |
|
280 // --------------------------------------------------------- |
|
281 // |
|
282 void CApSelectorListbox::HandleResourceChange(TInt aType) |
|
283 { |
|
284 APSETUILOGGER_ENTERFN( EListbox,"SelListbox::HandleResourceChange") |
|
285 |
|
286 if ( aType == KAknsMessageSkinChange ) |
|
287 { |
|
288 TRAP_IGNORE( LoadIconsL() ); |
|
289 SizeChanged(); |
|
290 } |
|
291 |
|
292 CAknSingleGraphicStyleListBox::HandleResourceChange( aType ); |
|
293 |
|
294 APSETUILOGGER_LEAVEFN( EListbox,"SelListbox::HandleResourceChange") |
|
295 } |
|
296 |
|
297 // End of File |
|