|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of CDestListbox |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <eikclbd.h> |
|
19 #include <avkon.mbg> |
|
20 #include <aknkeys.h> |
|
21 #include <data_caging_path_literals.hrh> |
|
22 #include <cmmanager.mbg> |
|
23 |
|
24 #include "destlistbox.h" |
|
25 #include "destlistboxmodel.h" |
|
26 #include "destlistitem.h" |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CDestListbox::NewL |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CDestListbox* CDestListbox::NewL( const CCoeControl* aParent ) |
|
33 { |
|
34 CDestListbox* listbox = new ( ELeave ) CDestListbox(); |
|
35 CleanupStack::PushL( listbox ); |
|
36 listbox->ConstructL( aParent, EAknListBoxSelectionList ); |
|
37 CleanupStack::Pop( listbox ); |
|
38 return listbox; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CDestListbox::CDestListbox |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CDestListbox::CDestListbox() |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CDestListbox::~CDestListbox |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CDestListbox::~CDestListbox() |
|
54 { |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // CDestListbox::OfferKeyEventL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 TKeyResponse CDestListbox::OfferKeyEventL |
|
62 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
63 { |
|
64 if ( aKeyEvent.iCode == EKeyOK && |
|
65 !( aKeyEvent.iModifiers & EModifierShift ) ) |
|
66 { |
|
67 // Enter pressed (not Shift-Enter). This will report an |
|
68 // EEnterKeyPressed event sent to the observer (the view), which may |
|
69 // delete this listbox. The code which processes keypresses by |
|
70 // default, will continue (on the already deleted listbox), and |
|
71 // will crash. So we grab this keypress here, and generate the |
|
72 // same event, but after that, quit immediately! |
|
73 ReportListBoxEventL( MEikListBoxObserver::EEventEnterKeyPressed ); |
|
74 // By now the listbox may have been deleted! |
|
75 // Do not access it after this point! |
|
76 return EKeyWasConsumed; |
|
77 } |
|
78 else |
|
79 { |
|
80 return CAknDoubleLargeStyleListBox::OfferKeyEventL( aKeyEvent, aType ); |
|
81 } |
|
82 } |
|
83 |
|
84 // --------------------------------------------------------------------------- |
|
85 // CDestListbox::FocusChanged |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 void CDestListbox::FocusChanged( TDrawNow aDrawNow ) |
|
89 { |
|
90 // Do nothing until the listbox is fully constructed |
|
91 // The dialogpage sets the focus before calling ConstructL |
|
92 if ( iView ) |
|
93 { |
|
94 CAknDoubleLargeStyleListBox::FocusChanged( aDrawNow ); |
|
95 } |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CDestListbox::Uid4Item |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 TUint32 CDestListbox::Uid4Item( TInt aItem ) const |
|
103 { |
|
104 CDestListboxModel* lbmodel = |
|
105 STATIC_CAST( CDestListboxModel*, Model()->ItemTextArray() ); |
|
106 return lbmodel->At( aItem )->Uid(); |
|
107 } |
|
108 |
|
109 // --------------------------------------------------------------------------- |
|
110 // CDestListbox::CurrentItemUid |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 TUint32 CDestListbox::CurrentItemUid() const |
|
114 { |
|
115 CDestListboxModel* lbmodel = |
|
116 STATIC_CAST( CDestListboxModel*, Model()->ItemTextArray() ); |
|
117 TInt idx = CurrentItemIndex(); |
|
118 TUint32 retval( 0 ); |
|
119 if ( idx >= 0 ) |
|
120 { |
|
121 retval = lbmodel->At( idx )->Uid(); |
|
122 } |
|
123 return retval; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CDestListbox::CurrentItemNameL |
|
128 // --------------------------------------------------------------------------- |
|
129 // |
|
130 const TDesC& CDestListbox::CurrentItemNameL() |
|
131 { |
|
132 CDestListboxModel* lbmodel = new( ELeave )CDestListboxModel; |
|
133 lbmodel = STATIC_CAST( CDestListboxModel*, Model()->ItemTextArray() ); |
|
134 return lbmodel->At( CurrentItemIndex() )->Name(); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------------------------- |
|
138 // CDestListbox::HandleResourceChange |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CDestListbox::HandleResourceChange(TInt aType) |
|
142 { |
|
143 if ( aType == KAknsMessageSkinChange ) |
|
144 { |
|
145 SizeChanged(); |
|
146 } |
|
147 |
|
148 CAknDoubleLargeStyleListBox::HandleResourceChange( aType ); |
|
149 } |
|
150 |