williamr@2: /* williamr@2: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: * Support for popup setting item lists. THe MAknQueryValue abstract type is williamr@2: * used to carry the state of the selection. williamr@2: * williamr@2: * This file also contains the definition for the contained editor of the setting page, williamr@2: * CAknPopupSettingList williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef __AKNPOPUPSETTINGPAGE_H__ williamr@2: #define __AKNPOPUPSETTINGPAGE_H__ williamr@2: williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: #include williamr@2: #include williamr@2: williamr@2: class CAknPopupSettingList; williamr@2: class CAknPopupSettingListExtension; williamr@2: williamr@2: /** williamr@2: * This interface should be implemented by classes that need to know williamr@2: * about events occurring in the popup field control williamr@2: */ williamr@2: class MAknPopupSettingListObserver williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Event types williamr@2: */ williamr@2: enum TAknPopupSettingListEvent williamr@2: { williamr@2: EAknPopupSettingSelectionAndRequestAccept, williamr@2: EAknPopupSettingSelectionAndStayOpen, williamr@2: EAknPopupSettingSelectionAndClose williamr@2: }; williamr@2: public: williamr@2: /** williamr@2: * Handle events from the popup field control, such as when it changes between williamr@2: * selection list mode and label mode. williamr@2: * williamr@2: * Implementations of this observer routine should perform a base call to this specific williamr@2: * method, in order to pick up any default re-layout actions. williamr@2: * williamr@2: * @param aPopupSettingList pointer to the popup field control that generated the event williamr@2: * @param aEventType the type of event williamr@2: * @param aHint for possible future use williamr@2: * williamr@2: */ williamr@2: virtual void HandlePopupSettingListEventL( CAknPopupSettingList* aPopupSettingList, williamr@2: TAknPopupSettingListEvent aEventType, williamr@2: TInt aHint)=0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * williamr@2: * Represents menu list that appears in a popped up setting item williamr@2: */ williamr@2: class CAknPopupSettingList : williamr@2: public CAknSetStyleListBox, williamr@2: public MEikListBoxObserver williamr@2: { williamr@2: williamr@2: protected: williamr@2: williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Standard constructor. williamr@2: */ williamr@2: IMPORT_C CAknPopupSettingList(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: * williamr@2: */ williamr@2: IMPORT_C ~CAknPopupSettingList(); williamr@2: williamr@2: /** williamr@2: * 2nd phase construction williamr@2: * williamr@2: */ williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Sets flag that enables user defined entry. Note that flag can also be set from resources, williamr@2: * but this method allows behaviour to be changed at runtime. williamr@2: * williamr@2: * @param aAllows if ETrue, set flag; if EFalse, clear flag. williamr@2: */ williamr@2: IMPORT_C void SetAllowsUserDefinedEntry(TBool aAllows); williamr@2: williamr@2: williamr@2: /** williamr@2: * Used by the client to set the query value used to represent the user defined williamr@2: * value belonging to this popup field control. williamr@2: * williamr@2: * @param aValue pointer to value, ownership is not passed williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetQueryValueL(MAknQueryValue* aValue); williamr@2: williamr@2: williamr@2: /** williamr@2: * Set the flag which determines whether the indicators are shown williamr@2: * In practice the indicators have the appearance of radio buttons williamr@2: * williamr@2: * @param aShowIndicators williamr@2: * If ETrue, indicators are displayed; williamr@2: * if EFalse, indicators are not displayed williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetShowIndicators(TBool aShowIndicators); williamr@2: williamr@2: /** williamr@2: * number of lines used williamr@2: * williamr@2: * @return number of lines being currently displayed by control, which is determined williamr@2: * by the number of entries on the selection list, and whether the selection list is active. williamr@2: * NOTE that the number is limited by KAknMaxLinesOnOnePage williamr@2: * williamr@2: */ williamr@2: IMPORT_C TInt NumLines() const; williamr@2: williamr@2: /** williamr@2: * set an observer of this class to receive events from popup setting list williamr@2: * williamr@2: * @param aObserver pointer to the class that implements the observer interface, williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetPopupSettingListObserver(MAknPopupSettingListObserver* aObserver); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * from CCoeControl williamr@2: * Construct from resources. williamr@2: * @param aReader constucted and positioned TResourceReader& williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Create the popup list. williamr@2: * williamr@2: */ williamr@2: IMPORT_C void CreateMenuListL(); williamr@2: williamr@2: /** williamr@2: * Causes the list of pre-defined values to appear. williamr@2: * Use this method to activate the pop-up field from a menu option command. williamr@2: * Note that the desired control must have the focus before it can be activated. williamr@2: * williamr@2: */ williamr@2: IMPORT_C void ActivateMenuListL(); williamr@2: williamr@2: /** williamr@2: * williamr@2: * This routine sets up the text arrays for the menu list williamr@2: * williamr@2: */ williamr@2: IMPORT_C void ConfigureMenuListL(); williamr@2: williamr@2: /** williamr@2: * All this does now is remove this from the stack williamr@2: * williamr@2: */ williamr@2: IMPORT_C void DestroyMenuList(); williamr@2: williamr@2: public: williamr@2: /** williamr@2: * From CCoeControl. Handles pointer event williamr@2: * @param aPointerEvent Pointer event to be handled williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); williamr@2: williamr@2: IMPORT_C void HandleResourceChange(TInt aType); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * From MEikListBoxObserver williamr@2: * Processes key events from the listbox. Responds to EEventEnterKeyPressed to accept williamr@2: * the pop-up. williamr@2: * williamr@2: * @param aListBox Listbox being observed williamr@2: * @param aEventType Event observed williamr@2: * williamr@2: * williamr@2: * This implementation is vestige of former implementation when the listbox was wrapped up, williamr@2: * not derived from. Currently observing itself.. williamr@2: * williamr@2: */ williamr@2: IMPORT_C void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType); williamr@2: williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void Reserved_1(); williamr@2: IMPORT_C void Reserved_2(); williamr@2: private: williamr@2: void CommonConstructL(); williamr@2: void SetUpSelectionListL(); williamr@2: /** williamr@2: * Set up the bitmap array for the "not pushed" and "pushed in" states williamr@2: * williamr@2: */ williamr@2: void InitialiseRadioButtonBitmapsL(); williamr@2: private: williamr@2: /** williamr@2: * Configures the decoration according to the currently set flags. williamr@2: * Should be called whenever the flags are changed. williamr@2: * williamr@2: */ williamr@2: void ConfigureDecorator(); williamr@2: /** williamr@2: * Configures the layout decoration according to the "has buttons" flag williamr@2: * Should be called whenever the flags are changed. williamr@2: * williamr@2: */ williamr@2: void ConstructLayoutDecoratorL(); williamr@2: williamr@2: private: williamr@2: // the following members are owned williamr@2: williamr@2: TAknDesCArrayDecorator iDecorator; williamr@2: CAknListBoxLayoutDecorator* iLayoutDecorator; williamr@2: williamr@2: // the following fields are reflected in the POPUP_SETTING_LIST resource structure williamr@2: TInt iFlags; williamr@2: HBufC* iOtherText; williamr@2: williamr@2: TInt iCurrentSelection; williamr@2: // elements to hold info regarding "new Item"- produced setting page williamr@2: TInt iNewItemSettingPageResourceId; williamr@2: TInt iNewItemEditorType; williamr@2: TInt iNewItemEditorControlResourceId; williamr@2: williamr@2: // the following members are not owned williamr@2: MAknQueryValue* iValue; williamr@2: MAknPopupSettingListObserver* iPopupSettingListObserver; williamr@2: williamr@2: //TInt iSpare_1; williamr@2: CAknPopupSettingListExtension* iExtension; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * Interface for the setting page containing a menu list with a Query value data model williamr@2: * This is the more generic of the list-style setting pages. williamr@2: * williamr@2: */ williamr@2: class CAknPopupSettingPage : williamr@2: public CAknListBoxSettingPage, williamr@2: public MAknPopupSettingListObserver williamr@2: { williamr@2: williamr@2: public: williamr@2: /** williamr@2: * C++ constructor. This constructor uses just the setting page resource Id to williamr@2: * construct the setting page, using listbox resource contained in the setting page williamr@2: * resource. williamr@2: * @param aResourceId a resource identifier for a AVKON_SETTING_PAGE resource williamr@2: * @param aQueryValue a reference to a query value object williamr@2: */ williamr@2: IMPORT_C CAknPopupSettingPage(TInt aResourceID, MAknQueryValue& aQueryValue ); williamr@2: williamr@2: /** williamr@2: * Constructor that allows separate setting page and editor resources williamr@2: * williamr@2: * This constructor allows the use of setting page using only the editor resource. Other combinations are also possible williamr@2: * williamr@2: * In all cases the number (if supplied i.e. <> 0 ) is used. williamr@2: * williamr@2: * Editor Resource Setting Page Resource williamr@2: * present present Both are used (but text & number overridden) williamr@2: * = 0 present Editor resource is used via SP resource (Effectively like the other constructor) williamr@2: * present = 0 Default Avkon SP resource if used + this editor resource williamr@2: * = 0 = 0 uses default resource for both SP and editor. This is OK if: williamr@2: * i) control type is present, williamr@2: * ii) a default resource exists ( OK for text, integer, date, time, duration ) williamr@2: * williamr@2: * Note: THe first argument is a TDesC* (rather than TDesC&) because the other constructor williamr@2: * cannot initialize such a member without allocation or having an internal dummy buffer. williamr@2: * williamr@2: * Rules for text and numbers: The rules are the same for both: (non-zero length) text or number other williamr@2: * than EAknSettingPageNoOrdinalDisplayed if given in this constructor will not override resource williamr@2: * (unless that is zero length or EAknSettingPageNoOrdinalDisplayed). Note, however, that text or number given via the williamr@2: * specific API for setting them, WILL override resource. williamr@2: * It is assumed that number from resource is very rare. Special text is somewhat more likely. williamr@2: * williamr@2: * @param aSettingTitleText Text at top of setting pane williamr@2: * @param aSettingNumber Number at top left (if present) williamr@2: * @param aControlType Determines the type constructed and how its resource is read williamr@2: * @param aEditorResourceId Editor resource to use in the setting page (if present) williamr@2: * @param aSettingPageResourceId Setting Page to use (if present) williamr@2: * @param aQueryValue reference to a query value object williamr@2: */ williamr@2: IMPORT_C CAknPopupSettingPage( const TDesC* aSettingTitleText, williamr@2: TInt aSettingNumber, williamr@2: TInt aControlType, williamr@2: TInt aEditorResourceId, williamr@2: TInt aSettingPageResourceId, williamr@2: MAknQueryValue& aQueryValue); williamr@2: williamr@2: /** williamr@2: * 2nd stage construction method. Type specific work is done here; most of the setting williamr@2: * page constuction is performed in a call the base contstruction of CAknSettingPage williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Access to the contained listbox (inside popup setting list) williamr@2: * williamr@2: * @return CAknSetStyleListBox* pointer to the listbox used in the setting page; Does not transfer ownership williamr@2: */ williamr@2: IMPORT_C CAknSetStyleListBox* ListBoxControl() const; williamr@2: williamr@2: /** williamr@2: * Access to the editor control williamr@2: * williamr@2: * @return CAknPopupSettingList* a reference to the contained "editor" as a listbox; no ownership transferred williamr@2: */ williamr@2: IMPORT_C CAknPopupSettingList* PopupSettingListBox() const; williamr@2: williamr@2: /** williamr@2: * From MAknPopupSettingListObserver williamr@2: * Handle events from the popup field control, such as when it changes between williamr@2: * selection list mode and label mode. williamr@2: * williamr@2: * @param aPopupSettingList pointer to the popup field control that generated the event williamr@2: * @param aEventType the type of event williamr@2: * @param aHint for possible future use williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void HandlePopupSettingListEventL(CAknPopupSettingList* aPopupSettingList, williamr@2: TAknPopupSettingListEvent aEventType, TInt aHint); williamr@2: williamr@2: /** williamr@2: * Can be used dynamically to set a new query value. This manages the setting up of the new williamr@2: * PopupSettingList and its listbox, and also the resizing and redrawing of the setting page williamr@2: * Note that all former query value objects and its associated arrays are owned by the client williamr@2: * and if no longer used, should be deleted. williamr@2: * williamr@2: * @param MAknQueryValue* aQueryValue - the new value; no transfer of ownership williamr@2: */ williamr@2: IMPORT_C void UpdateQueryValueL( MAknQueryValue* aQueryValue ); williamr@2: williamr@2: /** williamr@2: * From CCoeControl williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: protected: williamr@2: /** williamr@2: * C++ destructor williamr@2: */ williamr@2: IMPORT_C virtual ~CAknPopupSettingPage(); williamr@2: williamr@2: /** williamr@2: * This is required to give access to the QueryValue data member from williamr@2: * re-implementations of the popup setting page williamr@2: * williamr@2: * @return MAknQueryValue* a pointer to the query value object williamr@2: * williamr@2: */ williamr@2: IMPORT_C MAknQueryValue* QueryValue() const; williamr@2: williamr@2: /** williamr@2: * This method should be implemented in listbox classes to move the selection in williamr@2: * listbox editors prior to exiting from the setting page williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void SelectCurrentItemL(); williamr@2: williamr@2: // williamr@2: // CoeControl Framework and reserved methods williamr@2: // williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Writes the internal state of the control and its components to aStream. williamr@2: * Does nothing in release mode. williamr@2: * Designed to be overidden and base called by subclasses. williamr@2: * williamr@2: * @param aWriteSteam A connected write stream williamr@2: */ williamr@2: IMPORT_C virtual void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: /** williamr@2: * Reserved method derived from CCoeControl williamr@2: */ williamr@2: IMPORT_C virtual void Reserved_2(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: /** williamr@2: * New reserved methods for CAknSettingPage hierarchy williamr@2: */ williamr@2: private: williamr@2: IMPORT_C virtual void CAknSettingPage_Reserved_1(); williamr@2: IMPORT_C virtual void CAknSettingPage_Reserved_2(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * New reserved method from CAknListBoxSettingPage williamr@2: * williamr@2: */ williamr@2: IMPORT_C virtual void CAknListBoxSettingPage_Reserved_1(); williamr@2: williamr@2: private: williamr@2: williamr@2: // The objects pointed to or referenced by this is not owned williamr@2: MAknQueryValue& iQueryValue; williamr@2: williamr@2: TInt iSpare_1; williamr@2: TInt iSpare_2; williamr@2: williamr@2: }; williamr@2: williamr@2: #endif