|
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: This file implements the Setting Dialog which |
|
15 * is used to display Settings container |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
24 #include <uikon/eikctrlstatus.h> |
|
25 #endif |
|
26 #include <e32std.h> |
|
27 #include <AknDialog.h> |
|
28 #include <coeaui.h> |
|
29 #include <eikenv.h> |
|
30 #include <bautils.h> |
|
31 #include <eikdialg.h> |
|
32 #include <eikmenup.h> |
|
33 #include <eikspane.h> |
|
34 |
|
35 #ifdef __SERIES60_HELP |
|
36 #include <hlplch.h> |
|
37 #endif // __SERIES60_HELP |
|
38 |
|
39 #ifdef __SERIES60_HELP |
|
40 // Help Context UID = DLL UID3 |
|
41 const TUid KScreenSaverAnimPluginHelpContextUid = { 0x10207447 }; |
|
42 #endif // __SERIES60_HELP |
|
43 |
|
44 #include <coeaui.h> |
|
45 #include <AknWaitNoteWrapper.h> |
|
46 #include <aknnotewrappers.h> |
|
47 #include <akntitle.h> |
|
48 #include <data_caging_path_literals.hrh> |
|
49 #include <StringLoader.h> |
|
50 #include <screensaveranimplugin.rsg> |
|
51 //----------- |
|
52 // USER INCLUDES |
|
53 #include "ScreenSaverAnimPlugin.h" |
|
54 #include "ScreenSaverAnimPlugin.hrh" |
|
55 #include "ScreenSaverAnimSettingDialog.h" |
|
56 #include "ScreenSaverAnimPluginContainer.h" |
|
57 #include "screensaver.hlp.hrh" |
|
58 |
|
59 // Middle softkey control ID |
|
60 const TInt KSanimMSKControlID = 3; |
|
61 |
|
62 // ============================ MEMBER FUNCTIONS =============================== |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CScreenSaverAnimSettingDialog::CScreenSaverAnimSettingDialog |
|
66 // Default Constructor. Initialises Dialog State Variables. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CScreenSaverAnimSettingDialog::CScreenSaverAnimSettingDialog( |
|
70 CScreenSaverAnimPlugin* aCaller, |
|
71 CScreenSaverAnimSettingObject* aSettingObject ) |
|
72 :iSettingObject( aSettingObject ), |
|
73 iCaller( aCaller ) |
|
74 { |
|
75 iCustControl = NULL; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CScreenSaverAnimSettingDialog::ConstructL |
|
80 // Second Phase Constructor for CScreenSaverAnimSettingDialog. Opens resource file, reads the |
|
81 // dialog menu resource and calls CAknDialog::ConstructL with the resource as |
|
82 // param. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CScreenSaverAnimSettingDialog::ConstructL() |
|
86 { |
|
87 CAknDialog::ConstructL( R_SANIM_DIALOG_MENUBAR ); |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CScreenSaverAnimSettingDialog::NewL |
|
92 // Factory function for creating CScreenSaverAnimSettingDialog objects. |
|
93 // Returns: CScreenSaverAnimSettingDialog* ; Pointer to the created object. |
|
94 // Leaves if error occurs during creation. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 CScreenSaverAnimSettingDialog* CScreenSaverAnimSettingDialog::NewL( |
|
98 CScreenSaverAnimPlugin* aCaller, |
|
99 CScreenSaverAnimSettingObject* aSettingObject ) |
|
100 { |
|
101 CScreenSaverAnimSettingDialog* self = CScreenSaverAnimSettingDialog::NewLC( |
|
102 aCaller, |
|
103 aSettingObject ); |
|
104 CleanupStack::Pop( self ); |
|
105 return self; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CScreenSaverAnimSettingDialog::NewLC |
|
110 // Factory function for creating CScreenSaverAnimSettingDialog objects. |
|
111 // It also pushes the created dialog object onto the cleanup stack. |
|
112 // Returns: CScreenSaverAnimSettingDialog* ; Pointer to the created object. |
|
113 // Leaves if error occurs during creation. |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 CScreenSaverAnimSettingDialog* CScreenSaverAnimSettingDialog::NewLC( |
|
117 CScreenSaverAnimPlugin* aCaller, |
|
118 CScreenSaverAnimSettingObject* aSettingObject ) |
|
119 { |
|
120 CScreenSaverAnimSettingDialog* self = new ( ELeave ) |
|
121 CScreenSaverAnimSettingDialog( aCaller, aSettingObject ); |
|
122 CleanupStack::PushL( self ); |
|
123 self->ConstructL(); |
|
124 return self; |
|
125 } |
|
126 |
|
127 // Destructor |
|
128 CScreenSaverAnimSettingDialog::~CScreenSaverAnimSettingDialog() |
|
129 { |
|
130 if (this->IsFocused()) |
|
131 { |
|
132 CEikDialog::ButtonGroupContainer().RemoveCommandObserver( |
|
133 KSanimMSKControlID ); |
|
134 } |
|
135 |
|
136 // Custom Control will be automatically destroyed by dialog framework |
|
137 iCustControl = NULL; |
|
138 |
|
139 // Set the text in status pane to the stored one |
|
140 if (iAppTitleText) |
|
141 { |
|
142 // Get the Status Pane Control |
|
143 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
144 // Get the title pane |
|
145 CAknTitlePane* tp = NULL; |
|
146 TRAPD( errGetControl, |
|
147 tp = static_cast< CAknTitlePane* >( sp->ControlL( |
|
148 TUid::Uid( EEikStatusPaneUidTitle ) ) ) ); |
|
149 if ( errGetControl == KErrNone && tp ) |
|
150 { |
|
151 //set application name in the title pane |
|
152 TRAPD( errSetText, |
|
153 tp->SetTextL( *iAppTitleText ) ); |
|
154 if ( errSetText != KErrNone ) |
|
155 { |
|
156 // No error handling here |
|
157 } |
|
158 } |
|
159 |
|
160 delete iAppTitleText; |
|
161 iAppTitleText = NULL; |
|
162 } |
|
163 |
|
164 delete iTitlePaneString; |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CScreenSaverAnimSettingDialog::ExecuteLD |
|
169 // Reimplements CAknDialog::ExecuteLD. It initialises the member variables of |
|
170 // the class and calls CAknDialog::ExecuteLD() with the dialog resource. |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 TInt CScreenSaverAnimSettingDialog::ExecuteLD() |
|
174 { |
|
175 #ifdef SCREENSAVER_LOG_ENABLED |
|
176 _LIT( msg, "In Executeld dlg" ); |
|
177 PrintDebugMsg( msg ); |
|
178 #endif |
|
179 |
|
180 // Save this pointer since there are leaving functions in the flow |
|
181 CleanupStack::PushL( this ); |
|
182 |
|
183 // Get the Status Pane Control |
|
184 CEikStatusPane* sp = iEikonEnv->AppUiFactory()->StatusPane(); |
|
185 |
|
186 // Get the Title Pane Control |
|
187 CAknTitlePane* tp = static_cast< CAknTitlePane* >( sp->ControlL( |
|
188 TUid::Uid( EEikStatusPaneUidTitle ) ) ); |
|
189 |
|
190 // Store the Application's title text |
|
191 iAppTitleText = HBufC::NewL( tp->Text()->Length() ); |
|
192 *iAppTitleText = *tp->Text(); |
|
193 |
|
194 // Display Settings in the title pane of application |
|
195 iTitlePaneString = NULL; |
|
196 iTitlePaneString = StringLoader::LoadL( R_SANIM_TITLE_SETTINGS, |
|
197 iEikonEnv ); |
|
198 // SetTextL also ensures that if the length exceeds the layout space |
|
199 // available the text is truncated from the end. |
|
200 tp->SetTextL( iTitlePaneString->Des() ); |
|
201 |
|
202 // ExecuteLD will delete this, so we have to Pop it... |
|
203 CleanupStack::Pop( this ); // this |
|
204 |
|
205 return CAknDialog::ExecuteLD( R_SANIM_SETTING_DIALOG ); |
|
206 |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CScreenSaverAnimSettingDialog::DynInitMenuPaneL |
|
211 // Reimplements CAknDialog::DynInitMenuPaneL inorder to support dynamic hiding |
|
212 // of menu items based on current state of the viewer. |
|
213 // ----------------------------------------------------------------------------- |
|
214 // |
|
215 void CScreenSaverAnimSettingDialog::DynInitMenuPaneL( |
|
216 TInt aResourceId, // Resource Id for which this func is called |
|
217 CEikMenuPane* aMenuPane ) // Menupane object pointer for manipulation |
|
218 { |
|
219 if ( ( aResourceId == R_SANIM_DIALOG_MENU ) && ( aMenuPane ) ) |
|
220 { |
|
221 } |
|
222 } |
|
223 |
|
224 |
|
225 // ----------------------------------------------------------------------------- |
|
226 // Layouts dialog before showing it. |
|
227 // ----------------------------------------------------------------------------- |
|
228 // |
|
229 void CScreenSaverAnimSettingDialog::PreLayoutDynInitL() |
|
230 { |
|
231 // Set middle softkey as Change. |
|
232 SetMiddleSoftKeyLabelL( R_SANIM_MSK_CHANGE, ESanimDlgChangeCommand ); |
|
233 |
|
234 CAknDialog::PreLayoutDynInitL(); |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // CScreenSaverAnimSettingDialog::OkToExitL |
|
239 // Reimplements CAknDialog::OkToExitL inorder to display custom menu and |
|
240 // trap the back softkey to provide restore view functionality/exit. |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 TBool CScreenSaverAnimSettingDialog::OkToExitL( TInt aButtonId ) // ButtonId of button pressed |
|
244 { |
|
245 if ( aButtonId == EAknSoftkeyOptions ) |
|
246 { |
|
247 DisplayMenuL(); |
|
248 return EFalse; |
|
249 } |
|
250 else |
|
251 { |
|
252 if ( aButtonId == EAknSoftkeyBack ) |
|
253 { |
|
254 } |
|
255 else |
|
256 { |
|
257 // Especially handle Select Key |
|
258 if ( ( aButtonId == EAknSoftkeySelect ) || |
|
259 ( aButtonId == EEikBidOk ) || |
|
260 ( aButtonId == ESanimDlgChangeCommand ) ) |
|
261 { |
|
262 // Select button pressed, handle, do not leave dialog |
|
263 ProcessCommandL( ESanimDlgChangeCommand ); |
|
264 return EFalse; |
|
265 } |
|
266 if ( aButtonId == EEikCmdExit ) |
|
267 { |
|
268 } |
|
269 } |
|
270 } |
|
271 |
|
272 return ETrue; |
|
273 } |
|
274 |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // CScreenSaverAnimSettingDialog::HandleApplicationForegroundEvent |
|
278 // This API is used by the application to give background/foreground events |
|
279 // to the Dialog. The dialog inturn passes the events to custom control. |
|
280 // --------------------------------------------------------------------------- |
|
281 // |
|
282 void CScreenSaverAnimSettingDialog::HandleApplicationForegroundEvent( TBool |
|
283 /*aForeground*/ ) |
|
284 { |
|
285 } |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // CScreenSaverAnimSettingDialog::ProcessCommandL |
|
289 // Reimplements CAknDialog::ProcessCommandL inorder to handle dialog menu |
|
290 // commands. |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void CScreenSaverAnimSettingDialog::ProcessCommandL( TInt aCommandId ) // Command Id |
|
294 { |
|
295 // The Commands are handled by the custom CCoe Control and |
|
296 // a boolean varialble is used inorder to keep track whether |
|
297 // the control command processing needs to be invoked or not. |
|
298 CAknDialog::ProcessCommandL( aCommandId ); |
|
299 switch ( aCommandId ) |
|
300 { |
|
301 case ESanimDlgChangeCommand: |
|
302 if ( iCustControl ) |
|
303 { |
|
304 iCustControl->HandleListBoxSelectionL(); |
|
305 } |
|
306 break; |
|
307 case ESanimDlgHelpCommand: |
|
308 { |
|
309 #ifdef __SERIES60_HELP |
|
310 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
311 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
312 #endif |
|
313 } |
|
314 break; |
|
315 case EAknSoftkeyBack: // Fall Through |
|
316 case EEikCmdExit: |
|
317 case EAknCmdExit: |
|
318 // Close this dialog |
|
319 TryExitL( aCommandId ); |
|
320 iAvkonAppUi->ProcessCommandL( aCommandId ); |
|
321 break; |
|
322 default: |
|
323 break; |
|
324 } |
|
325 } |
|
326 |
|
327 #ifdef __SERIES60_HELP |
|
328 // ----------------------------------------------------------------------------- |
|
329 // CScreenSaverAnimSettingDialog::OfferKeyEventL |
|
330 // Handles Key events by reimplementing CCoeControl::OfferKeyEventL. |
|
331 // Returns: |
|
332 // EKeyWasConsumed: If this control uses this key. |
|
333 // EKeyWasNotConsumed: Otherwise. |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void CScreenSaverAnimSettingDialog::GetHelpContext( TCoeHelpContext& |
|
337 aContext ) const |
|
338 { |
|
339 aContext.iMajor = KScreenSaverAnimPluginHelpContextUid; |
|
340 aContext.iContext = KSCREENSAVER_HLP_ANIM_SETTINGS; |
|
341 } |
|
342 #endif // __SERIES60_HELP |
|
343 |
|
344 // ----------------------------------------------------------------------------- |
|
345 // CScreenSaverAnimSettingDialog::CreateCustomControlL |
|
346 // Reimplements CAknDialog::CreateCustomControlL inorder to add the |
|
347 // custom control as part of the dialog in the UI framework. |
|
348 // Returns: SEikControlInfo which contains the Cust Control, if |
|
349 // aControlType == ESanimCustControl |
|
350 // else, |
|
351 // the structure does not contain any control. |
|
352 // ----------------------------------------------------------------------------- |
|
353 // |
|
354 SEikControlInfo CScreenSaverAnimSettingDialog::CreateCustomControlL( |
|
355 TInt aControlType ) // Control Type |
|
356 { |
|
357 #ifdef SCREENSAVER_LOG_ENABLED |
|
358 _LIT( msg, "In Create Custom Control" ); |
|
359 PrintDebugMsg( msg ); |
|
360 #endif |
|
361 |
|
362 SEikControlInfo controlInfo; |
|
363 controlInfo.iControl = NULL; |
|
364 controlInfo.iTrailerTextId = 0; |
|
365 controlInfo.iFlags = EEikControlIsNonFocusing; |
|
366 |
|
367 switch ( aControlType ) |
|
368 { |
|
369 case ESanimCustControl: |
|
370 iCustControl = CScreenSaverAnimPluginContainer::NewL( |
|
371 iCaller, |
|
372 this, |
|
373 iSettingObject ); |
|
374 controlInfo.iControl = iCustControl; |
|
375 break; |
|
376 default: |
|
377 break; |
|
378 } |
|
379 return controlInfo; |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CScreenSaverAnimSettingDialog::SizeChanged |
|
384 // Reimplements CAknDialog::SizeChanged inorder to support the resize of the |
|
385 // dialog when functions such as SetRect, SetExtent are called on the dialog. |
|
386 // ----------------------------------------------------------------------------- |
|
387 // |
|
388 void CScreenSaverAnimSettingDialog::SizeChanged() |
|
389 { |
|
390 CAknDialog::SizeChanged(); |
|
391 iCustControl->SetExtent( Rect().iTl, Rect().Size() ); |
|
392 DrawNow(); |
|
393 } |
|
394 |
|
395 // ----------------------------------------------------------------------------- |
|
396 // CScreenSaverAnimSettingDialog::OfferKeyEventL |
|
397 // Handles Key events by reimplementing CCoeControl::OfferKeyEventL. |
|
398 // Returns: |
|
399 // EKeyWasConsumed: If this control uses this key. |
|
400 // EKeyWasNotConsumed: Otherwise. |
|
401 // ----------------------------------------------------------------------------- |
|
402 // |
|
403 TKeyResponse CScreenSaverAnimSettingDialog::OfferKeyEventL( |
|
404 const TKeyEvent& aKeyEvent, // Key Event |
|
405 TEventCode aType ) // Event Code |
|
406 { |
|
407 if ( iCustControl ) |
|
408 { |
|
409 TKeyResponse lCcRetVal = iCustControl->OfferKeyEventL( aKeyEvent, aType ); |
|
410 if ( lCcRetVal == EKeyWasConsumed ) |
|
411 { |
|
412 // Key was consumed, UNLESS it was the End key, which should be |
|
413 // passed to base class. For some reason listboxes like to eat |
|
414 // end keys |
|
415 if ( aKeyEvent.iCode != EKeyEscape ) |
|
416 { |
|
417 return EKeyWasConsumed; |
|
418 } |
|
419 } |
|
420 } |
|
421 return CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
422 } |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CScreenSaverAnimSettingDialog::HandleResourceChange |
|
426 // Handles change of skin/Layout |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 void CScreenSaverAnimSettingDialog::HandleResourceChange( TInt aType ) |
|
430 { |
|
431 if ( iCustControl ) |
|
432 { |
|
433 iCustControl->HandleResourceChange( aType ); |
|
434 } |
|
435 CAknDialog::HandleResourceChange( aType ); |
|
436 } |
|
437 |
|
438 // --------------------------------------------------------------------------- |
|
439 // CScreenSaverAnimSettingDialog::FocusChanged |
|
440 // --------------------------------------------------------------------------- |
|
441 // |
|
442 void CScreenSaverAnimSettingDialog::FocusChanged( TDrawNow aDrawNow ) |
|
443 { |
|
444 // Pass focus changed event to listbox. |
|
445 if ( iCustControl ) |
|
446 { |
|
447 iCustControl->SetFocus( IsFocused(), aDrawNow ); |
|
448 } |
|
449 } |
|
450 |
|
451 // --------------------------------------------------------------------------- |
|
452 // Sets middle softkey label. |
|
453 // --------------------------------------------------------------------------- |
|
454 // |
|
455 void CScreenSaverAnimSettingDialog::SetMiddleSoftKeyLabelL( |
|
456 const TInt aResourceId, const TInt aCommandId ) |
|
457 { |
|
458 HBufC* middleSKText = StringLoader::LoadLC( aResourceId ); |
|
459 TPtr mskPtr = middleSKText->Des(); |
|
460 CEikDialog::ButtonGroupContainer().AddCommandToStackL( |
|
461 KSanimMSKControlID, |
|
462 aCommandId, |
|
463 mskPtr ); |
|
464 CEikDialog::ButtonGroupContainer().UpdateCommandObserverL( |
|
465 KSanimMSKControlID, |
|
466 *this ); |
|
467 CleanupStack::PopAndDestroy( middleSKText ); |
|
468 } |
|
469 |
|
470 // End of File |