|
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 * Implementation of popup setting item in its editing state |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 #include "aknpopupsettingpage.h" |
|
22 |
|
23 //For TResourceReader |
|
24 #include <barsread.h> |
|
25 |
|
26 // For icon array support |
|
27 #include <AknIconArray.h> |
|
28 |
|
29 // For icon support |
|
30 #include <gulicon.h> |
|
31 |
|
32 #include <AknTasHook.h> |
|
33 // For Avkon list styles |
|
34 #include "aknlists.h" |
|
35 |
|
36 |
|
37 #include <aknlayoutscalable_avkon.cdl.h> |
|
38 |
|
39 // Used for setting 1 in the radio button |
|
40 _LIT(KPopupSettingListLeadingLayoutText, "1\t"); |
|
41 |
|
42 #ifdef RD_UI_TRANSITION_EFFECTS_LIST |
|
43 #include <aknlistloadertfx.h> |
|
44 #include <aknlistboxtfxinternal.h> |
|
45 #endif //RD_UI_TRANSITION_EFFECTS_LIST |
|
46 |
|
47 #include <aknpriv.hrh> |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // Extension class definition |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 NONSHARABLE_CLASS( CAknPopupSettingListExtension ) : public CBase |
|
54 { |
|
55 public: |
|
56 /** |
|
57 * C++ constructor. |
|
58 */ |
|
59 CAknPopupSettingListExtension( CCoeControl& aOwner ); |
|
60 |
|
61 public: // Data |
|
62 TInt iOldFocusedItemIndex; |
|
63 TBool iIsDragged; |
|
64 |
|
65 /** |
|
66 * Extension flags definition. |
|
67 */ |
|
68 enum TFlags |
|
69 { |
|
70 ESingleClickEnabled |
|
71 }; |
|
72 |
|
73 /** |
|
74 * Extension flags. |
|
75 */ |
|
76 TBitFlags iFlags; |
|
77 }; |
|
78 |
|
79 // ---------------------------------------------------------------------------- |
|
80 // Extension class constructor. |
|
81 // ---------------------------------------------------------------------------- |
|
82 // |
|
83 CAknPopupSettingListExtension::CAknPopupSettingListExtension( |
|
84 CCoeControl& aOwner ) |
|
85 { |
|
86 if ( static_cast<CAknAppUi*>( |
|
87 aOwner.ControlEnv()->AppUi() )->IsSingleClickCompatible() ) |
|
88 { |
|
89 iFlags.Set( ESingleClickEnabled ); |
|
90 } |
|
91 } |
|
92 |
|
93 // end of CAknPopupSettingListExtension class definition |
|
94 |
|
95 |
|
96 |
|
97 //*******************************************************************************************/ |
|
98 // CAknPopupSettingList |
|
99 |
|
100 |
|
101 /** |
|
102 * Standard constructor. |
|
103 */ |
|
104 EXPORT_C CAknPopupSettingList::CAknPopupSettingList() |
|
105 { |
|
106 } |
|
107 |
|
108 /** |
|
109 * Destructor. |
|
110 * |
|
111 */ |
|
112 EXPORT_C CAknPopupSettingList::~CAknPopupSettingList() |
|
113 { |
|
114 DestroyMenuList(); // currnetly just removes this from control stack |
|
115 delete iLayoutDecorator; |
|
116 delete iOtherText; |
|
117 delete iExtension; |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 /** |
|
123 * 2nd phase construction |
|
124 * |
|
125 */ |
|
126 EXPORT_C void CAknPopupSettingList::ConstructL() |
|
127 { |
|
128 iOtherText = HBufC::NewL(0); |
|
129 CommonConstructL(); |
|
130 } |
|
131 |
|
132 /** |
|
133 * Construct from resources. |
|
134 * |
|
135 */ |
|
136 EXPORT_C void CAknPopupSettingList::ConstructFromResourceL(TResourceReader& aReader) |
|
137 { |
|
138 // First construct the standard lisbox using a standard Avkon resource |
|
139 TResourceReader defaultReader; |
|
140 iCoeEnv->CreateResourceReaderLC(defaultReader, R_AVKON_POPUP_SETTING_LIST_EMPTY_LISTBOX ); |
|
141 CEikFormattedCellListBox::ConstructFromResourceL(defaultReader); |
|
142 CleanupStack::PopAndDestroy(); // defaultReader |
|
143 SetListBoxObserver(this); |
|
144 |
|
145 iFlags=aReader.ReadInt16(); |
|
146 aReader.ReadInt16(); // Read in and discard Width. |
|
147 iOtherText = aReader.ReadHBufCL(); |
|
148 iNewItemSettingPageResourceId = aReader.ReadInt32(); |
|
149 iNewItemEditorType = aReader.ReadInt16(); |
|
150 iNewItemEditorControlResourceId = aReader.ReadInt32(); |
|
151 |
|
152 CommonConstructL(); |
|
153 |
|
154 } |
|
155 |
|
156 void CAknPopupSettingList::CommonConstructL() |
|
157 { |
|
158 // Finish construction |
|
159 SetUpSelectionListL(); |
|
160 |
|
161 // It may be possible that value is set already |
|
162 if (iValue) |
|
163 { |
|
164 ConfigureMenuListL(); |
|
165 ActivateMenuListL(); |
|
166 } |
|
167 } |
|
168 |
|
169 /** |
|
170 * |
|
171 * This routine sets up the text arrays for the menu list |
|
172 * |
|
173 */ |
|
174 EXPORT_C void CAknPopupSettingList::ConfigureMenuListL() |
|
175 { |
|
176 ConfigureDecorator(); |
|
177 ConstructLayoutDecoratorL(); |
|
178 } |
|
179 |
|
180 /** |
|
181 * Causes the list of pre-defined values to appear. |
|
182 * Use this method to activate the pop-up field from a menu option command. |
|
183 * Note that the desired control must have the focus before it can be activated. |
|
184 * |
|
185 */ |
|
186 EXPORT_C void CAknPopupSettingList::ActivateMenuListL() |
|
187 { |
|
188 if (iValue) |
|
189 { |
|
190 CreateMenuListL(); |
|
191 SetFocus(ETrue, ENoDrawNow); |
|
192 } |
|
193 } |
|
194 |
|
195 |
|
196 /** |
|
197 * Create the menu list. |
|
198 * |
|
199 */ |
|
200 void CAknPopupSettingList::SetUpSelectionListL() |
|
201 { |
|
202 TResourceReader reader; |
|
203 iCoeEnv->CreateResourceReaderLC( reader, R_AVKON_SET_PANE_EMPTY) ; |
|
204 HBufC *buf = reader.ReadHBufC16L(); // read text stored as a LBUF, which is actually a LTEXT |
|
205 CleanupStack::PopAndDestroy(); // reader no longer needed. |
|
206 CleanupStack::PushL(buf); |
|
207 View()->SetListEmptyTextL(*buf); |
|
208 CleanupStack::PopAndDestroy(); // buf no longer needed. |
|
209 InitialiseRadioButtonBitmapsL(); |
|
210 } |
|
211 |
|
212 /** |
|
213 * Set up the bitmap array for the "not pushed" and "pushed in" states |
|
214 * |
|
215 */ |
|
216 void CAknPopupSettingList::InitialiseRadioButtonBitmapsL() |
|
217 { |
|
218 // This method is more or less a verbatim copy of |
|
219 // CAknPopupField::InitialiseRadioButtonBitmapsL |
|
220 |
|
221 // In case CAknPopupSettingList has already created the icons |
|
222 if ( ItemDrawer()->FormattedCellData()->IconArray() ) |
|
223 { |
|
224 ItemDrawer()->FormattedCellData()->IconArray()->ResetAndDestroy(); |
|
225 delete (ItemDrawer()->FormattedCellData()->IconArray()); |
|
226 } |
|
227 |
|
228 TResourceReader reader; |
|
229 iCoeEnv->CreateResourceReaderLC(reader, R_AVKON_SETTING_PAGE_RADIOBUTTON_ICONS); |
|
230 |
|
231 reader.ReadInt16(); //not needed, simple or complex |
|
232 |
|
233 HBufC* bmpFile = reader.ReadHBufCL(); |
|
234 TInt count = reader.ReadInt16(); // count |
|
235 |
|
236 if(count<2) |
|
237 User::Leave(KErrCorrupt); |
|
238 |
|
239 TInt32 bmpSelected = reader.ReadInt32(); |
|
240 TInt32 bmpSelectedM = reader.ReadInt32(); |
|
241 TInt32 bmp = reader.ReadInt32(); |
|
242 TInt32 bmpM = reader.ReadInt32(); |
|
243 CleanupStack::PopAndDestroy(); // reader |
|
244 |
|
245 if (bmpFile == NULL) |
|
246 User::Leave(KErrCorrupt); |
|
247 |
|
248 CleanupStack::PushL(bmpFile); |
|
249 |
|
250 CArrayPtr<CGulIcon>* icons = new(ELeave) CAknIconArray(4); |
|
251 // put on the cleanup stack until ownership is transferred |
|
252 CleanupStack::PushL( icons ); |
|
253 |
|
254 // create normally colored icons |
|
255 CAknListBoxSettingPage::CreateIconAndAddToArrayL( |
|
256 icons, |
|
257 KAknsIIDQgnIndiRadiobuttOn, |
|
258 EAknsCIQsnIconColorsCG14, |
|
259 *bmpFile, |
|
260 bmpSelected, |
|
261 bmpSelectedM ); |
|
262 |
|
263 CAknListBoxSettingPage::CreateIconAndAddToArrayL( |
|
264 icons, |
|
265 KAknsIIDQgnIndiRadiobuttOff, |
|
266 EAknsCIQsnIconColorsCG14, |
|
267 *bmpFile, |
|
268 bmp, |
|
269 bmpM ); |
|
270 |
|
271 // create highlight colored icons |
|
272 CAknListBoxSettingPage::CreateIconAndAddToArrayL( |
|
273 icons, |
|
274 KAknsIIDQgnIndiRadiobuttOn, |
|
275 EAknsCIQsnIconColorsCG18, |
|
276 *bmpFile, |
|
277 bmpSelected, |
|
278 bmpSelectedM ); |
|
279 |
|
280 CAknListBoxSettingPage::CreateIconAndAddToArrayL( |
|
281 icons, |
|
282 KAknsIIDQgnIndiRadiobuttOff, |
|
283 EAknsCIQsnIconColorsCG18, |
|
284 *bmpFile, |
|
285 bmp, |
|
286 bmpM ); |
|
287 |
|
288 |
|
289 ItemDrawer()->FormattedCellData()->SetIconArrayL(icons); // ownership transferred, cell data deletes all members of list |
|
290 ItemDrawer()->FormattedCellData()->UseHighlightIconSwapping( ETrue ); |
|
291 |
|
292 CleanupStack::Pop(icons); // icons - ownership now transferred; do not destroy |
|
293 |
|
294 CleanupStack::PopAndDestroy(bmpFile); // bmpfile |
|
295 } |
|
296 |
|
297 |
|
298 /** |
|
299 * Processes key events from the listbox. Responds to EEventEnterKeyPressed to accept |
|
300 * the pop-up. |
|
301 * |
|
302 * @param aListBox Listbox being observed |
|
303 * @param aEventType Event observed |
|
304 * |
|
305 * |
|
306 * This implementation is vestige of former implementation when the listbox was wrapped up, |
|
307 * not derived from. Currently observing itself.. |
|
308 * |
|
309 */ |
|
310 EXPORT_C void CAknPopupSettingList::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aEventType) |
|
311 { |
|
312 switch ( aEventType ) |
|
313 { |
|
314 case MEikListBoxObserver::EEventPanningStopped: |
|
315 case MEikListBoxObserver::EEventFlickStopped: |
|
316 // Change list's current item index to the selected item. This |
|
317 // ensures that correct item gets selected if setting page is |
|
318 // accepted by clicking the left softkey. |
|
319 if ( iExtension && iExtension->iFlags.IsSet( |
|
320 CAknPopupSettingListExtension::ESingleClickEnabled ) ) |
|
321 { |
|
322 View()->SetCurrentItemIndex( iCurrentSelection ); |
|
323 } |
|
324 break; |
|
325 |
|
326 case MEikListBoxObserver::EEventItemSingleClicked: |
|
327 case MEikListBoxObserver::EEventEnterKeyPressed: |
|
328 case MEikListBoxObserver::EEventItemActioned: |
|
329 case MEikListBoxObserver::EEventItemDoubleClicked: |
|
330 { |
|
331 CListBoxView* view = View(); |
|
332 |
|
333 if ( aEventType == MEikListBoxObserver::EEventItemSingleClicked || |
|
334 !( ItemDrawer()->Flags() & |
|
335 CListItemDrawer::ESingleClickDisabledHighlight ) ) |
|
336 { |
|
337 // Update the current selection only if the selection came from |
|
338 // HW-keys, i.e. the list highlight is visible OR in case |
|
339 // of single tap event. |
|
340 if ( iCurrentSelection != view->CurrentItemIndex() ) |
|
341 { |
|
342 view->DeselectItem( iCurrentSelection ); |
|
343 iCurrentSelection = view->CurrentItemIndex(); |
|
344 view->SelectItemL( iCurrentSelection ); |
|
345 } |
|
346 } |
|
347 |
|
348 if ( iValue ) |
|
349 { |
|
350 if ( aEventType == MEikListBoxObserver::EEventItemSingleClicked ) |
|
351 { |
|
352 iValue->SetCurrentValueIndex( iCurrentSelection ); |
|
353 } |
|
354 else |
|
355 { |
|
356 iValue->SetCurrentValueIndex( view->CurrentItemIndex() ); |
|
357 } |
|
358 } |
|
359 |
|
360 if ( iPopupSettingListObserver ) |
|
361 { |
|
362 // To do selection, point event needs |
|
363 // EAknPopupSettingSelectionAndClose, but it will also cause |
|
364 // AttemptExit() run twice. So we give different oberver |
|
365 // event for them. |
|
366 iPopupSettingListObserver->HandlePopupSettingListEventL( |
|
367 this, |
|
368 aEventType == MEikListBoxObserver::EEventEnterKeyPressed ? |
|
369 MAknPopupSettingListObserver::EAknPopupSettingSelectionAndRequestAccept : |
|
370 MAknPopupSettingListObserver::EAknPopupSettingSelectionAndClose, |
|
371 iCurrentSelection ); |
|
372 } |
|
373 } |
|
374 break; |
|
375 |
|
376 default: |
|
377 break; |
|
378 } |
|
379 } |
|
380 |
|
381 // ---------------------------------------------------------------------------- |
|
382 // CAknPopupSettingList::HandlePointerEventL() |
|
383 // Processes listbox's pointer event's so that listboxt will act like radiobuttons. |
|
384 // This implementation overwrites CEikListBox's HandlePointerEventL function |
|
385 // It will not act for control-button presses. So multiple selection is impossible. |
|
386 // ---------------------------------------------------------------------------- |
|
387 EXPORT_C void CAknPopupSettingList::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
388 { |
|
389 // remove pointer event modifiers to prevent marking etc |
|
390 TPointerEvent& pointerEvent = const_cast<TPointerEvent&>( aPointerEvent ); |
|
391 pointerEvent.iModifiers &= ~EModifierShift; |
|
392 pointerEvent.iModifiers &= ~EModifierCtrl; |
|
393 |
|
394 CAknSetStyleListBox::HandlePointerEventL( pointerEvent ); |
|
395 } |
|
396 |
|
397 |
|
398 EXPORT_C void* CAknPopupSettingList::ExtensionInterface( TUid /*aInterface*/ ) |
|
399 { |
|
400 return NULL; |
|
401 } |
|
402 |
|
403 /** |
|
404 * All this does now is remove this from the stack |
|
405 * |
|
406 */ |
|
407 EXPORT_C void CAknPopupSettingList::DestroyMenuList() |
|
408 { |
|
409 iEikonEnv->RemoveFromStack(this); |
|
410 } |
|
411 |
|
412 /** |
|
413 * Create the popup list. Current implementation |
|
414 * |
|
415 */ |
|
416 EXPORT_C void CAknPopupSettingList::CreateMenuListL() |
|
417 { |
|
418 if (!iExtension) |
|
419 { |
|
420 iExtension = new ( ELeave ) CAknPopupSettingListExtension( *this ); |
|
421 } |
|
422 |
|
423 // set the array into the listbox |
|
424 Model()->SetItemTextArray(iLayoutDecorator); |
|
425 Model()->SetOwnershipType(ELbmDoesNotOwnItemArray); |
|
426 View()->ClearSelection(); |
|
427 |
|
428 // must update the scrollbars before setting the current index |
|
429 UpdateScrollBarsL(); |
|
430 |
|
431 TInt selection = -1; |
|
432 |
|
433 if(iValue) |
|
434 selection = iValue->CurrentValueIndex(); |
|
435 |
|
436 if ( selection > -1 ) |
|
437 { |
|
438 View()->SelectItemL(selection); |
|
439 iCurrentSelection = selection; |
|
440 } |
|
441 |
|
442 MakeVisible(ETrue); |
|
443 ActivateL(); |
|
444 |
|
445 } |
|
446 |
|
447 |
|
448 EXPORT_C void CAknPopupSettingList::Reserved_1() |
|
449 {} |
|
450 EXPORT_C void CAknPopupSettingList::Reserved_2() |
|
451 {} |
|
452 |
|
453 |
|
454 |
|
455 /** |
|
456 * Sets flag that enables user defined entry. Note that flag can also be set from resources, |
|
457 * but this method allows behaviour to be changed at runtime. |
|
458 * |
|
459 * @param aAllows if ETrue, set flag; if EFalse, clear flag. |
|
460 */ |
|
461 EXPORT_C void CAknPopupSettingList::SetAllowsUserDefinedEntry(TBool aAllows) |
|
462 { |
|
463 if(aAllows) |
|
464 iFlags |= EAknPopupSettingListFlagAllowsUserDefinedEntry; |
|
465 else |
|
466 iFlags &= ~EAknPopupSettingListFlagAllowsUserDefinedEntry; |
|
467 |
|
468 ConfigureDecorator(); |
|
469 } |
|
470 |
|
471 |
|
472 |
|
473 /** |
|
474 * Used by the client to set the query value used to represent the user defined |
|
475 * value belonging to this popup field control. |
|
476 * |
|
477 * @param aValue pointer to value, ownership is not passed |
|
478 * |
|
479 */ |
|
480 EXPORT_C void CAknPopupSettingList::SetQueryValueL(MAknQueryValue* aValue) |
|
481 { |
|
482 __ASSERT_DEBUG(aValue, Panic(EAknPanicPopupSettingListInvalidValue)); |
|
483 iValue = aValue; // The query value is externally owned. Just copy the pointer |
|
484 ConfigureMenuListL(); |
|
485 ActivateMenuListL(); |
|
486 } |
|
487 |
|
488 |
|
489 /** |
|
490 * Set the flag which determines whether the indicators are shown |
|
491 * In practice the indicators have the appearance of radio buttons |
|
492 * |
|
493 * @param aShowIndicators |
|
494 * If ETrue, indicators are displayed; |
|
495 * if EFalse, indicators are not displayed |
|
496 * |
|
497 */ |
|
498 EXPORT_C void CAknPopupSettingList::SetShowIndicators(TBool aShowIndicators) |
|
499 { |
|
500 __ASSERT_DEBUG(iLayoutDecorator, Panic(EAknPanicPopupSettingListUninitialisedMember)); |
|
501 iLayoutDecorator->SetActive(aShowIndicators); |
|
502 } |
|
503 |
|
504 /** |
|
505 * number of lines used |
|
506 * |
|
507 * @returns number of lines being currently displayed by control, which is determined |
|
508 * by the number of entries on the selection list, and whether the selection list is active. |
|
509 * NOTE that the number is limited by KAknMaxLinesOnOnePage |
|
510 * |
|
511 */ |
|
512 EXPORT_C TInt CAknPopupSettingList::NumLines() const |
|
513 { |
|
514 TInt lines = iDecorator.MdcaCount(); |
|
515 |
|
516 // The maximum lines for the listbox |
|
517 TAknLayoutScalableParameterLimits listBoxLimits = |
|
518 AknLayoutScalable_Avkon::list_set_graphic_pane_ParamLimits(); |
|
519 TInt maxNumberOfRows = listBoxLimits.LastRow() + 1; |
|
520 |
|
521 // we must restrict ourselves to the max number of lines, as form will allow controls to be larger (e.g. edwin) |
|
522 if(lines > maxNumberOfRows) |
|
523 lines = maxNumberOfRows; |
|
524 |
|
525 return lines; |
|
526 } |
|
527 |
|
528 /** |
|
529 * set an observer of this class to receive events from popup setting list |
|
530 * |
|
531 * @param aObserver pointer to the class that implements the observer interface, |
|
532 * |
|
533 */ |
|
534 EXPORT_C void CAknPopupSettingList::SetPopupSettingListObserver(MAknPopupSettingListObserver* aObserver) |
|
535 { |
|
536 iPopupSettingListObserver = aObserver; |
|
537 } |
|
538 |
|
539 /** |
|
540 * Selects current item. |
|
541 */ |
|
542 void CAknPopupSettingList::SelectCurrentItemL() |
|
543 { |
|
544 CListBoxView* view = View(); |
|
545 |
|
546 if ( iCurrentSelection != view->CurrentItemIndex() ) |
|
547 { |
|
548 view->DeselectItem( iCurrentSelection ); |
|
549 iCurrentSelection = view->CurrentItemIndex(); |
|
550 view->SelectItemL( iCurrentSelection ); |
|
551 } |
|
552 |
|
553 if ( iValue ) |
|
554 { |
|
555 iValue->SetCurrentValueIndex( iCurrentSelection ); |
|
556 } |
|
557 |
|
558 if ( iPopupSettingListObserver ) |
|
559 { |
|
560 // To do selection, point event needs |
|
561 // EAknPopupSettingSelectionAndClose, but it will also cause |
|
562 // AttemptExit() run twice. So we give different oberver |
|
563 // event for them. |
|
564 iPopupSettingListObserver->HandlePopupSettingListEventL( |
|
565 this, |
|
566 MAknPopupSettingListObserver::EAknPopupSettingSelectionAndRequestAccept, |
|
567 iCurrentSelection ); |
|
568 } |
|
569 } |
|
570 |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CAknPopupSettingList::CurrentSelection |
|
574 // ----------------------------------------------------------------------------- |
|
575 // |
|
576 TInt CAknPopupSettingList::CurrentSelection() const |
|
577 { |
|
578 return iCurrentSelection; |
|
579 } |
|
580 |
|
581 |
|
582 /** |
|
583 * Configures the decoration according to the currently set flags. |
|
584 * Should be called whenever the flags are changed. |
|
585 * |
|
586 */ |
|
587 void CAknPopupSettingList::ConfigureDecorator() |
|
588 { |
|
589 __ASSERT_DEBUG(iOtherText, Panic(EAknPanicPopupSettingListUninitialisedMember)); |
|
590 |
|
591 iDecorator.SetDecorationText(*iOtherText); |
|
592 iDecorator.SetActive(iFlags & EAknPopupSettingListFlagAllowsUserDefinedEntry); |
|
593 |
|
594 // decorate the array from the query value |
|
595 if(iValue) |
|
596 { |
|
597 const MDesCArray* array = iValue->MdcArray(); |
|
598 iDecorator.SetArray(array); |
|
599 } |
|
600 } |
|
601 |
|
602 /** |
|
603 * Configures the layout decoration according to the "has buttons" flag |
|
604 * Should be called whenever the flags are changed. |
|
605 * |
|
606 */ |
|
607 void CAknPopupSettingList::ConstructLayoutDecoratorL() |
|
608 { |
|
609 delete iLayoutDecorator; |
|
610 iLayoutDecorator = NULL; |
|
611 iLayoutDecorator = CAknListBoxLayoutDecorator::NewL(); |
|
612 TPtrC textPtr(KPopupSettingListLeadingLayoutText); |
|
613 iLayoutDecorator->SetLeadingDecorationTextL(textPtr); |
|
614 iLayoutDecorator->SetArray(&iDecorator); |
|
615 iLayoutDecorator->SetActive(ETrue); // for now, always has buttons |
|
616 } |
|
617 |
|
618 EXPORT_C void CAknPopupSettingList::HandleResourceChange(TInt aType) |
|
619 { |
|
620 if( aType == KAknsMessageSkinChange ) |
|
621 { |
|
622 TRAP_IGNORE(InitialiseRadioButtonBitmapsL()); |
|
623 } |
|
624 CAknSetStyleListBox::HandleResourceChange(aType); |
|
625 } |
|
626 // |
|
627 // CAknPopupSettingPage Implementation |
|
628 // |
|
629 // |
|
630 |
|
631 |
|
632 ////////////////////////////////////////////////////////////////////// |
|
633 // Construction/Destruction |
|
634 ////////////////////////////////////////////////////////////////////// |
|
635 |
|
636 |
|
637 EXPORT_C CAknPopupSettingPage::CAknPopupSettingPage( TInt aResourceId, MAknQueryValue& aQueryValue ): |
|
638 CAknListBoxSettingPage(aResourceId), iQueryValue(aQueryValue) |
|
639 { |
|
640 AKNTASHOOK_ADD( this, "CAknPopupSettingPage" ); |
|
641 } |
|
642 |
|
643 EXPORT_C CAknPopupSettingPage::CAknPopupSettingPage( |
|
644 const TDesC* aSettingText, |
|
645 TInt aSettingNumber, |
|
646 TInt aControlType, |
|
647 TInt aEditorResourceId, |
|
648 TInt aSettingPageResourceId, |
|
649 MAknQueryValue& aQueryValue) |
|
650 : CAknListBoxSettingPage( |
|
651 aSettingText, |
|
652 aSettingNumber, |
|
653 aControlType, |
|
654 aEditorResourceId, |
|
655 aSettingPageResourceId ), |
|
656 iQueryValue(aQueryValue) |
|
657 { |
|
658 AKNTASHOOK_ADD( this, "CAknPopupSettingPage" ); |
|
659 } |
|
660 |
|
661 /** |
|
662 * Destructor |
|
663 * |
|
664 */ |
|
665 EXPORT_C CAknPopupSettingPage::~CAknPopupSettingPage() |
|
666 { |
|
667 AKNTASHOOK_REMOVE(); |
|
668 } |
|
669 |
|
670 EXPORT_C void CAknPopupSettingPage::ConstructL() |
|
671 { |
|
672 BaseConstructL(); |
|
673 |
|
674 // Construct an appropriate control context for the contained editor areas. |
|
675 // Context produced is owned by CAknSettingPage. |
|
676 SetEditedItemFrameIID( KAknsIIDQsnFrSetOpt, KAknsIIDQsnFrSetOptCenter ); |
|
677 |
|
678 iQueryValue.SetQueryMode( MAknQueryValue::ESettingPageMode ); |
|
679 PopupSettingListBox()->SetQueryValueL( &iQueryValue ); |
|
680 CheckAndSetDataValidity(); |
|
681 UpdateCbaL(); |
|
682 |
|
683 PopupSettingListBox()->SetPopupSettingListObserver( this ); |
|
684 // Set the scroller indication to appear when needed |
|
685 ListBoxControl()->CreateScrollBarFrameL(ETrue, ETrue); |
|
686 ListBoxControl()->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto); |
|
687 ListBoxControl()->ScrollBarFrame()->VerticalScrollBar()->SetMopParent(this); |
|
688 |
|
689 if(!IsBackgroundDrawingEnabled()) |
|
690 ListBoxControl()->ScrollBarFrame()->DrawBackground(EFalse, EFalse); |
|
691 |
|
692 ListBoxControl()->ItemDrawer()->FormattedCellData()->SetDrawScrollbarBackground( EFalse ); |
|
693 |
|
694 // This must be called to propogate the changed size of the listbox upward |
|
695 SizeChanged(); |
|
696 |
|
697 // Exercise initial selection policy |
|
698 if ( FocusToSelectedItem() ) |
|
699 ListBoxControl()->SetCurrentItemIndex( iQueryValue.CurrentValueIndex() ); |
|
700 if ( FocusToFirstItem() ) |
|
701 ListBoxControl()->SetCurrentItemIndex( 0 ); |
|
702 } |
|
703 |
|
704 EXPORT_C void CAknPopupSettingPage::HandlePopupSettingListEventL(CAknPopupSettingList* /*aPopupSettingList*/, TAknPopupSettingListEvent aEventType, TInt /*aHint*/) |
|
705 { |
|
706 if ( aEventType == MAknPopupSettingListObserver::EAknPopupSettingSelectionAndRequestAccept ) |
|
707 { |
|
708 CheckAndSetDataValidity(); |
|
709 UpdateCbaL(); |
|
710 SizeChanged(); |
|
711 ListBoxControl()->SetCurrentItemIndex( iQueryValue.CurrentValueIndex() ); |
|
712 DrawDeferred(); |
|
713 } |
|
714 else if ( aEventType == MAknPopupSettingListObserver::EAknPopupSettingSelectionAndClose ) |
|
715 { |
|
716 AttemptExitL(ETrue); |
|
717 } |
|
718 } |
|
719 |
|
720 |
|
721 EXPORT_C CAknPopupSettingList* CAknPopupSettingPage::PopupSettingListBox() const |
|
722 { |
|
723 return STATIC_CAST( CAknPopupSettingList*, EditorControl()); |
|
724 } |
|
725 |
|
726 /** |
|
727 * This is required to give access to the QUery from re-implementations of the |
|
728 * popup setting page |
|
729 * |
|
730 */ |
|
731 EXPORT_C MAknQueryValue* CAknPopupSettingPage::QueryValue() const |
|
732 { |
|
733 return &iQueryValue; |
|
734 } |
|
735 |
|
736 EXPORT_C void CAknPopupSettingPage::SelectCurrentItemL() |
|
737 { |
|
738 CAknPopupSettingList* list = PopupSettingListBox(); |
|
739 |
|
740 if ( ( list->ItemDrawer()->Flags() & |
|
741 CListItemDrawer::ESingleClickDisabledHighlight ) |
|
742 && list->CurrentItemIndex() != list->CurrentSelection() ) |
|
743 { |
|
744 list->View()->SetCurrentItemIndex( list->CurrentSelection() ); |
|
745 } |
|
746 |
|
747 PopupSettingListBox()->SelectCurrentItemL(); |
|
748 } |
|
749 |
|
750 EXPORT_C void CAknPopupSettingPage::UpdateQueryValueL( MAknQueryValue* aQueryValue ) |
|
751 { |
|
752 PopupSettingListBox()->SetQueryValueL( aQueryValue ); |
|
753 iQueryValue = *aQueryValue ; |
|
754 CheckAndSetDataValidity(); |
|
755 UpdateCbaL(); |
|
756 SizeChanged(); |
|
757 // Note that there is no update of the highlight selection here. |
|
758 DrawDeferred(); |
|
759 } |
|
760 |
|
761 EXPORT_C CAknSetStyleListBox* CAknPopupSettingPage::ListBoxControl() const |
|
762 { |
|
763 return ( PopupSettingListBox() ); |
|
764 } |
|
765 |
|
766 /** |
|
767 * Writes the internal state of the control and its components to aStream. |
|
768 * Does nothing in release mode. |
|
769 * Designed to be overidden and base called by subclasses. |
|
770 */ |
|
771 #ifndef _DEBUG |
|
772 EXPORT_C void CAknPopupSettingPage::WriteInternalStateL(RWriteStream& /*aWriteStream*/) const |
|
773 {} |
|
774 #else |
|
775 EXPORT_C void CAknPopupSettingPage::WriteInternalStateL(RWriteStream& aWriteStream) const |
|
776 { |
|
777 CAknSettingPage::WriteInternalStateL(aWriteStream); |
|
778 } |
|
779 #endif |
|
780 |
|
781 EXPORT_C void CAknPopupSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
782 { |
|
783 CAknListBoxSettingPage::HandlePointerEventL(aPointerEvent); |
|
784 if ( TPointerEvent::EDrag == aPointerEvent.iType ) |
|
785 { |
|
786 if ( !( Rect().Contains( aPointerEvent.iPosition ) ) ) |
|
787 { |
|
788 // Clear focus if dragged outside popup |
|
789 PopupSettingListBox()->HandleResourceChange( KAknMessageFocusLost ); |
|
790 } |
|
791 } |
|
792 } |
|
793 |
|
794 EXPORT_C void* CAknPopupSettingPage::ExtensionInterface( TUid /*aInterface*/ ) |
|
795 { |
|
796 return NULL; |
|
797 } |
|
798 |
|
799 /** |
|
800 * Reserved method derived from CCoeControl |
|
801 */ |
|
802 EXPORT_C void CAknPopupSettingPage::Reserved_2() |
|
803 { |
|
804 } |
|
805 |
|
806 /** |
|
807 * Setting Page reserved methods |
|
808 */ |
|
809 EXPORT_C void CAknPopupSettingPage::CAknSettingPage_Reserved_1() |
|
810 { |
|
811 } |
|
812 EXPORT_C void CAknPopupSettingPage::CAknSettingPage_Reserved_2() |
|
813 { |
|
814 } |
|
815 /** |
|
816 * CAknListBoxSettingPage-derived reserved methods |
|
817 */ |
|
818 EXPORT_C void CAknPopupSettingPage::CAknListBoxSettingPage_Reserved_1() |
|
819 { |
|
820 } |
|
821 |
|
822 // End of File |