|
1 /* |
|
2 * Copyright (c) 2002-2009 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: |
|
15 * Base class for Setting Item Editing |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "aknsettingpage.h" |
|
21 |
|
22 #include <akninputblock.h> |
|
23 //For TResourceReader |
|
24 #include <barsread.h> |
|
25 |
|
26 //For the CEikLabels |
|
27 #include <eiklabel.h> |
|
28 |
|
29 // For the hint text support in the navi pane |
|
30 #include <aknnavide.h> |
|
31 #include <aknappui.h> |
|
32 |
|
33 #include <eikmop.h> |
|
34 |
|
35 // Skins support |
|
36 #include <aknconsts.h> |
|
37 #include <avkon.mbg> |
|
38 #include <AknsDrawUtils.h> |
|
39 #include <AknsFrameBackgroundControlContext.h> |
|
40 |
|
41 #include <AknTasHook.h> |
|
42 // Skin layout macros |
|
43 #include <aknlayoutscalable_avkon.cdl.h> |
|
44 #include <layoutmetadata.cdl.h> |
|
45 //For MCoeCaptionRetrieverForFep |
|
46 #include <fepbase.h> |
|
47 #include <AknPopupFader.h> |
|
48 #include <gfxtranseffect/gfxtranseffect.h> |
|
49 #include <akntransitionutils.h> |
|
50 #include "aknitemactionmenuregister.h" |
|
51 #include "aknqueryeditorindicator.h" |
|
52 |
|
53 // This determines the maximum number of digits in the optional number displayed on the |
|
54 // top left of the setting page |
|
55 const TInt KAknSettingPageMaxOrdinalDigits = 3; |
|
56 |
|
57 // For formatting numbers; maximum is taken care of by an assert in the source |
|
58 _LIT( KAknSettingPageNumberFormat, "%d" ); |
|
59 |
|
60 /** |
|
61 * Local Panic Function and Panic Codes |
|
62 */ |
|
63 |
|
64 enum TAknSettingPagePanicCodes |
|
65 { |
|
66 EAknPanicSettingPageGeneralPanic, |
|
67 EAknPanicSettingPageNoMenuBar, |
|
68 EAknPanicSettingPageNoMenuBarResource, |
|
69 EAknPanicSettingPageDeprecated, |
|
70 EAknPanicSettingPageIllegalSettingNumber, |
|
71 EAknPanicSettingPageIllegalLayout |
|
72 }; |
|
73 |
|
74 GLDEF_C void Panic(TAknSettingPagePanicCodes aPanic) |
|
75 { |
|
76 _LIT(KPanicCat,"AknSettingPage"); |
|
77 User::Panic(KPanicCat, aPanic); |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // Calculates and returns control rectangle i.e. whole popup rect common to |
|
82 // all setting pages. |
|
83 // --------------------------------------------------------------------------- |
|
84 // |
|
85 static TRect ControlRect( TBool aEmbeddedSoftkeys ) |
|
86 { |
|
87 TRect container; |
|
88 |
|
89 if ( aEmbeddedSoftkeys ) |
|
90 { |
|
91 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, |
|
92 container ); |
|
93 |
|
94 TAknLayoutRect layoutRect; |
|
95 layoutRect.LayoutRect( container, |
|
96 AknLayoutScalable_Avkon::popup_settings_window( 0 ) ); |
|
97 |
|
98 TRect finalRect( AknPopupUtils::Position( layoutRect.Rect().Size(), |
|
99 ETrue ), layoutRect.Rect().Size() ); |
|
100 |
|
101 return finalRect; |
|
102 } |
|
103 |
|
104 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, container); |
|
105 |
|
106 return container; |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // Calculates and returns container rectangle common to all setting pages. |
|
112 // This container holds all setting view items excluding caption and softkeys. |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 static TRect ContainerRect( TBool aEmbeddedSoftkeys ) |
|
116 { |
|
117 TAknLayoutRect layoutRect; |
|
118 layoutRect.LayoutRect( TRect( ControlRect( aEmbeddedSoftkeys ) ).Size(), |
|
119 AknLayoutScalable_Avkon::settings_container_pane( 0 ) ); |
|
120 |
|
121 return layoutRect.Rect(); |
|
122 } |
|
123 |
|
124 |
|
125 NONSHARABLE_CLASS(CAknSettingPageExtension): public CBase, public MCoeCaptionRetrieverForFep |
|
126 , public MCoeControlBackground, public MAknFadedComponent |
|
127 { |
|
128 public: |
|
129 static CAknSettingPageExtension* NewL( CAknSettingPage* parent ); |
|
130 ~CAknSettingPageExtension(); |
|
131 |
|
132 /** |
|
133 * Sets the skin item ID for the frame graphics that is drawn |
|
134 * around the setting item. |
|
135 * |
|
136 * @param aFrameIID Skin item ID of the frame graphics. |
|
137 * @param aFrameCenterIID Skin item ID of the center piece of the frame |
|
138 * graphics. |
|
139 */ |
|
140 void SetEditedItemFrameIID( const TAknsItemID& aFrameIID, |
|
141 const TAknsItemID& aFrameCenterIID ); |
|
142 |
|
143 /** |
|
144 * Sets the outer and inner rectangle for the frame graphics that is drawn |
|
145 * around the setting item. |
|
146 * |
|
147 * @param aOuterRect Frame outer rectangle. |
|
148 * @param aInnerRect Frame inner rectangle. |
|
149 */ |
|
150 void SetEditedItemFrameRects( const TRect& aOuterRect, |
|
151 const TRect& aInnerRect ); |
|
152 |
|
153 /** |
|
154 * Creates if necessary and returns the editor indicator |
|
155 * container control. |
|
156 * |
|
157 * @return Editor indicator container control. |
|
158 */ |
|
159 CAknQueryEditIndicator* EditorIndicatorContainer(); |
|
160 |
|
161 /** |
|
162 * Creates background skin context. |
|
163 */ |
|
164 void CreateBackgroundContextL(); |
|
165 |
|
166 public: // From base class MCoeControlBackground |
|
167 |
|
168 /** |
|
169 * Draws the background for the setting page and |
|
170 * the editor control (aControl). |
|
171 * |
|
172 * @param aGc Graphics context used for drawing. |
|
173 * @param aControl The control being drawn. |
|
174 * @param aRect The area to be redrawn. |
|
175 */ |
|
176 void Draw( CWindowGc& aGc, |
|
177 const CCoeControl& aControl, |
|
178 const TRect& aRect ) const; |
|
179 |
|
180 public: // From base class MAknFadedComponent |
|
181 |
|
182 /** |
|
183 * Returns the number of faded components. |
|
184 * |
|
185 * @return Number of faded components. |
|
186 */ |
|
187 TInt CountFadedComponents(); |
|
188 |
|
189 /** |
|
190 * Returns faded component. |
|
191 * |
|
192 * @param aIndex Component index. |
|
193 * @return Faded component. |
|
194 */ |
|
195 CCoeControl* FadedComponent( TInt aIndex ); |
|
196 |
|
197 private: |
|
198 CAknSettingPageExtension(); |
|
199 void ConstructL( CAknSettingPage* aParent ); |
|
200 /** |
|
201 * from MCoeCaptionRetrieverForFep |
|
202 * fill aCaption with the target control's caption |
|
203 */ |
|
204 IMPORT_C virtual void GetCaptionForFep(TDes& aCaption) const; |
|
205 |
|
206 public: // data |
|
207 TBool iDrawBackground; // Determines if background should be drawn (transparency) |
|
208 TBool iIsStopActiveSchedulerCalled; // Determins if the CAknSettingPage::StopActiveScheduler function called |
|
209 CEikScrollBarFrame* iSBFrame; |
|
210 |
|
211 /** |
|
212 * Control context for the setting page background graphics. |
|
213 * Not own. |
|
214 */ |
|
215 CAknsBasicBackgroundControlContext* iSettingPageBgContext; |
|
216 |
|
217 /** |
|
218 * Control context for the setting page bitmap background graphics. |
|
219 * Own. |
|
220 */ |
|
221 CAknsBasicBackgroundControlContext* iBasicBgContext; |
|
222 |
|
223 /** |
|
224 * Control context for the setting page frame background graphics. |
|
225 * Own. |
|
226 */ |
|
227 CAknsFrameBackgroundControlContext* iFrameBgContext; |
|
228 |
|
229 CEikLabel* iShadowText; |
|
230 CFbsBitmap* iLockIcon; |
|
231 CFbsBitmap* iLockIconMask; |
|
232 TRect iLockIconRect; |
|
233 CAknSettingPage* iParent; |
|
234 |
|
235 /** |
|
236 * Control context for providing the skinning for the hosted editor |
|
237 * and it's surrounding area. |
|
238 * Own. |
|
239 */ |
|
240 CAknsFrameBackgroundControlContext* iEditedItemControlContext; |
|
241 |
|
242 /** |
|
243 * Popup fader. |
|
244 */ |
|
245 TAknPopupFader iFader; |
|
246 |
|
247 /** |
|
248 * Editing state indicator container for the editor setting pages. |
|
249 * Own. |
|
250 */ |
|
251 CAknQueryEditIndicator* iEditIndicator; |
|
252 |
|
253 /** |
|
254 * Whether softkeys are embedded or not. |
|
255 */ |
|
256 TBool iEmbeddedSoftkeys; |
|
257 }; |
|
258 |
|
259 |
|
260 void CAknSettingPage::GetCaptionForFep(TDes& aCaption) const |
|
261 { |
|
262 if (iSettingText==NULL) |
|
263 { |
|
264 aCaption=KNullDesC; |
|
265 } |
|
266 else |
|
267 { |
|
268 const TInt maximumLength=aCaption.MaxLength(); |
|
269 if (iSettingText->Length()>maximumLength) |
|
270 { |
|
271 aCaption=iSettingText->Left(maximumLength); |
|
272 } |
|
273 else |
|
274 { |
|
275 aCaption=*iSettingText; |
|
276 } |
|
277 } |
|
278 } |
|
279 |
|
280 |
|
281 CAknSettingPageExtension* CAknSettingPageExtension::NewL(CAknSettingPage* aParent ) |
|
282 { |
|
283 CAknSettingPageExtension* self = new (ELeave) CAknSettingPageExtension; |
|
284 CleanupStack::PushL(self); |
|
285 self->ConstructL( aParent ); |
|
286 CleanupStack::Pop(self); |
|
287 return self; |
|
288 } |
|
289 |
|
290 CAknSettingPageExtension::~CAknSettingPageExtension() |
|
291 { |
|
292 delete iSBFrame; |
|
293 delete iSettingPageBgContext; |
|
294 delete iShadowText; |
|
295 delete iLockIcon; |
|
296 delete iLockIconMask; |
|
297 delete iEditedItemControlContext; |
|
298 delete iEditIndicator; |
|
299 } |
|
300 |
|
301 |
|
302 // ---------------------------------------------------------------------------- |
|
303 // Sets the skin item IDs for the frame graphics drawn around the setting item. |
|
304 // ---------------------------------------------------------------------------- |
|
305 // |
|
306 void CAknSettingPageExtension::SetEditedItemFrameIID( |
|
307 const TAknsItemID& aFrameIID, |
|
308 const TAknsItemID& aFrameCenterIID ) |
|
309 { |
|
310 iEditedItemControlContext->SetFrame( aFrameIID ); |
|
311 iEditedItemControlContext->SetCenter( aFrameCenterIID ); |
|
312 } |
|
313 |
|
314 |
|
315 // ---------------------------------------------------------------------------- |
|
316 // Sets the frame rectangles of the setting item frame. |
|
317 // ---------------------------------------------------------------------------- |
|
318 // |
|
319 void CAknSettingPageExtension::SetEditedItemFrameRects( |
|
320 const TRect& aOuterRect, |
|
321 const TRect& aInnerRect ) |
|
322 { |
|
323 iEditedItemControlContext->SetFrameRects( aOuterRect, aInnerRect ); |
|
324 } |
|
325 |
|
326 |
|
327 // ---------------------------------------------------------------------------- |
|
328 // Creates if necessary and returns the editor indicator container control. |
|
329 // ---------------------------------------------------------------------------- |
|
330 // |
|
331 CAknQueryEditIndicator* CAknSettingPageExtension::EditorIndicatorContainer() |
|
332 { |
|
333 if ( !iEditIndicator ) |
|
334 { |
|
335 TRAPD( err, iEditIndicator = CAknQueryEditIndicator::NewL( iParent ) ); |
|
336 if ( !err ) |
|
337 { |
|
338 iEditIndicator->SetBackground( this ); |
|
339 } |
|
340 } |
|
341 |
|
342 return iEditIndicator; |
|
343 } |
|
344 |
|
345 |
|
346 // ---------------------------------------------------------------------------- |
|
347 // Creates background skin context. |
|
348 // ---------------------------------------------------------------------------- |
|
349 // |
|
350 void CAknSettingPageExtension::CreateBackgroundContextL() |
|
351 { |
|
352 TRect nullRect( 0, 0, 0, 0 ); |
|
353 |
|
354 if ( iEmbeddedSoftkeys ) |
|
355 { |
|
356 iFrameBgContext = |
|
357 CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrPopup, |
|
358 nullRect, |
|
359 nullRect, |
|
360 EFalse ); |
|
361 iSettingPageBgContext = iFrameBgContext; |
|
362 } |
|
363 else |
|
364 { |
|
365 iBasicBgContext = |
|
366 CAknsBasicBackgroundControlContext::NewL( |
|
367 KAknsIIDQsnBgAreaMainListSet, |
|
368 nullRect, |
|
369 EFalse ); |
|
370 iSettingPageBgContext = iBasicBgContext; |
|
371 } |
|
372 } |
|
373 |
|
374 |
|
375 // ---------------------------------------------------------------------------- |
|
376 // Draws the background for the setting page and the setting page item. |
|
377 // ---------------------------------------------------------------------------- |
|
378 // |
|
379 void CAknSettingPageExtension::Draw( CWindowGc& aGc, |
|
380 const CCoeControl& aControl, |
|
381 const TRect& aRect ) const |
|
382 { |
|
383 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
384 |
|
385 if ( !iParent->IsBackgroundDrawingEnabled() ) |
|
386 { |
|
387 return; |
|
388 } |
|
389 |
|
390 if ( &aControl == iParent ) |
|
391 { |
|
392 AknsDrawUtils::Background( skin, |
|
393 iSettingPageBgContext, |
|
394 aGc, |
|
395 aRect ); |
|
396 |
|
397 AknsDrawUtils::Background( skin, |
|
398 iEditedItemControlContext, |
|
399 aGc, |
|
400 aRect ); |
|
401 } |
|
402 else if ( &aControl == iSBFrame->VerticalScrollBar() ) |
|
403 { |
|
404 AknsDrawUtils::Background( skin, |
|
405 iSettingPageBgContext, |
|
406 aGc, |
|
407 aRect ); |
|
408 } |
|
409 else if ( &aControl == iParent->EditorControl() ) |
|
410 { |
|
411 aGc.SetBrushColor( TRgb( ~0 ) ); |
|
412 |
|
413 AknsDrawUtils::Background( skin, |
|
414 iSettingPageBgContext, |
|
415 aGc, |
|
416 aRect ); |
|
417 |
|
418 AknsDrawUtils::Background( skin, |
|
419 iEditedItemControlContext, |
|
420 aGc, |
|
421 aRect ); |
|
422 } |
|
423 else if ( &aControl == iEditIndicator ) |
|
424 { |
|
425 AknsDrawUtils::Background( skin, |
|
426 iSettingPageBgContext, |
|
427 aGc, |
|
428 aRect ); |
|
429 } |
|
430 } |
|
431 |
|
432 |
|
433 // ---------------------------------------------------------------------------- |
|
434 // Counts faded components. |
|
435 // ---------------------------------------------------------------------------- |
|
436 // |
|
437 TInt CAknSettingPageExtension::CountFadedComponents() |
|
438 { |
|
439 TInt count = 1; // this |
|
440 |
|
441 CCoeControl* buttonGroupControl = NULL; |
|
442 |
|
443 if ( iParent->Cba() ) |
|
444 { |
|
445 MEikButtonGroup* buttonGroup = iParent->Cba()->ButtonGroup(); |
|
446 |
|
447 if ( buttonGroup ) |
|
448 { |
|
449 buttonGroupControl = buttonGroup->AsControl(); |
|
450 |
|
451 if ( buttonGroupControl ) |
|
452 { |
|
453 ++count; |
|
454 } |
|
455 } |
|
456 } |
|
457 |
|
458 return count; |
|
459 } |
|
460 |
|
461 |
|
462 // ---------------------------------------------------------------------------- |
|
463 // Returns faded components. |
|
464 // ---------------------------------------------------------------------------- |
|
465 // |
|
466 CCoeControl* CAknSettingPageExtension::FadedComponent( TInt aIndex ) |
|
467 { |
|
468 switch ( aIndex ) |
|
469 { |
|
470 case 0: |
|
471 return iParent; |
|
472 |
|
473 case 1: |
|
474 { |
|
475 CCoeControl* cba = NULL; |
|
476 |
|
477 if ( iParent->Cba() ) |
|
478 { |
|
479 MEikButtonGroup* buttonGroup = iParent->Cba()->ButtonGroup(); |
|
480 |
|
481 if ( buttonGroup ) |
|
482 { |
|
483 cba = buttonGroup->AsControl(); |
|
484 } |
|
485 } |
|
486 |
|
487 return cba; |
|
488 } |
|
489 |
|
490 default: |
|
491 return NULL; |
|
492 } |
|
493 } |
|
494 |
|
495 |
|
496 CAknSettingPageExtension::CAknSettingPageExtension() |
|
497 { |
|
498 iEmbeddedSoftkeys = ETrue; |
|
499 } |
|
500 |
|
501 void CAknSettingPageExtension::ConstructL( CAknSettingPage* aParent ) |
|
502 { |
|
503 iParent = aParent; |
|
504 iDrawBackground = ETrue; |
|
505 iIsStopActiveSchedulerCalled = EFalse; |
|
506 |
|
507 TRect nullRect( 0, 0, 0, 0 ); |
|
508 |
|
509 iEditedItemControlContext = |
|
510 CAknsFrameBackgroundControlContext::NewL( KAknsIIDDefault, |
|
511 nullRect, |
|
512 nullRect, |
|
513 EFalse ); |
|
514 } |
|
515 |
|
516 /** |
|
517 * GetCaptionForFep. Overrides MCoeCaptionRetrieverForFep::GetCaptionForFep |
|
518 * |
|
519 */ |
|
520 EXPORT_C void CAknSettingPageExtension::GetCaptionForFep(TDes& aCaption) const |
|
521 { |
|
522 iParent->GetCaptionForFep(aCaption); |
|
523 } |
|
524 |
|
525 ////////////////////////////////////////////////////////////////////// |
|
526 // Construction/Destruction |
|
527 ////////////////////////////////////////////////////////////////////// |
|
528 |
|
529 /** |
|
530 * Constructor |
|
531 * |
|
532 * @param aResourceId Setting Page resource ID |
|
533 */ |
|
534 EXPORT_C CAknSettingPage::CAknSettingPage( TInt aResourceId ) |
|
535 : iResourceId( aResourceId ), iIsProtected(0) |
|
536 { |
|
537 ResetFlags(); |
|
538 iSettingNumber = EAknSettingPageNoOrdinalDisplayed; |
|
539 AKNTASHOOK_ADD( this, "CAknSettingPage" ); |
|
540 } |
|
541 |
|
542 |
|
543 EXPORT_C CAknSettingPage::CAknSettingPage( |
|
544 const TDesC* aSettingText, |
|
545 TInt aSettingNumber, |
|
546 TInt aControlType, |
|
547 TInt aEditorResourceId, |
|
548 TInt aSettingPageResourceId ) |
|
549 : iSettingTextFromConstructor ( aSettingText ), |
|
550 iResourceId( aSettingPageResourceId ), |
|
551 iSettingNumber (aSettingNumber), |
|
552 iControlType (aControlType), |
|
553 iEditorResourceId (aEditorResourceId) |
|
554 { |
|
555 ResetFlags(); |
|
556 AKNTASHOOK_ADD( this, "CAknSettingPage" ); |
|
557 } |
|
558 |
|
559 EXPORT_C void CAknSettingPage::ResetFlags() |
|
560 { |
|
561 iUpdateMode = EUpdateWhenAccepted; |
|
562 iSettingId = KAknSettingPageNoIdSet; |
|
563 SetDataValidity( ETrue ); |
|
564 } |
|
565 |
|
566 /** |
|
567 * Destructor |
|
568 * |
|
569 */ |
|
570 EXPORT_C CAknSettingPage::~CAknSettingPage() |
|
571 { |
|
572 AKNTASHOOK_REMOVE(); |
|
573 |
|
574 if ( GfxTransEffect::IsRegistered( this ) ) |
|
575 { |
|
576 GfxTransEffect::Deregister( this ); |
|
577 } |
|
578 |
|
579 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
580 |
|
581 AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( NULL ); |
|
582 |
|
583 if (iMenuBar) |
|
584 { |
|
585 iEikonEnv->EikAppUi()->RemoveFromStack(iMenuBar); |
|
586 delete iMenuBar; |
|
587 } |
|
588 |
|
589 delete iNumberLabel; |
|
590 delete iTextLabel; |
|
591 delete iEditorControl; |
|
592 delete iSettingText; |
|
593 delete iHintText; |
|
594 delete iCba; |
|
595 delete iExtension; |
|
596 |
|
597 // If navi pane context is not poped out yet, pop it now. |
|
598 PopNaviDecoratorIfRequired(); |
|
599 delete iNaviDecorator; |
|
600 |
|
601 StopActiveScheduler(); |
|
602 } |
|
603 |
|
604 void CAknSettingPage::StopActiveScheduler() |
|
605 { |
|
606 SetStopActiveSchedulerFlag( ETrue ); |
|
607 CAknEnv::StopSchedulerWaitWithBusyMessage(iWait); |
|
608 } |
|
609 |
|
610 void CAknSettingPage::StartActiveScheduler() |
|
611 { |
|
612 if (!iWait.IsStarted()) |
|
613 { |
|
614 iWait.Start(); |
|
615 } |
|
616 } |
|
617 /** |
|
618 * Writes the internal state of the control and its components to aStream. |
|
619 * Does nothing in release mode. |
|
620 * Designed to be overidden and base called by subclasses. |
|
621 */ |
|
622 #ifndef _DEBUG |
|
623 EXPORT_C void CAknSettingPage::WriteInternalStateL(RWriteStream& /*aWriteStream*/ ) const |
|
624 {} |
|
625 #else |
|
626 EXPORT_C void CAknSettingPage::WriteInternalStateL(RWriteStream& aWriteStream) const |
|
627 { |
|
628 CCoeControl::WriteInternalStateL(aWriteStream); |
|
629 } |
|
630 #endif |
|
631 |
|
632 /** |
|
633 * Reserved method derived from CCoeControl |
|
634 */ |
|
635 EXPORT_C void CAknSettingPage::Reserved_2() |
|
636 { |
|
637 } |
|
638 |
|
639 /** |
|
640 * New reserved methods |
|
641 */ |
|
642 EXPORT_C void CAknSettingPage::CAknSettingPage_Reserved_1() |
|
643 { |
|
644 } |
|
645 EXPORT_C void CAknSettingPage::CAknSettingPage_Reserved_2() |
|
646 { |
|
647 } |
|
648 |
|
649 /** |
|
650 * public method for construction. Only thing required to do in this class is to call the |
|
651 * BaseConstructL(). Derived classes may be required to do more |
|
652 * |
|
653 */ |
|
654 EXPORT_C void CAknSettingPage::ConstructL() |
|
655 { |
|
656 BaseConstructL(); |
|
657 } |
|
658 |
|
659 /** |
|
660 * Protected non-virtual base method for construction. Only thing required to do in this class is |
|
661 * call the ConstructFromResourceL routine and set the flag that says construction has occured |
|
662 * |
|
663 */ |
|
664 EXPORT_C void CAknSettingPage::BaseConstructL() |
|
665 { |
|
666 if( iFlags.IsSet( EIsBaseConstructedIndex ) ) |
|
667 { |
|
668 return; |
|
669 } |
|
670 |
|
671 if ( !iExtension ) |
|
672 { |
|
673 iExtension = CAknSettingPageExtension::NewL( this ); |
|
674 } |
|
675 |
|
676 // Setting pages have a default object provider parent set in the eikappui. |
|
677 SetMopParent(iEikonEnv->EikAppUi()); |
|
678 ConstructFromResourceL( SettingPageResourceId() ); |
|
679 iFlags.Set( EIsBaseConstructedIndex ); |
|
680 } |
|
681 |
|
682 /** |
|
683 * |
|
684 * This routes the keys to the editor. |
|
685 * However, if the menu is showing, then events have to be forwarded manually to it. |
|
686 * |
|
687 */ |
|
688 EXPORT_C TKeyResponse CAknSettingPage::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType) |
|
689 { |
|
690 if( IsStopActiveSchudlerCalled() ) |
|
691 { |
|
692 switch( aKeyEvent.iCode ) |
|
693 { |
|
694 case EKeyOK: |
|
695 case EKeyEnter: |
|
696 case EKeyEscape: |
|
697 return EKeyWasConsumed; |
|
698 default: |
|
699 break; |
|
700 } |
|
701 return EKeyWasNotConsumed; |
|
702 } |
|
703 |
|
704 // Always react to Escape key by cancelling the setting page |
|
705 if ( aType == EEventKey && aKeyEvent.iCode == EKeyEscape) |
|
706 { |
|
707 ProcessCommandL( EAknSoftkeyCancel ); |
|
708 //Remove self from stack to make CAknShutter continue shutdown. |
|
709 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
710 return EKeyWasConsumed; |
|
711 } |
|
712 |
|
713 if(!IsEditable()) |
|
714 { |
|
715 return EKeyWasConsumed; |
|
716 } |
|
717 |
|
718 // Only handle other key events if we're focused |
|
719 |
|
720 if (IsFocused()) |
|
721 { |
|
722 if (iEditorControl) |
|
723 { |
|
724 // Abstraction of key events: Escape is handled like Cancel |
|
725 // OK is handled like select. |
|
726 if ( aType == EEventKey ) |
|
727 { |
|
728 |
|
729 switch ( aKeyEvent.iCode ) |
|
730 { |
|
731 |
|
732 // OK key is handled like the Select softkey by default |
|
733 // Note that in listbox editor types the OK key must be sent to the listbox |
|
734 // so that may have to be synthesized |
|
735 case EKeyEnter: |
|
736 case EKeyOK : |
|
737 if (aKeyEvent.iRepeats != 0) return EKeyWasConsumed; |
|
738 if ( DataValidity() ) |
|
739 ProcessCommandL( EAknSoftkeySelect ); |
|
740 return EKeyWasConsumed; |
|
741 |
|
742 |
|
743 default : |
|
744 break ; |
|
745 } |
|
746 } |
|
747 |
|
748 iEditorControl->OfferKeyEventL( aKeyEvent, aType ); |
|
749 } |
|
750 |
|
751 return (aKeyEvent.iScanCode == EStdKeyYes ? EKeyWasNotConsumed : EKeyWasConsumed); |
|
752 } |
|
753 |
|
754 return EKeyWasNotConsumed; // Keys can fall through to menus |
|
755 |
|
756 } |
|
757 |
|
758 /** |
|
759 * This constructs the control based upon the id passed |
|
760 * |
|
761 */ |
|
762 EXPORT_C void CAknSettingPage::ConstructFromResourceL( TInt aResourceId ) |
|
763 { |
|
764 if (!aResourceId ) |
|
765 aResourceId = R_AVKON_DEFAULT_SETTING_PAGE; |
|
766 TResourceReader reader; |
|
767 iCoeEnv->CreateResourceReaderLC(reader,aResourceId); |
|
768 ConstructFromResourceL(reader); |
|
769 CleanupStack::PopAndDestroy(); //reader |
|
770 } |
|
771 |
|
772 /** |
|
773 * Used by ConstructFromResource() |
|
774 * This routine does all the work. |
|
775 * |
|
776 */ |
|
777 EXPORT_C void CAknSettingPage::ConstructFromResourceL(TResourceReader &aRes) |
|
778 { |
|
779 CreateWindowL(); |
|
780 |
|
781 SetGloballyCapturing( ETrue ); |
|
782 SetPointerCapture(ETrue); |
|
783 |
|
784 if( NULL == iExtension ) |
|
785 { |
|
786 iExtension = CAknSettingPageExtension::NewL( this ); |
|
787 } |
|
788 |
|
789 // Ensure that any value set from constructors turns on the numbering |
|
790 if (iSettingNumber != EAknSettingPageNoOrdinalDisplayed ) |
|
791 { |
|
792 SetNumbered( ETrue ); |
|
793 } |
|
794 |
|
795 // Read in the number from resource |
|
796 TInt number = aRes.ReadInt16(); |
|
797 |
|
798 if ( number != EAknSettingPageNoOrdinalDisplayed ) |
|
799 { |
|
800 iSettingNumber = number; |
|
801 SetNumbered( ETrue ); |
|
802 } |
|
803 |
|
804 // |
|
805 // Handle the setting text ( i.e. the title at the top of the setting page ) |
|
806 // |
|
807 TPtrC settingText = aRes.ReadTPtrC(); |
|
808 |
|
809 // |
|
810 // Resource text overrides text set via constructor. However, if the text was |
|
811 // set via the method SetSettingTextL then we use text given by that API |
|
812 // |
|
813 // |
|
814 if ( settingText.Length() > 0 && ( !iSettingText ) ) |
|
815 { |
|
816 SetSettingTextL( settingText ); |
|
817 } |
|
818 |
|
819 // if there is no iSettingText by this point, use the value given at construction: |
|
820 if (!iSettingText ) |
|
821 // But the value passed at constuction is a pointer and must be tested too: |
|
822 if ( iSettingTextFromConstructor ) |
|
823 SetSettingTextL( *iSettingTextFromConstructor ); |
|
824 else |
|
825 SetSettingTextL( KNullDesC ); // empty (zero-length) descriptor. |
|
826 |
|
827 TPtrC hintText = aRes.ReadTPtrC(); |
|
828 if ( hintText.Length() > 0 ) |
|
829 { |
|
830 delete iHintText; |
|
831 iHintText = 0; |
|
832 iHintText = hintText.AllocL(); |
|
833 } |
|
834 |
|
835 // Both CBa and Menu have defaults set here, not in .rh file for dependcy reasons |
|
836 iCbaResourceId = aRes.ReadInt32(); |
|
837 if ( !iCbaResourceId ) |
|
838 iCbaResourceId = R_AVKON_SOFTKEYS_OK_CANCEL__OK; |
|
839 |
|
840 iMenuBarId = aRes.ReadInt32(); |
|
841 if ( !iMenuBarId ) |
|
842 iMenuBarId = R_AVKON_MENUPANE_EMPTY; |
|
843 |
|
844 // The following are put in temporary variables because pre-existing EditorResourceId will over-ride |
|
845 // that in the resource link |
|
846 TInt controlType = aRes.ReadInt16(); |
|
847 TInt editorResourceId = aRes.ReadInt32(); |
|
848 |
|
849 // Use the resource if it is not the case that both are present from construction |
|
850 if (!( iEditorResourceId && iControlType ) ) |
|
851 { |
|
852 iEditorResourceId = editorResourceId; |
|
853 iControlType = controlType; |
|
854 } |
|
855 |
|
856 // Possible user-defined softkey bindings for invalid data |
|
857 iInvalidDataCbaResourceId = aRes.ReadInt32(); |
|
858 // If it is not defined by the user (.rh default is 0), then |
|
859 // it is set the specified default value if the valid cba resource is also |
|
860 // the default. Otherwise, it is set to be equal to the valid cba resource |
|
861 if ( !iInvalidDataCbaResourceId ) |
|
862 if ( iCbaResourceId == R_AVKON_SOFTKEYS_OK_CANCEL__SELECT || |
|
863 iCbaResourceId == R_AVKON_SOFTKEYS_OK_CANCEL || |
|
864 iCbaResourceId == R_AVKON_SOFTKEYS_OK_CANCEL__OK) |
|
865 iInvalidDataCbaResourceId = R_AVKON_SOFTKEYS_CANCEL; |
|
866 else |
|
867 iInvalidDataCbaResourceId = iCbaResourceId; |
|
868 |
|
869 iExtensionId = aRes.ReadInt32(); |
|
870 |
|
871 // Resource all read now |
|
872 |
|
873 // Construct menubar and cba before constructed-from resource objects might need them |
|
874 |
|
875 // Create a CBA for use with the setting page |
|
876 const TSize screenSize=TSize(AKN_LAYOUT_WINDOW_screen.iW, AKN_LAYOUT_WINDOW_screen.iH); |
|
877 |
|
878 TInt resourceId = 0; |
|
879 if(IsEditable()) |
|
880 resourceId = iCbaResourceId; |
|
881 else |
|
882 resourceId = iInvalidDataCbaResourceId; |
|
883 |
|
884 if ( iExtensionId ) |
|
885 { |
|
886 TResourceReader reader; |
|
887 iCoeEnv->CreateResourceReaderLC( reader, iExtensionId ); |
|
888 TInt flags = reader.ReadInt32(); |
|
889 CleanupStack::PopAndDestroy(); // reader |
|
890 |
|
891 if ( flags & KAknSettingPageNoEmbeddedSoftKeys ) |
|
892 { |
|
893 iExtension->iEmbeddedSoftkeys = EFalse; |
|
894 } |
|
895 } |
|
896 |
|
897 AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( this ); |
|
898 |
|
899 if ( !iExtension->iEmbeddedSoftkeys ) |
|
900 { |
|
901 iCba = CEikButtonGroupContainer::NewL(CEikButtonGroupContainer::ECba, |
|
902 CEikButtonGroupContainer::EHorizontal, this, resourceId, *this); |
|
903 iCba->SetBoundingRect(TRect(screenSize)); |
|
904 } |
|
905 else |
|
906 { |
|
907 iCba = CEikButtonGroupContainer::NewL( CEikButtonGroupContainer::ECba, |
|
908 CEikButtonGroupContainer::EHorizontal, |
|
909 this, resourceId, *this, CEikButtonGroupContainer::EIsEmbedded | |
|
910 CEikButtonGroupContainer::EAddToStack ); |
|
911 } |
|
912 |
|
913 iExtension->CreateBackgroundContextL(); |
|
914 |
|
915 if ( iExtension->iEmbeddedSoftkeys ) |
|
916 { |
|
917 EnableWindowTransparency(); |
|
918 GfxTransEffect::Register( this, KGfxPopupDefaultControlUid ); |
|
919 } |
|
920 |
|
921 // Make the menu bar |
|
922 iMenuBar = new (ELeave) CEikMenuBar() ; |
|
923 iMenuBar->ConstructL( this, NULL, iMenuBarId ) ; |
|
924 iEikonEnv->EikAppUi()->AddToStackL(iMenuBar,ECoeStackPriorityMenu,ECoeStackFlagRefusesFocus); |
|
925 |
|
926 iTextLabel = new(ELeave) CEikLabel( ); |
|
927 iTextLabel->UseLogicalToVisualConversion(ETrue); |
|
928 iTextLabel->SetContainerWindowL(*this); |
|
929 |
|
930 iExtension->iShadowText = new(ELeave) CEikLabel( ); |
|
931 iExtension->iShadowText->UseLogicalToVisualConversion(ETrue); |
|
932 iExtension->iShadowText->SetContainerWindowL(*this); |
|
933 |
|
934 // IsNumbered() should give the current answer now whether to have a number of not |
|
935 if ( IsNumbered() && ( iSettingNumber != EAknSettingPageNoOrdinalDisplayed ) ) |
|
936 { |
|
937 iNumberLabel = new(ELeave) CEikLabel( ); |
|
938 TBuf<KAknSettingPageMaxOrdinalDigits> text; |
|
939 __ASSERT_DEBUG( (iSettingNumber < 1000), Panic(EAknPanicSettingPageIllegalSettingNumber ) ); |
|
940 __ASSERT_DEBUG( (iSettingNumber > -100), Panic(EAknPanicSettingPageIllegalSettingNumber ) ); |
|
941 text.Format( KAknSettingPageNumberFormat,iSettingNumber ); |
|
942 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(text); |
|
943 iNumberLabel->SetTextL( text ); |
|
944 iNumberLabel->SetContainerWindowL(*this); |
|
945 } |
|
946 |
|
947 // Create scrollbar here before making sizechanged |
|
948 delete iExtension->iSBFrame; |
|
949 iExtension->iSBFrame=NULL; |
|
950 iExtension->iSBFrame=new(ELeave) CEikScrollBarFrame(this, NULL, ETrue); |
|
951 |
|
952 iExtension->iSBFrame->CreateDoubleSpanScrollBarsL(EFalse, EFalse, ETrue, EFalse); // non-window owning scrollbar (1st param) |
|
953 iExtension->iSBFrame->SetTypeOfVScrollBar(CEikScrollBarFrame::EDoubleSpan); |
|
954 iExtension->iSBFrame->DrawBackground( EFalse, EFalse ); |
|
955 iExtension->iSBFrame->SetScrollBarVisibilityL( CEikScrollBarFrame::EOff, |
|
956 CEikScrollBarFrame::EOff ); |
|
957 |
|
958 iExtension->iSBFrame->VerticalScrollBar()->SetContainerWindowL(*this); |
|
959 iExtension->iSBFrame->VerticalScrollBar()->SetMopParent(this); |
|
960 iExtension->iSBFrame->VerticalScrollBar()->CopyControlContextFrom(this);//iSkinsInfo->BackgroundAndFrameControl() |
|
961 iExtension->iSBFrame->VerticalScrollBar()->SetBackground( iExtension ); |
|
962 |
|
963 SEikControlInfo controlInfo=EikControlFactory::CreateByTypeL(iControlType); |
|
964 |
|
965 iEditorControl=controlInfo.iControl; |
|
966 iEditorControl->SetContainerWindowL(*this); |
|
967 iEditorControl->SetBackground( iExtension ); |
|
968 SetBackground( iExtension ); |
|
969 |
|
970 // Construct contained control from given resource Id |
|
971 |
|
972 { |
|
973 TResourceReader editorReader; |
|
974 iCoeEnv->CreateResourceReaderLC(editorReader,iEditorResourceId); |
|
975 iEditorControl->ConstructFromResourceL( editorReader ); |
|
976 CleanupStack::PopAndDestroy(); //editorReader |
|
977 } // editorReader out of scope |
|
978 |
|
979 // Position of the entire setting page - the mainpane |
|
980 TRect containerRect( ControlRect( iExtension->iEmbeddedSoftkeys ) ); |
|
981 |
|
982 // Create lock icon |
|
983 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
984 |
|
985 AknsUtils::CreateColorIconL(skin, KAknsIIDQgnIndiSettProtectedAdd, |
|
986 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG16, iExtension->iLockIcon, |
|
987 iExtension->iLockIconMask, KAvkonBitmapFile, EMbmAvkonQgn_indi_sett_protected_add, |
|
988 EMbmAvkonQgn_indi_sett_protected_add_mask, KRgbBlack); |
|
989 |
|
990 |
|
991 // Root the layout chain of calls: This will cause SizeChanged to be called |
|
992 // SizeChanged in turn will layout skin information as well as contained controls |
|
993 SetRect(containerRect); |
|
994 |
|
995 if ( iSettingText ) |
|
996 { |
|
997 iTextLabel->SetTextL(*iSettingText); |
|
998 iTextLabel->CropText(); |
|
999 if(iExtension->iShadowText) |
|
1000 { |
|
1001 iExtension->iShadowText->SetTextL(*iSettingText); |
|
1002 iExtension->iShadowText->CropText(); |
|
1003 } |
|
1004 } |
|
1005 } |
|
1006 |
|
1007 /** |
|
1008 * |
|
1009 * Method to get the editor resource via the setting page resource. Done as a static |
|
1010 * method in this class. |
|
1011 * |
|
1012 */ |
|
1013 EXPORT_C void CAknSettingPage::GetEditorResourceInfoL( |
|
1014 TInt aSettingPageResourceId, |
|
1015 TInt& aControlType, |
|
1016 TInt& aEditorResourceId ) |
|
1017 { |
|
1018 |
|
1019 aEditorResourceId = 0; |
|
1020 aControlType = -1; |
|
1021 |
|
1022 TResourceReader reader; |
|
1023 // Static method; cannot use iCoeEnv: |
|
1024 CEikonEnv::Static()->CreateResourceReaderLC(reader,aSettingPageResourceId); // reader on C-stack |
|
1025 |
|
1026 // Only the editor resource items (type nad resource link) are needed; others are discarded |
|
1027 reader.ReadInt16(); // number |
|
1028 reader.ReadTPtrC(); // setting text |
|
1029 reader.ReadTPtrC(); // hint text |
|
1030 reader.ReadInt32(); // CBA resource id |
|
1031 reader.ReadInt32(); // Menubar |
|
1032 |
|
1033 aControlType = reader.ReadInt16(); |
|
1034 aEditorResourceId = reader.ReadInt32(); |
|
1035 |
|
1036 CleanupStack::PopAndDestroy(); //reader |
|
1037 } |
|
1038 /** |
|
1039 * This routine is called as part of the set-up of the control. It is the place to put |
|
1040 * layout code. |
|
1041 * |
|
1042 */ |
|
1043 EXPORT_C void CAknSettingPage::SizeChanged() |
|
1044 { |
|
1045 StandardSettingPageLayout(); // Must be part of any re-implementation |
|
1046 AknLayoutUtils::LayoutControl( |
|
1047 iEditorControl, |
|
1048 SettingItemContentRect( ETrue ), |
|
1049 AknLayoutScalable_Avkon::setting_text_pane_copy1( 0 ) ); |
|
1050 } |
|
1051 |
|
1052 /** |
|
1053 * This routine is the base layout for CAknSettingPage. It lays out the labels and configures |
|
1054 * the drawing in general |
|
1055 * |
|
1056 */ |
|
1057 EXPORT_C void CAknSettingPage::StandardSettingPageLayout() |
|
1058 { |
|
1059 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
1060 TRgb color; |
|
1061 TInt error = AknsUtils::GetCachedColor( skin, color, |
|
1062 KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG10 ); |
|
1063 |
|
1064 TRect rect = Rect(); |
|
1065 |
|
1066 if ( iCba && iExtension->iEmbeddedSoftkeys ) |
|
1067 { |
|
1068 CEikCba* cba = static_cast<CEikCba*>( iCba->ButtonGroup() ); |
|
1069 |
|
1070 if ( cba ) |
|
1071 { |
|
1072 TAknLayoutRect cbaLayout; |
|
1073 cbaLayout.LayoutRect( rect, |
|
1074 AknLayoutScalable_Avkon::popup_sk_window( 0 ) ); |
|
1075 |
|
1076 // CBA's layout data contains also distance from left and right |
|
1077 // borders so we can take only its height - otherwise |
|
1078 // horizontal position would be wrong in landscape. |
|
1079 TRect cbaRect( cbaLayout.Rect().Size() ); |
|
1080 cbaRect.Move( 0, iSize.iHeight - cbaRect.Height() ); |
|
1081 |
|
1082 cba->SetRect( cbaRect ); |
|
1083 } |
|
1084 } |
|
1085 |
|
1086 TRect highlightRect( SettingItemContentRect( ETrue ) ); |
|
1087 |
|
1088 // transparent setting page |
|
1089 if(!IsBackgroundDrawingEnabled()) |
|
1090 { |
|
1091 color = AKN_LAF_COLOR_STATIC(0); |
|
1092 AknLayoutUtils::LayoutLabel( |
|
1093 iTextLabel, |
|
1094 rect, |
|
1095 AknLayoutScalable_Avkon::main_pane_set_t1_copy1( 3 ) ); |
|
1096 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *iTextLabel, EColorLabelText, color ) ); |
|
1097 |
|
1098 if(iExtension->iShadowText) |
|
1099 { |
|
1100 highlightRect.Move(1,1); |
|
1101 color = AKN_LAF_COLOR_STATIC(215); |
|
1102 AknLayoutUtils::LayoutLabel( |
|
1103 iExtension->iShadowText, |
|
1104 rect, |
|
1105 AknLayoutScalable_Avkon::main_pane_set_t1_copy1( 3 ) ); |
|
1106 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *(iExtension->iShadowText), EColorLabelText, color ) ); |
|
1107 } |
|
1108 } |
|
1109 else // normal setting page |
|
1110 { |
|
1111 // no ordinal |
|
1112 if ( !iNumberLabel ) |
|
1113 { |
|
1114 AknLayoutUtils::LayoutLabel( |
|
1115 iTextLabel, |
|
1116 rect, |
|
1117 AknLayoutScalable_Avkon::main_pane_set_t1_copy1( iIsProtected ? 3 : 2 ) ); |
|
1118 } |
|
1119 else |
|
1120 { |
|
1121 TAknTextLineLayout textLabelLayout( |
|
1122 AknLayoutScalable_Avkon::main_pane_set_t1_copy1( 4 ).LayoutLine() ); |
|
1123 |
|
1124 if ( !iIsProtected ) // is there lock icon |
|
1125 { |
|
1126 // There's isn't a variety for this case, so we do some |
|
1127 // composing. |
|
1128 TAknTextLineLayout longTextLabelLayout( |
|
1129 AknLayoutScalable_Avkon::main_pane_set_t1_copy1( 2 ) ); |
|
1130 textLabelLayout.ir = longTextLabelLayout.ir; |
|
1131 } |
|
1132 |
|
1133 AknLayoutUtils::LayoutLabel( |
|
1134 iTextLabel, |
|
1135 rect, |
|
1136 textLabelLayout ); |
|
1137 AknLayoutUtils::LayoutLabel( |
|
1138 iNumberLabel, |
|
1139 rect, |
|
1140 AknLayoutScalable_Avkon::main_pane_set_t2_copy1( 1 ) ); |
|
1141 |
|
1142 if (!error) |
|
1143 { |
|
1144 // set the ordinal color |
|
1145 // Ignore error |
|
1146 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *iNumberLabel, |
|
1147 EColorLabelText, color ) ); |
|
1148 } |
|
1149 } |
|
1150 |
|
1151 if (!error) |
|
1152 { |
|
1153 // set the text color, same for all so set in general place |
|
1154 // Ignore error |
|
1155 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *iTextLabel, |
|
1156 EColorLabelText, color ) ); |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 if(!IsBackgroundDrawingEnabled() && iExtension->iSBFrame) |
|
1161 { |
|
1162 TRAP_IGNORE( iExtension->iSBFrame->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EOff) ); |
|
1163 } |
|
1164 |
|
1165 if ( iExtension->iEmbeddedSoftkeys ) |
|
1166 { |
|
1167 TAknLayoutRect innerRect; |
|
1168 innerRect.LayoutRect( |
|
1169 rect, |
|
1170 AknLayoutScalable_Avkon::bg_popup_window_pane_g1( 0 ) ); |
|
1171 iExtension->iFrameBgContext->SetFrameRects( rect, innerRect.Rect() ); |
|
1172 } |
|
1173 else |
|
1174 { |
|
1175 iExtension->iBasicBgContext->SetRect( rect ); |
|
1176 } |
|
1177 |
|
1178 TEikScrollBarModel hSbarModel; |
|
1179 TEikScrollBarModel vSbarModel; |
|
1180 |
|
1181 vSbarModel.iScrollSpan= 0; |
|
1182 vSbarModel.iThumbSpan = 0; |
|
1183 |
|
1184 // Layout scrollbar |
|
1185 |
|
1186 if ( iExtension->iSBFrame ) |
|
1187 { |
|
1188 vSbarModel.iThumbPosition = 0; |
|
1189 TAknDoubleSpanScrollBarModel hDsSbarModel( hSbarModel ); |
|
1190 TAknDoubleSpanScrollBarModel vDsSbarModel( vSbarModel ); |
|
1191 |
|
1192 iExtension->iSBFrame->Tile( &vDsSbarModel ); |
|
1193 AknLayoutUtils::LayoutVerticalScrollBar( iExtension->iSBFrame, |
|
1194 ContainerRect( iExtension->iEmbeddedSoftkeys ), |
|
1195 TAknWindowComponentLayout::Compose( |
|
1196 AknLayoutScalable_Avkon::listscroll_set_pane_copy1( 0 ), |
|
1197 AknLayoutScalable_Avkon::scroll_pane_cp121_copy1( 0 ) ) ); |
|
1198 iExtension->iSBFrame->SetVFocusPosToThumbPos( vDsSbarModel.FocusPosition() ); |
|
1199 } |
|
1200 |
|
1201 if(iExtension->iLockIcon) |
|
1202 { |
|
1203 TAknLayoutRect layRect; |
|
1204 layRect.LayoutRect( |
|
1205 rect, |
|
1206 AknLayoutScalable_Avkon::set_content_pane_g1_copy1( 0 ) ); |
|
1207 iExtension->iLockIconRect = layRect.Rect(); |
|
1208 AknIconUtils::SetSize(iExtension->iLockIcon, iExtension->iLockIconRect.Size(), |
|
1209 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
1210 } |
|
1211 } |
|
1212 |
|
1213 /** |
|
1214 *From MEikMenuObserver ( this one has to be implemented as is pure virtual ) |
|
1215 * (called when menu is cancelled) |
|
1216 */ |
|
1217 EXPORT_C void CAknSettingPage::SetEmphasis(CCoeControl* aMenuControl, TBool aEmphasis) |
|
1218 { |
|
1219 CEikAppUi* appUi = iEikonEnv->EikAppUi(); |
|
1220 appUi->UpdateStackedControlFlags(this, aEmphasis ? ECoeStackFlagRefusesFocus : 0, ECoeStackFlagRefusesFocus); |
|
1221 appUi->RemoveFromStack(aMenuControl); |
|
1222 TRAP_IGNORE(appUi->AddToStackL(aMenuControl, aEmphasis ? ECoeStackPriorityDialog : ECoeStackPriorityMenu)); // should not leave since just removed. |
|
1223 appUi->UpdateStackedControlFlags(aMenuControl, aEmphasis ? 0 : ECoeStackFlagRefusesFocus, ECoeStackFlagRefusesFocus); |
|
1224 appUi->HandleStackChanged(); |
|
1225 } |
|
1226 |
|
1227 /** |
|
1228 * This function intialiases the items on the menu. It's used to disable and enable menu items and may be |
|
1229 * over ridden to add new ones. |
|
1230 * In addition it adds menu items which have been provided in the ConstructL in the form of a Menu Bar resource. |
|
1231 * Instead of using the Menu Bar directly it extracts the menu panes and adds them to it's own menu pane. |
|
1232 * It must be called in the DynInitMenuPaneL() function of any derived class before anything else!! |
|
1233 * |
|
1234 */ |
|
1235 EXPORT_C void CAknSettingPage::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane ) |
|
1236 { |
|
1237 if ( aResourceId == R_AVKON_FORM_MENUPANE ) |
|
1238 { |
|
1239 if ( iMenuBarId ) |
|
1240 { |
|
1241 TResourceReader reader ; |
|
1242 iCoeEnv->CreateResourceReaderLC( reader, iMenuBarId ) ; |
|
1243 |
|
1244 TInt count = reader.ReadInt16() ; // Number of menu panes |
|
1245 while (count--) |
|
1246 { |
|
1247 TInt menuPaneResourceId = reader.ReadInt32() ; |
|
1248 reader.ReadTPtrC() ; // read and ignore the rest... |
|
1249 reader.ReadInt32() ; |
|
1250 reader.ReadTPtrC() ; |
|
1251 reader.ReadInt16() ; |
|
1252 reader.ReadInt16() ; |
|
1253 reader.ReadInt32() ; |
|
1254 aMenuPane->AddMenuItemsL( menuPaneResourceId, 0, ETrue ) ; // at the top, with a separator |
|
1255 } |
|
1256 CleanupStack::PopAndDestroy() ; // Resource Reader |
|
1257 } |
|
1258 } |
|
1259 } |
|
1260 /** |
|
1261 * This implementation concerns itself only with the layout switch. Otherwise, the base |
|
1262 * class is called. |
|
1263 */ |
|
1264 EXPORT_C void CAknSettingPage::HandleResourceChange(TInt aType) |
|
1265 { |
|
1266 if(aType==KEikDynamicLayoutVariantSwitch) |
|
1267 { |
|
1268 SetRect( ControlRect( iExtension->iEmbeddedSoftkeys ) ); |
|
1269 } |
|
1270 else if( aType == KAknsMessageSkinChange ) |
|
1271 { |
|
1272 // Create lock icon |
|
1273 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
1274 |
|
1275 delete iExtension->iLockIcon; |
|
1276 delete iExtension->iLockIconMask; |
|
1277 iExtension->iLockIcon = NULL; |
|
1278 iExtension->iLockIconMask = NULL; |
|
1279 TRAP_IGNORE(AknsUtils::CreateColorIconL(skin, KAknsIIDQgnIndiSettProtectedAdd, |
|
1280 KAknsIIDQsnIconColors, EAknsCIQsnIconColorsCG16, iExtension->iLockIcon, |
|
1281 iExtension->iLockIconMask, KAvkonBitmapFile, EMbmAvkonQgn_indi_sett_protected_add, |
|
1282 EMbmAvkonQgn_indi_sett_protected_add_mask, KRgbBlack)); |
|
1283 |
|
1284 StandardSettingPageLayout(); |
|
1285 } |
|
1286 |
|
1287 CCoeControl::HandleResourceChange(aType); |
|
1288 } |
|
1289 |
|
1290 /** |
|
1291 * Processes events from the softkeys. Responds to EAknSoftkeyOk and EAknSoftkeyBack |
|
1292 * to accept or cancel the pop-up. |
|
1293 * |
|
1294 * @param aCommandId Event Id from the soft-key |
|
1295 */ |
|
1296 EXPORT_C void CAknSettingPage::ProcessCommandL(TInt aCommandId) |
|
1297 { |
|
1298 if(!IsEditable() && !(aCommandId == EAknSoftkeyBack || aCommandId == EAknSoftkeyCancel)) |
|
1299 { |
|
1300 return; |
|
1301 } |
|
1302 |
|
1303 HideMenu(); |
|
1304 |
|
1305 // Respond to softkey events |
|
1306 switch (aCommandId) |
|
1307 { |
|
1308 case EAknSoftkeyOk: |
|
1309 case EAknSoftkeySelect: |
|
1310 case EAknSoftkeyDone: |
|
1311 SelectCurrentItemL(); // has non-trivial implemenations in listbox type |
|
1312 // controls to put the selection on the current item |
|
1313 AttemptExitL(ETrue); |
|
1314 break; |
|
1315 case EAknSoftkeyBack: |
|
1316 case EAknSoftkeyCancel: |
|
1317 AttemptExitL(EFalse); |
|
1318 break; |
|
1319 case EAknSoftkeyOptions: |
|
1320 DisplayMenuL(); |
|
1321 break; |
|
1322 default: |
|
1323 break; |
|
1324 } |
|
1325 } |
|
1326 |
|
1327 /** |
|
1328 * Acts upon changes in the hosted control's state. |
|
1329 * This class's implementation is trivial and should be able to be |
|
1330 * safely re-implemented in client-derived classes. |
|
1331 * |
|
1332 * @param aControl The control changing its state (not used) |
|
1333 * @param aEventType The type of control event |
|
1334 */ |
|
1335 EXPORT_C void CAknSettingPage::HandleControlEventL(CCoeControl* /*aControl*/, |
|
1336 MCoeControlObserver::TCoeEvent aEventType) |
|
1337 { |
|
1338 // This implementation is good for most controls so it is provided |
|
1339 // here in the base class |
|
1340 if ( aEventType == EEventStateChanged && iUpdateMode == EUpdateWhenChanged ) |
|
1341 { |
|
1342 UpdateSettingL(); |
|
1343 } |
|
1344 } |
|
1345 |
|
1346 /** |
|
1347 * Called when the user accepts or cancels the setting. Default implementation |
|
1348 * sets the return value and exists. |
|
1349 * |
|
1350 * @param aAccept ETrue if the user accepted. EFalse if the user cancelled. |
|
1351 */ |
|
1352 EXPORT_C void CAknSettingPage::AttemptExitL(TBool aAccept) |
|
1353 { |
|
1354 if ( OkToExitL( aAccept ) ) |
|
1355 { |
|
1356 DismissL( aAccept ); |
|
1357 if(iReturn) |
|
1358 { |
|
1359 *iReturn = aAccept; |
|
1360 } |
|
1361 StopActiveScheduler(); |
|
1362 } |
|
1363 else |
|
1364 { |
|
1365 DrawDeferred(); |
|
1366 } |
|
1367 } |
|
1368 |
|
1369 /** |
|
1370 * Checks if it OK to exit. Derived classes may check for valid data before allowing the dialog to |
|
1371 * leave, possibly putting up notes. |
|
1372 * |
|
1373 * Returns ETrue if the dialog is ready to exit. Returns ETrue by default. |
|
1374 */ |
|
1375 EXPORT_C TBool CAknSettingPage::OkToExitL(TBool /*aAccept*/ ) |
|
1376 { |
|
1377 return(ETrue); |
|
1378 } |
|
1379 |
|
1380 |
|
1381 /** |
|
1382 * Called to remove the setting page |
|
1383 * |
|
1384 * @param aAccept ETrue to accept the current value; EFalse otherwise |
|
1385 */ |
|
1386 EXPORT_C void CAknSettingPage::DismissL(TBool aAccept) |
|
1387 { |
|
1388 AknItemActionMenuRegister::SetOverridingMenuBarOwnerL( NULL ); |
|
1389 |
|
1390 if ( aAccept ) |
|
1391 { |
|
1392 AcceptSettingL(); |
|
1393 if ( iSettingPageObserver ) |
|
1394 iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingOked); |
|
1395 } |
|
1396 else |
|
1397 { |
|
1398 RestoreOriginalSettingL(); |
|
1399 if ( iSettingPageObserver ) |
|
1400 iSettingPageObserver->HandleSettingPageEventL(this, MAknSettingPageObserver::EEventSettingCancelled); |
|
1401 } |
|
1402 |
|
1403 if ( GfxTransEffect::IsRegistered( this ) ) |
|
1404 { |
|
1405 GfxTransEffect::Begin( this, KGfxControlDisappearAction ); |
|
1406 MakeVisible( EFalse ); |
|
1407 GfxTransEffect::End( this ); |
|
1408 } |
|
1409 else |
|
1410 { |
|
1411 MakeVisible( EFalse ); |
|
1412 } |
|
1413 |
|
1414 iEikonEnv->RemoveFromStack(iCba); |
|
1415 delete iCba; |
|
1416 iCba = 0; |
|
1417 |
|
1418 PopNaviDecoratorIfRequired(); |
|
1419 } |
|
1420 |
|
1421 /** |
|
1422 * Substitutes the new setting number. If not yet constructed, just record the new value. |
|
1423 * If already constructed, we have to reformat the label. |
|
1424 * |
|
1425 * The label reformatting code needs to be soaked up in another routine for ROM saving and |
|
1426 * double maintenance |
|
1427 * |
|
1428 * @param aSettingNumber The new setting number to display |
|
1429 */ |
|
1430 EXPORT_C void CAknSettingPage::SetSettingNumberL( TInt aSettingNumber ) |
|
1431 { |
|
1432 iSettingNumber = aSettingNumber; |
|
1433 SetNumbered( ETrue); |
|
1434 |
|
1435 // Update the number label if present |
|
1436 if ( iNumberLabel ) |
|
1437 { |
|
1438 TBuf<KAknSettingPageMaxOrdinalDigits> text; |
|
1439 text.Format(_L("%d"),iSettingNumber); // Subject to layout changes |
|
1440 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(text); |
|
1441 iNumberLabel->SetTextL( text ); |
|
1442 } |
|
1443 } |
|
1444 |
|
1445 /** |
|
1446 * Sets the observer for the setting. |
|
1447 * |
|
1448 * @param aObserver The observer for changes to the setting |
|
1449 */ |
|
1450 EXPORT_C void CAknSettingPage::SetSettingPageObserver( MAknSettingPageObserver* aObserver) |
|
1451 { |
|
1452 iSettingPageObserver = aObserver; |
|
1453 } |
|
1454 |
|
1455 /** |
|
1456 * Sets the setting Id. The Id may be used to unabiguously number a setting in some context |
|
1457 * It would be useful to call SettingId() on aSettingPageControl in handling an observer |
|
1458 * callback |
|
1459 * |
|
1460 * @param aSettingId An id to provide to the observer in the callback |
|
1461 */ |
|
1462 EXPORT_C void CAknSettingPage::SetSettingId( TInt aSettingId ) |
|
1463 { |
|
1464 iSettingId = aSettingId; |
|
1465 } |
|
1466 |
|
1467 /** |
|
1468 * returns the setting Id. |
|
1469 * |
|
1470 */ |
|
1471 EXPORT_C TInt CAknSettingPage::SettingId( void ) const |
|
1472 { |
|
1473 return iSettingId; |
|
1474 } |
|
1475 |
|
1476 |
|
1477 /** |
|
1478 * Substitutes the new setting text. Allocate memory for it. |
|
1479 * If already constructed, we have to reformat the label. |
|
1480 * |
|
1481 * Note that calling this will over-ride text in Setting Page resource |
|
1482 * |
|
1483 * @param aSettingText The new setting text to display |
|
1484 */ |
|
1485 EXPORT_C void CAknSettingPage::SetSettingTextL( const TDesC& aText ) |
|
1486 { |
|
1487 HBufC* newBuffer = |
|
1488 HBufC::NewL(aText.Length()); |
|
1489 |
|
1490 delete iSettingText; |
|
1491 iSettingText = newBuffer; |
|
1492 |
|
1493 *iSettingText = aText; |
|
1494 |
|
1495 if (iTextLabel && iSettingText) |
|
1496 { |
|
1497 iTextLabel->SetTextL(*iSettingText); |
|
1498 iTextLabel->CropText(); |
|
1499 if(iExtension->iShadowText) |
|
1500 { |
|
1501 iExtension->iShadowText->SetTextL(*iSettingText); |
|
1502 iExtension->iShadowText->CropText(); |
|
1503 } |
|
1504 } |
|
1505 } |
|
1506 |
|
1507 |
|
1508 /** |
|
1509 * Standard CCoeControl routine to return the control at a given index |
|
1510 * |
|
1511 * @param aIndex index at which to return control |
|
1512 */ |
|
1513 EXPORT_C CCoeControl* CAknSettingPage::ComponentControl(TInt aIndex) const |
|
1514 { |
|
1515 CCoeControl* buttonGroupControl = NULL; |
|
1516 |
|
1517 if ( iCba && iExtension->iEmbeddedSoftkeys ) |
|
1518 { |
|
1519 MEikButtonGroup* buttonGroup = iCba->ButtonGroup(); |
|
1520 |
|
1521 if ( buttonGroup ) |
|
1522 { |
|
1523 buttonGroupControl = buttonGroup->AsControl(); |
|
1524 } |
|
1525 } |
|
1526 CCoeControl* controls[] = { |
|
1527 iEditorControl, |
|
1528 iExtension->iShadowText, |
|
1529 iTextLabel, |
|
1530 iNumberLabel, |
|
1531 buttonGroupControl, |
|
1532 iExtension->iSBFrame ? |
|
1533 iExtension->iSBFrame->VerticalScrollBar() : NULL, |
|
1534 iExtension->iEditIndicator }; |
|
1535 |
|
1536 for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++) |
|
1537 if (controls[ii] && aIndex-- == 0) |
|
1538 { |
|
1539 return controls[ii]; |
|
1540 } |
|
1541 return NULL; |
|
1542 } |
|
1543 |
|
1544 EXPORT_C void CAknSettingPage::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
1545 { |
|
1546 CAknControl::HandlePointerEventL(aPointerEvent); |
|
1547 } |
|
1548 |
|
1549 /** |
|
1550 * Get InputCapabilities. Overrides CoeControl::InputCapabilities |
|
1551 * |
|
1552 */ |
|
1553 EXPORT_C TCoeInputCapabilities CAknSettingPage::InputCapabilities() const |
|
1554 { |
|
1555 return TCoeInputCapabilities(TCoeInputCapabilities::EAllText, NULL, iExtension); |
|
1556 } |
|
1557 |
|
1558 EXPORT_C void* CAknSettingPage::ExtensionInterface( TUid /*aInterface*/ ) |
|
1559 { |
|
1560 return NULL; |
|
1561 } |
|
1562 |
|
1563 /** |
|
1564 * Standard CCoeControl routine to return the number of component controls |
|
1565 * |
|
1566 * @return number of component controls |
|
1567 */ |
|
1568 EXPORT_C TInt CAknSettingPage::CountComponentControls() const |
|
1569 { |
|
1570 TInt count = 0; |
|
1571 CCoeControl* buttonGroupControl = NULL; |
|
1572 |
|
1573 if ( iCba && iExtension->iEmbeddedSoftkeys ) |
|
1574 { |
|
1575 MEikButtonGroup* buttonGroup = iCba->ButtonGroup(); |
|
1576 |
|
1577 if ( buttonGroup ) |
|
1578 { |
|
1579 buttonGroupControl = buttonGroup->AsControl(); |
|
1580 } |
|
1581 } |
|
1582 CCoeControl* controls[] = { |
|
1583 iEditorControl, |
|
1584 iExtension->iShadowText, |
|
1585 iTextLabel, |
|
1586 iNumberLabel, |
|
1587 buttonGroupControl, |
|
1588 iExtension->iSBFrame ? |
|
1589 iExtension->iSBFrame->VerticalScrollBar() : NULL, |
|
1590 iExtension->iEditIndicator }; |
|
1591 for (TUint ii=0;ii<sizeof(controls)/sizeof(CCoeControl*);ii++) |
|
1592 if (controls[ii]) |
|
1593 count++; |
|
1594 return count; |
|
1595 |
|
1596 } |
|
1597 |
|
1598 /** |
|
1599 * Returns reference to the hosted "editor" control as a CCoeControl. |
|
1600 * This routine is used in derived classes, which then case to the specific run-time type |
|
1601 * |
|
1602 */ |
|
1603 EXPORT_C CCoeControl* CAknSettingPage::EditorControl() const |
|
1604 { |
|
1605 return iEditorControl; |
|
1606 } |
|
1607 |
|
1608 /** |
|
1609 * Access routine for private state data |
|
1610 */ |
|
1611 EXPORT_C TBool CAknSettingPage::Waiting() |
|
1612 { |
|
1613 return iWait.IsStarted(); |
|
1614 } |
|
1615 |
|
1616 /** |
|
1617 * Internal routine to restore a saved "original" value |
|
1618 * |
|
1619 */ |
|
1620 EXPORT_C void CAknSettingPage::RestoreOriginalSettingL() |
|
1621 { |
|
1622 } |
|
1623 |
|
1624 /** |
|
1625 * |
|
1626 * Executes a waiting dialog-like setting page |
|
1627 * |
|
1628 * The passed mode determines if the editor's value is updated continuously, or just |
|
1629 * when it is accepted. |
|
1630 * |
|
1631 * @param aMode The update mode of the class |
|
1632 */ |
|
1633 EXPORT_C TBool CAknSettingPage::ExecuteLD( TAknSettingPageUpdateMode aMode ) |
|
1634 { |
|
1635 |
|
1636 // This is a copy of the return value on the stack |
|
1637 TBool returnValue = EFalse; |
|
1638 // Set a pointer to this return value so that it can be modified in other |
|
1639 // methods while the setting page is running. |
|
1640 // This relationship must be set up before any user-re-implementable methods |
|
1641 // so that they have a value return value. |
|
1642 iReturn = &returnValue; |
|
1643 |
|
1644 CleanupStack::PushL( this ); // Matching Pop is in AttemptExitL |
|
1645 CAknInputBlock* inputBlock = CAknInputBlock::NewLC( ); |
|
1646 if ( !IsBaseConstructed() ) |
|
1647 ConstructL(); |
|
1648 iUpdateMode = aMode; |
|
1649 |
|
1650 // Ensure we have a menu bar by this point |
|
1651 __ASSERT_DEBUG( iMenuBar, Panic( EAknPanicSettingPageNoMenuBar ) ) ; |
|
1652 |
|
1653 DynamicInitL(); |
|
1654 ActivateL(); |
|
1655 |
|
1656 if ( iExtension->iEmbeddedSoftkeys ) |
|
1657 { |
|
1658 iExtension->iFader.FadeBehindPopup( iExtension, this, ETrue ); |
|
1659 } |
|
1660 |
|
1661 if ( GfxTransEffect::IsRegistered( this ) ) |
|
1662 { |
|
1663 GfxTransEffect::Begin( this, KGfxControlAppearAction ); |
|
1664 |
|
1665 TRect demarcation; |
|
1666 CAknTransitionUtils::GetDemarcation( CAknTransitionUtils::EPopup, |
|
1667 demarcation ); |
|
1668 GfxTransEffect::SetDemarcation( this, demarcation ); |
|
1669 |
|
1670 MakeVisible( ETrue ); |
|
1671 GfxTransEffect::End( this ); |
|
1672 } |
|
1673 else |
|
1674 { |
|
1675 MakeVisible( ETrue ); |
|
1676 } |
|
1677 |
|
1678 iEditorControl->SetObserver( this ); |
|
1679 iEikonEnv->EikAppUi()->AddToStackL(this,ECoeStackPriorityDialog); |
|
1680 |
|
1681 if( !iExtension->iEmbeddedSoftkeys ) |
|
1682 { |
|
1683 if (!iNaviPane) |
|
1684 { |
|
1685 CEikStatusPane *sp = ((CAknAppUi*)iEikonEnv->EikAppUi())->StatusPane(); |
|
1686 if(sp) |
|
1687 iNaviPane = (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi)); |
|
1688 } |
|
1689 |
|
1690 // It would be nice if iNaviDecorator is always going to point to uniquely identifiable |
|
1691 // Pop-able item - but this is not the case. |
|
1692 // The default navipane Wipe is represented by a NULL in the stack, so that |
|
1693 // is not much good for recording if the leaving methods were successful or not - |
|
1694 // That is, you cannot distinguish between failed creation/Pushing, or the result of a |
|
1695 // PushDefaultL(). |
|
1696 // The solution is to use iNaviPane as a record as to whether we need to pop or not, |
|
1697 // hence it needs to be zeroed if the Push fails |
|
1698 if ( iHintText && iNaviPane ) |
|
1699 { |
|
1700 TRAPD( err, iNaviDecorator = iNaviPane->CreateNavigationLabelL( iHintText->Des() ) ); |
|
1701 if ( err != KErrNone ) |
|
1702 { |
|
1703 iNaviPane = 0; // This will suppress the Pop |
|
1704 User::Leave( err ); |
|
1705 } |
|
1706 else |
|
1707 { |
|
1708 // OK if this leaves. iNaviDecorator will not be found when you pop |
|
1709 iNaviPane->PushL(*iNaviDecorator); |
|
1710 } |
|
1711 } |
|
1712 else if(iNaviPane) |
|
1713 { |
|
1714 TRAPD( err, iNaviPane->PushDefaultL( ETrue ) ); // We will have to suppress Pop if this fails |
|
1715 if ( err != KErrNone ) |
|
1716 { |
|
1717 iNaviPane = 0; // This will suppress the Pop |
|
1718 User::Leave( err ); |
|
1719 } |
|
1720 else |
|
1721 { |
|
1722 // Actually, this returns a NULL but still do it for in case the wipe becomes |
|
1723 // represented by a concrete object in future. |
|
1724 iNaviDecorator = iNaviPane->Top(); |
|
1725 } |
|
1726 } |
|
1727 } |
|
1728 |
|
1729 CleanupStack::PopAndDestroy( inputBlock ); |
|
1730 |
|
1731 if ( PostDisplayCheckL() ) |
|
1732 { |
|
1733 StartActiveScheduler(); |
|
1734 } |
|
1735 else |
|
1736 AttemptExitL(EFalse); |
|
1737 |
|
1738 iEikonEnv->EikAppUi()->RemoveFromStack(this); |
|
1739 CleanupStack::Pop(); // this |
|
1740 |
|
1741 if ( iExtension->iEmbeddedSoftkeys ) |
|
1742 { |
|
1743 iExtension->iFader.FadeBehindPopup( iExtension, this, EFalse ); |
|
1744 } |
|
1745 |
|
1746 delete (this); |
|
1747 return returnValue; |
|
1748 } |
|
1749 |
|
1750 /** |
|
1751 * Puts up a constructed dialog. Part of the non-waiting API calls. |
|
1752 * Activity to perform as soon as the setting page is displayed |
|
1753 * |
|
1754 */ |
|
1755 EXPORT_C TBool CAknSettingPage::PostDisplayCheckL() |
|
1756 { |
|
1757 return ETrue; |
|
1758 } |
|
1759 |
|
1760 /** |
|
1761 * Called immediately prior to activation of the dialog. Framework routine for derived |
|
1762 * classes. |
|
1763 * |
|
1764 */ |
|
1765 EXPORT_C void CAknSettingPage::DynamicInitL() |
|
1766 { |
|
1767 } |
|
1768 |
|
1769 /** |
|
1770 * Called when something has changed. Use to update the object referenced by |
|
1771 * the client code. |
|
1772 * |
|
1773 */ |
|
1774 EXPORT_C void CAknSettingPage::UpdateSettingL() |
|
1775 { |
|
1776 } |
|
1777 |
|
1778 /** |
|
1779 * Called when the setting page has been dismissed and the user is accepting the value. |
|
1780 * Derived classes need to implement. |
|
1781 */ |
|
1782 EXPORT_C void CAknSettingPage::AcceptSettingL() |
|
1783 { |
|
1784 } |
|
1785 /** |
|
1786 * Draw routine. Overrides CoeControl::Draw |
|
1787 * |
|
1788 */ |
|
1789 |
|
1790 EXPORT_C void CAknSettingPage::Draw(const TRect& aRect) const |
|
1791 { |
|
1792 BaseDraw( aRect ); |
|
1793 } |
|
1794 |
|
1795 |
|
1796 EXPORT_C void CAknSettingPage::BaseDraw( const TRect& /*aRect*/ ) const |
|
1797 { |
|
1798 CWindowGc& gc = SystemGc(); |
|
1799 |
|
1800 if ( iIsProtected && iExtension->iLockIcon ) |
|
1801 { |
|
1802 TRect lockRect( TPoint( 0, 0 ), iExtension->iLockIconRect.Size() ); |
|
1803 |
|
1804 gc.BitBltMasked( iExtension->iLockIconRect.iTl, |
|
1805 iExtension->iLockIcon, |
|
1806 lockRect, |
|
1807 iExtension->iLockIconMask, |
|
1808 ETrue ); |
|
1809 } |
|
1810 } |
|
1811 |
|
1812 /** |
|
1813 * Return the CBA reference; Must be called after full construction, or null reference will |
|
1814 * be returned. |
|
1815 * |
|
1816 */ |
|
1817 EXPORT_C CEikButtonGroupContainer* CAknSettingPage::Cba() const |
|
1818 { |
|
1819 return (iCba); |
|
1820 } |
|
1821 |
|
1822 /** |
|
1823 * |
|
1824 */ |
|
1825 EXPORT_C void CAknSettingPage::DisplayMenuL() |
|
1826 { |
|
1827 iMenuBar->TryDisplayMenuBarL() ; |
|
1828 } |
|
1829 |
|
1830 /** |
|
1831 * |
|
1832 */ |
|
1833 EXPORT_C void CAknSettingPage::HideMenu() |
|
1834 { |
|
1835 if( iMenuBar ) |
|
1836 { |
|
1837 iMenuBar->StopDisplayingMenuBar(); |
|
1838 } |
|
1839 } |
|
1840 |
|
1841 /** |
|
1842 * This is used as a protected access function for the state of the menu bar |
|
1843 * |
|
1844 */ |
|
1845 EXPORT_C TBool CAknSettingPage::MenuShowing() const |
|
1846 { |
|
1847 if(iMenuBar) |
|
1848 { |
|
1849 return iMenuBar->IsDisplayed(); |
|
1850 } |
|
1851 |
|
1852 return EFalse; |
|
1853 } |
|
1854 /** |
|
1855 * This is used to access the default resource id for the cba |
|
1856 */ |
|
1857 EXPORT_C TInt CAknSettingPage::DefaultCbaResourceId() const |
|
1858 { |
|
1859 return ( iCbaResourceId ) ; |
|
1860 } |
|
1861 |
|
1862 EXPORT_C void CAknSettingPage::Reserved_MtsmPosition() |
|
1863 { |
|
1864 } |
|
1865 |
|
1866 EXPORT_C void CAknSettingPage::Reserved_MtsmObject() |
|
1867 { |
|
1868 } |
|
1869 |
|
1870 /** |
|
1871 * Access method for the number of the setting page |
|
1872 * |
|
1873 */ |
|
1874 EXPORT_C TInt CAknSettingPage::SettingNumber() const |
|
1875 { |
|
1876 return iSettingNumber; |
|
1877 } |
|
1878 |
|
1879 /** |
|
1880 * Access method for whether the setting page is numbered or not |
|
1881 * |
|
1882 */ |
|
1883 EXPORT_C TBool CAknSettingPage::IsNumbered() const |
|
1884 { |
|
1885 return ( iFlags.IsSet( ENumberedStyleIndex ) ); |
|
1886 } |
|
1887 |
|
1888 /** |
|
1889 * Set method for whether the setting page is numbered or not |
|
1890 * |
|
1891 */ |
|
1892 EXPORT_C void CAknSettingPage::SetNumbered( TBool aNumbered ) |
|
1893 { |
|
1894 iFlags.Assign( ENumberedStyleIndex, aNumbered ); |
|
1895 } |
|
1896 /** |
|
1897 * Access method for the internally held resource Id |
|
1898 * |
|
1899 */ |
|
1900 EXPORT_C TInt CAknSettingPage::SettingPageResourceId() |
|
1901 { |
|
1902 return iResourceId; |
|
1903 } |
|
1904 |
|
1905 /** |
|
1906 * This method can be used to test if BaseConstructL() has been called yet |
|
1907 * successfully |
|
1908 * |
|
1909 */ |
|
1910 EXPORT_C TBool CAknSettingPage::IsBaseConstructed() |
|
1911 { |
|
1912 return ( iFlags.IsSet( EIsBaseConstructedIndex ) ); |
|
1913 } |
|
1914 |
|
1915 /** |
|
1916 * Puts the focus back on the editor. For complicated setting pages that have focus removed from them |
|
1917 * at some point, then a re-implementation may have to do some work here. |
|
1918 * |
|
1919 */ |
|
1920 EXPORT_C void CAknSettingPage::SetFocusToEditor() |
|
1921 { |
|
1922 __ASSERT_DEBUG(EFalse, Panic(EAknPanicSettingPageDeprecated) ) ; |
|
1923 } |
|
1924 |
|
1925 /** |
|
1926 * This framework method is used to update the contents of the CBA in a custom way. |
|
1927 * Some setting page classes implement a degree of validation and will implement this. |
|
1928 * Derived classes should ensure that this and CheckAndSetDataValidity() are called frequently enough for their |
|
1929 * purposes. |
|
1930 * |
|
1931 */ |
|
1932 EXPORT_C void CAknSettingPage::UpdateCbaL() |
|
1933 { |
|
1934 if ( IsStopActiveSchudlerCalled() ) |
|
1935 { |
|
1936 CAknEnv::StopSchedulerWaitWithBusyMessage(iWait); |
|
1937 return; |
|
1938 } |
|
1939 |
|
1940 if(!IsEditable()) |
|
1941 { |
|
1942 Cba()->SetCommandSetL( InvalidDataCbaResourceId() ); |
|
1943 return; |
|
1944 } |
|
1945 |
|
1946 if ( InvalidDataCbaResourceId() != DefaultCbaResourceId() ) |
|
1947 { |
|
1948 TBool validLabels = ETrue; |
|
1949 if ( !DataValidity() ) |
|
1950 { |
|
1951 TInt leftId; |
|
1952 leftId = (Cba()->ButtonGroup()->CommandId(0)); |
|
1953 if ( (leftId == EAknSoftkeyOk ) |
|
1954 || (leftId == EEikBidBlank) |
|
1955 || (leftId == EAknSoftkeyEmpty) |
|
1956 || (leftId == 0 ) ) // Despite the resources, only switch if the left is OK or blank |
|
1957 validLabels = EFalse; |
|
1958 } |
|
1959 |
|
1960 if ( validLabels ) |
|
1961 Cba()->SetCommandSetL( DefaultCbaResourceId() ); |
|
1962 else |
|
1963 Cba()->SetCommandSetL( InvalidDataCbaResourceId() ); |
|
1964 |
|
1965 Cba()->DrawDeferred(); |
|
1966 } |
|
1967 } |
|
1968 |
|
1969 /** |
|
1970 * This method is re-implemented in listbox editor setting pages to move |
|
1971 * the selection to the current highlighted item |
|
1972 * |
|
1973 */ |
|
1974 EXPORT_C void CAknSettingPage::SelectCurrentItemL() |
|
1975 { |
|
1976 // No action by default |
|
1977 } |
|
1978 |
|
1979 EXPORT_C void CAknSettingPage::FocusChanged(TDrawNow aDrawNow) |
|
1980 { |
|
1981 CCoeControl* ctrl = EditorControl(); |
|
1982 if (ctrl) |
|
1983 ctrl->SetFocus(IsFocused(), aDrawNow); |
|
1984 } |
|
1985 |
|
1986 EXPORT_C TInt CAknSettingPage::InvalidDataCbaResourceId() const |
|
1987 { |
|
1988 return iInvalidDataCbaResourceId; |
|
1989 } |
|
1990 |
|
1991 EXPORT_C void CAknSettingPage::SetDataValidity( TBool aValid ) |
|
1992 { |
|
1993 iFlags.Assign( EHasValidDataIndex, aValid ); |
|
1994 } |
|
1995 |
|
1996 EXPORT_C TBool CAknSettingPage::DataValidity( ) const |
|
1997 { |
|
1998 return (iFlags.IsSet( EHasValidDataIndex )); |
|
1999 } |
|
2000 |
|
2001 EXPORT_C void CAknSettingPage::CheckAndSetDataValidity() |
|
2002 { |
|
2003 // Default implementation in the base class |
|
2004 SetDataValidity( ETrue ); |
|
2005 } |
|
2006 |
|
2007 |
|
2008 // ---------------------------------------------------------------------------- |
|
2009 // Sets the outer and inner rectangle for the frame graphics that is drawn |
|
2010 // around the setting item. |
|
2011 // ---------------------------------------------------------------------------- |
|
2012 // |
|
2013 void CAknSettingPage::SetEditedItemFrameRects( const TRect& aOuterRect, |
|
2014 const TRect& aInnerRect ) |
|
2015 { |
|
2016 iExtension->SetEditedItemFrameRects( aOuterRect, aInnerRect ); |
|
2017 } |
|
2018 |
|
2019 |
|
2020 // ---------------------------------------------------------------------------- |
|
2021 // Sets the skin item ID for the frame graphics that is drawn around the |
|
2022 // setting item. |
|
2023 // ---------------------------------------------------------------------------- |
|
2024 // |
|
2025 void CAknSettingPage::SetEditedItemFrameIID( |
|
2026 const TAknsItemID& aFrameIID, |
|
2027 const TAknsItemID& aFrameCenterIID ) |
|
2028 { |
|
2029 iExtension->SetEditedItemFrameIID( aFrameIID, aFrameCenterIID ); |
|
2030 } |
|
2031 |
|
2032 |
|
2033 // ---------------------------------------------------------------------------- |
|
2034 // Sets the rectangle for the editing state indicators. |
|
2035 // ---------------------------------------------------------------------------- |
|
2036 // |
|
2037 void CAknSettingPage::SetEditorIndicatorRect( const TRect& aRect ) |
|
2038 { |
|
2039 CAknQueryEditIndicator* editIndicator = |
|
2040 iExtension->EditorIndicatorContainer(); |
|
2041 |
|
2042 if ( editIndicator ) |
|
2043 { |
|
2044 editIndicator->SetRect( aRect ); |
|
2045 } |
|
2046 } |
|
2047 |
|
2048 |
|
2049 TBool CAknSettingPage::IsSkinsHandlingEditorFrameDrawing() const |
|
2050 { |
|
2051 return ETrue; |
|
2052 } |
|
2053 |
|
2054 CAknsFrameBackgroundControlContext* CAknSettingPage::EditedItemControlContext() const |
|
2055 { |
|
2056 return NULL; |
|
2057 } |
|
2058 |
|
2059 |
|
2060 // --------------------------------------------------------------------------- |
|
2061 // CAknSettingPage::BaseConstructL |
|
2062 // --------------------------------------------------------------------------- |
|
2063 // |
|
2064 void CAknSettingPage::BaseConstructL( TUint aFlags ) |
|
2065 { |
|
2066 if ( aFlags & KAknSettingPageNoEmbeddedSoftKeys ) |
|
2067 { |
|
2068 if ( !iExtension ) |
|
2069 { |
|
2070 iExtension = CAknSettingPageExtension::NewL( this ); |
|
2071 } |
|
2072 |
|
2073 iExtension->iEmbeddedSoftkeys = EFalse; |
|
2074 } |
|
2075 |
|
2076 BaseConstructL(); |
|
2077 } |
|
2078 |
|
2079 |
|
2080 EXPORT_C TTypeUid::Ptr CAknSettingPage::MopSupplyObject(TTypeUid aId) |
|
2081 { |
|
2082 if ( aId.iUid == CEikScrollBarFrame::ETypeId && iExtension->iSBFrame ) |
|
2083 { |
|
2084 return aId.MakePtr( iExtension->iSBFrame ); |
|
2085 } |
|
2086 else if ( aId.iUid == MAknEditingStateIndicator::ETypeId && |
|
2087 iExtension->iEditIndicator ) |
|
2088 { |
|
2089 return SupplyMopObject( aId, iExtension->iEditIndicator ); |
|
2090 } |
|
2091 |
|
2092 return SupplyMopObject( aId, iCba, iMenuBar ); |
|
2093 } |
|
2094 |
|
2095 EXPORT_C void CAknSettingPage::SetEditState(const TBool aEditable) |
|
2096 { |
|
2097 if(aEditable) |
|
2098 iIsProtected = 0; |
|
2099 else |
|
2100 iIsProtected = 1; |
|
2101 |
|
2102 if(Cba()) |
|
2103 { |
|
2104 TRAP_IGNORE( UpdateCbaL() ); |
|
2105 } |
|
2106 } |
|
2107 |
|
2108 EXPORT_C TBool CAknSettingPage::IsEditable() const |
|
2109 { |
|
2110 TBool editable = ETrue; |
|
2111 |
|
2112 if(iIsProtected != 0) |
|
2113 editable = EFalse; |
|
2114 |
|
2115 return editable; |
|
2116 } |
|
2117 |
|
2118 |
|
2119 // --------------------------------------------------------------------------- |
|
2120 // Calculates and returns setting item content rect. |
|
2121 // --------------------------------------------------------------------------- |
|
2122 // |
|
2123 TRect CAknSettingPage::SettingItemContentRect( TBool aScrollBarUsed ) |
|
2124 { |
|
2125 TRect containerRect( ContainerRect( iExtension->iEmbeddedSoftkeys ) ); |
|
2126 TRect contentRect; |
|
2127 |
|
2128 TAknLayoutRect listScrollSetPane; |
|
2129 listScrollSetPane.LayoutRect( |
|
2130 containerRect, |
|
2131 AknLayoutScalable_Avkon::listscroll_set_pane_copy1() ); |
|
2132 |
|
2133 if ( aScrollBarUsed ) |
|
2134 { |
|
2135 TAknLayoutRect setContentPane; |
|
2136 setContentPane.LayoutRect( |
|
2137 listScrollSetPane.Rect(), |
|
2138 AknLayoutScalable_Avkon::set_content_pane_copy1() ); |
|
2139 contentRect = setContentPane.Rect(); |
|
2140 } |
|
2141 else |
|
2142 { |
|
2143 // Take the space reserved for scrollbar into use for the content |
|
2144 // if the scrollbar is not shown. |
|
2145 contentRect = listScrollSetPane.Rect(); |
|
2146 } |
|
2147 |
|
2148 return contentRect; |
|
2149 } |
|
2150 |
|
2151 |
|
2152 void CAknSettingPage::PopNaviDecoratorIfRequired() |
|
2153 { |
|
2154 if ( iNaviPane && !iExtension->iEmbeddedSoftkeys ) |
|
2155 { |
|
2156 iNaviPane->Pop( iNaviDecorator ); // iNaviDecorator is not to be detroyed yet |
|
2157 |
|
2158 // This is only a reference. Set to zero only to ensure invariant that we have |
|
2159 // poped out iNaviPane context already. |
|
2160 iNaviPane=0; |
|
2161 } |
|
2162 } |
|
2163 |
|
2164 /** |
|
2165 * Enables / disables transparency effect, ie. does the setting page draw it's own background or not. |
|
2166 * @param aDrawBackground EFalse enables transparency |
|
2167 */ |
|
2168 void CAknSettingPage::SetDrawBackground(const TBool aDrawBackground) |
|
2169 { |
|
2170 iExtension->iDrawBackground = aDrawBackground; |
|
2171 } |
|
2172 |
|
2173 /** |
|
2174 * Is the setting page drawing the background itself or not (= "transparency") |
|
2175 */ |
|
2176 TBool CAknSettingPage::IsBackgroundDrawingEnabled() const |
|
2177 { |
|
2178 return iExtension->iDrawBackground; |
|
2179 } |
|
2180 |
|
2181 /** |
|
2182 * Set the flag to indicate that if the function CAknSettingPage::StopActiveScheduler called or not |
|
2183 * @param aStopCalled ETrue means the StopActiveScheduler have been called |
|
2184 */ |
|
2185 void CAknSettingPage::SetStopActiveSchedulerFlag(const TBool aStopCalled ) |
|
2186 { |
|
2187 if( iExtension ) |
|
2188 { |
|
2189 iExtension->iIsStopActiveSchedulerCalled = aStopCalled; |
|
2190 } |
|
2191 } |
|
2192 |
|
2193 /** |
|
2194 * Is the setting page's function StopActiveSchudler called or not |
|
2195 */ |
|
2196 TBool CAknSettingPage::IsStopActiveSchudlerCalled()const |
|
2197 { |
|
2198 if( iExtension ) |
|
2199 { |
|
2200 return iExtension->iIsStopActiveSchedulerCalled; |
|
2201 } |
|
2202 |
|
2203 return ETrue; |
|
2204 } |
|
2205 |
|
2206 /** |
|
2207 * Returns pointer to text label |
|
2208 */ |
|
2209 EXPORT_C CEikLabel* CAknSettingPage::TextLabel() const |
|
2210 { |
|
2211 return iTextLabel; |
|
2212 } |
|
2213 |
|
2214 /** |
|
2215 * Returns pointer to shadow text |
|
2216 */ |
|
2217 EXPORT_C CEikLabel* CAknSettingPage::ShadowText() const |
|
2218 { |
|
2219 return iExtension->iShadowText; |
|
2220 } |
|
2221 |
|
2222 // End of File |