1 /* |
|
2 * Copyright (c) 2005 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: Source file for Location System UI container. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // System Includes |
|
21 #include <eikspane.h> // Status pane |
|
22 #include <akntitle.h> // CAknTitlePane |
|
23 #include <barsread.h> // For TResourceReader |
|
24 #include <aknlists.h> // List box |
|
25 #include <locsysuiviewrsc.rsg> |
|
26 #include <csxhelp/locset.hlp.hrh> |
|
27 |
|
28 // User Includes |
|
29 #include "locsysuicontainer.h" |
|
30 #include "locsysuiview.h" |
|
31 #include "locationsettings.h" |
|
32 #include "locsysuilbmodel.h" |
|
33 #include "locsysuiviewuid.hrh" |
|
34 |
|
35 // ========================= MEMBER FUNCTIONS ================================ |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CLocSysUiContainer::CLocSysUiContainer |
|
39 // Overloaded Constructor |
|
40 // |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CLocSysUiContainer::CLocSysUiContainer( |
|
44 MLocSysUiContainerEventHandler& aEventHandler ) |
|
45 :iEventHandler( aEventHandler ) |
|
46 { |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CLocSysUiContainer::~CLocSysUiContainer |
|
51 // Destructor |
|
52 // |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CLocSysUiContainer::~CLocSysUiContainer() |
|
56 { |
|
57 // Delete the list box |
|
58 delete iListBox; |
|
59 |
|
60 // Delete the List box model |
|
61 delete iListBoxModel; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CLocSysUiContainer* CLocSysUiContainer::NewL |
|
66 // Static Two phase contructor that instantiates the CLocationSystemUiUIContainer |
|
67 // |
|
68 // @param aEventHandler Reference to the Container's event handler |
|
69 // @param aSettingsArray Reference to the Settings UI array. |
|
70 // @param aRect Client rectangle. |
|
71 // @return CLocSysUiContainer* Reference to the object created. |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 CLocSysUiContainer* CLocSysUiContainer::NewL( |
|
75 MLocSysUiContainerEventHandler& aEventHandler, |
|
76 RPointerArray<CLocationSettings>& aSettingsArray, |
|
77 const TRect& aRect ) |
|
78 { |
|
79 CLocSysUiContainer* self = CLocSysUiContainer::NewLC( aEventHandler, |
|
80 aSettingsArray, |
|
81 aRect ); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // CLocSysUiContainer* CLocSysUiContainer::NewL |
|
88 // Static Two phase contructor that instantiates the CLocationSystemUiUIContainer |
|
89 // |
|
90 // @param aEventHandler Reference to the Container's event handler |
|
91 // @param aSettingsArray Reference to the Settings UI array. |
|
92 // @param aRect Client rectangle. |
|
93 // @return CLocSysUiContainer* Reference to the object created. |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CLocSysUiContainer* CLocSysUiContainer::NewLC( |
|
97 MLocSysUiContainerEventHandler& aEventHandler, |
|
98 RPointerArray<CLocationSettings>& aSettingsArray, |
|
99 const TRect& aRect ) |
|
100 { |
|
101 CLocSysUiContainer* self = new(ELeave) CLocSysUiContainer( aEventHandler ); |
|
102 CleanupStack::PushL( self ); |
|
103 self->ConstructL( aSettingsArray, aRect ); |
|
104 return self; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // void CLocSysUiContainer::ConstructL |
|
109 // Second phase of the two phase Construction process |
|
110 // |
|
111 // @param aSettingsArray Reference to the Settings UI array. |
|
112 // @param aRect Client rectangle |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 void CLocSysUiContainer::ConstructL( |
|
116 RPointerArray<CLocationSettings>& aSettingsArray, |
|
117 const TRect& aRect ) |
|
118 { |
|
119 //Make this control a window-owning control |
|
120 CreateWindowL(); |
|
121 |
|
122 // Create a New Title for the View |
|
123 MakeTitleL(R_LOCSYSUIVIEW_TITLE); |
|
124 |
|
125 CreateListboxL( aSettingsArray ); |
|
126 |
|
127 iContextName = KLOC_HLP_SETTINGS(); |
|
128 SetRect( aRect ); |
|
129 ActivateL(); |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CLocationSettings& CLocSysUiContainer::GetFocussedSettingsUiDescL |
|
134 // Returns the Description for the Settings Ui item that is currently focussed |
|
135 // |
|
136 // @return CLocSettingsUiDesc* Reference to the description object of |
|
137 // the item that is currently focussed |
|
138 // NULL If there is no list box |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 CLocationSettings& CLocSysUiContainer::GetFocussedSettingsUiL() |
|
142 { |
|
143 TInt selectedItem = iListBox->CurrentItemIndex(); |
|
144 return iListBoxModel->SettingsUiL( selectedItem ); |
|
145 } |
|
146 |
|
147 // --------------------------------------------------------------------------- |
|
148 // void CLocSysUiContainer::UpdateListBoxL |
|
149 // Calls upon the container to update the list bix contents. |
|
150 // |
|
151 // @param aSettingsArray Reference to the Settings UI array. |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void CLocSysUiContainer::UpdateListBoxL( |
|
155 RPointerArray<CLocationSettings>& aSettingsArray ) |
|
156 { |
|
157 iListBoxModel->UpdateListBoxContentsL( aSettingsArray ); |
|
158 iListBox->HandleItemAdditionL(); |
|
159 iListBox->HandleItemRemovalL(); |
|
160 DrawDeferred(); |
|
161 } |
|
162 |
|
163 // --------------------------------------------------------------------------- |
|
164 // TUint CLocSysUiContainer::CurrentFocussedElement |
|
165 // Returns the currently focussed element index |
|
166 // |
|
167 // @return TUint Currently focussed element index |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 TUint CLocSysUiContainer::CurrentFocussedElement() |
|
171 { |
|
172 TInt ret = iListBox->CurrentItemIndex(); |
|
173 if( ret < 0 ) |
|
174 { |
|
175 ret = 0; |
|
176 } |
|
177 return ret; |
|
178 } |
|
179 |
|
180 // --------------------------------------------------------------------------- |
|
181 // Sets the current highlighted element |
|
182 // |
|
183 // @param aCurrentElement Currently focussed element index |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void CLocSysUiContainer::SetFocussedElement( TUint aCurrentElement ) |
|
187 { |
|
188 iListBox->SetCurrentItemIndex( aCurrentElement ); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // void CLocSysUiContainer::OfferKeyEventL |
|
193 // |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 TKeyResponse CLocSysUiContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
197 TEventCode aType ) |
|
198 { |
|
199 switch ( aKeyEvent.iCode ) |
|
200 { |
|
201 case EKeyLeftArrow: |
|
202 case EKeyRightArrow: |
|
203 { |
|
204 // Listbox takes all event even if it doesn't use them |
|
205 return EKeyWasNotConsumed; |
|
206 } |
|
207 default: |
|
208 { |
|
209 break; |
|
210 } |
|
211 } |
|
212 // now it's iListBox's job to process the key event |
|
213 return iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // void CLocSysUiContainer::HandleResourceChange |
|
218 // |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CLocSysUiContainer::HandleResourceChange(TInt aType) |
|
222 { |
|
223 // Pass the event to the base class |
|
224 CCoeControl::HandleResourceChange(aType); |
|
225 switch ( aType ) |
|
226 { |
|
227 // Dynamic Layout switch |
|
228 case KEikDynamicLayoutVariantSwitch: |
|
229 { |
|
230 iEventHandler.HandleScreenSizeChange(); |
|
231 break; |
|
232 } |
|
233 default: |
|
234 { |
|
235 break; |
|
236 } |
|
237 } |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // TInt CLocSysUiContainer::CountComponentControls |
|
242 // |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 TInt CLocSysUiContainer::CountComponentControls() const |
|
246 { |
|
247 return 1; |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // CCoeControl* CLocSysUiContainer::ComponentControl |
|
252 // |
|
253 // --------------------------------------------------------------------------- |
|
254 // |
|
255 CCoeControl* CLocSysUiContainer::ComponentControl(TInt /*aIndex*/) const |
|
256 { |
|
257 return iListBox; |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CLocSysUiContainer::GetHelpContext |
|
262 // Overridden from CCoeControl. Retruns the help context |
|
263 // |
|
264 // @param aContext The requested Help context |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 void CLocSysUiContainer::GetHelpContext( TCoeHelpContext& aContext ) const |
|
268 { |
|
269 aContext.iContext = iContextName; |
|
270 aContext.iMajor = TUid::Uid( LOCSYSUIVIEW_UID3 ); |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------------------------- |
|
274 // void CLocSysUiContainer::HandleListBoxEventL |
|
275 // |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void CLocSysUiContainer::HandleListBoxEventL( CEikListBox* /* aListBox */, |
|
279 TListBoxEvent aEventType ) |
|
280 { |
|
281 switch (aEventType) |
|
282 { |
|
283 // List box Item Selection |
|
284 case EEventEnterKeyPressed: |
|
285 case EEventItemSingleClicked: |
|
286 { |
|
287 iEventHandler.ListBoxItemSelectedL(); |
|
288 break; |
|
289 } |
|
290 default: |
|
291 break; |
|
292 } |
|
293 } |
|
294 |
|
295 // --------------------------------------------------------------------------- |
|
296 // void CLocSysUiContainer::FocusChanged |
|
297 // |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CLocSysUiContainer::FocusChanged(TDrawNow aDrawNow) |
|
301 { |
|
302 CCoeControl::FocusChanged( aDrawNow ); |
|
303 if ( iListBox ) |
|
304 { |
|
305 iListBox->SetFocus( IsFocused(), aDrawNow ); |
|
306 } |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CLocSysUiContainer::SizeChanged |
|
311 // |
|
312 // --------------------------------------------------------------------------- |
|
313 // |
|
314 void CLocSysUiContainer::SizeChanged() |
|
315 { |
|
316 if ( iListBox ) |
|
317 { |
|
318 iListBox->SetRect( Rect()); |
|
319 } |
|
320 } |
|
321 |
|
322 // --------------------------------------------------------------------------- |
|
323 // void CLocSysUiContainer::CreateListboxL |
|
324 // Creates the List box and the Listbox model. Associates the list box model |
|
325 // with the list box |
|
326 // |
|
327 // @param aSettingsArray Reference to the Settings UI array. |
|
328 // --------------------------------------------------------------------------- |
|
329 // |
|
330 void CLocSysUiContainer::CreateListboxL( |
|
331 RPointerArray<CLocationSettings>& aSettingsArray ) |
|
332 { |
|
333 // Create the Listbox model |
|
334 iListBoxModel = CLocSysUiLBModel::NewL( aSettingsArray ); |
|
335 |
|
336 // Create the List box |
|
337 iListBox = new( ELeave )CAknSettingStyleListBox; |
|
338 iListBox->ConstructL( this, EAknListBoxSelectionList ); |
|
339 iListBox->SetContainerWindowL( *this ); |
|
340 iListBox->SetListBoxObserver( this ); |
|
341 iListBox->CreateScrollBarFrameL(ETrue); |
|
342 iListBox->ScrollBarFrame()->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
343 CEikScrollBarFrame::EAuto ); |
|
344 |
|
345 iListBox->Model()->SetItemTextArray( iListBoxModel ); |
|
346 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
347 iListBox->ActivateL(); |
|
348 } |
|
349 |
|
350 // --------------------------------------------------------------------------- |
|
351 // void CLocSysUiContainer::StatusPane |
|
352 // Returns the Appui's status pane |
|
353 // |
|
354 // @return CEikStatusPane* Statuspane pointer |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 CEikStatusPane* CLocSysUiContainer::StatusPane() |
|
358 { |
|
359 return iEikonEnv->AppUiFactory()->StatusPane(); |
|
360 } |
|
361 |
|
362 // --------------------------------------------------------------------------- |
|
363 // void CLocSysUiContainer::MakeTitleL |
|
364 // Sets the Title text |
|
365 // |
|
366 // @param aResourceText Resource to create title |
|
367 // --------------------------------------------------------------------------- |
|
368 // |
|
369 void CLocSysUiContainer::MakeTitleL( TInt aResourceText ) |
|
370 { |
|
371 // Obtain the title from the Status Pane |
|
372 CAknTitlePane* title = static_cast<CAknTitlePane*>( StatusPane()-> |
|
373 ControlL( TUid::Uid( EEikStatusPaneUidTitle ))); |
|
374 |
|
375 // Set the Title's buffer |
|
376 TResourceReader rReader; |
|
377 iCoeEnv->CreateResourceReaderLC( rReader, aResourceText ); |
|
378 title->SetFromResourceL( rReader ); |
|
379 CleanupStack::PopAndDestroy(); //rReader |
|
380 } |
|
381 |
|