|
1 /* |
|
2 * Copyright (c) 2002-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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDES |
|
20 #include "CAknCommonDialogsRadioButtonSettingPage.h" |
|
21 #include "MAknCommonDialogsEventObserver.h" |
|
22 #include "CAknMemorySelectionDialog.h" |
|
23 #include "CAknMemorySelectionModel.h" |
|
24 |
|
25 #include <AknTasHook.h> // for testability hooks |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CAknCommonDialogsRadioButtonSettingPage::CAknCommonDialogsRadioButtonSettingPage |
|
30 // |
|
31 // |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CAknCommonDialogsRadioButtonSettingPage::CAknCommonDialogsRadioButtonSettingPage( |
|
35 TInt aResourceId, |
|
36 TInt& aCurrentSelectionItem, |
|
37 const MDesCArray* aItemArray, |
|
38 MAknCommonDialogsEventObserver& aObserver, |
|
39 CAknMemorySelectionModel* aModel ) |
|
40 : CAknRadioButtonSettingPage( aResourceId, aCurrentSelectionItem, aItemArray ), |
|
41 iObserver( aObserver ), iModel( aModel ) |
|
42 { |
|
43 AKNTASHOOK_ADD( this, "CAknCommonDialogsRadioButtonSettingPage" ); |
|
44 } |
|
45 |
|
46 // Destructor |
|
47 CAknCommonDialogsRadioButtonSettingPage::~CAknCommonDialogsRadioButtonSettingPage() |
|
48 { |
|
49 AKNTASHOOK_REMOVE(); |
|
50 } |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CAknCommonDialogsRadioButtonSettingPage::Cba |
|
55 // |
|
56 // |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CEikButtonGroupContainer* CAknCommonDialogsRadioButtonSettingPage::Cba() const |
|
60 { |
|
61 return CAknSettingPage::Cba(); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CAknCommonDialogsRadioButtonSettingPage::OkToExitL |
|
66 // |
|
67 // |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 TBool CAknCommonDialogsRadioButtonSettingPage::OkToExitL( TBool aAccept ) |
|
71 { |
|
72 // If user accepts a selection |
|
73 if( aAccept ) |
|
74 { |
|
75 CAknSetStyleListBox* lb = ListBoxControl(); |
|
76 TInt focus( lb->CurrentItemIndex() ); |
|
77 TInt topIndex( lb->TopItemIndex() ); |
|
78 if( iObserver.HandleEventL( |
|
79 MAknCommonDialogsEventObserver::ELeftSoftkeyPress, focus, topIndex, NULL ) |
|
80 != MAknCommonDialogsEventObserver::ETryingToExit ) |
|
81 { |
|
82 return EFalse; |
|
83 } |
|
84 else |
|
85 { |
|
86 UpdateAndRedrawItemL(); |
|
87 } |
|
88 |
|
89 } |
|
90 return CAknRadioButtonSettingPage::OkToExitL( aAccept ); |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CAknCommonDialogsRadioButtonSettingPage::OfferKeyEventL |
|
95 // |
|
96 // |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 TKeyResponse CAknCommonDialogsRadioButtonSettingPage::OfferKeyEventL( |
|
100 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
101 { |
|
102 if( aType == EEventKey ) |
|
103 { |
|
104 CAknSetStyleListBox* lb = ListBoxControl(); |
|
105 switch( aKeyEvent.iCode ) |
|
106 { |
|
107 case EKeyUpArrow: |
|
108 case EKeyDownArrow: |
|
109 { |
|
110 // Get current item index |
|
111 TInt oldIndex( lb->CurrentItemIndex() ); |
|
112 // Call OfferKeyEventL |
|
113 TKeyResponse response( |
|
114 CAknSettingPage::OfferKeyEventL( aKeyEvent, aType ) ); |
|
115 // Get new item index |
|
116 TInt newIndex( lb->CurrentItemIndex() ); |
|
117 // Compare new and old index |
|
118 if( oldIndex != newIndex ) |
|
119 { |
|
120 // Notify focus change only if focus actually changes |
|
121 // Top item index value is zero because there is no need to |
|
122 // know what it is in focus change. |
|
123 oldIndex = 0; |
|
124 iObserver.HandleEventL( MAknCommonDialogsEventObserver::EFocusChange, |
|
125 newIndex, oldIndex, Cba() ); |
|
126 } |
|
127 iUpdateItem = EFalse; |
|
128 return response; |
|
129 // No break needed after return |
|
130 } |
|
131 |
|
132 case EKeyOK: |
|
133 { |
|
134 TInt focus( lb->CurrentItemIndex() ); |
|
135 TInt topIndex( lb->TopItemIndex() ); |
|
136 |
|
137 if( iObserver.HandleEventL( |
|
138 MAknCommonDialogsEventObserver::ESelectionKeyPress, focus, topIndex, Cba() ) |
|
139 == MAknCommonDialogsEventObserver::ETryingToExit ) |
|
140 { |
|
141 HideMenu(); |
|
142 SelectCurrentItemL(); |
|
143 AttemptExitL( ETrue ); |
|
144 } |
|
145 return EKeyWasConsumed; |
|
146 // No break needed after return |
|
147 } |
|
148 |
|
149 case EKeyEscape: |
|
150 { |
|
151 AttemptExitL( EFalse ); |
|
152 return EKeyWasConsumed; |
|
153 // No break needed after return |
|
154 } |
|
155 |
|
156 default: |
|
157 { |
|
158 break; |
|
159 } |
|
160 } |
|
161 } |
|
162 else if( aType == EEventKeyUp ) |
|
163 { |
|
164 if( iUpdateItem ) |
|
165 { |
|
166 UpdateAndRedrawItemL(); |
|
167 } |
|
168 else |
|
169 { |
|
170 iUpdateItem = ETrue; |
|
171 } |
|
172 } |
|
173 return CAknSettingPage::OfferKeyEventL( aKeyEvent, aType ); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // CAknCommonDialogsRadioButtonSettingPage::UpdateAndRedrawItemL( ) |
|
178 // |
|
179 // |
|
180 // ----------------------------------------------------------------------------- |
|
181 // |
|
182 void CAknCommonDialogsRadioButtonSettingPage::UpdateAndRedrawItemL() |
|
183 { |
|
184 iModel->UpdateItemsL(); |
|
185 const CListBoxView::CSelectionIndexArray* selections = |
|
186 ListBoxControl()->View()->SelectionIndexes(); |
|
187 SetItemArrayAndSelectionL(iModel, (*selections)[0]); |
|
188 } |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CAknCommonDialogsRadioButtonSettingPage::ProcessCommandL(TInt aCommandId) |
|
192 // |
|
193 // |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CAknCommonDialogsRadioButtonSettingPage::ProcessCommandL(TInt aCommandId) |
|
197 { |
|
198 if(!IsEditable() && !(aCommandId == EAknSoftkeyBack || aCommandId == EAknSoftkeyCancel)) |
|
199 { |
|
200 return; |
|
201 } |
|
202 |
|
203 HideMenu(); |
|
204 |
|
205 // Respond to softkey events |
|
206 switch (aCommandId) |
|
207 { |
|
208 case EAknSoftkeyOk: |
|
209 case EAknSoftkeySelect: |
|
210 case EAknSoftkeyDone: |
|
211 { |
|
212 SelectCurrentItemL(); // has non-trivial implemenations in listbox type |
|
213 // controls to put the selection on the current item |
|
214 AttemptExitL(ETrue); |
|
215 break; |
|
216 } |
|
217 case EAknSoftkeyBack: |
|
218 case EAknSoftkeyCancel: |
|
219 AttemptExitL(EFalse); |
|
220 break; |
|
221 case EAknSoftkeyOptions: |
|
222 DisplayMenuL(); |
|
223 break; |
|
224 default: |
|
225 break; |
|
226 } |
|
227 } |
|
228 // ----------------------------------------------------------------------------- |
|
229 // CAknCommonDialogsRadioButtonSettingPage::NotifyDrivesChangedL |
|
230 // |
|
231 // |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 void CAknCommonDialogsRadioButtonSettingPage::NotifyDrivesChangedL( |
|
235 const MDesCArray* aItemArray) |
|
236 { |
|
237 // Update memory names & keep old selection |
|
238 const CListBoxView::CSelectionIndexArray* selections = |
|
239 ListBoxControl()->View()->SelectionIndexes(); |
|
240 SetItemArrayAndSelectionL(aItemArray, (*selections)[0]); |
|
241 |
|
242 // Enable button in CBA |
|
243 CEikButtonGroupContainer* cba = Cba(); |
|
244 MEikButtonGroup* buttonGroup = cba->ButtonGroup(); |
|
245 cba->MakeCommandVisible( buttonGroup->CommandId( 0 ), |
|
246 TBool( ETrue ) ); |
|
247 } |
|
248 |
|
249 // End of File |