|
1 /* |
|
2 * Copyright (c) 2002-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: |
|
15 * |
|
16 * Support for setting item lists and their setting |
|
17 * items. THe setting item list owns a listbox and an array of |
|
18 * setting items. The latter provides a MDesCArray interface for the |
|
19 * listbox model. |
|
20 * |
|
21 * Setting Items are abstractions of data types, that |
|
22 * have a capability to launch setting pages. |
|
23 * |
|
24 * |
|
25 */ |
|
26 |
|
27 |
|
28 #include <gulicon.h> |
|
29 #include <coemain.h> |
|
30 |
|
31 //For TResourceReader |
|
32 #include <barsread.h> |
|
33 |
|
34 #include <avkon.hrh> |
|
35 #include <avkon.rsg> |
|
36 #include <avkon.mbg> |
|
37 |
|
38 // For Numbered and unnumbered setting style lists |
|
39 #include <aknlists.h> |
|
40 #include <aknnotewrappers.h> |
|
41 |
|
42 #include <aknlayoutscalable_avkon.cdl.h> |
|
43 #include <aknconsts.h> |
|
44 |
|
45 // For layout switch events |
|
46 #include "AknDef.h" |
|
47 |
|
48 // For proper icon array management |
|
49 #include "AknIconArray.h" |
|
50 |
|
51 #include "aknsettingitemlist.h" |
|
52 #include "akntextsettingpage.h" |
|
53 #include "aknvolumesettingpage.h" |
|
54 #include "aknslidersettingpage.h" |
|
55 #include "aknmfnesettingpage.h" |
|
56 #include "aknpopupsettingpage.h" |
|
57 #include "aknpasswordsettingpage.h" |
|
58 #include <AknsConstants.h> |
|
59 |
|
60 #include "akntrace.h" |
|
61 |
|
62 const TInt KAknSettingItemMaxNumberDigits = 3; // for the setting item numbers |
|
63 const TInt KAknSettingItemArrayGranularity = 5; |
|
64 const TInt KAknSettingItemTimeBufferLength = 30; |
|
65 const TInt KAknSettingItemIpTextBufferLength = 15; //Assumes 4 fields of 3 + 3 dots |
|
66 |
|
67 |
|
68 // Separator for listbox text decoration |
|
69 _LIT(KListBoxTextSeparator, "\t"); |
|
70 |
|
71 // Format for a number |
|
72 _LIT(KAknSettingItemDecimalFormat, "%d" ); |
|
73 |
|
74 // Space used for listbox and time offset text formatting |
|
75 _LIT(KAknSettingItemSingleSpace, " " ); |
|
76 |
|
77 // Plus and minus used for listbox time offset |
|
78 _LIT(KAknSettingItemPlus, "+" ); |
|
79 _LIT(KAknSettingItemMinus, "-" ); |
|
80 |
|
81 // Empty IP address |
|
82 _LIT(KAknSettingItemEmptyIpAddress, "0.0.0.0" ); |
|
83 |
|
84 enum TAknSettingItemListPanic |
|
85 { |
|
86 EAknPanicSettingItemListUnused, |
|
87 EAknPanicSettingItemListNoEmptyText, |
|
88 EAknPanicSettingItemListInsufficientResource, |
|
89 EAknPanicSettingItemListInconsistentControlType, |
|
90 EAknPanicSettingItemListInvalidPasswordMode, |
|
91 EAknPanicSettingItemListInvalidDateMode, |
|
92 EAknPanicSettingItemListInvalidEnumeratedValue, |
|
93 EAknPanicSettingItemListWrongNumberOfValues, |
|
94 EAknPanicSettingItemListRequiredValueNotInArray, |
|
95 EAknPanicSettingItemListInvalidIndex, |
|
96 EAknPanicSettingItemListConstructionNotComplete, |
|
97 EAknPanicSettingItemListArrayLengthsMisMatch, |
|
98 EAknPanicSettingItemListNotBinaryCompatible, |
|
99 EAknPanicSettingItemListInvalidPointer, |
|
100 EAknPanicSettingItemListBadIcon |
|
101 }; |
|
102 |
|
103 GLDEF_C void Panic(TAknSettingItemListPanic aPanic) |
|
104 { |
|
105 _LIT(KPanicCat,"Setting Item List"); |
|
106 User::Panic(KPanicCat, aPanic); |
|
107 } |
|
108 |
|
109 // ------------------------------- |
|
110 // CAknSettingItemExtension |
|
111 // ------------------------------- |
|
112 // |
|
113 |
|
114 NONSHARABLE_CLASS( CAknSettingItemExtension ) : CBase |
|
115 { |
|
116 public: |
|
117 |
|
118 static CAknSettingItemExtension* NewL(); |
|
119 ~CAknSettingItemExtension(); |
|
120 void CreateLockIconL(CArrayPtr<CGulIcon>* aIconArray); |
|
121 |
|
122 protected: |
|
123 void ConstructL(); |
|
124 |
|
125 private: |
|
126 CAknSettingItemExtension(); |
|
127 |
|
128 //members |
|
129 public: |
|
130 TInt iLockIconIndex; |
|
131 TInt iLockIconHighlightIndex; |
|
132 |
|
133 private: |
|
134 |
|
135 }; |
|
136 |
|
137 CAknSettingItemExtension::CAknSettingItemExtension() |
|
138 : iLockIconIndex(KErrNotFound), iLockIconHighlightIndex(KErrNotFound) |
|
139 { |
|
140 } |
|
141 CAknSettingItemExtension::~CAknSettingItemExtension() |
|
142 { |
|
143 } |
|
144 |
|
145 void CAknSettingItemExtension::ConstructL() |
|
146 { |
|
147 } |
|
148 |
|
149 CAknSettingItemExtension* CAknSettingItemExtension::NewL() |
|
150 { |
|
151 CAknSettingItemExtension* settingExtension = new (ELeave) CAknSettingItemExtension; |
|
152 CleanupStack::PushL(settingExtension); |
|
153 settingExtension->ConstructL(); |
|
154 CleanupStack::Pop(settingExtension); |
|
155 return settingExtension; |
|
156 } |
|
157 |
|
158 void CAknSettingItemExtension::CreateLockIconL(CArrayPtr<CGulIcon>* aIconArray) |
|
159 { |
|
160 // START of lock icon creation |
|
161 |
|
162 // Create the lock icon as the last icon in the table |
|
163 CFbsBitmap* skinnedBitmap = NULL; |
|
164 CFbsBitmap* skinnedMask = NULL; |
|
165 |
|
166 // Make the icon and put it in the array |
|
167 CGulIcon* icon = CGulIcon::NewL(); |
|
168 CleanupStack::PushL(icon); |
|
169 |
|
170 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
171 |
|
172 // Create color icon |
|
173 AknsUtils::CreateColorIconL(skin, KAknsIIDQgnIndiSettProtectedAdd, |
|
174 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG13, |
|
175 skinnedBitmap, skinnedMask, KAvkonBitmapFile, |
|
176 EMbmAvkonQgn_indi_sett_protected_add, |
|
177 EMbmAvkonQgn_indi_sett_protected_add_mask, KRgbBlack); |
|
178 |
|
179 icon->SetMask(skinnedMask);// ownership transferred |
|
180 icon->SetBitmap(skinnedBitmap); // ownership transferred |
|
181 |
|
182 if(iLockIconIndex == KErrNotFound) |
|
183 { |
|
184 aIconArray->AppendL( icon ); |
|
185 iLockIconIndex = aIconArray->Count() - 1; |
|
186 } |
|
187 else |
|
188 { |
|
189 delete aIconArray->At(iLockIconIndex); |
|
190 aIconArray->Delete(iLockIconIndex); |
|
191 aIconArray->InsertL(iLockIconIndex, icon); |
|
192 } |
|
193 |
|
194 CleanupStack::Pop(); // icon |
|
195 |
|
196 // Create the lock icon for highlight |
|
197 skinnedBitmap = NULL; |
|
198 skinnedMask = NULL; |
|
199 |
|
200 // Make the icon and put it in the array |
|
201 icon = CGulIcon::NewL(); |
|
202 CleanupStack::PushL(icon); |
|
203 |
|
204 // Create color icon |
|
205 AknsUtils::CreateColorIconL(skin, KAknsIIDQgnIndiSettProtectedAdd, |
|
206 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG16, |
|
207 skinnedBitmap, skinnedMask, KAvkonBitmapFile, |
|
208 EMbmAvkonQgn_indi_sett_protected_add, |
|
209 EMbmAvkonQgn_indi_sett_protected_add_mask, KRgbBlack); |
|
210 |
|
211 |
|
212 icon->SetMask(skinnedMask);// ownership transferred |
|
213 icon->SetBitmap(skinnedBitmap); // ownership transferred |
|
214 |
|
215 if(iLockIconHighlightIndex == KErrNotFound) |
|
216 { |
|
217 aIconArray->AppendL( icon ); |
|
218 iLockIconHighlightIndex = aIconArray->Count() - 1; |
|
219 } |
|
220 else |
|
221 { |
|
222 delete aIconArray->At(iLockIconHighlightIndex); |
|
223 aIconArray->Delete(iLockIconHighlightIndex); |
|
224 aIconArray->InsertL(iLockIconHighlightIndex, icon); |
|
225 } |
|
226 |
|
227 CleanupStack::Pop(); // icon |
|
228 |
|
229 // END of lock icon creation |
|
230 } |
|
231 // ------------------------------- |
|
232 // CAknSettingItem |
|
233 // ------------------------------- |
|
234 // |
|
235 // public: |
|
236 |
|
237 /** |
|
238 * Default constructor. |
|
239 */ |
|
240 EXPORT_C CAknSettingItem::CAknSettingItem( TInt aIdentifier) : iIdentifier( aIdentifier ) |
|
241 { |
|
242 } |
|
243 EXPORT_C CAknSettingItem::~CAknSettingItem() |
|
244 { |
|
245 delete iExtension; |
|
246 delete iSettingName; |
|
247 delete iListBoxText; |
|
248 delete iEmptyItemText; |
|
249 delete iCompulsoryText; |
|
250 } |
|
251 |
|
252 EXPORT_C void CAknSettingItem::ConstructL( |
|
253 const TBool aIsNumberedStyle, |
|
254 const TInt aOrdinal, |
|
255 const TDesC& aSettingName, |
|
256 CArrayPtr<CGulIcon>* aIconArray, |
|
257 TInt aSettingPageResourceId, |
|
258 TInt aEditorControlType, |
|
259 TInt aSettingEditorResourceId, |
|
260 TInt aAssociatedResourceId) |
|
261 { |
|
262 _AKNTRACE_FUNC_ENTER; |
|
263 iExtension = CAknSettingItemExtension::NewL(); |
|
264 |
|
265 if ( aIsNumberedStyle ) |
|
266 iFlags |= EIsNumberedStyle; |
|
267 else |
|
268 iFlags &= (~EIsNumberedStyle); |
|
269 |
|
270 iOrdinal = aOrdinal; |
|
271 |
|
272 HBufC* newText = aSettingName.AllocL(); |
|
273 delete( iSettingName ); // after the AllocL succeeds |
|
274 iSettingName = newText; |
|
275 |
|
276 iIconArray = aIconArray; |
|
277 |
|
278 iSettingPageResourceId = aSettingPageResourceId; |
|
279 iEditorControlType = aEditorControlType; |
|
280 iSettingEditorResourceId = aSettingEditorResourceId; |
|
281 iAssociatedResourceId = aAssociatedResourceId; |
|
282 |
|
283 // Give the derived classes a chance to use the additional resource id: |
|
284 CompleteConstructionL(); |
|
285 |
|
286 // Perform the initial load of the data |
|
287 LoadL(); |
|
288 |
|
289 CFbsBitmap* bitmap = CreateBitmapL(); // This is a test to see if the setting item HAS a bitmap to offfer |
|
290 if ( bitmap ) |
|
291 { |
|
292 CleanupStack::PushL(bitmap); |
|
293 // Make the icon and put it in the array |
|
294 CGulIcon* icon = CGulIcon::NewL(); |
|
295 icon->SetBitmap( bitmap ); // ownership transferred |
|
296 CleanupStack::Pop(); // bitmap; |
|
297 |
|
298 CleanupStack::PushL( icon ); |
|
299 iIconArray->AppendL( icon ); |
|
300 CleanupStack::Pop(); // icon |
|
301 |
|
302 iIconIndex = iIconArray->Count() - 1; |
|
303 iFlags |= EHasIcon; |
|
304 |
|
305 // This is repeated to catch any mask information that might be available |
|
306 bitmap = CreateBitmapL(); |
|
307 if ( bitmap ) |
|
308 icon->SetBitmap( bitmap ); // ownership transferred |
|
309 } |
|
310 else |
|
311 { |
|
312 iFlags &= (~EHasIcon); |
|
313 } |
|
314 |
|
315 // Finally this sets up the text for the MDcaPoint calls from listbox |
|
316 UpdateListBoxTextL(); |
|
317 |
|
318 _AKNTRACE_FUNC_EXIT; |
|
319 } |
|
320 /** |
|
321 * This routine is used to replace the old bitmap with a new one. |
|
322 * |
|
323 */ |
|
324 void CAknSettingItem::UpdateBitmapL() |
|
325 { |
|
326 if (HasIcon() ) |
|
327 { |
|
328 CFbsBitmap* bitmap = CreateBitmapL(); |
|
329 if ( bitmap ) |
|
330 { |
|
331 // This deletes the old one as the bitmaps are owned |
|
332 iIconArray->At(iIconIndex)->SetBitmap( bitmap ); |
|
333 } |
|
334 } |
|
335 |
|
336 } |
|
337 |
|
338 EXPORT_C void CAknSettingItem::StoreL() |
|
339 { |
|
340 } |
|
341 EXPORT_C void CAknSettingItem::LoadL() |
|
342 { |
|
343 } |
|
344 EXPORT_C CFbsBitmap* CAknSettingItem::CreateBitmapL() |
|
345 { |
|
346 return 0; |
|
347 } |
|
348 EXPORT_C TBool CAknSettingItem::IsNumberedStyle() const |
|
349 { |
|
350 return (iFlags & EIsNumberedStyle ); |
|
351 } |
|
352 EXPORT_C TBool CAknSettingItem::IsHidden() const |
|
353 { |
|
354 return (iFlags & EIsHidden ); |
|
355 } |
|
356 |
|
357 EXPORT_C void CAknSettingItem::SetHidden(TBool aHidden) |
|
358 { |
|
359 if ( aHidden ) |
|
360 iFlags |= EIsHidden; |
|
361 else |
|
362 iFlags &= (~EIsHidden); |
|
363 // Note the the client code needs to do any recalculation and re-presentation of the listbox |
|
364 } |
|
365 |
|
366 |
|
367 EXPORT_C TPtrC CAknSettingItem::SettingName() |
|
368 { |
|
369 return (TPtrC) *iSettingName; |
|
370 } |
|
371 |
|
372 /** |
|
373 * Returns the ordinal for the setting. Only valid the numberstyle is Numbered; |
|
374 * if not it returns the "NOt displaeyd" value |
|
375 */ |
|
376 |
|
377 EXPORT_C TInt CAknSettingItem::SettingNumber() const |
|
378 { |
|
379 if (IsNumberedStyle()) |
|
380 return iOrdinal; |
|
381 else |
|
382 return EAknSettingPageNoOrdinalDisplayed; |
|
383 } |
|
384 |
|
385 EXPORT_C HBufC* CAknSettingItem::ListBoxText() |
|
386 { |
|
387 return iListBoxText; |
|
388 } |
|
389 |
|
390 EXPORT_C const TDesC& CAknSettingItem::SettingTextL() |
|
391 { |
|
392 return EmptyItemText(); |
|
393 } |
|
394 |
|
395 EXPORT_C TBool CAknSettingItem::HasIcon() const |
|
396 { |
|
397 return (iFlags & EHasIcon ); |
|
398 } |
|
399 |
|
400 EXPORT_C void CAknSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
401 { |
|
402 } |
|
403 |
|
404 EXPORT_C void CAknSettingItem::HandleSettingPageEventL(CAknSettingPage* /* aSettingPage */,MAknSettingPageObserver::TAknSettingPageEvent /* aEventType */ ) |
|
405 { |
|
406 _AKNTRACE_FUNC_ENTER; |
|
407 UpdateListBoxTextL(); |
|
408 _AKNTRACE_FUNC_EXIT; |
|
409 } |
|
410 /** |
|
411 * |
|
412 */ |
|
413 EXPORT_C void CAknSettingItem::SetSettingPage( CAknSettingPage* aSettingPage ) |
|
414 { |
|
415 iSettingPage = aSettingPage; |
|
416 } |
|
417 |
|
418 /** |
|
419 * |
|
420 */ |
|
421 EXPORT_C CAknSettingPage* CAknSettingItem::SettingPage() const |
|
422 { |
|
423 return iSettingPage; |
|
424 } |
|
425 |
|
426 /** |
|
427 * |
|
428 * Set up the setting page in the standard way |
|
429 * |
|
430 * |
|
431 */ |
|
432 EXPORT_C void CAknSettingItem::SetUpStandardSettingPageL() |
|
433 { |
|
434 SettingPage()->SetSettingTextL( SettingName() ); |
|
435 |
|
436 if ( IsNumberedStyle() ) |
|
437 { |
|
438 SettingPage()->SetSettingNumberL( SettingNumber() ); |
|
439 SettingPage()->SetNumbered(ETrue); |
|
440 } |
|
441 else |
|
442 SettingPage()->SetNumbered(EFalse); // Suppress the numbering |
|
443 } |
|
444 |
|
445 /** |
|
446 * |
|
447 * |
|
448 * |
|
449 */ |
|
450 EXPORT_C TInt CAknSettingItem::SettingPageResourceId() const |
|
451 { |
|
452 return iSettingPageResourceId; |
|
453 } |
|
454 |
|
455 /** |
|
456 * Access method for the setting editor resource id |
|
457 * |
|
458 * |
|
459 */ |
|
460 EXPORT_C TInt CAknSettingItem::SettingEditorResourceId() const |
|
461 { |
|
462 return iSettingEditorResourceId; |
|
463 } |
|
464 |
|
465 /** |
|
466 * Access function for the associated resource Id |
|
467 * |
|
468 * |
|
469 */ |
|
470 EXPORT_C TInt CAknSettingItem::AssociatedResourceId() const |
|
471 { |
|
472 return iAssociatedResourceId; |
|
473 } |
|
474 |
|
475 EXPORT_C void CAknSettingItem::UpdateListBoxTextL() |
|
476 { |
|
477 _AKNTRACE_FUNC_ENTER; |
|
478 |
|
479 // Get rid of the old value |
|
480 delete iListBoxText; |
|
481 iListBoxText = 0; |
|
482 |
|
483 // Update the bitmap |
|
484 UpdateBitmapL(); |
|
485 |
|
486 if((iFlags & EViewOnly) || (iFlags & EProtected)) |
|
487 { |
|
488 iExtension->CreateLockIconL(iIconArray); |
|
489 } |
|
490 |
|
491 // Calculate the right length |
|
492 TInt lengthRequired = 2 * KAknSettingItemMaxNumberDigits; |
|
493 lengthRequired += 4 * KListBoxTextSeparator().Length(); |
|
494 lengthRequired += (SettingName().Length() ); |
|
495 lengthRequired += (SettingTextL().Length() ); |
|
496 if (iCompulsoryText) |
|
497 { |
|
498 lengthRequired += (iCompulsoryText->Length() ); |
|
499 } |
|
500 |
|
501 if ( ProtectionState() == ESettingItemViewOnly || |
|
502 ProtectionState() == ESettingItemProtected ) |
|
503 { |
|
504 lengthRequired += 4 * KAknSettingItemMaxNumberDigits; // 4*3 |
|
505 } |
|
506 |
|
507 // Create the buffer |
|
508 iListBoxText = HBufC::NewL( lengthRequired ); |
|
509 |
|
510 TPtr listBoxTextPtr = iListBoxText->Des(); |
|
511 if ( iFlags & EIsNumberedStyle ) |
|
512 { |
|
513 // Locale-specific number conversion of this is done in listbox code, so not |
|
514 // done here |
|
515 listBoxTextPtr.Format( KAknSettingItemDecimalFormat, iOrdinal ); |
|
516 } |
|
517 else |
|
518 { |
|
519 listBoxTextPtr.Copy( KAknSettingItemSingleSpace ); |
|
520 } |
|
521 listBoxTextPtr.Append( KListBoxTextSeparator ); // index 1 |
|
522 listBoxTextPtr.Append( SettingName() ); |
|
523 listBoxTextPtr.Append( KListBoxTextSeparator ); // index 2 |
|
524 if ( HasIcon() ) |
|
525 { |
|
526 TBuf<KAknSettingItemMaxNumberDigits> iconIndexText; |
|
527 iconIndexText.Format( _L("%d"), iIconIndex ); // bitmap index encoding; not locale specific! |
|
528 listBoxTextPtr.Append( iconIndexText ); |
|
529 } |
|
530 |
|
531 listBoxTextPtr.Append( KListBoxTextSeparator ); // index 3 |
|
532 |
|
533 // The text put into the setting item list has had its non-printing chracters replace |
|
534 // by spaces: |
|
535 HBufC* settingText = SettingTextL().AllocL(); |
|
536 TPtr settingPtr = settingText->Des(); |
|
537 listBoxTextPtr.Append(ReplaceNonPrintingCharacters( settingPtr ) ); |
|
538 delete settingText; |
|
539 |
|
540 if (iCompulsoryText) |
|
541 { |
|
542 listBoxTextPtr.Append( KListBoxTextSeparator ); // index 4 |
|
543 listBoxTextPtr.Append( *iCompulsoryText ); |
|
544 } |
|
545 |
|
546 if ( ProtectionState() == ESettingItemViewOnly || |
|
547 ProtectionState() == ESettingItemProtected ) |
|
548 { |
|
549 // icon coloring is supported in lists by using upper and lower 16 bits of the icon index number to |
|
550 // include the both non-highlight and highligh icon index in the same number |
|
551 TBuf<KAknSettingItemMaxNumberDigits*4> protectedIconIndexText; |
|
552 TInt iconIndex = iExtension->iLockIconIndex; |
|
553 iconIndex |= iExtension->iLockIconHighlightIndex << 16; // shift one word, to get the highlight to upper part |
|
554 protectedIconIndexText.Format( _L("%d"), iconIndex ); // bitmap index encoding; not locale specific! |
|
555 |
|
556 if (!iCompulsoryText) |
|
557 listBoxTextPtr.Append( KListBoxTextSeparator ); // index 4 |
|
558 |
|
559 listBoxTextPtr.Append( KListBoxTextSeparator ); //index 5 |
|
560 listBoxTextPtr.Append( KListBoxTextSeparator ); // index 6 -> icon 2 |
|
561 listBoxTextPtr.Append( protectedIconIndexText ); |
|
562 } |
|
563 _AKNTRACE_FUNC_EXIT; |
|
564 } |
|
565 |
|
566 /** |
|
567 * |
|
568 * Complete the construction using the additional resource id. This is called from within ConstructXXXL routines. |
|
569 * Note that Load() will not have been called yet, so the setting is still uninitialized in terms of its data content |
|
570 * after this has finished. Otherwise, the instance should be ready. |
|
571 * |
|
572 */ |
|
573 EXPORT_C void CAknSettingItem::CompleteConstructionL() |
|
574 { |
|
575 } |
|
576 |
|
577 EXPORT_C void CAknSettingItem::SetEmptyItemTextL( const TDesC& aEmptyItemText ) |
|
578 { |
|
579 delete iEmptyItemText; |
|
580 iEmptyItemText = NULL; |
|
581 iEmptyItemText = aEmptyItemText.AllocL(); |
|
582 } |
|
583 |
|
584 EXPORT_C void CAknSettingItem::SetCompulsoryIndTextL( const TDesC& aCompulsoryText ) |
|
585 { |
|
586 delete iCompulsoryText; |
|
587 iCompulsoryText = NULL; |
|
588 iCompulsoryText = aCompulsoryText.AllocL(); |
|
589 } |
|
590 |
|
591 EXPORT_C TDesC& CAknSettingItem::EmptyItemText() const |
|
592 { |
|
593 __ASSERT_ALWAYS( iEmptyItemText , Panic( EAknPanicSettingItemListNoEmptyText ) ); |
|
594 return *iEmptyItemText; |
|
595 } |
|
596 |
|
597 TInt CAknSettingItem::EditorControlType() const |
|
598 { |
|
599 return iEditorControlType; |
|
600 } |
|
601 |
|
602 EXPORT_C TBool CAknSettingItem::SetIconMask( CFbsBitmap* aMask ) |
|
603 { |
|
604 TBool successfullyTransferred( EFalse ); |
|
605 if (HasIcon() && aMask ) |
|
606 { |
|
607 __ASSERT_DEBUG( !iIconArray->At(iIconIndex)->BitmapsOwnedExternally() , Panic( EAknPanicSettingItemListBadIcon ) ); |
|
608 // This deletes the old one as the bitmaps are owned internally |
|
609 iIconArray->At(iIconIndex)->SetMask( aMask ); |
|
610 successfullyTransferred = ETrue; |
|
611 } |
|
612 return successfullyTransferred; |
|
613 } |
|
614 |
|
615 CFbsBitmap* CAknSettingItem::SetIconMaskAndReturnBitmap( CGulIcon* aIcon ) |
|
616 { |
|
617 CFbsBitmap* returnedBitmap = NULL; |
|
618 |
|
619 if ( aIcon ) |
|
620 { |
|
621 aIcon->SetBitmapsOwnedExternally( ETrue ); |
|
622 CFbsBitmap* bitmap = aIcon->Bitmap(); |
|
623 CFbsBitmap* mask = aIcon->Mask(); |
|
624 delete aIcon; // does not own the bitmaps, so let it go |
|
625 |
|
626 // Nothing leaves for the rest of the routine. No Pushing |
|
627 |
|
628 // always return the bitmap and transfer ownership if there is one. |
|
629 if ( bitmap ) |
|
630 returnedBitmap = bitmap; |
|
631 |
|
632 // Set the mask if there is a bitmap, an icon and a mask |
|
633 TBool maskOwnershipTransferred(EFalse); |
|
634 if ( bitmap && mask && HasIcon() ) |
|
635 maskOwnershipTransferred = SetIconMask( mask ); |
|
636 if ( !maskOwnershipTransferred ) |
|
637 delete mask; |
|
638 |
|
639 } |
|
640 return returnedBitmap; |
|
641 } |
|
642 |
|
643 // For managing item hiding |
|
644 EXPORT_C TInt CAknSettingItem::VisibleIndex() |
|
645 { |
|
646 return iVisibleIndex; |
|
647 } |
|
648 |
|
649 void CAknSettingItem::SetVisibleIndex( TInt aVisibleIndex) |
|
650 { |
|
651 iVisibleIndex = aVisibleIndex; |
|
652 } |
|
653 |
|
654 void CAknSettingItem::SetOrdinal( TInt aOrdinal ) |
|
655 { |
|
656 iOrdinal = aOrdinal; |
|
657 } |
|
658 |
|
659 EXPORT_C void CAknSettingItem::SetSettingPageFlags( TInt aFlagPattern) |
|
660 { |
|
661 iSettingPageFlags = aFlagPattern; |
|
662 _AKNTRACE( "[%s][%s] iSettingPageFlags = %d", "CAknSettingItem", __FUNCTION__, iSettingPageFlags ); |
|
663 } |
|
664 |
|
665 EXPORT_C TInt CAknSettingItem::SettingPageFlags( ) const |
|
666 { |
|
667 return iSettingPageFlags; |
|
668 } |
|
669 |
|
670 void CAknSettingItem::SetParentListBox( const CEikFormattedCellListBox* aListBox ) |
|
671 { |
|
672 iParentListBox = aListBox; |
|
673 } |
|
674 |
|
675 EXPORT_C TInt CAknSettingItem::Identifier() const |
|
676 { |
|
677 return iIdentifier; |
|
678 } |
|
679 |
|
680 TPtrC CAknSettingItem::ReplaceNonPrintingCharacters( TDes& aText ) |
|
681 { |
|
682 /* |
|
683 * |
|
684 * this methdod is needed for stripping tab's away, so user |
|
685 * entered text can not crash the listbox |
|
686 * |
|
687 * 0x0001 should not be stripped away, since it is used as |
|
688 * separator for different length localization strings |
|
689 * |
|
690 * 0x200F and 0x200E are token for RTL and LTR. |
|
691 * |
|
692 */ |
|
693 for(TInt i = 0; i < aText.Length(); i++) |
|
694 { |
|
695 TChar c (aText[i]); |
|
696 |
|
697 if ( !c.IsPrint() && c != 0x0001 && c != 0x200F && c != 0x200E ) |
|
698 { |
|
699 TLanguage lang = User::Language(); |
|
700 if ( ELangThai == lang && c == 0x200B ) |
|
701 continue; |
|
702 aText[i] = ' '; |
|
703 } |
|
704 } |
|
705 return (TPtrC) aText; |
|
706 } |
|
707 |
|
708 EXPORT_C void CAknSettingItem::CAknSettingItem_Reserved() |
|
709 { |
|
710 } |
|
711 |
|
712 EXPORT_C void CAknSettingItem::SetProtectionState( CAknSettingItem::TSettingItemProtection aProtected ) |
|
713 { |
|
714 _AKNTRACE( "[%s][%s] aProtected = %d", "CAknSettingItem", __FUNCTION__, aProtected ); |
|
715 if (aProtected == ENoSettingItemProtection) |
|
716 { |
|
717 iFlags |= ENoProtection; |
|
718 iFlags &= (~(EViewOnly | EProtected)); |
|
719 } |
|
720 else if(aProtected == ESettingItemViewOnly) |
|
721 { |
|
722 iFlags |= EViewOnly; |
|
723 iFlags &= (~(ENoProtection | EProtected)); |
|
724 } |
|
725 else if(aProtected == ESettingItemProtected) |
|
726 { |
|
727 iFlags |= EProtected; |
|
728 iFlags &= (~(ENoProtection | EViewOnly)); |
|
729 } |
|
730 } |
|
731 |
|
732 EXPORT_C CAknSettingItem::TSettingItemProtection CAknSettingItem::ProtectionState() |
|
733 { |
|
734 TSettingItemProtection isProtected = ENoSettingItemProtection; |
|
735 |
|
736 if(iFlags & ENoProtection) |
|
737 isProtected = ENoSettingItemProtection; |
|
738 else if(iFlags & EViewOnly) |
|
739 isProtected = ESettingItemViewOnly; |
|
740 else if(iFlags & EProtected) |
|
741 isProtected = ESettingItemProtected; |
|
742 |
|
743 return isProtected; |
|
744 } |
|
745 // --------------------------------------- |
|
746 // CAknTextSettingItem |
|
747 // |
|
748 //---------------------------------------- |
|
749 |
|
750 EXPORT_C CAknTextSettingItem::CAknTextSettingItem( TInt aIdentifier, TDes& aText ): |
|
751 CAknSettingItem(aIdentifier), iExternalText( aText ), iInternalTextPtr(0,0) |
|
752 { |
|
753 // iInternalTextPtr points to no buffer, so no allocation is done here |
|
754 } |
|
755 |
|
756 EXPORT_C CAknTextSettingItem::~CAknTextSettingItem() |
|
757 { |
|
758 delete iInternalText; |
|
759 } |
|
760 |
|
761 EXPORT_C void CAknTextSettingItem::StoreL() |
|
762 { |
|
763 // Copy the internal to the external |
|
764 iExternalText.Copy(iInternalText->Des() ); |
|
765 } |
|
766 |
|
767 EXPORT_C void CAknTextSettingItem::LoadL() |
|
768 { |
|
769 // iInternalText is always deleted and re-created. |
|
770 delete iInternalText; |
|
771 iInternalText = 0; |
|
772 // New buffer is long enough for the maximum length of the external buffer. |
|
773 iInternalText = HBufC::NewL(iExternalText.MaxLength()); |
|
774 // Use Set so that the whole TPtr is just overwritten - and gets a new buffer |
|
775 // Note that the TPtr's buffer is owned by iInternalText, hence the old one is |
|
776 // already deleted - see above. |
|
777 iInternalTextPtr.Set(iInternalText->Des() ); |
|
778 iInternalTextPtr.Copy( iExternalText ); |
|
779 } |
|
780 |
|
781 EXPORT_C const TDesC& CAknTextSettingItem::SettingTextL() |
|
782 { |
|
783 if ( iInternalText->Length() > 0 ) |
|
784 return *iInternalText; |
|
785 else |
|
786 return EmptyItemText(); |
|
787 } |
|
788 |
|
789 EXPORT_C void CAknTextSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
790 { |
|
791 _AKNTRACE_FUNC_ENTER; |
|
792 TPtrC settingName = SettingName(); |
|
793 CAknSettingPage* dlg = new( ELeave )CAknTextSettingPage( |
|
794 &settingName, |
|
795 SettingNumber(), |
|
796 EditorControlType(), |
|
797 SettingEditorResourceId(), |
|
798 SettingPageResourceId(), |
|
799 iInternalTextPtr, |
|
800 SettingPageFlags() ); // Flags |
|
801 SetSettingPage( dlg ); |
|
802 SettingPage()->SetSettingPageObserver(this); |
|
803 |
|
804 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
805 SettingPage()->SetEditState(EFalse); |
|
806 |
|
807 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
808 SetSettingPage(0); // it is deleted now |
|
809 _AKNTRACE_FUNC_EXIT; |
|
810 } |
|
811 |
|
812 EXPORT_C TPtr& CAknTextSettingItem::InternalTextPtr() |
|
813 { |
|
814 return iInternalTextPtr; |
|
815 } |
|
816 |
|
817 EXPORT_C TPtrC CAknTextSettingItem::ExternalText() |
|
818 { |
|
819 return (TPtrC)(iExternalText); |
|
820 } |
|
821 |
|
822 EXPORT_C void CAknTextSettingItem::SetExternalText( TDesC& aNewExternalText ) |
|
823 { |
|
824 iExternalText.Copy( aNewExternalText ); |
|
825 } |
|
826 |
|
827 EXPORT_C void CAknTextSettingItem::CAknSettingItem_Reserved() |
|
828 { |
|
829 }; |
|
830 |
|
831 // --------------------------------------- |
|
832 // CAknIntegerSettingItem |
|
833 // |
|
834 //---------------------------------------- |
|
835 |
|
836 EXPORT_C CAknIntegerSettingItem::CAknIntegerSettingItem( TInt aIdentifier, TInt& aValue ): |
|
837 CAknSettingItem(aIdentifier), iExternalValue( aValue ), iInternalTextPtr(0,0) |
|
838 { |
|
839 } |
|
840 EXPORT_C CAknIntegerSettingItem::~CAknIntegerSettingItem() |
|
841 { |
|
842 delete iInternalText; |
|
843 } |
|
844 |
|
845 EXPORT_C void CAknIntegerSettingItem::CompleteConstructionL() |
|
846 { |
|
847 // Prepare the date buffer |
|
848 iInternalText = HBufC::NewMaxL(EAknMaxIntegerDigits); |
|
849 } |
|
850 EXPORT_C void CAknIntegerSettingItem::StoreL() |
|
851 { |
|
852 // Copy the internal to the external |
|
853 iExternalValue = iInternalValue; |
|
854 } |
|
855 EXPORT_C void CAknIntegerSettingItem::LoadL() |
|
856 { |
|
857 iInternalValue = iExternalValue; |
|
858 } |
|
859 |
|
860 EXPORT_C const TDesC& CAknIntegerSettingItem::SettingTextL() |
|
861 { |
|
862 _AKNTRACE( "[%s][%s][%d].", "CAknIntegerSettingItem", __FUNCTION__, __LINE__ ); |
|
863 // set the text ptr again. Its buffers are always owned by some else, so |
|
864 // removing the reference from the TPtr is OK. |
|
865 iInternalTextPtr.Set(iInternalText->Des()); |
|
866 iInternalTextPtr.Format(KAknIntegerFormat, iInternalValue ); |
|
867 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(iInternalTextPtr); |
|
868 return iInternalTextPtr; |
|
869 } |
|
870 |
|
871 |
|
872 EXPORT_C TInt& CAknIntegerSettingItem::InternalValueRef() |
|
873 { |
|
874 return iInternalValue; |
|
875 } |
|
876 |
|
877 EXPORT_C TInt& CAknIntegerSettingItem::ExternalValueRef() |
|
878 { |
|
879 return iExternalValue; |
|
880 } |
|
881 |
|
882 EXPORT_C void CAknIntegerSettingItem::SetExternalValue( TInt& aValue ) |
|
883 { |
|
884 iExternalValue = aValue; |
|
885 } |
|
886 |
|
887 EXPORT_C void CAknIntegerSettingItem::CAknSettingItem_Reserved() |
|
888 { |
|
889 }; |
|
890 |
|
891 EXPORT_C CAknIntegerEdwinSettingItem::CAknIntegerEdwinSettingItem( TInt aIdentifier, TInt& aValue ): |
|
892 CAknIntegerSettingItem(aIdentifier, aValue) |
|
893 {} |
|
894 |
|
895 EXPORT_C void CAknIntegerEdwinSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
896 { |
|
897 _AKNTRACE_FUNC_ENTER; |
|
898 TPtrC settingName = SettingName(); |
|
899 CAknSettingPage* dlg = new( ELeave )CAknIntegerSettingPage( |
|
900 &settingName, |
|
901 SettingNumber(), |
|
902 EditorControlType(), |
|
903 SettingEditorResourceId(), |
|
904 SettingPageResourceId(), |
|
905 InternalValueRef(), |
|
906 SettingPageFlags() ); // Flags |
|
907 |
|
908 SetSettingPage( dlg ); |
|
909 SettingPage()->SetSettingPageObserver(this); |
|
910 |
|
911 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
912 SettingPage()->SetEditState(EFalse); |
|
913 |
|
914 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
915 SetSettingPage( 0 ); |
|
916 |
|
917 _AKNTRACE_FUNC_EXIT; |
|
918 } |
|
919 |
|
920 EXPORT_C void CAknIntegerEdwinSettingItem::CAknSettingItem_Reserved() |
|
921 { |
|
922 }; |
|
923 |
|
924 |
|
925 // --------------------------------------- |
|
926 // CAknPasswordSettingItem |
|
927 // |
|
928 //---------------------------------------- |
|
929 |
|
930 EXPORT_C CAknPasswordSettingItem::CAknPasswordSettingItem( TInt aIdentifier, enum CAknPasswordSettingItem::TAknPasswordSettingItemMode aPasswordMode, TDes& aPassword ): |
|
931 CAknTextSettingItem(aIdentifier, aPassword ), iPasswordMode( aPasswordMode ) |
|
932 { |
|
933 } |
|
934 |
|
935 EXPORT_C void CAknPasswordSettingItem::CompleteConstructionL( ) |
|
936 { |
|
937 _AKNTRACE_FUNC_ENTER; |
|
938 if ( AssociatedResourceId() != 0 ) |
|
939 { |
|
940 |
|
941 TResourceReader reader; |
|
942 CEikonEnv::Static()->CreateResourceReaderLC( reader, AssociatedResourceId() ); |
|
943 |
|
944 TPtrC text = reader.ReadTPtrC(); // LTEXT name; |
|
945 iBlankingText.Copy( text ); |
|
946 iBlankingText.Copy( text.Left( Min( KMaxPasswordBlankingTextLength, text.Length() ) ) ); |
|
947 |
|
948 // Read the Old password confirmation LLINK |
|
949 iOldPasswordQueryResourceId = reader.ReadInt32(); |
|
950 |
|
951 CleanupStack::PopAndDestroy(); // reader |
|
952 } |
|
953 |
|
954 // No blanking text, then read the password blanking from AVKON resource |
|
955 if ( iBlankingText.Length() == 0 ) |
|
956 { |
|
957 HBufC* blankingText; |
|
958 |
|
959 if ( iPasswordMode == ENumeric ) |
|
960 blankingText = CCoeEnv::Static()->AllocReadResourceLC( R_AVKON_NUMERIC_PASSWORD_BLANKING_TEXT ); |
|
961 else |
|
962 blankingText = CCoeEnv::Static()->AllocReadResourceLC( R_AVKON_ALPHA_PASSWORD_BLANKING_TEXT ); |
|
963 |
|
964 iBlankingText.Copy( blankingText->Left( Min( KMaxPasswordBlankingTextLength, blankingText->Length() ) ) ); |
|
965 CleanupStack::PopAndDestroy(); // blankingText |
|
966 } |
|
967 _AKNTRACE_FUNC_EXIT; |
|
968 } |
|
969 |
|
970 EXPORT_C const TDesC& CAknPasswordSettingItem::SettingTextL() |
|
971 { |
|
972 if ( InternalTextPtr().Length() != 0 ) |
|
973 return iBlankingText; |
|
974 else |
|
975 return EmptyItemText(); |
|
976 } |
|
977 |
|
978 EXPORT_C void CAknPasswordSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
979 { |
|
980 _AKNTRACE_FUNC_ENTER; |
|
981 const TPtrC oldPassword = ExternalText(); |
|
982 TPtrC settingName = SettingName(); |
|
983 |
|
984 // Allocate a new password to the length of the internal buffer |
|
985 HBufC* newPasswordBuf = HBufC::NewLC( InternalTextPtr().MaxLength() ); |
|
986 TPtr newPassword( newPasswordBuf->Des() ); |
|
987 |
|
988 CAknSettingPage* dlg = 0; |
|
989 |
|
990 switch ( iPasswordMode ) |
|
991 { |
|
992 case EAlpha: |
|
993 dlg = new( ELeave )CAknAlphaPasswordSettingPage( |
|
994 &settingName, |
|
995 SettingNumber(), |
|
996 EditorControlType(), |
|
997 SettingEditorResourceId(), |
|
998 SettingPageResourceId(), |
|
999 newPassword, |
|
1000 oldPassword ); |
|
1001 |
|
1002 break; |
|
1003 |
|
1004 case ENumeric: |
|
1005 dlg = new( ELeave )CAknNumericPasswordSettingPage( |
|
1006 &settingName, |
|
1007 SettingNumber(), |
|
1008 EditorControlType(), |
|
1009 SettingEditorResourceId(), |
|
1010 SettingPageResourceId(), |
|
1011 newPassword, |
|
1012 oldPassword ); |
|
1013 break; |
|
1014 |
|
1015 default: |
|
1016 __ASSERT_ALWAYS(0, Panic(EAknPanicSettingItemListInvalidPasswordMode ) ); |
|
1017 break; |
|
1018 } |
|
1019 |
|
1020 SetSettingPage( dlg ); |
|
1021 SettingPage()->SetSettingPageObserver(this); |
|
1022 |
|
1023 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
1024 SettingPage()->SetEditState(EFalse); |
|
1025 |
|
1026 // Copy the new password text in if return value is ETrue |
|
1027 if ( SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged) ) |
|
1028 InternalTextPtr().Copy( newPassword ); |
|
1029 |
|
1030 SetSettingPage( 0 ); |
|
1031 |
|
1032 CleanupStack::PopAndDestroy(); // newPasswordBuf |
|
1033 |
|
1034 _AKNTRACE_FUNC_EXIT; |
|
1035 } |
|
1036 |
|
1037 EXPORT_C void CAknPasswordSettingItem::CAknSettingItem_Reserved() |
|
1038 { |
|
1039 }; |
|
1040 |
|
1041 // --------------------------------------- |
|
1042 // CAknVolumeSettingItem |
|
1043 // |
|
1044 //---------------------------------------- |
|
1045 |
|
1046 EXPORT_C CAknVolumeSettingItem::CAknVolumeSettingItem( TInt aIdentifier, TInt& aVolume ): |
|
1047 CAknSettingItem(aIdentifier), iExternalVolume( aVolume ) |
|
1048 { |
|
1049 } |
|
1050 |
|
1051 EXPORT_C void CAknVolumeSettingItem::StoreL() |
|
1052 { |
|
1053 // Copy the internal to the external |
|
1054 iExternalVolume = iInternalVolume; |
|
1055 } |
|
1056 |
|
1057 EXPORT_C void CAknVolumeSettingItem::LoadL() |
|
1058 { |
|
1059 iInternalVolume = iExternalVolume; |
|
1060 } |
|
1061 |
|
1062 EXPORT_C const TDesC& CAknVolumeSettingItem::SettingTextL() |
|
1063 { |
|
1064 return KAknSettingItemSingleSpace; |
|
1065 } |
|
1066 |
|
1067 EXPORT_C void CAknVolumeSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
1068 { |
|
1069 _AKNTRACE_FUNC_ENTER; |
|
1070 |
|
1071 TPtrC settingName = SettingName(); |
|
1072 |
|
1073 CAknVolumeSettingPage* dlg = new( ELeave )CAknVolumeSettingPage( |
|
1074 &settingName, |
|
1075 SettingNumber(), |
|
1076 EditorControlType(), |
|
1077 SettingEditorResourceId(), |
|
1078 SettingPageResourceId(), |
|
1079 InternalVolumeValue() ); |
|
1080 SetSettingPage( dlg ); |
|
1081 SettingPage()->SetSettingPageObserver(this); |
|
1082 |
|
1083 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
1084 SettingPage()->SetEditState(EFalse); |
|
1085 |
|
1086 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
1087 SetSettingPage(0); |
|
1088 UpdateListBoxTextL(); // update bitmap |
|
1089 |
|
1090 _AKNTRACE_FUNC_EXIT; |
|
1091 } |
|
1092 |
|
1093 EXPORT_C TInt& CAknVolumeSettingItem::InternalVolumeValue() |
|
1094 { |
|
1095 return iInternalVolume; |
|
1096 } |
|
1097 |
|
1098 /** |
|
1099 * This method is used to generate an appropriate bitmap for the current internal value |
|
1100 * |
|
1101 */ |
|
1102 EXPORT_C CFbsBitmap* CAknVolumeSettingItem::CreateBitmapL() |
|
1103 { |
|
1104 _AKNTRACE_FUNC_ENTER; |
|
1105 |
|
1106 CGulIcon* icon = NULL; |
|
1107 TResourceReader reader; |
|
1108 CCoeEnv::Static()->CreateResourceReaderLC( reader, SettingPageResourceId() ); |
|
1109 |
|
1110 TInt number= reader.ReadInt16(); |
|
1111 TPtrC settingText = reader.ReadTPtrC(); |
|
1112 TPtrC hintText = reader.ReadTPtrC(); |
|
1113 TInt cba = reader.ReadInt32(); |
|
1114 TInt menuBarId = reader.ReadInt32(); |
|
1115 TInt controlType = reader.ReadInt16(); |
|
1116 TInt editorResourceId = reader.ReadInt32(); |
|
1117 CleanupStack::PopAndDestroy(); // reader |
|
1118 |
|
1119 CCoeEnv::Static()->CreateResourceReaderLC( reader, editorResourceId ); |
|
1120 |
|
1121 TInt style = reader.ReadInt16(); |
|
1122 |
|
1123 if ( style == EDynRangeSettingsVolumeControl ) |
|
1124 { |
|
1125 TInt value = reader.ReadInt16(); |
|
1126 TPtrC bmpFile=reader.ReadTPtrC(); |
|
1127 TInt bmpId=reader.ReadInt16(); |
|
1128 TInt bmpMask=reader.ReadInt16(); |
|
1129 TInt min= reader.ReadInt16(); |
|
1130 TInt max = reader.ReadInt16(); |
|
1131 |
|
1132 icon = CAknVolumeControl::CreateSetDynRangeStyleListBoxIconL( InternalVolumeValue(),min,max ); |
|
1133 } |
|
1134 else |
|
1135 { |
|
1136 icon = CAknVolumeControl::CreateSetStyleListBoxIconL( InternalVolumeValue() ); |
|
1137 } |
|
1138 CleanupStack::PopAndDestroy(); // reader |
|
1139 |
|
1140 |
|
1141 CFbsBitmap* returnedBitmap = SetIconMaskAndReturnBitmap( icon ); // ownership of icon transfered, |
|
1142 |
|
1143 _AKNTRACE_FUNC_EXIT; |
|
1144 return returnedBitmap; // and this transfers ownership to caller |
|
1145 } |
|
1146 |
|
1147 EXPORT_C void CAknVolumeSettingItem::CAknSettingItem_Reserved() |
|
1148 { |
|
1149 }; |
|
1150 |
|
1151 // --------------------------------------- |
|
1152 // CAknSliderSettingItem |
|
1153 // |
|
1154 //---------------------------------------- |
|
1155 |
|
1156 EXPORT_C CAknSliderSettingItem::CAknSliderSettingItem( TInt aIdentifier, TInt& aSliderValue ): |
|
1157 CAknSettingItem(aIdentifier), iExternalSliderValue( aSliderValue ) |
|
1158 { |
|
1159 } |
|
1160 |
|
1161 EXPORT_C void CAknSliderSettingItem::StoreL() |
|
1162 { |
|
1163 // Copy the internal to the external |
|
1164 iExternalSliderValue = iInternalSliderValue; |
|
1165 } |
|
1166 |
|
1167 EXPORT_C void CAknSliderSettingItem::LoadL() |
|
1168 { |
|
1169 iInternalSliderValue = iExternalSliderValue; |
|
1170 } |
|
1171 |
|
1172 EXPORT_C const TDesC& CAknSliderSettingItem::SettingTextL() |
|
1173 { |
|
1174 return KAknSettingItemSingleSpace; |
|
1175 } |
|
1176 |
|
1177 |
|
1178 EXPORT_C TInt& CAknSliderSettingItem::InternalSliderValue() |
|
1179 { |
|
1180 return iInternalSliderValue; |
|
1181 } |
|
1182 |
|
1183 EXPORT_C void CAknSliderSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
1184 { |
|
1185 CreateAndExecuteSettingPageL(); |
|
1186 } |
|
1187 |
|
1188 EXPORT_C void CAknSliderSettingItem::CreateAndExecuteSettingPageL() |
|
1189 { |
|
1190 _AKNTRACE_FUNC_ENTER; |
|
1191 |
|
1192 CAknSettingPage* dlg = CreateSettingPageL(); |
|
1193 |
|
1194 SetSettingPage( dlg ); |
|
1195 SettingPage()->SetSettingPageObserver(this); |
|
1196 |
|
1197 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
1198 SettingPage()->SetEditState(EFalse); |
|
1199 |
|
1200 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
1201 SetSettingPage(0); |
|
1202 UpdateListBoxTextL(); |
|
1203 |
|
1204 _AKNTRACE_FUNC_EXIT; |
|
1205 } |
|
1206 |
|
1207 EXPORT_C CAknSettingPage* CAknSliderSettingItem::CreateSettingPageL() |
|
1208 { |
|
1209 TPtrC text = SettingName(); |
|
1210 return new( ELeave )CAknSliderSettingPage(&text,SettingNumber(),EAknCtSlider, |
|
1211 SettingEditorResourceId(), SettingPageResourceId(), iInternalSliderValue); |
|
1212 } |
|
1213 |
|
1214 |
|
1215 /** |
|
1216 * This method is used to generate an appropriate bitmap for the current internal value |
|
1217 * |
|
1218 */ |
|
1219 EXPORT_C CFbsBitmap* CAknSliderSettingItem::CreateBitmapL() |
|
1220 { |
|
1221 _AKNTRACE_FUNC_ENTER; |
|
1222 TInt editorResource = SettingEditorResourceId(); |
|
1223 if ( ( editorResource == 0 ) && ( SettingPageResourceId() != 0 ) ) |
|
1224 { |
|
1225 TInt editorType; |
|
1226 CAknSettingPage::GetEditorResourceInfoL( SettingPageResourceId(), editorType, editorResource ); |
|
1227 __ASSERT_ALWAYS( editorType == EAknCtSlider, Panic( EAknPanicSettingItemListInconsistentControlType ) ); |
|
1228 } |
|
1229 __ASSERT_ALWAYS( editorResource , Panic( EAknPanicSettingItemListInsufficientResource ) ); |
|
1230 |
|
1231 |
|
1232 CGulIcon* icon = CAknSlider::CreateSetStyleListBoxIconL( InternalSliderValue(), editorResource ); |
|
1233 CFbsBitmap* returnedBitmap = SetIconMaskAndReturnBitmap( icon ); // ownership of icon transfered, |
|
1234 |
|
1235 _AKNTRACE_FUNC_EXIT; |
|
1236 return returnedBitmap; // and this transfers ownership to caller |
|
1237 } |
|
1238 |
|
1239 EXPORT_C void CAknSliderSettingItem::CAknSettingItem_Reserved() |
|
1240 { |
|
1241 }; |
|
1242 |
|
1243 // --------------------------------------- |
|
1244 // CAknTimeOrDateSettingItem |
|
1245 // |
|
1246 //---------------------------------------- |
|
1247 |
|
1248 EXPORT_C CAknTimeOrDateSettingItem::CAknTimeOrDateSettingItem( TInt aIdentifier, enum CAknTimeOrDateSettingItem::TAknTimeOrDateSettingItemMode aTimeOrDateMode, TTime& aTime ): |
|
1249 CAknSettingItem(aIdentifier), iExternalTime( aTime ), iInternalTextPtr(0,0), iTimeFormatPtr(0,0), iTimeOrDateMode (aTimeOrDateMode ) |
|
1250 { |
|
1251 } |
|
1252 |
|
1253 |
|
1254 EXPORT_C CAknTimeOrDateSettingItem::~CAknTimeOrDateSettingItem() |
|
1255 { |
|
1256 delete iTimeFormat; |
|
1257 delete iInternalText; |
|
1258 } |
|
1259 |
|
1260 |
|
1261 /** |
|
1262 * |
|
1263 * Complete the construction |
|
1264 * |
|
1265 */ |
|
1266 |
|
1267 EXPORT_C void CAknTimeOrDateSettingItem::CompleteConstructionL() |
|
1268 { |
|
1269 _AKNTRACE_FUNC_ENTER; |
|
1270 // Prepare the date buffer |
|
1271 iInternalText = HBufC::NewL(KAknSettingItemTimeBufferLength); |
|
1272 // and the format buffer |
|
1273 // Set up according to default |
|
1274 |
|
1275 delete iTimeFormat; |
|
1276 iTimeFormat = NULL; |
|
1277 switch ( iTimeOrDateMode ) |
|
1278 { |
|
1279 case ETime: |
|
1280 iTimeFormat = CCoeEnv::Static()->AllocReadResourceL( R_QTN_TIME_USUAL_WITH_ZERO ); |
|
1281 break; |
|
1282 |
|
1283 case EDate: |
|
1284 iTimeFormat = CCoeEnv::Static()->AllocReadResourceL( R_QTN_DATE_USUAL_WITH_ZERO ); |
|
1285 break; |
|
1286 |
|
1287 default: |
|
1288 __ASSERT_ALWAYS(0, Panic(EAknPanicSettingItemListInvalidDateMode) ); |
|
1289 break; |
|
1290 |
|
1291 } |
|
1292 |
|
1293 iTimeFormatPtr.Set(iTimeFormat->Des()); |
|
1294 |
|
1295 _AKNTRACE_FUNC_EXIT; |
|
1296 } |
|
1297 |
|
1298 |
|
1299 EXPORT_C void CAknTimeOrDateSettingItem::StoreL() |
|
1300 { |
|
1301 // Copy the internal to the external |
|
1302 iExternalTime = iInternalTime; |
|
1303 } |
|
1304 |
|
1305 EXPORT_C void CAknTimeOrDateSettingItem::LoadL() |
|
1306 { |
|
1307 iInternalTime = iExternalTime; |
|
1308 } |
|
1309 |
|
1310 EXPORT_C const TDesC& CAknTimeOrDateSettingItem::SettingTextL() |
|
1311 { |
|
1312 |
|
1313 // set the text ptr again |
|
1314 iInternalTextPtr.Set(iInternalText->Des()); |
|
1315 iInternalTime.FormatL(iInternalTextPtr, TimeFormatString()); |
|
1316 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(iInternalTextPtr); |
|
1317 return iInternalTextPtr; |
|
1318 } |
|
1319 |
|
1320 EXPORT_C void CAknTimeOrDateSettingItem::SetTimeFormatStringL( const TDesC& aTimeFormat ) |
|
1321 { |
|
1322 delete iTimeFormat; |
|
1323 iTimeFormat = 0; |
|
1324 iTimeFormat = aTimeFormat.AllocL(); |
|
1325 // Use Set so that the whole TPtr is just overwritten - and gets a new buffer |
|
1326 iTimeFormatPtr.Set(iTimeFormat->Des() ); |
|
1327 } |
|
1328 |
|
1329 EXPORT_C const TPtrC CAknTimeOrDateSettingItem::TimeFormatString() |
|
1330 { |
|
1331 return TPtrC(iTimeFormatPtr); |
|
1332 } |
|
1333 |
|
1334 |
|
1335 EXPORT_C void CAknTimeOrDateSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
1336 { |
|
1337 _AKNTRACE_FUNC_ENTER; |
|
1338 TPtrC text = SettingName(); |
|
1339 CAknSettingPage* dlg = 0; |
|
1340 |
|
1341 switch ( iTimeOrDateMode ) |
|
1342 { |
|
1343 case ETime: |
|
1344 dlg = new( ELeave )CAknTimeSettingPage( |
|
1345 &text, |
|
1346 SettingNumber(), |
|
1347 EditorControlType(), |
|
1348 SettingEditorResourceId(), |
|
1349 SettingPageResourceId(), |
|
1350 iInternalTime); |
|
1351 |
|
1352 break; |
|
1353 |
|
1354 case EDate: |
|
1355 dlg = new( ELeave )CAknDateSettingPage( |
|
1356 &text, |
|
1357 SettingNumber(), |
|
1358 EditorControlType(), |
|
1359 SettingEditorResourceId(), |
|
1360 SettingPageResourceId(), |
|
1361 iInternalTime); |
|
1362 break; |
|
1363 |
|
1364 default: |
|
1365 __ASSERT_ALWAYS(0, Panic(EAknPanicSettingItemListInvalidDateMode) ); |
|
1366 break; |
|
1367 } |
|
1368 |
|
1369 SetSettingPage( dlg ); |
|
1370 SettingPage()->SetSettingPageObserver(this); |
|
1371 |
|
1372 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
1373 SettingPage()->SetEditState(EFalse); |
|
1374 |
|
1375 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
1376 SetSettingPage(0); |
|
1377 |
|
1378 _AKNTRACE_FUNC_EXIT; |
|
1379 } |
|
1380 |
|
1381 EXPORT_C void CAknTimeOrDateSettingItem::CAknSettingItem_Reserved() |
|
1382 { |
|
1383 }; |
|
1384 |
|
1385 |
|
1386 // --------------------------------------- |
|
1387 // CAknTimeOffsetSettingItem |
|
1388 // |
|
1389 //---------------------------------------- |
|
1390 |
|
1391 EXPORT_C CAknTimeOffsetSettingItem::CAknTimeOffsetSettingItem( TInt aIdentifier, TTimeIntervalSeconds& aTime ): |
|
1392 CAknSettingItem(aIdentifier), iExternalTime( aTime ), iInternalTextPtr(0,0), iTimeFormatPtr(0,0) |
|
1393 { |
|
1394 } |
|
1395 |
|
1396 |
|
1397 EXPORT_C CAknTimeOffsetSettingItem::~CAknTimeOffsetSettingItem() |
|
1398 { |
|
1399 delete iTimeFormat; |
|
1400 delete iInternalText; |
|
1401 } |
|
1402 |
|
1403 |
|
1404 /** |
|
1405 * |
|
1406 * Complete the construction |
|
1407 * |
|
1408 */ |
|
1409 |
|
1410 EXPORT_C void CAknTimeOffsetSettingItem::CompleteConstructionL() |
|
1411 { |
|
1412 _AKNTRACE_FUNC_ENTER; |
|
1413 // Prepare the date buffer |
|
1414 iInternalText = HBufC::NewL(KAknSettingItemTimeBufferLength); |
|
1415 // and the format buffer |
|
1416 // Set up according to default |
|
1417 |
|
1418 delete iTimeFormat; |
|
1419 iTimeFormat = NULL; |
|
1420 |
|
1421 iTimeFormat = CCoeEnv::Static()->AllocReadResourceL( R_QTN_TIME_DURAT_SHORT ); |
|
1422 |
|
1423 iTimeFormatPtr.Set(iTimeFormat->Des()); |
|
1424 |
|
1425 _AKNTRACE_FUNC_EXIT; |
|
1426 } |
|
1427 |
|
1428 |
|
1429 EXPORT_C void CAknTimeOffsetSettingItem::StoreL() |
|
1430 { |
|
1431 // Copy the internal to the external |
|
1432 iExternalTime = iInternalTime; |
|
1433 } |
|
1434 |
|
1435 EXPORT_C void CAknTimeOffsetSettingItem::LoadL() |
|
1436 { |
|
1437 iInternalTime = iExternalTime; |
|
1438 } |
|
1439 |
|
1440 EXPORT_C const TDesC& CAknTimeOffsetSettingItem::SettingTextL() |
|
1441 { |
|
1442 _AKNTRACE_FUNC_ENTER; |
|
1443 // set the text ptr again |
|
1444 TBool minus = EFalse; |
|
1445 |
|
1446 TInt timeInSeconds = iInternalTime.Int(); |
|
1447 if (timeInSeconds<0) |
|
1448 { |
|
1449 minus = ETrue; |
|
1450 timeInSeconds = -timeInSeconds; |
|
1451 } |
|
1452 |
|
1453 TTimeIntervalHours hours = (timeInSeconds - timeInSeconds%3600)/3600; |
|
1454 TTimeIntervalMinutes minutes = (timeInSeconds%3600 - timeInSeconds%60)/60; |
|
1455 TTimeIntervalSeconds seconds = timeInSeconds%60; |
|
1456 |
|
1457 TTime time(0); |
|
1458 time += hours; |
|
1459 time += minutes; |
|
1460 time += seconds; |
|
1461 |
|
1462 HBufC* buf; |
|
1463 buf = HBufC::NewL(KAknSettingItemTimeBufferLength); |
|
1464 CleanupStack::PushL(buf); |
|
1465 |
|
1466 TPtr bufPtr(0,0); |
|
1467 |
|
1468 bufPtr.Set(buf->Des()); |
|
1469 |
|
1470 time.FormatL(bufPtr, TimeFormatString()); |
|
1471 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(bufPtr); |
|
1472 |
|
1473 iInternalTextPtr.Set(iInternalText->Des()); |
|
1474 |
|
1475 if (minus) |
|
1476 { |
|
1477 iInternalTextPtr = KAknSettingItemMinus; |
|
1478 } |
|
1479 else |
|
1480 { |
|
1481 iInternalTextPtr = KAknSettingItemPlus; |
|
1482 } |
|
1483 iInternalTextPtr += KAknSettingItemSingleSpace; |
|
1484 iInternalTextPtr += bufPtr; |
|
1485 CleanupStack::Pop(); //buf |
|
1486 |
|
1487 delete buf; |
|
1488 |
|
1489 _AKNTRACE_FUNC_EXIT; |
|
1490 return iInternalTextPtr; |
|
1491 } |
|
1492 |
|
1493 EXPORT_C void CAknTimeOffsetSettingItem::SetTimeFormatStringL( const TDesC& aTimeFormat ) |
|
1494 { |
|
1495 _AKNTRACE( "[%s][%s][%d]", "CAknTimeOffsetSettingItem", __FUNCTION__, __LINE__ ); |
|
1496 delete iTimeFormat; |
|
1497 iTimeFormat = 0; |
|
1498 iTimeFormat = aTimeFormat.AllocL(); |
|
1499 // Use Set so that the whole TPtr is just overwritten - and gets a new buffer |
|
1500 iTimeFormatPtr.Set(iTimeFormat->Des() ); |
|
1501 } |
|
1502 |
|
1503 EXPORT_C const TPtrC CAknTimeOffsetSettingItem::TimeFormatString() |
|
1504 { |
|
1505 return TPtrC(iTimeFormatPtr); |
|
1506 } |
|
1507 |
|
1508 |
|
1509 EXPORT_C void CAknTimeOffsetSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
1510 { |
|
1511 _AKNTRACE_FUNC_ENTER; |
|
1512 TPtrC text = SettingName(); |
|
1513 CAknSettingPage* dlg = 0; |
|
1514 |
|
1515 dlg = new( ELeave )CAknTimeOffsetSettingPage( |
|
1516 &text, |
|
1517 SettingNumber(), |
|
1518 EditorControlType(), |
|
1519 SettingEditorResourceId(), |
|
1520 SettingPageResourceId(), |
|
1521 iInternalTime); |
|
1522 //interval); |
|
1523 |
|
1524 SetSettingPage( dlg ); |
|
1525 SettingPage()->SetSettingPageObserver(this); |
|
1526 |
|
1527 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
1528 SettingPage()->SetEditState(EFalse); |
|
1529 |
|
1530 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
1531 SetSettingPage(0); |
|
1532 |
|
1533 _AKNTRACE_FUNC_EXIT; |
|
1534 } |
|
1535 |
|
1536 EXPORT_C void CAknTimeOffsetSettingItem::CAknSettingItem_Reserved() |
|
1537 { |
|
1538 }; |
|
1539 |
|
1540 |
|
1541 // --------------------------------------- |
|
1542 // CAknIpFieldSettingItem |
|
1543 // |
|
1544 //---------------------------------------- |
|
1545 |
|
1546 EXPORT_C CAknIpFieldSettingItem::CAknIpFieldSettingItem( TInt aIdentifier, TInetAddr& aIpAddress ): |
|
1547 CAknSettingItem(aIdentifier), iExternalIpAddress( aIpAddress ), iInternalTextPtr(0,0) |
|
1548 { |
|
1549 } |
|
1550 |
|
1551 |
|
1552 EXPORT_C CAknIpFieldSettingItem::~CAknIpFieldSettingItem() |
|
1553 { |
|
1554 delete iInternalText; |
|
1555 } |
|
1556 |
|
1557 |
|
1558 /** |
|
1559 * |
|
1560 * Complete the construction |
|
1561 * |
|
1562 */ |
|
1563 |
|
1564 EXPORT_C void CAknIpFieldSettingItem::CompleteConstructionL() |
|
1565 { |
|
1566 // Allocate the ip text buffer |
|
1567 iInternalText = HBufC::NewL(KAknSettingItemIpTextBufferLength); |
|
1568 } |
|
1569 |
|
1570 |
|
1571 EXPORT_C void CAknIpFieldSettingItem::StoreL() |
|
1572 { |
|
1573 // Copy the internal to the external |
|
1574 iExternalIpAddress = iInternalIpAddress; |
|
1575 } |
|
1576 |
|
1577 EXPORT_C void CAknIpFieldSettingItem::LoadL() |
|
1578 { |
|
1579 iInternalIpAddress = iExternalIpAddress; |
|
1580 } |
|
1581 |
|
1582 EXPORT_C const TDesC& CAknIpFieldSettingItem::SettingTextL() |
|
1583 { |
|
1584 // set the text ptr again |
|
1585 iInternalTextPtr.Set(iInternalText->Des()); |
|
1586 |
|
1587 if ( iInternalIpAddress.IsUnspecified() ) |
|
1588 { |
|
1589 iInternalTextPtr.Copy(KAknSettingItemEmptyIpAddress); |
|
1590 } |
|
1591 else |
|
1592 { |
|
1593 iInternalIpAddress.Output(iInternalTextPtr); |
|
1594 } |
|
1595 return iInternalTextPtr; |
|
1596 } |
|
1597 |
|
1598 |
|
1599 EXPORT_C void CAknIpFieldSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
1600 { |
|
1601 _AKNTRACE_FUNC_ENTER; |
|
1602 TPtrC text = SettingName(); |
|
1603 CAknSettingPage* dlg = 0; |
|
1604 |
|
1605 dlg = new( ELeave )CAknIpFieldSettingPage( |
|
1606 &text, |
|
1607 SettingNumber(), |
|
1608 EditorControlType(), |
|
1609 SettingEditorResourceId(), |
|
1610 SettingPageResourceId(), |
|
1611 iInternalIpAddress); |
|
1612 |
|
1613 SetSettingPage( dlg ); |
|
1614 SettingPage()->SetSettingPageObserver(this); |
|
1615 |
|
1616 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
1617 SettingPage()->SetEditState(EFalse); |
|
1618 |
|
1619 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
1620 SetSettingPage(0); |
|
1621 |
|
1622 _AKNTRACE_FUNC_EXIT; |
|
1623 } |
|
1624 |
|
1625 EXPORT_C void CAknIpFieldSettingItem::CAknSettingItem_Reserved() |
|
1626 { |
|
1627 }; |
|
1628 |
|
1629 |
|
1630 |
|
1631 // |
|
1632 // |
|
1633 EXPORT_C CAknEnumeratedItemBase::CAknEnumeratedItemBase( TInt aEnumerationValue, TAny* aValue ): |
|
1634 iEnumerationValue( aEnumerationValue ), iValue ( aValue ) |
|
1635 { |
|
1636 } |
|
1637 |
|
1638 EXPORT_C CAknEnumeratedItemBase::~CAknEnumeratedItemBase() |
|
1639 { |
|
1640 } |
|
1641 |
|
1642 EXPORT_C TInt CAknEnumeratedItemBase::EnumerationValue() const |
|
1643 { |
|
1644 return iEnumerationValue; |
|
1645 } |
|
1646 |
|
1647 EXPORT_C void CAknEnumeratedItemBase::SetEnumerationValue( TInt aNewEnumerationValue ) |
|
1648 { |
|
1649 _AKNTRACE( "[%s][%s] aNewEnumerationValue = %d", "CAknEnumeratedItemBase", |
|
1650 __FUNCTION__, aNewEnumerationValue ); |
|
1651 iEnumerationValue = aNewEnumerationValue; |
|
1652 } |
|
1653 |
|
1654 EXPORT_C TAny* CAknEnumeratedItemBase::Value() const |
|
1655 { |
|
1656 return iValue; |
|
1657 } |
|
1658 |
|
1659 EXPORT_C void CAknEnumeratedItemBase::SetValue( TAny* aNewValue ) |
|
1660 { |
|
1661 iValue = aNewValue; |
|
1662 } |
|
1663 |
|
1664 |
|
1665 // |
|
1666 // Implementation of CAknEnumeratedTextSettingItem |
|
1667 // |
|
1668 // |
|
1669 |
|
1670 #define EMPTY_LIST (NumberOfItems() == 0) |
|
1671 |
|
1672 EXPORT_C CAknEnumeratedTextSettingItem::CAknEnumeratedTextSettingItem( |
|
1673 TInt aIdentifier ): CAknSettingItem(aIdentifier) |
|
1674 { |
|
1675 } |
|
1676 |
|
1677 EXPORT_C CAknEnumeratedTextSettingItem::~CAknEnumeratedTextSettingItem() |
|
1678 { |
|
1679 DeleteAndZeroPrimaryArrays(); |
|
1680 delete iSettingPageText; |
|
1681 } |
|
1682 |
|
1683 /** |
|
1684 * |
|
1685 * Complete the construction using the additional resource id. |
|
1686 * This reads in the two sets of texts : texts for for the setting item list display |
|
1687 * and texts for any setting page that may be raised. |
|
1688 * |
|
1689 * This also sets the empty listbox text |
|
1690 */ |
|
1691 EXPORT_C void CAknEnumeratedTextSettingItem::CompleteConstructionL( ) |
|
1692 { |
|
1693 _AKNTRACE_FUNC_ENTER; |
|
1694 |
|
1695 if ( AssociatedResourceId() ) |
|
1696 { |
|
1697 TResourceReader reader; |
|
1698 CEikonEnv::Static()->CreateResourceReaderLC( reader, AssociatedResourceId() ); |
|
1699 |
|
1700 iTextPopupFlags = reader.ReadInt16(); // Flags |
|
1701 |
|
1702 iEnumeratedTextArrayResourceId = reader.ReadInt32(); // LLINK to values |
|
1703 iPoppedUpTextArrayResourceId = reader.ReadInt32(); // optional LLINK to values |
|
1704 |
|
1705 /* Throw away */ reader.ReadInt32(); // For future needs |
|
1706 |
|
1707 CleanupStack::PopAndDestroy(); // reader |
|
1708 |
|
1709 // Read in the texts to be used in the setting item list |
|
1710 CEikonEnv::Static()->CreateResourceReaderLC( reader, iEnumeratedTextArrayResourceId ); |
|
1711 |
|
1712 TInt numberOfItems = reader.ReadInt16(); // item count |
|
1713 |
|
1714 // Construct the array |
|
1715 iEnumeratedTextArray = new (ELeave) CArrayPtrFlat<CAknEnumeratedText>( KAknSettingItemArrayGranularity ); |
|
1716 iPoppedUpTextArray = new (ELeave) CArrayPtrFlat<HBufC>(KAknSettingItemArrayGranularity); |
|
1717 |
|
1718 TInt index = 0; |
|
1719 //Loop through all the texts |
|
1720 for ( index=0; index < numberOfItems ; ++index ) |
|
1721 { |
|
1722 TInt value = reader.ReadInt16(); |
|
1723 TPtrC text = reader.ReadTPtrC(); // LTEXT name; |
|
1724 HBufC* thisText = text.AllocLC(); // pushed thisText |
|
1725 TPtr thisTextDes = thisText->Des(); |
|
1726 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(thisTextDes); |
|
1727 CAknEnumeratedText* enumeratedText = new (ELeave) CAknEnumeratedText( value, thisText); |
|
1728 CleanupStack::Pop(); // thisText |
|
1729 CleanupStack::PushL( enumeratedText ); |
|
1730 iEnumeratedTextArray->AppendL( enumeratedText ); |
|
1731 CleanupStack::Pop(); // enumeratedText |
|
1732 } |
|
1733 |
|
1734 CleanupStack::PopAndDestroy(); // reader |
|
1735 |
|
1736 // If the "Popped Up" resource is non-zero, then read it in too |
|
1737 if ( iPoppedUpTextArrayResourceId ) |
|
1738 { |
|
1739 // Read in the texts to be used in the setting item list |
|
1740 CEikonEnv::Static()->CreateResourceReaderLC( reader, iPoppedUpTextArrayResourceId ); |
|
1741 |
|
1742 // Read the item count |
|
1743 TInt numberOfItems = reader.ReadInt16(); // item count |
|
1744 |
|
1745 //Loop through all the texts |
|
1746 for ( index=0; index < numberOfItems ; ++index ) |
|
1747 { |
|
1748 TPtrC text = reader.ReadTPtrC();// LTEXT name; |
|
1749 if ( text.Length() > 0 ) |
|
1750 { |
|
1751 HBufC* thisText = text.AllocLC(); |
|
1752 TPtr thisTextDes = thisText->Des(); |
|
1753 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(thisTextDes); |
|
1754 |
|
1755 iPoppedUpTextArray->AppendL(thisText); |
|
1756 CleanupStack::Pop(); // thisText |
|
1757 } |
|
1758 else |
|
1759 iPoppedUpTextArray->AppendL(0); // zero pointers for the zero length texts |
|
1760 } |
|
1761 |
|
1762 CleanupStack::PopAndDestroy(); // reader |
|
1763 |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 _AKNTRACE_FUNC_EXIT; |
|
1768 } |
|
1769 |
|
1770 EXPORT_C CArrayPtr<CAknEnumeratedText>* CAknEnumeratedTextSettingItem::EnumeratedTextArray() const |
|
1771 { |
|
1772 return iEnumeratedTextArray; |
|
1773 } |
|
1774 |
|
1775 EXPORT_C CArrayPtr<HBufC>* CAknEnumeratedTextSettingItem::PoppedUpTextArray() const |
|
1776 { |
|
1777 return iPoppedUpTextArray; |
|
1778 } |
|
1779 |
|
1780 /** |
|
1781 * Set the enumerated arrays. |
|
1782 * Ownership of these arrays and their contents is wholly given over to the setting item |
|
1783 * object. |
|
1784 * |
|
1785 */ |
|
1786 EXPORT_C void CAknEnumeratedTextSettingItem::SetEnumeratedTextArrays( CArrayPtr<CAknEnumeratedText>* aEnumeratedTextArray, |
|
1787 CArrayPtr<HBufC>* aPoppedUpTextArray ) |
|
1788 { |
|
1789 __ASSERT_ALWAYS( aEnumeratedTextArray, Panic( EAknPanicSettingItemListInvalidPointer ) ); |
|
1790 __ASSERT_ALWAYS( aPoppedUpTextArray, Panic( EAknPanicSettingItemListInvalidPointer ) ); |
|
1791 DeleteAndZeroPrimaryArrays(); |
|
1792 iEnumeratedTextArray = aEnumeratedTextArray; |
|
1793 iPoppedUpTextArray = aPoppedUpTextArray; |
|
1794 } |
|
1795 |
|
1796 /** |
|
1797 * The virtual method LoadL() is called as the base class's best guess as to what needs to be |
|
1798 * done at this point. |
|
1799 */ |
|
1800 EXPORT_C void CAknEnumeratedTextSettingItem::HandleTextArrayUpdateL() |
|
1801 { |
|
1802 LoadL(); |
|
1803 } |
|
1804 |
|
1805 // Construct the Text Popup with the Setting Page texts. |
|
1806 //This may be different from the values |
|
1807 // on the setting item list |
|
1808 EXPORT_C void CAknEnumeratedTextSettingItem::SetSettingPageTextL() |
|
1809 { |
|
1810 _AKNTRACE_FUNC_ENTER; |
|
1811 |
|
1812 delete iSettingPageText; |
|
1813 iSettingPageText = 0; |
|
1814 iSettingPageText = new(ELeave) CDesCArrayFlat(KAknSettingItemArrayGranularity); |
|
1815 |
|
1816 TBool textIsSet; |
|
1817 TInt numberOfItems = NumberOfItems(); |
|
1818 for ( TInt index = 0; index < numberOfItems ; index++ ) |
|
1819 { |
|
1820 textIsSet = EFalse; |
|
1821 HBufC* poppedUpText; |
|
1822 if ( index < iPoppedUpTextArray->Count() ) // Note popped up text array may be shorter than numberOfItems |
|
1823 { |
|
1824 if ( (poppedUpText = iPoppedUpTextArray->At( index ) ) != 0 ) |
|
1825 { |
|
1826 iSettingPageText->AppendL( poppedUpText->Des() ); |
|
1827 textIsSet = ETrue; |
|
1828 } |
|
1829 } |
|
1830 |
|
1831 if (!textIsSet) |
|
1832 iSettingPageText->AppendL( iEnumeratedTextArray->At( index )->Value()->Des() ); |
|
1833 } |
|
1834 |
|
1835 _AKNTRACE_FUNC_EXIT; |
|
1836 } |
|
1837 |
|
1838 EXPORT_C CDesCArray* CAknEnumeratedTextSettingItem::SettingPageTextArray() const |
|
1839 { |
|
1840 return iSettingPageText; |
|
1841 } |
|
1842 |
|
1843 |
|
1844 EXPORT_C TInt CAknEnumeratedTextSettingItem::NumberOfItems() const |
|
1845 { |
|
1846 if ( iEnumeratedTextArray ) |
|
1847 return iEnumeratedTextArray->Count(); |
|
1848 else |
|
1849 return 0; |
|
1850 } |
|
1851 |
|
1852 |
|
1853 /** |
|
1854 * Find the index of the enumeration that matches the input value |
|
1855 * -1 is returned if the value is not in the enumerated text array |
|
1856 * |
|
1857 */ |
|
1858 EXPORT_C TInt CAknEnumeratedTextSettingItem::IndexFromValue( TInt aInputValue ) const |
|
1859 { |
|
1860 // Find this value in the enumerated items |
|
1861 TInt indexToFind = -1; |
|
1862 TInt numItems = EnumeratedTextArray()->Count(); |
|
1863 for ( TInt index = 0; index < numItems ; index++ ) |
|
1864 { |
|
1865 if ( aInputValue == EnumeratedTextArray()->At( index )->EnumerationValue() ) |
|
1866 { |
|
1867 indexToFind = index; |
|
1868 break; |
|
1869 } |
|
1870 } |
|
1871 _AKNTRACE( "[%s][%s] return value = %d", "CAknEnumeratedTextSettingItem", |
|
1872 __FUNCTION__, indexToFind ); |
|
1873 return indexToFind; |
|
1874 } |
|
1875 |
|
1876 void CAknEnumeratedTextSettingItem::DeleteAndZeroPrimaryArrays() |
|
1877 { |
|
1878 if ( iEnumeratedTextArray ) |
|
1879 { |
|
1880 iEnumeratedTextArray->ResetAndDestroy(); |
|
1881 delete iEnumeratedTextArray; |
|
1882 iEnumeratedTextArray = 0; |
|
1883 } |
|
1884 if ( iPoppedUpTextArray ) |
|
1885 { |
|
1886 iPoppedUpTextArray->ResetAndDestroy(); |
|
1887 delete iPoppedUpTextArray; |
|
1888 iPoppedUpTextArray = 0; |
|
1889 } |
|
1890 } |
|
1891 |
|
1892 EXPORT_C void CAknEnumeratedTextSettingItem::CAknSettingItem_Reserved() |
|
1893 { |
|
1894 }; |
|
1895 |
|
1896 |
|
1897 // |
|
1898 // Implementation of CAknEnumeratedTextPopupSettingItem |
|
1899 // |
|
1900 |
|
1901 |
|
1902 EXPORT_C CAknEnumeratedTextPopupSettingItem::CAknEnumeratedTextPopupSettingItem( |
|
1903 TInt aIdentifier, |
|
1904 TInt& aValue ): |
|
1905 CAknEnumeratedTextSettingItem(aIdentifier), iExternalValue( aValue ) |
|
1906 { |
|
1907 #ifdef __DEBUG__ |
|
1908 __ASSERT_DEBUG( sizeof( CAknEnumeratedTextPopupSettingItem ) == 0x0000008c , Panic( EAknPanicSettingItemListNotBinaryCompatible ) ); |
|
1909 #endif |
|
1910 } |
|
1911 |
|
1912 EXPORT_C CAknEnumeratedTextPopupSettingItem::~CAknEnumeratedTextPopupSettingItem() |
|
1913 { |
|
1914 delete iQueryValue; |
|
1915 delete iQueryTextArray; // This does not own the objects it points to |
|
1916 } |
|
1917 |
|
1918 /** |
|
1919 * |
|
1920 * Complete the construction using the additional resource id. |
|
1921 * This reads in the two binary texts. |
|
1922 * Note that Load() will not have been called yet, so the setting is still uninitialized in terms of its data content |
|
1923 * after this has finished. Otherwise, the instance should be ready. |
|
1924 * |
|
1925 */ |
|
1926 |
|
1927 EXPORT_C void CAknEnumeratedTextPopupSettingItem::CompleteConstructionL( ) |
|
1928 { |
|
1929 _AKNTRACE_FUNC_ENTER; |
|
1930 CAknEnumeratedTextSettingItem::CompleteConstructionL(); |
|
1931 _AKNTRACE_FUNC_EXIT; |
|
1932 } |
|
1933 |
|
1934 |
|
1935 EXPORT_C void CAknEnumeratedTextPopupSettingItem::StoreL() |
|
1936 { |
|
1937 // Copy the internal to the external |
|
1938 iExternalValue = iInternalValue; |
|
1939 } |
|
1940 |
|
1941 EXPORT_C void CAknEnumeratedTextPopupSettingItem::LoadL() |
|
1942 { |
|
1943 iInternalValue = iExternalValue; |
|
1944 |
|
1945 // Find this value in the enumerated items |
|
1946 iSelectedIndex = IndexFromValue( iInternalValue ); |
|
1947 |
|
1948 if (iSelectedIndex == -1 && !EMPTY_LIST) |
|
1949 { |
|
1950 // There may be some sort of error here |
|
1951 // Depends on if there is a requirement to support "nothing selected" |
|
1952 __ASSERT_ALWAYS(0, Panic(EAknPanicSettingItemListInvalidEnumeratedValue) ); |
|
1953 } |
|
1954 } |
|
1955 |
|
1956 |
|
1957 EXPORT_C const TDesC& CAknEnumeratedTextPopupSettingItem::SettingTextL() |
|
1958 { |
|
1959 if (EMPTY_LIST) return EmptyItemText(); |
|
1960 return *(EnumeratedTextArray()->At( iSelectedIndex )->Value()); |
|
1961 } |
|
1962 |
|
1963 EXPORT_C MAknQueryValue* CAknEnumeratedTextPopupSettingItem::QueryValue() const |
|
1964 { |
|
1965 return iQueryValue; |
|
1966 } |
|
1967 |
|
1968 /** |
|
1969 * Launch the setting page for this setting. |
|
1970 * |
|
1971 * |
|
1972 */ |
|
1973 EXPORT_C void CAknEnumeratedTextPopupSettingItem::EditItemL( TBool /* aCalledFromMenu */) |
|
1974 { |
|
1975 _AKNTRACE_FUNC_ENTER; |
|
1976 |
|
1977 SetSettingPageTextL(); |
|
1978 CreateTextArrayL(); |
|
1979 |
|
1980 CreateQueryValueL(); |
|
1981 CreateAndExecuteSettingPageL(); |
|
1982 |
|
1983 UpdateInternalValuesL(); |
|
1984 UpdateListBoxTextL(); |
|
1985 |
|
1986 _AKNTRACE_FUNC_EXIT; |
|
1987 } |
|
1988 |
|
1989 // Construct the Text Popup with the Setting Page texts. |
|
1990 //This may be different from the values |
|
1991 // on the setting item list |
|
1992 void CAknEnumeratedTextPopupSettingItem::SetSettingPageTextL() |
|
1993 { |
|
1994 CAknEnumeratedTextSettingItem::SetSettingPageTextL(); |
|
1995 } |
|
1996 |
|
1997 void CAknEnumeratedTextPopupSettingItem::CreateTextArrayL() |
|
1998 { |
|
1999 delete iQueryTextArray; |
|
2000 iQueryTextArray = 0; |
|
2001 iQueryTextArray = CAknQueryValueTextArray::NewL(); |
|
2002 iQueryTextArray->SetArray( *(SettingPageTextArray()) ); |
|
2003 } |
|
2004 |
|
2005 //Set the same datearray into all the values, and set initial index values |
|
2006 void CAknEnumeratedTextPopupSettingItem::CreateQueryValueL() |
|
2007 { |
|
2008 delete iQueryValue; |
|
2009 iQueryValue = 0; |
|
2010 iQueryValue = CAknQueryValueText::NewL(); |
|
2011 iQueryValue->SetArrayL(iQueryTextArray); |
|
2012 if (!EMPTY_LIST) |
|
2013 iQueryValue->SetCurrentValueIndex(iSelectedIndex); |
|
2014 } |
|
2015 |
|
2016 EXPORT_C void CAknEnumeratedTextPopupSettingItem::CreateAndExecuteSettingPageL() |
|
2017 { |
|
2018 _AKNTRACE_FUNC_ENTER; |
|
2019 |
|
2020 CAknSettingPage* dlg = CreateSettingPageL(); |
|
2021 CleanupStack::PushL(dlg); |
|
2022 SetSettingPage( dlg ); |
|
2023 |
|
2024 SettingPage()->SetSettingPageObserver(this); |
|
2025 SetUpStandardSettingPageL(); |
|
2026 |
|
2027 CleanupStack::Pop(dlg); |
|
2028 |
|
2029 if(ProtectionState() == CAknSettingItem::ESettingItemViewOnly) |
|
2030 SettingPage()->SetEditState(EFalse); |
|
2031 |
|
2032 |
|
2033 SettingPage()->ExecuteLD(CAknSettingPage::EUpdateWhenChanged); |
|
2034 SetSettingPage(0); |
|
2035 |
|
2036 _AKNTRACE_FUNC_EXIT; |
|
2037 } |
|
2038 |
|
2039 EXPORT_C CAknSettingPage* CAknEnumeratedTextPopupSettingItem::CreateSettingPageL() |
|
2040 { |
|
2041 TPtrC settingName = SettingName(); |
|
2042 return new( ELeave )CAknPopupSettingPage( &settingName, SettingNumber(), |
|
2043 EditorControlType(), SettingEditorResourceId(), SettingPageResourceId(),*iQueryValue); |
|
2044 } |
|
2045 |
|
2046 void CAknEnumeratedTextPopupSettingItem::UpdateInternalValuesL() |
|
2047 { |
|
2048 _AKNTRACE_FUNC_ENTER; |
|
2049 |
|
2050 if (!EMPTY_LIST) |
|
2051 { |
|
2052 iSelectedIndex = iQueryValue->CurrentValueIndex(); |
|
2053 // Check if new value has been added |
|
2054 if ( iSelectedIndex >= EnumeratedTextArray()->Count() ) |
|
2055 { |
|
2056 // calculate the next enumeration value. |
|
2057 TInt nextFreeEnum = FindNextEnumerationValue(); |
|
2058 // Create the new enumeration (number, text) object |
|
2059 HBufC* newText = iQueryValue->CurrentValueTextLC(); |
|
2060 CAknEnumeratedText* newEnumeratedText = new (ELeave) CAknEnumeratedText( nextFreeEnum, newText ); |
|
2061 // Ownership of newText has been given to newEnumeratedText. |
|
2062 CleanupStack::Pop(); // newText |
|
2063 CleanupStack::PushL( newEnumeratedText ); |
|
2064 EnumeratedTextArray()->AppendL( newEnumeratedText ); |
|
2065 CleanupStack::Pop(); // newEnumeratedText |
|
2066 iNumberOfItems++; // Now we have one more item |
|
2067 } |
|
2068 // Assert the tie between iNumberOfItems and iEnumeratedItemArray-Count() |
|
2069 __ASSERT_DEBUG( (NumberOfItems() == EnumeratedTextArray()->Count()), Panic( EAknPanicSettingItemListArrayLengthsMisMatch ) ); |
|
2070 // Asserts on the in-range-ness of iSelectedIndex are done inside the array access: |
|
2071 iInternalValue = EnumeratedTextArray()->At( iSelectedIndex )->EnumerationValue(); |
|
2072 } |
|
2073 |
|
2074 _AKNTRACE_FUNC_EXIT; |
|
2075 } |
|
2076 |
|
2077 EXPORT_C void CAknEnumeratedTextPopupSettingItem::SetExternalValue( TInt aNewValue ) |
|
2078 { |
|
2079 iExternalValue = aNewValue; |
|
2080 } |
|
2081 |
|
2082 EXPORT_C void CAknEnumeratedTextPopupSettingItem::SetInternalValue( TInt aNewValue ) |
|
2083 { |
|
2084 iInternalValue = aNewValue; |
|
2085 } |
|
2086 |
|
2087 EXPORT_C TInt CAknEnumeratedTextPopupSettingItem::ExternalValue() const |
|
2088 { |
|
2089 return iExternalValue; |
|
2090 } |
|
2091 |
|
2092 EXPORT_C TInt CAknEnumeratedTextPopupSettingItem::InternalValue() const |
|
2093 { |
|
2094 return iInternalValue; |
|
2095 } |
|
2096 |
|
2097 EXPORT_C void CAknEnumeratedTextPopupSettingItem::SetSelectedIndex( TInt aNewIndex ) |
|
2098 { |
|
2099 iSelectedIndex = aNewIndex; |
|
2100 } |
|
2101 |
|
2102 /** |
|
2103 * Find the index of the enumeration that matches the input value |
|
2104 * -1 is returned if the value is not in the enumerated text array |
|
2105 * |
|
2106 */ |
|
2107 EXPORT_C TInt CAknEnumeratedTextPopupSettingItem::IndexFromValue( TInt aInputValue ) const |
|
2108 { |
|
2109 _AKNTRACE( "[%s][%s] aInputValue = %d", "CAknEnumeratedTextPopupSettingItem", __FUNCTION__, aInputValue ); |
|
2110 return CAknEnumeratedTextSettingItem::IndexFromValue( aInputValue ); |
|
2111 } |
|
2112 |
|
2113 EXPORT_C CArrayPtr<CAknEnumeratedText>* CAknEnumeratedTextPopupSettingItem::EnumeratedTextArray() const |
|
2114 { |
|
2115 return CAknEnumeratedTextSettingItem::EnumeratedTextArray(); |
|
2116 } |
|
2117 |
|
2118 EXPORT_C CArrayPtr<HBufC>* CAknEnumeratedTextPopupSettingItem::PoppedUpTextArray() const |
|
2119 { |
|
2120 return CAknEnumeratedTextSettingItem::PoppedUpTextArray(); |
|
2121 } |
|
2122 |
|
2123 TInt CAknEnumeratedTextPopupSettingItem::FindNextEnumerationValue() const |
|
2124 { |
|
2125 _AKNTRACE_FUNC_ENTER; |
|
2126 // loop through the enumerated texts and record the highest enumeration value |
|
2127 TInt highestEnumValue = -1; // value chosen so as to return 0 if empty array |
|
2128 TInt enumInArray; |
|
2129 TInt count = EnumeratedTextArray()->Count(); |
|
2130 for ( TInt index = 0; index < count; ++index ) |
|
2131 { |
|
2132 enumInArray = EnumeratedTextArray()->At(index)->EnumerationValue(); |
|
2133 if (highestEnumValue < enumInArray ) |
|
2134 highestEnumValue = enumInArray; |
|
2135 } |
|
2136 |
|
2137 _AKNTRACE_FUNC_EXIT; |
|
2138 return (++highestEnumValue); |
|
2139 } |
|
2140 |
|
2141 EXPORT_C void CAknEnumeratedTextPopupSettingItem::CAknSettingItem_Reserved() |
|
2142 { |
|
2143 }; |
|
2144 |
|
2145 // ============================================================================== |
|
2146 // CAknBinaryPopupSettingItem |
|
2147 // ============================================================================== |
|
2148 |
|
2149 |
|
2150 EXPORT_C CAknBinaryPopupSettingItem::CAknBinaryPopupSettingItem( |
|
2151 TInt aIdentifier, |
|
2152 TBool& aBinaryValue ): |
|
2153 CAknEnumeratedTextPopupSettingItem(aIdentifier, (TInt&)aBinaryValue ) |
|
2154 { |
|
2155 } |
|
2156 |
|
2157 /** |
|
2158 * |
|
2159 * Complete the construction using the additional resource id. |
|
2160 * This reads in the two binary texts This is called from within ConstructXXXL routines. |
|
2161 * Note that Load() will not have been called yet, so the setting is still uninitialized in terms of its data content |
|
2162 * after this has finished. Otherwise, the instance should be ready. |
|
2163 * |
|
2164 */ |
|
2165 |
|
2166 EXPORT_C void CAknBinaryPopupSettingItem::CompleteConstructionL( ) |
|
2167 { |
|
2168 _AKNTRACE_FUNC_ENTER; |
|
2169 |
|
2170 CAknEnumeratedTextPopupSettingItem::CompleteConstructionL(); |
|
2171 |
|
2172 __ASSERT_DEBUG( EnumeratedTextArray() , Panic(EAknPanicSettingItemListConstructionNotComplete) ); |
|
2173 // that there are 2 values |
|
2174 __ASSERT_DEBUG( EnumeratedTextArray()->Count() == 2 , Panic(EAknPanicSettingItemListWrongNumberOfValues) ); |
|
2175 // that the values are 0 and 1 |
|
2176 __ASSERT_DEBUG( IndexFromValue( 0 ) != -1 , Panic(EAknPanicSettingItemListRequiredValueNotInArray) ); |
|
2177 __ASSERT_DEBUG( IndexFromValue( 1 ) != -1 , Panic(EAknPanicSettingItemListRequiredValueNotInArray) ); |
|
2178 |
|
2179 _AKNTRACE_FUNC_EXIT; |
|
2180 } |
|
2181 |
|
2182 |
|
2183 EXPORT_C void CAknBinaryPopupSettingItem::StoreL() |
|
2184 { |
|
2185 SetExternalValue( InternalValue() ); |
|
2186 } |
|
2187 |
|
2188 |
|
2189 EXPORT_C void CAknBinaryPopupSettingItem::LoadL() |
|
2190 { |
|
2191 // Regularize the external value to 0 or 1 |
|
2192 TInt tempExternalValue = 0; |
|
2193 if ( ExternalValue() ) |
|
2194 tempExternalValue = 1; |
|
2195 |
|
2196 SetExternalValue( tempExternalValue ); |
|
2197 |
|
2198 // This then sets the internal value |
|
2199 CAknEnumeratedTextPopupSettingItem::LoadL(); |
|
2200 } |
|
2201 |
|
2202 /** |
|
2203 * Launch the setting page for this setting. |
|
2204 * |
|
2205 * |
|
2206 */ |
|
2207 EXPORT_C void CAknBinaryPopupSettingItem::EditItemL( TBool aCalledFromMenu ) |
|
2208 { |
|
2209 _AKNTRACE_FUNC_ENTER; |
|
2210 |
|
2211 // Use base class for the main functionality |
|
2212 if ( aCalledFromMenu ) |
|
2213 { |
|
2214 CAknEnumeratedTextPopupSettingItem::EditItemL( aCalledFromMenu ); |
|
2215 // Check if another value has been added. We should not have to handle this in |
|
2216 // Binary setting page |
|
2217 // Note, however, that because of index discipline below, the 3rd item that might have |
|
2218 // been added will not ever be selected. Only when the list is popped up again, will the user's |
|
2219 // (ignored) choice be present |
|
2220 __ASSERT_DEBUG( EnumeratedTextArray()->Count() == 2 , Panic(EAknPanicSettingItemListWrongNumberOfValues) ); |
|
2221 __ASSERT_DEBUG( InternalValue() < 2 , Panic(EAknPanicSettingItemListInvalidIndex) ); |
|
2222 } |
|
2223 else if(ProtectionState() == ESettingItemViewOnly) |
|
2224 { |
|
2225 // Do not toggle! |
|
2226 } |
|
2227 else |
|
2228 { |
|
2229 |
|
2230 // Toggle the value and update the listbox text |
|
2231 if ( InternalValue() ) |
|
2232 SetInternalValue(0); |
|
2233 else |
|
2234 SetInternalValue(1); |
|
2235 |
|
2236 TInt index = IndexFromValue( InternalValue() ); |
|
2237 if (index >= 0 ) |
|
2238 SetSelectedIndex( index ); |
|
2239 else // put the seletion on the first in the list |
|
2240 SetSelectedIndex( 0 ); |
|
2241 |
|
2242 UpdateListBoxTextL(); |
|
2243 |
|
2244 } |
|
2245 |
|
2246 _AKNTRACE_FUNC_EXIT; |
|
2247 } |
|
2248 |
|
2249 EXPORT_C void CAknBinaryPopupSettingItem::CAknSettingItem_Reserved() |
|
2250 { |
|
2251 }; |
|
2252 |
|
2253 |
|
2254 /** |
|
2255 * This constructor merely initializes the empty string descriptor required for formatting the |
|
2256 * listbox text |
|
2257 * |
|
2258 */ |
|
2259 EXPORT_C CAknBigSettingItemBase::CAknBigSettingItemBase( TInt aIdentifier ): CAknSettingItem( aIdentifier ), iEmptyString( KNullDesC ) |
|
2260 { |
|
2261 } |
|
2262 |
|
2263 /** |
|
2264 * Just returns the pre-set empty string |
|
2265 * |
|
2266 */ |
|
2267 EXPORT_C const TDesC& CAknBigSettingItemBase::SettingTextL() |
|
2268 { |
|
2269 return iEmptyString; |
|
2270 } |
|
2271 |
|
2272 EXPORT_C void CAknBigSettingItemBase::CAknSettingItem_Reserved() |
|
2273 { |
|
2274 }; |
|
2275 |
|
2276 //======================================== |
|
2277 |
|
2278 |
|
2279 EXPORT_C CAknSettingItemArray::CAknSettingItemArray(TInt aGranularity, TBool aIsNumbered, TInt aInitialOrdinal ) : |
|
2280 CArrayPtrFlat<CAknSettingItem>( aGranularity ), iIsNumbered( aIsNumbered ), iInitialOrdinal( aInitialOrdinal ) |
|
2281 { |
|
2282 } |
|
2283 |
|
2284 EXPORT_C CAknSettingItemArray::~CAknSettingItemArray() |
|
2285 { |
|
2286 } |
|
2287 |
|
2288 EXPORT_C TInt CAknSettingItemArray::MdcaCount() const |
|
2289 { |
|
2290 return VisibleCount(); |
|
2291 } |
|
2292 |
|
2293 EXPORT_C TPtrC16 CAknSettingItemArray::MdcaPoint(TInt aVisibleIndex ) const |
|
2294 { |
|
2295 TInt indexToUse = ItemIndexFromVisibleIndex( aVisibleIndex ); |
|
2296 return ( (TPtrC)( *(At( indexToUse )->ListBoxText() ) ) ); |
|
2297 } |
|
2298 |
|
2299 |
|
2300 EXPORT_C void CAknSettingItemArray::SetVisibleCount( TInt aVisibleCount ) |
|
2301 { |
|
2302 iVisibleCount = aVisibleCount; |
|
2303 } |
|
2304 |
|
2305 EXPORT_C void CAknSettingItemArray::RecalculateVisibleIndicesL() |
|
2306 { |
|
2307 _AKNTRACE_FUNC_ENTER; |
|
2308 |
|
2309 TInt count = Count(); |
|
2310 TInt visibleIndex = -1; |
|
2311 for ( TInt index = 0; index < count; ++index ) |
|
2312 { |
|
2313 CAknSettingItem* item = At( index ); |
|
2314 if ( !( item->IsHidden() ) ) |
|
2315 { |
|
2316 visibleIndex++; |
|
2317 item->SetVisibleIndex( visibleIndex ); |
|
2318 if ( !(iFlags & EAknSettingItemIncludeHiddenInOrdinal ) ) |
|
2319 item->SetOrdinal( iInitialOrdinal + visibleIndex ); |
|
2320 else |
|
2321 item->SetOrdinal( iInitialOrdinal + index ); |
|
2322 |
|
2323 item->UpdateListBoxTextL(); |
|
2324 } |
|
2325 else |
|
2326 { |
|
2327 item->SetVisibleIndex( -1 ); |
|
2328 item->SetOrdinal( -1 ); |
|
2329 } |
|
2330 } |
|
2331 // The last index used gives the count (but add one first). |
|
2332 SetVisibleCount( visibleIndex+1 ); |
|
2333 |
|
2334 _AKNTRACE_FUNC_EXIT; |
|
2335 |
|
2336 } |
|
2337 EXPORT_C TInt CAknSettingItemArray::VisibleCount() const |
|
2338 { |
|
2339 return iVisibleCount; |
|
2340 } |
|
2341 |
|
2342 EXPORT_C TInt CAknSettingItemArray::ItemIndexFromVisibleIndex( TInt aVisibleIndex ) const |
|
2343 { |
|
2344 // go through item array until the one that returns the passed parameter is found |
|
2345 TInt count = Count(); |
|
2346 for ( TInt index = 0; index < count; ++index ) |
|
2347 { |
|
2348 if ( At( index )->VisibleIndex() == aVisibleIndex ) |
|
2349 return index; |
|
2350 } |
|
2351 return -1; |
|
2352 } |
|
2353 |
|
2354 EXPORT_C void CAknSettingItemArray::SetInitialOrdinal( TInt aInitialOrdinal ) |
|
2355 { |
|
2356 iInitialOrdinal = aInitialOrdinal; |
|
2357 } |
|
2358 |
|
2359 EXPORT_C void CAknSettingItemArray::SetFlags( TInt aFlags ) |
|
2360 { |
|
2361 iFlags = aFlags; |
|
2362 } |
|
2363 |
|
2364 |
|
2365 // ------------------------------- |
|
2366 // CAknSettingItemList |
|
2367 // ------------------------------- |
|
2368 |
|
2369 EXPORT_C CAknSettingItemList::CAknSettingItemList() |
|
2370 { |
|
2371 } |
|
2372 |
|
2373 EXPORT_C CAknSettingItemList::~CAknSettingItemList() |
|
2374 { |
|
2375 delete iSettingItemListBox; |
|
2376 |
|
2377 if (iSettingItemArray) |
|
2378 { |
|
2379 iSettingItemArray->ResetAndDestroy(); |
|
2380 delete iSettingItemArray; |
|
2381 } |
|
2382 |
|
2383 delete iSettingItemListTitle; |
|
2384 } |
|
2385 |
|
2386 |
|
2387 EXPORT_C CCoeControl* CAknSettingItemList::ComponentControl(TInt /*aIndex*/) const |
|
2388 { |
|
2389 return iSettingItemListBox; |
|
2390 } |
|
2391 |
|
2392 |
|
2393 EXPORT_C TInt CAknSettingItemList::CountComponentControls() const |
|
2394 { |
|
2395 return 1; |
|
2396 } |
|
2397 |
|
2398 /** |
|
2399 * Construct from resource using a new resource reader |
|
2400 * |
|
2401 */ |
|
2402 EXPORT_C void CAknSettingItemList::ConstructFromResourceL( TInt aResourceId ) |
|
2403 { |
|
2404 _AKNTRACE_FUNC_ENTER; |
|
2405 |
|
2406 TResourceReader reader; |
|
2407 iCoeEnv->CreateResourceReaderLC( reader, aResourceId ); |
|
2408 ConstructFromResourceL( reader ); |
|
2409 CleanupStack::PopAndDestroy(); // reader |
|
2410 |
|
2411 _AKNTRACE_FUNC_EXIT; |
|
2412 } |
|
2413 |
|
2414 /** |
|
2415 * This is the principal resource-reading Construct routine |
|
2416 * |
|
2417 * |
|
2418 */ |
|
2419 EXPORT_C void CAknSettingItemList::ConstructFromResourceL( TResourceReader& aReader ) |
|
2420 { |
|
2421 _AKNTRACE_FUNC_ENTER; |
|
2422 |
|
2423 if ( &(Window()) == 0 ) |
|
2424 CreateWindowL(); |
|
2425 |
|
2426 |
|
2427 // Flags read first |
|
2428 iFlags = aReader.ReadInt16(); // WORD flags |
|
2429 |
|
2430 TPtrC settingListTitle = aReader.ReadTPtrC(); // LTEXT title |
|
2431 HBufC* newText = settingListTitle.AllocL(); |
|
2432 if (iSettingItemListTitle) |
|
2433 delete( iSettingItemListTitle ); // after the AllocL succeeds |
|
2434 iSettingItemListTitle = newText; |
|
2435 |
|
2436 iInitialOrdinal = aReader.ReadInt16(); // WORD initial_number |
|
2437 |
|
2438 // Create the listbox in the right style |
|
2439 if ( IsNumberedStyle() ) |
|
2440 iSettingItemListBox = new(ELeave) CAknSettingNumberStyleListBox(); |
|
2441 else |
|
2442 iSettingItemListBox = new(ELeave) CAknSettingStyleListBox(); |
|
2443 |
|
2444 iSettingItemListBox->ConstructL( this, CEikListBox::ELeftDownInViewRect); |
|
2445 |
|
2446 TPoint pos = iEikonEnv->EikAppUi()->ClientRect().iTl; |
|
2447 TSize size = iSettingItemListBox->MinimumSize(); |
|
2448 SetExtent( pos,size ); |
|
2449 |
|
2450 |
|
2451 // Set up the CBA |
|
2452 iSettingItemListBox->CreateScrollBarFrameL(ETrue); |
|
2453 iSettingItemListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOn, CEikScrollBarFrame::EAuto); |
|
2454 |
|
2455 // The setting array |
|
2456 iSettingItemArray= new(ELeave)CAknSettingItemArray(KAknSettingItemArrayGranularity, IsNumberedStyle(), iInitialOrdinal ); |
|
2457 |
|
2458 // Transfer the flags to the item array |
|
2459 iSettingItemArray->SetFlags( iFlags ); |
|
2460 // Make the icon array |
|
2461 CArrayPtrFlat<CGulIcon>* iconArray = new(ELeave) CAknIconArray(KAknSettingItemArrayGranularity); |
|
2462 CleanupStack::PushL( iconArray ); |
|
2463 |
|
2464 // In case there is no empty text in resource, this can be set from resource. In order |
|
2465 // to get this only once, we can read the default empty text into an HBufC now |
|
2466 |
|
2467 HBufC* defaultEmptyText = iCoeEnv->AllocReadResourceLC(R_AVKON_SELEC_SETT_VAL_FIELD_NONE); // Pushed defaultEmptyText |
|
2468 |
|
2469 // Read the number of items and then loop |
|
2470 const TInt numberOfItems = aReader.ReadInt16(); // item count |
|
2471 TInt id; |
|
2472 for (TInt ii=0; ii < numberOfItems ; ++ii ) |
|
2473 { |
|
2474 id = aReader.ReadInt16(); // WORD identifier |
|
2475 TPtrC settingName = aReader.ReadTPtrC(); // LTEXT name; |
|
2476 |
|
2477 TInt settingPageResourceId = aReader.ReadInt32(); // LLINK setting_page_resource |
|
2478 TInt editorControlType = aReader.ReadInt16(); // WORD control type |
|
2479 TInt settingEditorResourceId = aReader.ReadInt32(); // LLINK setting_editor_resource |
|
2480 TInt associatedResourceId = aReader.ReadInt32(); // LLINK associated_resource |
|
2481 TPtrC emptyText = aReader.ReadTPtrC(); // LTEXT empty_text |
|
2482 TPtrC compulsoryText = aReader.ReadTPtrC(); |
|
2483 // Extension for future development |
|
2484 /* reserved */ aReader.ReadInt32(); |
|
2485 |
|
2486 // Call the factory for setting item |
|
2487 CAknSettingItem* settingItem = CreateSettingItemL( id ); |
|
2488 if ( settingItem ) |
|
2489 { |
|
2490 CleanupStack::PushL( settingItem ); |
|
2491 // If no empty text was read from resource, then supply it from the default |
|
2492 if ( emptyText.Length() != 0 ) |
|
2493 settingItem->SetEmptyItemTextL( emptyText ); |
|
2494 else |
|
2495 settingItem->SetEmptyItemTextL( *defaultEmptyText ); |
|
2496 |
|
2497 settingItem->SetCompulsoryIndTextL( compulsoryText ); |
|
2498 settingItem->ConstructL( |
|
2499 IsNumberedStyle(), |
|
2500 // This is just an initial provision for the ordinal value |
|
2501 // It may later one be adjusted for hidden items |
|
2502 iInitialOrdinal + ii, |
|
2503 settingName, |
|
2504 iconArray, |
|
2505 settingPageResourceId, |
|
2506 editorControlType, |
|
2507 settingEditorResourceId, |
|
2508 associatedResourceId ); |
|
2509 |
|
2510 settingItem->SetParentListBox( iSettingItemListBox ); |
|
2511 |
|
2512 iSettingItemArray->AppendL( settingItem ); // Ownership is transferred |
|
2513 CleanupStack::Pop(); // settingItem |
|
2514 } |
|
2515 } |
|
2516 |
|
2517 CleanupStack::PopAndDestroy(); // defaultEmptyText |
|
2518 |
|
2519 // Initial ordinal needed for dynamic numbering |
|
2520 iSettingItemArray->SetInitialOrdinal( iInitialOrdinal ); |
|
2521 |
|
2522 // Set up the visible indices in the listbox and update things |
|
2523 HandleChangeInItemArrayOrVisibilityL(); |
|
2524 |
|
2525 // Looks like we have no choice but to give ownership of this to the listbox |
|
2526 // There is no flag as there is for the item data |
|
2527 ListBox()->ItemDrawer()->FormattedCellData()->SetIconArrayL(iconArray); |
|
2528 |
|
2529 CleanupStack::Pop(); // iconArray now has ownership transferred |
|
2530 |
|
2531 CTextListBoxModel* model=ListBox()->Model(); |
|
2532 model->SetItemTextArray(iSettingItemArray); |
|
2533 model->SetOwnershipType(ELbmDoesNotOwnItemArray); // Ownership retained by SettingItemList |
|
2534 |
|
2535 TRect mainpaneRect; |
|
2536 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainpaneRect ); |
|
2537 iSettingItemListBox->SetRect(TRect(mainpaneRect.Size())); |
|
2538 |
|
2539 ListBox()->SetCurrentItemIndex(0); |
|
2540 ListBox()->SetListBoxObserver(this); |
|
2541 ListBox()->UpdateScrollBarsL(); |
|
2542 |
|
2543 _AKNTRACE_FUNC_EXIT; |
|
2544 } |
|
2545 |
|
2546 /** |
|
2547 * This is an example implementation of this routine. It shows the typical structure. Nothing else besides the |
|
2548 * C++ constuction of objects conforming to CAknSettingItem should be done. |
|
2549 * |
|
2550 * It may be useful to retain the default constuction of an object with run time type of CAknSettingItem. This will |
|
2551 * allow visibility of the data in the resource file at least. |
|
2552 * |
|
2553 */ |
|
2554 EXPORT_C CAknSettingItem* CAknSettingItemList::CreateSettingItemL( TInt identifier ) |
|
2555 { |
|
2556 _AKNTRACE( "[%s][%s][%d].", "CAknSettingItemList", __FUNCTION__, __LINE__ ); |
|
2557 |
|
2558 CAknSettingItem* settingItem; |
|
2559 |
|
2560 switch (identifier) |
|
2561 { |
|
2562 case 1: |
|
2563 settingItem = new (ELeave) CAknSettingItem(identifier); |
|
2564 return settingItem; |
|
2565 |
|
2566 |
|
2567 default: |
|
2568 settingItem = new (ELeave) CAknSettingItem(identifier); |
|
2569 return settingItem; |
|
2570 |
|
2571 } |
|
2572 } |
|
2573 |
|
2574 EXPORT_C TKeyResponse CAknSettingItemList::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
2575 { |
|
2576 _AKNTRACE( "[%s][%s][%d].", "CAknSettingItemList", __FUNCTION__, __LINE__ ); |
|
2577 // All events are sent to the listbox, |
|
2578 if (iSettingItemListBox) |
|
2579 return iSettingItemListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
2580 else |
|
2581 return EKeyWasNotConsumed; |
|
2582 } |
|
2583 |
|
2584 EXPORT_C void CAknSettingItemList::LoadSettingsL()// call Load() on each item in the MAknSettingItemArray. |
|
2585 { |
|
2586 TUint number = SettingItemArray()->Count(); |
|
2587 TUint index; |
|
2588 for ( index = 0; index < number; index++ ) |
|
2589 { |
|
2590 SettingItemArray()->At( index )->LoadL(); |
|
2591 } |
|
2592 UpdateAllListBoxTextsL(); |
|
2593 } |
|
2594 EXPORT_C void CAknSettingItemList::StoreSettingsL() // call StoreL() on each item in the MAknSettingItemArray |
|
2595 { |
|
2596 |
|
2597 TUint number = SettingItemArray()->Count(); |
|
2598 for (TUint index = 0; index < number; index++ ) |
|
2599 { |
|
2600 SettingItemArray()->At( index )->StoreL(); |
|
2601 } |
|
2602 |
|
2603 } |
|
2604 // Has an initial number (so that numbers can increment over several dialog pages, for instance ) |
|
2605 EXPORT_C void CAknSettingItemList::SetIncludeHiddenInOrdinal( TBool aInclude ) |
|
2606 { |
|
2607 _AKNTRACE( "[%s][%s] aInclude = %d", "CAknSettingItemList", __FUNCTION__, aInclude ); |
|
2608 if ( aInclude ) |
|
2609 iFlags |= EAknSettingItemIncludeHiddenInOrdinal; |
|
2610 else |
|
2611 iFlags &= (~EAknSettingItemIncludeHiddenInOrdinal); |
|
2612 // Update the copy of the flags in the array |
|
2613 if ( SettingItemArray() ) |
|
2614 SettingItemArray()->SetFlags( iFlags ); |
|
2615 } |
|
2616 |
|
2617 /** |
|
2618 * Framework method for launching the setting page. |
|
2619 * |
|
2620 */ |
|
2621 EXPORT_C void CAknSettingItemList::EditItemL(TInt aIndex, TBool aCalledFromMenu ) |
|
2622 { |
|
2623 _AKNTRACE_FUNC_ENTER; |
|
2624 |
|
2625 // Check if the setting page is locked |
|
2626 if(SettingItemArray()->At(aIndex)->ProtectionState() == |
|
2627 CAknSettingItem::ESettingItemProtected) |
|
2628 //show dialog |
|
2629 { |
|
2630 // R_QTN_SELEC_PROTECTED_SETTING |
|
2631 HBufC* warningText = |
|
2632 CCoeEnv::Static()->AllocReadResourceLC( R_QTN_SELEC_PROTECTED_SETTING ); |
|
2633 |
|
2634 CAknWarningNote* warningNote = new (ELeave) CAknWarningNote; |
|
2635 warningNote->ExecuteLD(warningText->Des()); |
|
2636 |
|
2637 CleanupStack::PopAndDestroy(); // warningText |
|
2638 } |
|
2639 else |
|
2640 { |
|
2641 // launch the setting page index |
|
2642 SettingItemArray()->At(aIndex)->EditItemL( aCalledFromMenu ); |
|
2643 iSettingItemListBox->View()->DrawItem( iSettingItemListBox->CurrentItemIndex() ); |
|
2644 } |
|
2645 |
|
2646 _AKNTRACE_FUNC_EXIT; |
|
2647 } |
|
2648 |
|
2649 EXPORT_C TBool CAknSettingItemList::IsNumberedStyle() |
|
2650 { |
|
2651 return ( iFlags & EAknSettingItemNumberedStyle ); |
|
2652 } |
|
2653 |
|
2654 EXPORT_C CAknSettingItemArray* CAknSettingItemList::SettingItemArray() const |
|
2655 { |
|
2656 return ( iSettingItemArray ); |
|
2657 } |
|
2658 |
|
2659 EXPORT_C CEikFormattedCellListBox* CAknSettingItemList::ListBox() |
|
2660 { |
|
2661 return ( iSettingItemListBox ); |
|
2662 } |
|
2663 |
|
2664 EXPORT_C void CAknSettingItemList::HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) |
|
2665 { |
|
2666 _AKNTRACE( "[%s][%s] aListBox = 0x%x, aEventType = %d", "CAknSettingItemList", __FUNCTION__, aListBox, aEventType ); |
|
2667 |
|
2668 switch(aEventType) |
|
2669 { |
|
2670 case EEventEnterKeyPressed: // Can be enter key (In Series 60, OK key) |
|
2671 case EEventItemDoubleClicked: // Or double click event |
|
2672 case EEventItemSingleClicked: |
|
2673 { |
|
2674 TInt itemIndex = SettingItemArray()->ItemIndexFromVisibleIndex( aListBox->CurrentItemIndex() ); |
|
2675 if ( itemIndex >= 0 ) |
|
2676 { |
|
2677 EditItemL( itemIndex, EFalse ); |
|
2678 aListBox->View()->DrawItem( aListBox->CurrentItemIndex() ); |
|
2679 } |
|
2680 } |
|
2681 break; |
|
2682 |
|
2683 default: |
|
2684 break; |
|
2685 } |
|
2686 } |
|
2687 |
|
2688 |
|
2689 //It is the responsibility of the client to call this whenever it hides or deletes |
|
2690 //SettingItems |
|
2691 EXPORT_C void CAknSettingItemList::HandleChangeInItemArrayOrVisibilityL() |
|
2692 { |
|
2693 _AKNTRACE_FUNC_ENTER; |
|
2694 |
|
2695 // Save the original highlight position. This will be -1 if there isn't one. |
|
2696 |
|
2697 TInt originalHighlight = ListBox()->CurrentItemIndex(); |
|
2698 //Listbox is only aware of the visible list (corresponding to "VisibleIndex"); |
|
2699 |
|
2700 |
|
2701 |
|
2702 //the actual list of ALL items (visible and invisible) corresponds to |
|
2703 //the "SettingItemIndex" |
|
2704 TInt originalSettingItemIndex = -1; |
|
2705 |
|
2706 // Possibly, there is no highlight yet, but if there is... |
|
2707 if ( originalHighlight >= 0 ) |
|
2708 { |
|
2709 // get the setting item index that corresponds to it |
|
2710 originalSettingItemIndex = SettingItemArray()-> |
|
2711 ItemIndexFromVisibleIndex( originalHighlight ); |
|
2712 } |
|
2713 |
|
2714 //Save the distance of the highlight from the top of the view window |
|
2715 //in order to try to preserve it after allowing for item deletions. |
|
2716 //this will be <0 if there is no highlight |
|
2717 TInt originalDistanceOfHighlightFromTopOfView = originalHighlight |
|
2718 - ListBox()->TopItemIndex(); |
|
2719 |
|
2720 |
|
2721 // Now recalculate the indices |
|
2722 SettingItemArray()->RecalculateVisibleIndicesL(); |
|
2723 |
|
2724 ListBox()->View()->CalcDataWidth(); |
|
2725 ListBox()->View()->CalcBottomItemIndex(); |
|
2726 ListBox()->UpdateScrollBarsL(); |
|
2727 |
|
2728 //ListBox assumes it's down to the client to ensure each time an item |
|
2729 //is added or deleted, the currentSettingItemIndex is recalculated. |
|
2730 //Thus if someone asynchronously deletes/hides an item without recalcing the SettingItemIndex |
|
2731 //then we're stuck. |
|
2732 TInt currentSettingItemIndex = originalSettingItemIndex; |
|
2733 |
|
2734 //We don't know if we will be able to position our highlight at the same place on |
|
2735 //the screen, various items may have been made invisible, |
|
2736 //So we now sort out which item will be at the top of the viewable window |
|
2737 // Scan backwards starting from currentSettingItem until we find a visible item. |
|
2738 TInt currentHighlight = -1; |
|
2739 |
|
2740 for ( ; currentSettingItemIndex >= 0; --currentSettingItemIndex ) |
|
2741 { |
|
2742 if ( !( SettingItemArray()->At(currentSettingItemIndex)->IsHidden() ) ) |
|
2743 // i.e.,if visible |
|
2744 { |
|
2745 currentHighlight = SettingItemArray()-> |
|
2746 At(currentSettingItemIndex)->VisibleIndex(); |
|
2747 break; |
|
2748 } |
|
2749 } |
|
2750 |
|
2751 |
|
2752 // If none found, then go to first visible item (which will be AFTER |
|
2753 // the original position) |
|
2754 if ( currentSettingItemIndex < 0 ) |
|
2755 { |
|
2756 if ( ListBox()->Model()->NumberOfItems() > 0 ) |
|
2757 currentHighlight = 0; |
|
2758 } |
|
2759 |
|
2760 |
|
2761 // if there is a highlight, set current item |
|
2762 if ( currentHighlight >= 0 ) |
|
2763 { |
|
2764 //if there are enough visible items above the highlight to return the highlight |
|
2765 //to the same position on the screen then do so, |
|
2766 //else draw it at the top of the screen. |
|
2767 if (currentHighlight >= (originalDistanceOfHighlightFromTopOfView+1) ) |
|
2768 ListBox()->SetTopItemIndex(currentHighlight |
|
2769 - originalDistanceOfHighlightFromTopOfView); |
|
2770 else |
|
2771 ListBox()->SetTopItemIndex(0); |
|
2772 |
|
2773 ListBox()->SetCurrentItemIndex( currentHighlight ); |
|
2774 ListBox()->DrawNow(); |
|
2775 } |
|
2776 |
|
2777 _AKNTRACE_FUNC_EXIT; |
|
2778 } |
|
2779 |
|
2780 |
|
2781 EXPORT_C void CAknSettingItemList::FocusChanged(TDrawNow aDrawNow) |
|
2782 { |
|
2783 TBool isFocused = IsFocused(); |
|
2784 ListBox()->SetFocus(isFocused, aDrawNow); |
|
2785 } |
|
2786 |
|
2787 EXPORT_C void CAknSettingItemList::HandleResourceChange( TInt aType ) |
|
2788 { |
|
2789 _AKNTRACE( "[%s][%s] aType = %d", "CAknSettingItemList", __FUNCTION__, aType ); |
|
2790 if(aType == KEikDynamicLayoutVariantSwitch) |
|
2791 { |
|
2792 TRect mainpaneRect; |
|
2793 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainpaneRect ); |
|
2794 |
|
2795 if ( OwnsWindow() ) |
|
2796 { |
|
2797 SetRect(mainpaneRect); |
|
2798 } |
|
2799 else |
|
2800 { |
|
2801 SetRect( TRect( mainpaneRect.Size() ) ); |
|
2802 } |
|
2803 |
|
2804 ListBox()->SetRect( TRect( mainpaneRect.Size() ) ); |
|
2805 } |
|
2806 |
|
2807 if( aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch) |
|
2808 { |
|
2809 TRAP_IGNORE( UpdateAllListBoxTextsL() ); |
|
2810 } |
|
2811 // put the list ok |
|
2812 CAknControl::HandleResourceChange(aType); |
|
2813 } |
|
2814 |
|
2815 EXPORT_C void CAknSettingItemList::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
2816 { |
|
2817 _AKNTRACE_FUNC_ENTER; |
|
2818 CAknControl::HandlePointerEventL(aPointerEvent); |
|
2819 _AKNTRACE_FUNC_EXIT; |
|
2820 } |
|
2821 |
|
2822 EXPORT_C void* CAknSettingItemList::ExtensionInterface( TUid /*aInterface*/ ) |
|
2823 { |
|
2824 return NULL; |
|
2825 } |
|
2826 |
|
2827 void CAknSettingItemList::UpdateAllListBoxTextsL() const |
|
2828 { |
|
2829 _AKNTRACE_FUNC_ENTER; |
|
2830 TUint number = SettingItemArray()->Count(); |
|
2831 TUint index; |
|
2832 for ( index = 0; index < number; index++ ) |
|
2833 { |
|
2834 SettingItemArray()->At( index )->UpdateListBoxTextL(); |
|
2835 } |
|
2836 _AKNTRACE_FUNC_EXIT; |
|
2837 } |
|
2838 // End of File |