|
1 /* |
|
2 * Copyright (c) 2007-2008 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: Role of this class is to show setting view and to set data. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknlists.h> |
|
19 #include <AknsBasicBackgroundControlContext.h> |
|
20 #include <akntitle.h> |
|
21 #include <aknsettingitemlist.h> |
|
22 #include <bldvariant.hrh> // For FeatureIds (lint warns without) |
|
23 #include <featmgr.h> |
|
24 #include <hlplch.h> |
|
25 #include <StringLoader.h> |
|
26 #include <csxhelp/cale.hlp.hrh> |
|
27 #include <Calendar.rsg> |
|
28 #include <calencommands.hrh> // Calendar commands |
|
29 |
|
30 #include "calendarui_debug.h" |
|
31 #include "calensettingsui.h" |
|
32 #include "calensettingsuicontainer.h" |
|
33 #include "calendar.hrh" |
|
34 #include "CalenUid.h" |
|
35 #include "calenglobaldata.h" |
|
36 |
|
37 // ================= MEMBER FUNCTIONS ======================= |
|
38 // ---------------------------------------------------------------------------- |
|
39 // CCalenSettingsUi::NewL |
|
40 // 1st phase of construction |
|
41 // (other items were commented in a header). |
|
42 // ---------------------------------------------------------------------------- |
|
43 // |
|
44 CCalenSettingsUi* CCalenSettingsUi::NewL( |
|
45 CCalenCustomisationManager& aCustomisationManager ) |
|
46 { |
|
47 TRACE_ENTRY_POINT; |
|
48 |
|
49 CCalenSettingsUi* self = new(ELeave) CCalenSettingsUi( aCustomisationManager ); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 CleanupStack::Pop( self ); |
|
53 |
|
54 TRACE_EXIT_POINT; |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ---------------------------------------------------------------------------- |
|
59 // CCalenSettingsUi::CCalenSettingsUi |
|
60 // First stage of construction. |
|
61 // (other items were commented in a header). |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 CCalenSettingsUi::CCalenSettingsUi( CCalenCustomisationManager& aCustomisationManager ) |
|
65 : iCustomisationManager( aCustomisationManager ) , iPageStatus(EFalse) |
|
66 { |
|
67 TRACE_ENTRY_POINT; |
|
68 TRACE_EXIT_POINT; |
|
69 } |
|
70 |
|
71 // ---------------------------------------------------------------------------- |
|
72 // CCalenSettingsUi::ConstructL |
|
73 // 2nd phase of construction. |
|
74 // (other items were commented in a header). |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 void CCalenSettingsUi::ConstructL() |
|
78 { |
|
79 TRACE_ENTRY_POINT; |
|
80 |
|
81 CAknDialog::ConstructL( R_CALENDAR_SETTING_MENUBAR ); |
|
82 |
|
83 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
84 |
|
85 // Set empty navi pane label |
|
86 iNaviContainer = static_cast<CAknNavigationControlContainer*>( |
|
87 sp->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) ); |
|
88 iNaviContainer->PushDefaultL(); |
|
89 |
|
90 iGlobalData = CCalenGlobalData::InstanceL(); |
|
91 |
|
92 // Set title text |
|
93 CAknTitlePane* tp = static_cast<CAknTitlePane*>( |
|
94 sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
95 |
|
96 HBufC* titleText = StringLoader::LoadLC( R_CALEN_SETTING_FORM_TITLE, iCoeEnv ); |
|
97 tp->SetTextL( *titleText ); |
|
98 CleanupStack::PopAndDestroy( titleText ); |
|
99 |
|
100 TRACE_EXIT_POINT; |
|
101 } |
|
102 |
|
103 // ---------------------------------------------------------------------------- |
|
104 // CCalenSettingsUi::~CCalenSettingsUi |
|
105 // Destructor. |
|
106 // (other items were commented in a header). |
|
107 // ---------------------------------------------------------------------------- |
|
108 // |
|
109 CCalenSettingsUi::~CCalenSettingsUi() |
|
110 { |
|
111 TRACE_ENTRY_POINT; |
|
112 |
|
113 if( iNaviContainer ) |
|
114 { |
|
115 // Remove navi pane used by settings view |
|
116 iNaviContainer->Pop(); |
|
117 // iNaviContainer is not owned |
|
118 iNaviContainer = NULL; |
|
119 } |
|
120 delete iContainer; |
|
121 delete iListBox; |
|
122 delete iBgContext; |
|
123 |
|
124 if( iGlobalData ) |
|
125 { |
|
126 iGlobalData->Release(); |
|
127 } |
|
128 |
|
129 TRACE_EXIT_POINT; |
|
130 } |
|
131 |
|
132 // ---------------------------------------------------------------------------- |
|
133 // CCalenSettingsUi::OfferKeyEventL |
|
134 // Handles key presses. |
|
135 // (other items were commented in a header). |
|
136 // ---------------------------------------------------------------------------- |
|
137 // |
|
138 TKeyResponse CCalenSettingsUi::OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
139 TEventCode aType ) |
|
140 { |
|
141 TRACE_ENTRY_POINT; |
|
142 |
|
143 if( aKeyEvent.iCode == EKeyNo ) |
|
144 { |
|
145 // Red cancel button. |
|
146 TryExitL( EKeyNo ); |
|
147 |
|
148 TRACE_EXIT_POINT; |
|
149 |
|
150 // Chain this one up to the main app so it closes calendar app. |
|
151 return EKeyWasNotConsumed; |
|
152 } |
|
153 else if( aKeyEvent.iCode == EKeyEscape ) |
|
154 { |
|
155 // For exiting from FSW |
|
156 TryExitL( EAknSoftkeyBack ); |
|
157 |
|
158 TRACE_EXIT_POINT; |
|
159 return EKeyWasNotConsumed; |
|
160 } |
|
161 else if(aKeyEvent.iScanCode == EStdKeyYes) //Process Send key |
|
162 { |
|
163 TRACE_EXIT_POINT; |
|
164 return EKeyWasNotConsumed; |
|
165 } |
|
166 else |
|
167 { |
|
168 iListBox->OfferKeyEventL( aKeyEvent, aType ); |
|
169 |
|
170 // Draw because pressing up/down means we have to redraw the backgrouns skin. |
|
171 DrawDeferred(); |
|
172 |
|
173 TRACE_EXIT_POINT; |
|
174 |
|
175 // Don't let other key events chain up to the calendar app. |
|
176 return EKeyWasConsumed; |
|
177 } |
|
178 } |
|
179 |
|
180 // ---------------------------------------------------------------------------- |
|
181 // CCalenSettingsUi::ProcessCommandL |
|
182 // Processes commands. |
|
183 // (other items were commented in a header). |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 void CCalenSettingsUi::ProcessCommandL( TInt aCommandId ) |
|
187 { |
|
188 TRACE_ENTRY_POINT; |
|
189 |
|
190 CAknDialog::ProcessCommandL( aCommandId ); |
|
191 |
|
192 switch(aCommandId) |
|
193 { |
|
194 case ECalenCmdChange: |
|
195 if(!iPageStatus) |
|
196 { |
|
197 iContainer->HandleListBoxSelectionL( ECalenCmdChange ,iPageStatus ); |
|
198 } |
|
199 break; |
|
200 case EAknCmdHelp: |
|
201 OnCmdHelpL(); |
|
202 break; |
|
203 case EAknCmdExit: |
|
204 case EAknSoftkeyExit: |
|
205 TryExitL( aCommandId ); |
|
206 break; |
|
207 default: |
|
208 break; |
|
209 } |
|
210 |
|
211 TRACE_EXIT_POINT; |
|
212 } |
|
213 |
|
214 // ---------------------------------------------------------------------------- |
|
215 // CCalenSettingsUi::OkToExitL |
|
216 // Returns ETrue if the button given is allowed to close settings. |
|
217 // (other items were commented in a header). |
|
218 // ---------------------------------------------------------------------------- |
|
219 // |
|
220 TBool CCalenSettingsUi::OkToExitL( TInt aButtonId ) |
|
221 { |
|
222 TRACE_ENTRY_POINT; |
|
223 |
|
224 TBool retVal = EFalse; |
|
225 |
|
226 switch( aButtonId ) |
|
227 { |
|
228 case EAknSoftkeyChange: |
|
229 if(!iPageStatus) |
|
230 { |
|
231 iContainer->HandleListBoxSelectionL( EAknSoftkeyEdit ,iPageStatus); |
|
232 } |
|
233 break; |
|
234 case EAknSoftkeyBack: |
|
235 if(!iPageStatus) |
|
236 { |
|
237 retVal = CAknDialog::OkToExitL( aButtonId ); |
|
238 } |
|
239 break; |
|
240 default: |
|
241 retVal = CAknDialog::OkToExitL( aButtonId ); |
|
242 break; |
|
243 } |
|
244 |
|
245 TRACE_EXIT_POINT; |
|
246 return retVal; |
|
247 } |
|
248 |
|
249 // ---------------------------------------------------------------------------- |
|
250 // CCalenSettingsUi::HandlePointerEventL |
|
251 // Handle pointer events |
|
252 // (other items were commented in a header). |
|
253 // ---------------------------------------------------------------------------- |
|
254 // |
|
255 void CCalenSettingsUi::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
256 { |
|
257 TRACE_ENTRY_POINT; |
|
258 |
|
259 if( !AknLayoutUtils::PenEnabled() ) |
|
260 { |
|
261 return; |
|
262 } |
|
263 TInt index = iListBox->CurrentItemIndex(); |
|
264 switch( aPointerEvent.iType ) |
|
265 { |
|
266 case TPointerEvent::EButton1Down: |
|
267 { |
|
268 iListBox->HandlePointerEventL(aPointerEvent); |
|
269 } |
|
270 break; |
|
271 case TPointerEvent::EButton1Up: |
|
272 { |
|
273 iListBox->HandlePointerEventL(aPointerEvent); |
|
274 } |
|
275 break; |
|
276 case TPointerEvent::EDrag: |
|
277 { |
|
278 iListBox->HandlePointerEventL(aPointerEvent); |
|
279 } |
|
280 break; |
|
281 default: |
|
282 break; |
|
283 } |
|
284 TRACE_EXIT_POINT; |
|
285 } |
|
286 |
|
287 // ---------------------------------------------------------------------------- |
|
288 // CCalenSettingsUi::PreLayoutDynInitL |
|
289 // Called before laying out control. |
|
290 // (other items were commented in a header). |
|
291 // ---------------------------------------------------------------------------- |
|
292 // |
|
293 void CCalenSettingsUi::PreLayoutDynInitL() |
|
294 { |
|
295 TRACE_ENTRY_POINT; |
|
296 |
|
297 // Get the background skin |
|
298 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain, |
|
299 CEikonEnv::Static()->EikAppUi()->ClientRect(), |
|
300 ETrue ); |
|
301 |
|
302 CAknSettingStyleListBox *lb; |
|
303 iListBox = lb = new( ELeave ) CAknSettingStyleListBox; |
|
304 iListBox->SetListBoxObserver( this ); |
|
305 |
|
306 iContainer = CCalenSettingsUiContainer::NewL( this, |
|
307 *lb, |
|
308 *iGlobalData, |
|
309 iCustomisationManager ); |
|
310 |
|
311 iContainer->ConstructListBoxL(); |
|
312 |
|
313 TRACE_EXIT_POINT; |
|
314 } |
|
315 |
|
316 // ----------------------------------------------------------------------------- |
|
317 // CCalenSettingsUi::SizeChanged |
|
318 // From CCoeControl. Called when the size changes. |
|
319 // (other items were commented in a header). |
|
320 // ----------------------------------------------------------------------------- |
|
321 // |
|
322 void CCalenSettingsUi::SizeChanged() |
|
323 { |
|
324 TRACE_ENTRY_POINT; |
|
325 |
|
326 CAknDialog::SizeChanged(); |
|
327 |
|
328 TRect rect = Rect(); |
|
329 |
|
330 if( iBgContext ) |
|
331 { |
|
332 iBgContext->SetRect( rect ); |
|
333 } |
|
334 |
|
335 if( iListBox ) |
|
336 { |
|
337 TRect parent; |
|
338 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, parent); |
|
339 AknLayoutUtils::LayoutControl(iListBox, parent, AknLayout::list_gen_pane(0)); |
|
340 |
|
341 TRect zerodRect( TPoint(0, 0), parent.Size() ); |
|
342 iListBox->SetRect( zerodRect ); |
|
343 } |
|
344 |
|
345 TRACE_EXIT_POINT; |
|
346 } |
|
347 |
|
348 // ----------------------------------------------------------------------------- |
|
349 // CCalenSettingsUi::GetHelpContext |
|
350 // Gets help context |
|
351 // (other items were commented in a header). |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 void CCalenSettingsUi::GetHelpContext( TCoeHelpContext& aContext ) const |
|
355 { |
|
356 TRACE_ENTRY_POINT; |
|
357 |
|
358 aContext.iMajor = KUidCalendar; |
|
359 aContext.iContext = KCALE_HLP_SETTINGS; |
|
360 |
|
361 TRACE_EXIT_POINT; |
|
362 } |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CCalenSettingsUi::Draw |
|
366 // Draws the background skin |
|
367 // (other items were commented in a header). |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CCalenSettingsUi::Draw( const TRect& aRect ) const |
|
371 { |
|
372 TRACE_ENTRY_POINT |
|
373 |
|
374 CWindowGc& gc = SystemGc(); |
|
375 TRect mainPane; |
|
376 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
377 TRect zerodRect( TPoint(0, 0), mainPane.Size() ); |
|
378 iBgContext->SetRect( zerodRect ); |
|
379 iBgContext->SetParentPos( mainPane.iTl ); |
|
380 AknsDrawUtils::Background( AknsUtils::SkinInstance(), iBgContext, this, gc, aRect ); |
|
381 |
|
382 TRACE_EXIT_POINT |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CCalenSettingsUi::HandleResourceChange |
|
387 // Handles resource changes |
|
388 // (other items were commented in a header). |
|
389 // ----------------------------------------------------------------------------- |
|
390 // |
|
391 void CCalenSettingsUi::HandleResourceChange( TInt aType ) |
|
392 { |
|
393 TRACE_ENTRY_POINT; |
|
394 |
|
395 if( aType == KEikDynamicLayoutVariantSwitch ) |
|
396 { |
|
397 TRect mainPane; |
|
398 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPane ); |
|
399 SetRect( mainPane ); |
|
400 TRect zerodRect( TPoint( 0, 0 ), mainPane.Size() ); |
|
401 iBgContext->SetRect( zerodRect ); |
|
402 iBgContext->SetParentPos( mainPane.iTl ); |
|
403 iListBox->SetRect( zerodRect ); |
|
404 } |
|
405 |
|
406 CAknDialog::HandleResourceChange( aType ); |
|
407 |
|
408 TRACE_EXIT_POINT; |
|
409 } |
|
410 |
|
411 // ----------------------------------------------------------------------------- |
|
412 // CCalenSettingsUi::MopSupplyObject |
|
413 // Supplies skinned mop object |
|
414 // (other items were commented in a header). |
|
415 // ----------------------------------------------------------------------------- |
|
416 // |
|
417 TTypeUid::Ptr CCalenSettingsUi::MopSupplyObject( TTypeUid aId ) |
|
418 { |
|
419 TRACE_ENTRY_POINT; |
|
420 |
|
421 if( aId.iUid == MAknsControlContext::ETypeId ) |
|
422 { |
|
423 ASSERT( iBgContext ); |
|
424 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
425 } |
|
426 |
|
427 TRACE_EXIT_POINT; |
|
428 return CAknDialog::MopSupplyObject( aId ); |
|
429 } |
|
430 |
|
431 // ---------------------------------------------------------------------------- |
|
432 // CCalenSettingsUi::CountComponentControls |
|
433 // Returns the number of controls contained in this control. |
|
434 // (other items were commented in a header). |
|
435 // ---------------------------------------------------------------------------- |
|
436 // |
|
437 TInt CCalenSettingsUi::CountComponentControls() const |
|
438 { |
|
439 TRACE_ENTRY_POINT; |
|
440 TRACE_EXIT_POINT; |
|
441 return 1; |
|
442 } |
|
443 |
|
444 // ---------------------------------------------------------------------------- |
|
445 // CCalenSettingsUi::ComponentControl |
|
446 // Returns the control contained in this control. |
|
447 // (other items were commented in a header). |
|
448 // ---------------------------------------------------------------------------- |
|
449 // |
|
450 CCoeControl* CCalenSettingsUi::ComponentControl( TInt /*aIndex*/ ) const |
|
451 { |
|
452 TRACE_ENTRY_POINT; |
|
453 TRACE_EXIT_POINT; |
|
454 return iListBox; |
|
455 } |
|
456 |
|
457 // ---------------------------------------------------------------------------- |
|
458 // CCalenSettingsUi::OnCmdHelpL |
|
459 // Handles Help command. |
|
460 // (other items were commented in a header). |
|
461 // ---------------------------------------------------------------------------- |
|
462 // |
|
463 void CCalenSettingsUi::OnCmdHelpL() |
|
464 { |
|
465 TRACE_ENTRY_POINT; |
|
466 |
|
467 if( FeatureManager::FeatureSupported( KFeatureIdHelp ) ) |
|
468 { |
|
469 HlpLauncher::LaunchHelpApplicationL( iCoeEnv->WsSession(), |
|
470 iAvkonAppUi->AppHelpContextL() ); |
|
471 } |
|
472 |
|
473 TRACE_EXIT_POINT; |
|
474 } |
|
475 |
|
476 // ---------------------------------------------------------------------------- |
|
477 // CCalenSettingsUi::HandleListBoxEventL |
|
478 // Control Passed to list box to handle the commands. |
|
479 // (other items were commented in a header). |
|
480 // ---------------------------------------------------------------------------- |
|
481 // |
|
482 void CCalenSettingsUi::HandleListBoxEventL(CEikListBox* /*aListBox*/, |
|
483 TListBoxEvent aEventType) |
|
484 { |
|
485 TRACE_ENTRY_POINT; |
|
486 switch( aEventType ) |
|
487 { |
|
488 //Single click integration |
|
489 case EEventItemSingleClicked: |
|
490 case EEventEnterKeyPressed: |
|
491 { |
|
492 if(!iPageStatus ) |
|
493 { |
|
494 iContainer->HandleListBoxSelectionL( EAknSoftkeyEdit, iPageStatus ); |
|
495 } |
|
496 break; |
|
497 } |
|
498 default: |
|
499 break; |
|
500 } |
|
501 } |
|
502 // End of file |