2 * Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
15 * Base class for setting page (setting item editing) UI
20 #ifndef __AKNSETTINGPAGE_H__
21 #define __AKNSETTINGPAGE_H__
23 #include <AknControl.h>
36 // for navipane support (hint text)
40 // Forward declarations
43 class CAknSettingPageSkinsInfo;
44 class MAknsControlContext;
45 class CAknsFrameBackgroundControlContext;
46 class CAknSettingPageExtension;
49 // Used as the return value of SettingId() if not yet set.
50 // This because the Id might want to be the index of a 0-based array
52 const TInt KAknSettingPageNoIdSet = -1;
54 class CAknSettingPage;
56 // This class is used as a means of notifying change in settings.
58 class MAknSettingPageObserver
61 enum TAknSettingPageEvent
64 EEventSettingCancelled,
70 * Handles an event of type aEventType reported by the Setting Page to this observer.
72 virtual void HandleSettingPageEventL(CAknSettingPage* aSettingPage,TAknSettingPageEvent aEventType )=0;
76 class CAknSettingPage : public CAknControl, public MCoeControlObserver, public MEikMenuObserver
81 * This enumeration is passed in the ExecuteLD() method to control how often the setting page
82 * updates the externally held client object
84 enum TAknSettingPageUpdateMode
91 * This enumeration is used to select the type and IIDs for the various classes defined in the
92 * Skins LAF spec for "Opened Setting Items"
94 enum TEditedItemSkinClass
96 ESettingPageSkinEditedItemClassValueItemList,
97 ESettingPageSkinEditedItemClassVolume,
98 ESettingPageSkinEditedItemClassSlider,
99 ESettingPageSkinEditedItemClassTextEntry,
100 ESettingPageSkinEditedItemClassCodeDateTimeEntry
103 * Simple contructor for using a single setting page resource which itself gives all
106 IMPORT_C CAknSettingPage( TInt aSettingPageResourceId );
108 * Constructor that allows separate setting page and editor resources
110 * In all cases the number (if supplied i.e. <> 0 ) is used.
112 * Editor Resource Setting Page Resource
113 * present present Both are used (but text & number overridden)
114 * = 0 present Editor resource is used via SP resource
115 * present = 0 Default Avkon SP resource if used
116 * = 0 = 0 Not permitted
118 * Note: The first argument is a TDesC* (rather than TDesC&) because the other constructor
119 * cannot initialize such a member without allocation or having an internal dummy buffer.
121 * Rules for text and numbers: The rules are the same for both: (non-zero length) text or number other
122 * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource
123 * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed). Note, however, that text or number given via the
124 * specific API for setting them, WILL override resource.
125 * It is assumed that number from resource is very rare. Special text is somewhat more likely.
127 * @param aSettingTitleText Text at top of setting pane (not copied; must be owned externally until ExecuteLD is called)
128 * @param aSettingNumber Number at top left (if present)
129 * @param aControlType Determines the type constructed and how its resource is read
130 * @param aEditorResourceId Editor resource to use in the setting page (if present)
131 * @param aSettingPageResourceId Setting Page to use (if present)
133 IMPORT_C CAknSettingPage( const TDesC* aSettingTitleText,
136 TInt aEditorResourceId,
137 TInt aSettingPageResourceId = 0 );
141 IMPORT_C virtual ~CAknSettingPage();
144 * Executes a waiting dialog-like setting page
146 * The passed mode determines if the editor's value is updated continuously, or just
147 * when it is accepted.
149 * @param aMode The update mode of the class
151 IMPORT_C TBool ExecuteLD( enum CAknSettingPage::TAknSettingPageUpdateMode aMode=EUpdateWhenAccepted );
154 * public method for construction. Only thing required to do in this class is to call the
155 * BaseConstructL(). Derived classes may be required to do more
158 IMPORT_C virtual void ConstructL();
161 * Returns reference to the hosted "editor" control as a CCoeControl.
162 * This routine is used in derived classes, which may then cast to the specific run-time type
163 * Note also that derived classes may provide type-specific access that performs these casts already
165 * @return CCoeControl* pointer to the hosted editor control
167 IMPORT_C CCoeControl* EditorControl() const;
170 * Returns the setting Id.
172 * @return TInt the setting Id
174 IMPORT_C TInt SettingId() const;
177 * Sets the setting Id. The Id may be used to unabiguously number a setting in some context.
178 * It would be useful to call SettingId() on aSettingPageControl in handling an observer
179 * callback. The Id is not used internally.
181 * @param aSettingId An id to provide to the observer in the callback
183 IMPORT_C void SetSettingId( TInt aSettingId );
185 * Substitutes the new setting number.
187 * @param aSettingNumber The new setting number to display
189 IMPORT_C void SetSettingNumberL( const TInt aSettingNumber );
192 * Substitutes the new setting text. Memory is allocated for a copy.
193 * If already constructed, the label is reformatted.
195 * Note that calling this will over-ride text in Setting Page resource
197 * @param aSettingText The new setting text to display
199 IMPORT_C void SetSettingTextL( const TDesC& aSettingText );
202 * Sets the observer for the setting page.
204 * @param aObserver The observer for changes to the setting
206 IMPORT_C void SetSettingPageObserver( MAknSettingPageObserver* aObserver);
209 * Access method for the number of the setting page
212 IMPORT_C TInt SettingNumber() const;
215 * Access method for whether the setting page is numbered or not
218 IMPORT_C TBool IsNumbered() const;
221 * Set method for whether the setting page is numbered or not
224 IMPORT_C void SetNumbered( TBool aNumbered );
227 * Reads the passed-in setting page resource in order to read the contained editor control
228 * resource information
229 * @param aSettingPageResoruceId This is used to specifiy what resource to read
230 * @param aControlType Returns the control type (MAY return 0 - that's a valid control type!
231 * @param aEditorResourceId Returns the setting page's LLINK editor resource, but returns 0 if not present
233 * This will leave if an invalid resource ID is passed
235 IMPORT_C static void GetEditorResourceInfoL(
236 TInt aSettingPageResourceId,
238 TInt& aEditorResourceId );
242 * Set the edit-state of the setting page. The setting page can be edited or
243 * it can be only viewed by the user.
246 * @param aEditable If false, the setting page cannot be modified by the user
248 IMPORT_C void SetEditState(const TBool aEditable);
251 * Is the setting page possible to edit by the user.
254 * @return Can user modify the setting page. True if can, false if cannot.
256 IMPORT_C TBool IsEditable() const;
259 * Used for aknsettingpage's extenstion corresponding function
262 * @param aCaption On return, this should be set to the caption of the target control.
264 void GetCaptionForFep(TDes& aCaption) const;
267 * Calculates and returns setting item content rect.
269 * @param aScrollBarUsed @c ETrue if the setting page content should have
270 * scrollbar, @c EFalse otherwise.
274 * @return Setting item content rectangle.
276 TRect SettingItemContentRect( TBool aScrollBarUsed );
279 * Is the setting page drawing the background itself or not (= "transparency")
281 TBool IsBackgroundDrawingEnabled() const;
284 * Access method to the Command button array
286 * Must be called after full construction, or null reference will be returned.
288 * @return CEikButtonGroupContainer* a pointer to the cba owned by the setting page
290 IMPORT_C CEikButtonGroupContainer* Cba() const ;
296 * This routine is called as part of the set-up of the control. It is the place to put
300 IMPORT_C virtual void SizeChanged();
305 * Takes any action required when the control gains or loses focus e.g. to change its appearance.
306 * The control should be redrawn depending on the value of aDrawNow. Empty by default.
308 IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow);
311 * From MEikCommandObserver
312 * Processes events from the softkeys. Responds to EAknSoftkeyOk and EAknSoftkeyBack
313 * to accept or cancel the pop-up.
315 * @param aCommandId Event Id from the soft-key
317 IMPORT_C virtual void ProcessCommandL(TInt aCommandId);
320 * From MCoeControlObserver:
321 * Acts upon changes in the hosted control's state.
323 * This class's implementation is trivial and should be able to be
324 * safely re-implemented in directly client-derived classes.
325 * For non-base setting page classes, a call to the base class should be made
327 * @param aControl The control changing its state (not used)
328 * @param aEventType The type of control event
330 IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
334 // Framework functions. New in this class
338 * Framework method to determine if it is OK to exit the setting page.
339 * Derived classes may check for valid data before allowing the dismissal of the
342 * @param aAccept ETrue if the user has indicated to accept the setting page; EFalse otherwise
343 * @return TBool a value indicating whether the setting page should be dismissed
345 IMPORT_C virtual TBool OkToExitL(TBool aAccept);
348 * Called immediately prior to activation of the dialog. Framework routine for derived
352 IMPORT_C virtual void DynamicInitL();
355 * Called when something has changed and the client's object needs to have its value updated
358 IMPORT_C virtual void UpdateSettingL();
361 * Called when the user accepts a setting and the setting page is about to be dismissed. The latest value of the
362 * setting is written to the client's object
364 IMPORT_C virtual void AcceptSettingL();
367 * Called when the user rejects the setting. A backup copy may need to be restored if UpdateWhenChanged flag was set
370 IMPORT_C virtual void RestoreOriginalSettingL();
375 IMPORT_C virtual void DisplayMenuL() ;
380 IMPORT_C virtual void HideMenu() ;
383 * Puts the focus back on the editor. For complicated setting pages that have focus removed from them
384 * at some point, then a re-implementation may have to do some work here.
386 IMPORT_C virtual void SetFocusToEditor();
389 * This method should be implemented in listbox classes to move the selection in
390 * listbox editors prior to exiting from the setting page. It is called on a
391 * CAknSettingPage* reference, and is therefore declared here.
393 IMPORT_C virtual void SelectCurrentItemL();
396 * Protected non-virtual base method for construction. Only thing required to do in this class is
397 * call the ConstructFromResourceL routine and set the flag that says construction has occured
400 IMPORT_C void BaseConstructL();
403 * Called to remove the setting page. Should not be called except from within re-implemented
406 * @param aAccept ETrue to accept the current value; EFalse otherwise
408 IMPORT_C void DismissL( TBool aAccept );
411 * This is used as a protected access function for the state of the menu bar
413 * @return TBool ETrue if the menu is currently showing
415 IMPORT_C TBool MenuShowing() const ;
418 * This constructs the control based upon the id passed
421 IMPORT_C void ConstructFromResourceL( TInt aResourceId);
424 * This constructs the control based upon a constructed and positioned reader
427 IMPORT_C void ConstructFromResourceL(TResourceReader& aRes);
430 * Called when the user accepts or cancels the setting. Default implementation
431 * sets the return value and exists.
433 * Re-implementations must call DismissL and StopActiveScheduler() if the setting is
436 * @param aAccept ETrue if the user accepted. EFalse if the user cancelled.
438 IMPORT_C void AttemptExitL(TBool aAccept);
440 * Method to determine the current running state of the setting page's
441 * ActiveScheduler level.
443 * @return EFalse only if the CActiveSheduler level is not running
445 IMPORT_C TBool Waiting();
448 * This is used to access the default resource id for the cba - the one used when
451 * @return TInt the default resource Id
453 IMPORT_C TInt DefaultCbaResourceId() const;
456 * This routine routes the keys to the editor.
457 * However, if the menu is showing, then events are sent to the menu.
459 * @param aKeyEvent event information
460 * @param aType type of event being handled
463 IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType);
466 * This routine is the base layout for CAknSettingPage. It lays out the labels and configures
467 * the drawing in general.
469 IMPORT_C void StandardSettingPageLayout();
472 * This method can be used to test if BaseConstructL() has been called yet
475 * @return TBool ETrue if BaseContructL has been called (and not left)
477 IMPORT_C TBool IsBaseConstructed();
480 * Access method for the internally held resource Id
483 IMPORT_C TInt SettingPageResourceId();
485 * Perform the drawing of coded within CAknSettingPage
488 IMPORT_C void BaseDraw(const TRect& aRect) const;
491 * Set default construction values of internal state
493 IMPORT_C void ResetFlags();
496 * Framework method called as soon as the setting page is displayed, but before the new active sheduler level
497 * is started. Returning EFalse will dismiss the setting page right away
499 * @return TBool ETrue if the setting page is to continue
501 IMPORT_C virtual TBool PostDisplayCheckL();
504 * This framework method is used to update the contents of the CBA in a custom way.
505 * Some setting page classes implement a degree of validation and will implement this.
506 * Derived classes should ensure that this is being called frequently enough for their
509 IMPORT_C virtual void UpdateCbaL();
512 * Called to access the validity state of the data
514 * @return TBool ETRrue if the data is valid
516 IMPORT_C TBool DataValidity() const;
519 * used to set the validity of the data
521 * @param TBool aValid Sets the validity true or false
523 IMPORT_C void SetDataValidity(TBool aValid);
526 * Framework method to set the validity of the data
527 * This is called when the data changes.
530 IMPORT_C virtual void CheckAndSetDataValidity();
533 * Sets the outer and inner rectangle for the frame graphics that is drawn
534 * around the setting item.
536 * @param aOuterRect Frame outer rectangle.
537 * @param aInnerRect Frame inner rectangle.
541 void SetEditedItemFrameRects( const TRect& aOuterRect,
542 const TRect& aInnerRect );
545 * Sets the skin item ID for the frame graphics that is drawn
546 * around the setting item.
548 * @param aFrameIID Skin item ID of the frame graphics.
549 * @param aFrameCenterIID Skin item ID of the center piece of the frame
554 void SetEditedItemFrameIID( const TAknsItemID& aFrameIID,
555 const TAknsItemID& aFrameCenterIID );
558 * Sets the rectangle for the editing state indicators.
559 * Should only be called by setting pages that have an editor which
560 * displays the editor indicators as the editor control.
562 * @param aRect Editor indicator rectangle.
566 void SetEditorIndicatorRect( const TRect& aRect );
569 * Indicates whether skin system will be able to draw the editor frame and background
571 * @return TBool ETrue iff the drawing of the edited item frame is going to be handled by
572 * the base CAknSettingPage class itself using Skins
575 TBool IsSkinsHandlingEditorFrameDrawing() const;
578 * Control context for providing to the skinning for the hosted editor and its framing
580 * @return A valid control context for frame drawing for a hosted editor or NULL
583 CAknsFrameBackgroundControlContext* EditedItemControlContext() const;
586 * Performs base construction and takes possible flags into account.
588 * @param aFlags Construction flags
592 void BaseConstructL( TUint aFlags );
595 * Stop current (additional) level on the active scheduler.
597 void StopActiveScheduler();
601 * From MEikMenuObserver
602 * Called when menu is cancelled.
604 IMPORT_C virtual void SetEmphasis(CCoeControl* /*aMenuControl*/,TBool aEmphasis);
607 * From MEikMenuObserver
608 * This function intializes the items on the menu. It is used to disable and enable menu items and may be
609 * over ridden to add new ones.
610 * In addition it adds menu items which have been provided in the ConstructL in the form of a Menu Bar resource.
611 * Instead of using the Menu Bar directly it extracts the menu panes and adds them to its own menu pane.
612 * It must be called in the DynInitMenuPaneL() function of any derived class before anything else.
614 IMPORT_C virtual void DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane );
616 public: // From CCoeControl
618 * Handles a change to the control's resources of type aType
619 * which are shared across the environment, e.g. colors or fonts.
622 * @param aType Reason for the "resource" change, usually an system event UID
624 IMPORT_C void HandleResourceChange(TInt aType);
626 * Standard CCoeControl routine to return the number of componentn controls
628 * @param aIndex index at which to return control
630 IMPORT_C TInt CountComponentControls() const;
633 * Standard CCoeControl routine to return the control at a given index
635 * @param aIndex index at which to return control
638 IMPORT_C CCoeControl* ComponentControl(TInt anIndex) const;
641 * Handles pointer events
643 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
646 * Gets the control's input capabilities.
648 * @return The control's input capabilities.
650 IMPORT_C TCoeInputCapabilities InputCapabilities() const;
653 IMPORT_C virtual void Reserved_MtsmPosition();
654 IMPORT_C virtual void Reserved_MtsmObject();
658 * Access method for the softkey resource used when there is invalid data
660 * @return TInt The resource Id of the softkey bindings.
662 IMPORT_C TInt InvalidDataCbaResourceId() const;
664 protected: // from MObjectProvider
665 IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
669 * Hold the update mode passed in the constructor
673 // The following are not owned:
676 * Pointer to setting page observer; may be NULL
678 MAknSettingPageObserver* iSettingPageObserver;
682 IMPORT_C void Draw(const TRect& aRect) const;
688 IMPORT_C void* ExtensionInterface( TUid aInterface );
693 * Writes the internal state of the control and its components to aStream.
694 * Does nothing in release mode.
695 * Designed to be overidden and base called by subclasses.
697 * @param aWriteSteam A connected write stream
699 IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const;
703 * Reserved method derived from CCoeControl
705 IMPORT_C virtual void Reserved_2();
708 * Activate another level on the active scheduler
710 void StartActiveScheduler();
713 * Pop the navidecorator. The iNaviPane is used as a flag to show if popping is required to
714 * be done or not. It is zeroed by this method.
717 void PopNaviDecoratorIfRequired();
722 * New reserved methods for CAknSettingPage hierarchy
725 IMPORT_C virtual void CAknSettingPage_Reserved_1();
726 IMPORT_C virtual void CAknSettingPage_Reserved_2();
730 * Enables / disables transparency effect, i.e. does the setting page draw its own background or not.
731 * @param aDrawBackground EFalse enables transparency
733 void SetDrawBackground(const TBool aDrawBackground);
736 * Set the flag to indicate that if the function CAknSettingPage::StopActiveScheduler called or not
737 *@param aStopCalled ETrue means the StopActiveScheduler is called.
739 void SetStopActiveSchedulerFlag(const TBool aStopCalled );
742 * Is the setting page call the StopActiveScheduler or not
744 TBool IsStopActiveSchudlerCalled()const;
747 * Pointer to setting text label
748 * @return pointer to the label
752 IMPORT_C CEikLabel* TextLabel() const;
755 * Pointer to shadow text label
756 * @return pointer to the label
760 IMPORT_C CEikLabel* ShadowText() const;
764 * This member points to the setting title text that is passed as part of its more complicated constructor.
765 * The descriptor pointed to is not owned, and therefor must be preserved in the client, at least until the
766 * 2nd stage construction is performed (inside ExecuteLD).
768 * Since, however, setting pages are all waiting, the descriptor can usually be on the stack in the client.
771 const TDesC* iSettingTextFromConstructor;
778 TInt iEditorResourceId;
782 TAknLayoutRect iShadow;
783 TAknLayoutRect iHighlight;
785 // pointer to the return value from the setting page.
786 // Needed when presented in waiting mode.
794 EMenuShowingIndex = 0,
796 EIsBaseConstructedIndex,
800 // Heap objects pointed to here are owned:
801 CCoeControl* iEditorControl;
802 CEikLabel* iNumberLabel;
803 CEikLabel* iTextLabel;
804 CEikButtonGroupContainer* iCba;
805 CEikMenuBar* iMenuBar ;
808 CAknNavigationDecorator* iNaviDecorator;
810 // The following are not owned:
811 // For hint text support
812 CAknNavigationControlContainer* iNaviPane;
814 // Softkey resource when the data is invalid
815 TInt iInvalidDataCbaResourceId;
817 // The following object is used to contain all skinning information required
818 CAknSettingPageSkinsInfo* iSkinsInfo;
820 CActiveSchedulerWait iWait; // owned, safe to use as direct member data.
822 // is setting page editable
825 // extension to setting page
826 CAknSettingPageExtension* iExtension;