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@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.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: * Represents a combo box type control, used to implement the Series 60 williamr@2: * pop-up field. williamr@2: * williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #ifndef AKNPOPUPFIELD_H williamr@2: #define AKNPOPUPFIELD_H williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: class TResourceReader; williamr@2: class CEikLabel; williamr@2: class CEikCommandButton; williamr@2: class CAknFormGraphicStyleListBox; williamr@2: class MAknQueryValue; williamr@2: williamr@2: class CAknPopupField; williamr@2: class CAknPopupFieldExtension; 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 MAknPopupFieldObserver williamr@2: { williamr@2: public: williamr@2: enum TAknPopupFieldEvent williamr@2: { williamr@2: EAknPopupFieldEventModeChange, williamr@2: EAknPopupFieldEventValueChange williamr@2: }; williamr@2: public: williamr@2: /** williamr@2: * Handles events from the popup field control, such as changes between williamr@2: * selection list mode and label mode. williamr@2: * williamr@2: * @param aPopupField pointer to the popup field control that generated williamr@2: * the event. williamr@2: * @param aEventType the type of event. williamr@2: * @param aHint for possible future use. williamr@2: */ williamr@2: virtual void HandlePopupFieldEventL(CAknPopupField* aPopupField, williamr@2: TAknPopupFieldEvent aEventType, williamr@2: TInt aHint)=0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Represents a combo box type control, used to implement the Series 60 williamr@2: * pop-up field. williamr@2: */ williamr@2: class CAknPopupField : williamr@2: public CEikBorderedControl, williamr@2: public MCoeControlObserver, williamr@2: public MEikCommandObserver, williamr@2: public MEikListBoxObserver williamr@2: { williamr@2: protected: williamr@2: /** williamr@2: * Specialises bitmap button to make the layout correct for popup field williamr@2: */ williamr@2: class CAknPopupFieldBitmapButton : public CEikBitmapButton williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Constructor williamr@2: */ williamr@2: CAknPopupFieldBitmapButton(); williamr@2: }; williamr@2: public: williamr@2: /** williamr@2: * Selection mode of the popup field. williamr@2: */ williamr@2: enum EAknPopupFieldSelectionMode williamr@2: { williamr@2: /** williamr@2: * Label mode. In Label mode popup field is minimized and popup field williamr@2: * looks identical to a list item. When it receives the selection key williamr@2: * press it is changed to @c EAknPopupFieldSelectionListMode and the williamr@2: * pre-defined list is displayed. williamr@2: */ williamr@2: EAknPopupFieldLabelMode, williamr@2: williamr@2: /** williamr@2: * Selection list mode. In this selection mode pre-defined popup williamr@2: * selection list is displayed. williamr@2: */ williamr@2: EAknPopupFieldSelectionListMode williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Form mode for the popup field. williamr@2: */ williamr@2: enum EAknFormMode williamr@2: { williamr@2: /** View mode. */ williamr@2: EAknFormModeView, williamr@2: williamr@2: /** Editable mode. */ williamr@2: EAknFormModeEdit, williamr@2: williamr@2: /** View mode with graphic. */ williamr@2: EAknFormModeViewWideWithGraphic, williamr@2: williamr@2: /** View mode without graphic. */ williamr@2: EAknFormModeViewWideWithoutGraphic, williamr@2: williamr@2: /** Edit mode with graphic. */ williamr@2: EAknFormModeEditWideWithGraphic, williamr@2: williamr@2: /** Edit mode without graphic. */ williamr@2: EAknFormModeEditWideWithoutGraphic williamr@2: }; williamr@2: public: williamr@2: EAknPopupFieldSelectionMode SelectionMode() const { return iSelectionMode; } williamr@2: EAknFormMode FormMode() const { return iFormMode; } williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CAknPopupField(); williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: IMPORT_C ~CAknPopupField(); williamr@2: williamr@2: /** williamr@2: * Handles 2nd phase construction. williamr@2: */ williamr@2: IMPORT_C void ConstructL(); williamr@2: williamr@2: /** williamr@2: * Sets a flag that enables user defined entry. Note that flag can also be williamr@2: * set from resources, but this method allows behaviour to be changed at williamr@2: * runtime. williamr@2: * williamr@2: * @param aAllows if @c ETrue sets a flag. williamr@2: */ williamr@2: IMPORT_C void SetAllowsUserDefinedEntry(TBool aAllows); williamr@2: williamr@2: /** williamr@2: * Causes a 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 be focused on before it can be williamr@2: * activated. williamr@2: */ williamr@2: IMPORT_C void ActivateSelectionListL(); williamr@2: williamr@2: /** williamr@2: * Used by the client to set the query value. It is used to represent the williamr@2: * user defined query value in this popup field control. williamr@2: * williamr@2: * @param aValue Pointer to query value, ownership is not passed. williamr@2: */ williamr@2: IMPORT_C void SetQueryValueL(MAknQueryValue* aValue); williamr@2: williamr@2: /** williamr@2: * Sets the font of the contained label. williamr@2: * williamr@2: * @param aFont Font definition used to set the font of the contained williamr@2: * label. williamr@2: */ williamr@2: IMPORT_C void SetFont(const CFont* aFont); williamr@2: williamr@2: /** williamr@2: * Sets a flag that determines whether the indicators are shown. williamr@2: * In practice the indicators have the appearance of radio buttons. williamr@2: * williamr@2: * @param aShowIndicators If @c ETrue, indicators are displayed. williamr@2: */ williamr@2: IMPORT_C void SetShowIndicatorsL(TBool aShowIndicators); williamr@2: williamr@2: /** williamr@2: * Number of lines used. williamr@2: * williamr@2: * @return Number of entries on the selection list. If selection list williamr@2: * is not active, 1 is returned. williamr@2: * NOTE that the number is limited by @c KAknMaxEditorLines. williamr@2: */ williamr@2: IMPORT_C TInt NumLines() const; williamr@2: williamr@2: /** williamr@2: * Sets an observer of this class to receive events from popup field. williamr@2: * williamr@2: * @param aObserver Pointer to the class that implements the observer williamr@2: * interface. williamr@2: */ williamr@2: IMPORT_C void SetPopupFieldObserver(MAknPopupFieldObserver* aObserver); williamr@2: williamr@2: /** williamr@2: * Sets the note to be displayed when the selection list has no items williamr@2: * available. williamr@2: * williamr@2: * @param aResourceId Resource id for the note. williamr@2: * @param aTimeout = CAknNoteDialog::EShortTimeout Timeout for the note. williamr@2: * @param aTone = CAknNoteDialog::ENoTone Tone for the note. williamr@2: */ williamr@2: IMPORT_C void SetEmptyListNoteL(TInt aResourceId, williamr@2: CAknNoteDialog::TTimeout aTimeout = CAknNoteDialog::EShortTimeout, williamr@2: CAknNoteDialog::TTone aTone = CAknNoteDialog::ENoTone); williamr@2: williamr@2: /** williamr@2: * Sets the empty list note text. This note is displayed when the williamr@2: * selection list has no items available. williamr@2: * williamr@2: * @param aEmptyText The empty list note text. williamr@2: */ williamr@2: IMPORT_C void SetEmptyTextL(const TDesC& aEmptyText); williamr@2: williamr@2: /** williamr@2: * Sets the text to be added to the bottom of the array to enter user williamr@2: * defined data. williamr@2: * williamr@2: * @param aOtherText Text to the bottom of the selection array. williamr@2: */ williamr@2: IMPORT_C void SetOtherTextL(const TDesC& aOtherText); williamr@2: williamr@2: /** williamr@2: * Sets the text for view state when none of the elements in the williamr@2: * list are available. williamr@2: * williamr@2: * @param aInvalidText The invalid text. williamr@2: */ williamr@2: IMPORT_C void SetInvalidTextL(const TDesC &aInvalidText); williamr@2: williamr@4: /** williamr@4: * Closes the selection list williamr@4: * williamr@4: * @since v5.2 williamr@4: */ williamr@4: IMPORT_C void CloseSelectionListL(); williamr@2: williamr@2: public: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles key events. williamr@2: * williamr@2: * @param aKeyEvent The key event. williamr@2: * @param aType The type of key event. williamr@2: * @return Indicates whether or not the key event was used by this control. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Constructs the control from a resource file. williamr@2: * williamr@2: * @param aReader The resource reader pointing to the popup field resource. williamr@2: */ williamr@2: IMPORT_C void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Determines the minimum size of the control. williamr@2: * williamr@2: * @return The minimum size required by the control. williamr@2: */ williamr@2: IMPORT_C TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles a change to the control's resources. williamr@2: * williamr@2: * @param aType The type of the resource change. williamr@2: */ williamr@2: IMPORT_C void HandleResourceChange(TInt aType); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Handles pointer events of popup field list. williamr@2: * williamr@2: * @param aPointerEvent The pointer event to be handled. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: public: williamr@2: /** williamr@2: /** williamr@2: * Sets the maximium number of lines that can be displayed. williamr@2: * williamr@2: * @param aMaxNoLines The maximum number of lines. williamr@2: */ williamr@2: IMPORT_C void SetMaxNumberOfLinesPermitted(TInt aMaxNoLines); williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Sets a form field rectangle so that a popup field can correctly position williamr@2: * the label. williamr@2: * williamr@2: * @param aFormFieldRect The form field rectangle. williamr@2: */ williamr@2: IMPORT_C void SetFormFieldRect(TRect aFormFieldRect); williamr@2: williamr@2: protected: // from MCoeControlObserver williamr@2: williamr@2: /** williamr@2: * From @c MCoeControlObserver. williamr@2: * williamr@2: * Handles an event from an observed control. williamr@2: * williamr@2: * @param aControl The control that sent the event. williamr@2: * @param aEvent The event type. williamr@2: */ williamr@2: IMPORT_C void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEvent); williamr@2: protected: // from MEikCommandObserver williamr@2: williamr@2: /** williamr@2: * From @c MEikCommandObserver. williamr@2: * williamr@2: * Processes events from the softkeys. Responds to @c EAknSoftkeyOk and williamr@2: * @c EAknSoftkeyCancel to accept or cancel the pop-up. williamr@2: * williamr@2: * @param aCommandId Event Id from the soft-key. williamr@2: */ williamr@2: IMPORT_C void ProcessCommandL(TInt aCommandId); williamr@2: protected: // From MEikListBoxObserver williamr@2: williamr@2: /** williamr@2: * From @c MEikListBoxObserver. williamr@2: * williamr@2: * Processes key events from the listbox. Responds to williamr@2: * @c EEventEnterKeyPressed to accept the pop-up. williamr@2: * williamr@2: * @param aListBox Listbox being observed. williamr@2: * @param aEventType Event observed. williamr@2: */ williamr@2: IMPORT_C void HandleListBoxEventL(CEikListBox* aListBox, williamr@2: TListBoxEvent aEventType); williamr@2: protected: // from CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Gets the number of controls contained in a compound control. williamr@2: * williamr@2: * @return The number of component controls contained by this control. williamr@2: */ williamr@2: IMPORT_C TInt CountComponentControls() const; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Gets an indexed component of a compound control. williamr@2: * williamr@2: * @param aIndex Control index. williamr@2: * @return The component control with an index of @c aIndex. williamr@2: */ williamr@2: IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Responds to changes to the size and position of the contents of this williamr@2: * control. williamr@2: */ williamr@2: IMPORT_C void SizeChanged(); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Responds to a change in focus. williamr@2: * williamr@2: * @param aDrawNow Contains the value that was passed to it by williamr@2: * @c SetFocus(). williamr@2: */ williamr@2: IMPORT_C void FocusChanged( TDrawNow aDrawNow ); williamr@2: williamr@2: /** williamr@2: * From @c CEikBorderedControl. williamr@2: * williamr@2: * Called by the framework to draw the control. williamr@2: * williamr@2: * @param aRect Rectangle in which the Cone framework believes drawing is williamr@2: * needed. williamr@2: */ williamr@2: IMPORT_C void Draw(const TRect& aRect) const; williamr@2: williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void Reserved_1(); williamr@2: IMPORT_C 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: protected: // personal williamr@2: williamr@2: /** williamr@2: * Construction tasks common to both a normal construction and a construction williamr@2: * from a resource. Used from @c ConstructL() and williamr@2: * @c ConstructFromResourceL(). williamr@2: */ williamr@2: void CommonConstructL(); williamr@2: protected: // from MObjectProvider williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Retrieves an object of the same type as that encapsulated in @c aId. williamr@2: * williamr@2: * @param aId An encapsulated object type ID. williamr@2: * @return Encapsulates the pointer to the object provided. williamr@2: * Note that the encapsulated pointer may be NULL. williamr@2: */ williamr@2: IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId); williamr@2: private: // personal williamr@2: williamr@2: /** williamr@2: * Create the label that will show the currently selected value. williamr@2: * williamr@2: */ williamr@2: void ConstructLabelL(); williamr@2: williamr@2: /** williamr@2: * Create the command button that will be used to show the other choices indicator. williamr@2: * williamr@2: */ williamr@2: void ConstructCommandButtonL(); williamr@2: williamr@2: /** williamr@2: * Create the selection list box that will fill the expanded popup field williamr@2: * williamr@2: */ williamr@2: void ConstructSelectionListL(); williamr@2: williamr@2: /** williamr@2: * setup the scroll bar within the selection list box williamr@2: * williamr@2: */ williamr@2: void SetUpScrollBarL(); williamr@2: williamr@2: /** williamr@2: * set the scroll bar selection williamr@2: * williamr@2: */ williamr@2: void SetScrollBarSelectionL(); williamr@2: 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: williamr@2: /** williamr@2: * Handles the case where the selection list is closed. If necessary, williamr@2: * update the value of the text label that is displayed. williamr@2: * williamr@2: * @return TBool ETrue always williamr@2: */ williamr@2: TBool HandleInteractionConfirmedL(); williamr@2: williamr@2: /** williamr@2: * Create the popup list. Warn the user if there are no entries in the list. williamr@2: * williamr@2: */ williamr@2: void CreatePopoutL(); williamr@2: williamr@2: /** williamr@2: * Destroy the popup list and remove it from the stack williamr@2: * williamr@2: */ williamr@2: void DestroyPopout(); williamr@2: williamr@2: /** williamr@2: * Checks to see if the popupfield is empty williamr@2: * williamr@2: */ williamr@2: TBool IsEmpty() const; williamr@2: /** williamr@2: * Checks to see if the popupfield is invalid williamr@2: * williamr@2: */ williamr@2: TBool IsInvalid() const; williamr@2: /** williamr@2: * Handles a horizontal key event williamr@2: * williamr@2: * @return TKeyResponse returns either EKeyWasConsumed williamr@2: * or EKeyWasNotConsumed williamr@2: */ williamr@2: TKeyResponse HandleHorizontalKeyEventL(TUint aKeyEventCode); williamr@2: private: // Avkon williamr@2: williamr@2: /** williamr@2: * Creates the CBA for use when the selection list is active williamr@2: */ williamr@2: void CreateCbaL(); williamr@2: 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: /** williamr@2: * Configures the layout decoration according to the radio button flag williamr@2: * Should be called whenever the flags are changed. williamr@2: * williamr@2: */ williamr@2: void ConstructLayoutDecoratorL(); williamr@2: williamr@2: /** williamr@2: * display a note when the selection list has no items available williamr@2: * williamr@2: */ williamr@2: void ShowEmptyListNoteL(); williamr@2: williamr@2: /** williamr@2: * Re-defined method of the base class. Gets called when the williamr@2: * user tries to select a value. If required, an editor is created to williamr@2: * allow the user to input the user defined value. Otherwise, the williamr@2: * normal selection behaviour of popup list is activated. williamr@2: * williamr@2: * @param aAccept If ETrue, popup list was accepted; williamr@2: * if EFalse, popup list was cancelled williamr@2: * williamr@2: */ williamr@2: void AttemptExitL(TBool aAccept); williamr@2: williamr@2: /** williamr@2: * Changes the mode of the popupfield to one of williamr@2: * the EAknPopupFieldSelectionMode's williamr@2: */ williamr@2: void ChangeMode(EAknPopupFieldSelectionMode aNewMode); williamr@2: williamr@2: private: // async williamr@2: static TInt AttemptExitCallbackL(TAny* aThis); williamr@2: void DoAttemptExitL(); williamr@2: void DoSizeChangedL(); williamr@2: protected: williamr@2: // the following members are owned williamr@2: /** williamr@2: * Label of the popup field. williamr@2: * Own. williamr@2: */ williamr@2: CEikLabel* iLabel; williamr@2: williamr@2: /** williamr@2: * Bitmap button for the popup field. williamr@2: * Own. williamr@2: */ williamr@2: CAknPopupFieldBitmapButton* iButton; williamr@2: williamr@2: /** williamr@2: * List box for the popup field usage. williamr@2: * Own. williamr@2: */ williamr@2: CAknFormGraphicStyleListBox* iSelectionList; williamr@2: williamr@2: /** williamr@2: * Contains a popup field selection array and a leading text that will be williamr@2: * inserted before the text from the descriptor array entry. williamr@2: * Own. williamr@2: */ williamr@2: CAknListBoxLayoutDecorator* iLayoutDecorator; williamr@2: williamr@2: /** williamr@2: * Button group container for the popup field. williamr@2: * Own. williamr@2: */ williamr@2: CEikButtonGroupContainer* iCba; williamr@2: williamr@2: /** williamr@2: * Active object for calling @c AttemptExitCallbackL asynchronously. williamr@2: * Own. williamr@2: */ williamr@2: CAsyncCallBack* iAttemptExitAsync; williamr@2: williamr@2: // the following fields are reflected in the POPUP_FIELD resource structure williamr@2: /** williamr@2: * Flags for the popup field. williamr@2: */ williamr@2: TInt iFlags; williamr@2: williamr@2: /** williamr@2: * Maximum line width. williamr@2: */ williamr@2: TInt iWidth; williamr@2: williamr@2: /** williamr@2: * Text to the bottom of the selection array. williamr@2: * Own. williamr@2: */ williamr@2: HBufC* iOtherText; williamr@2: williamr@2: /** williamr@2: * The empty list note text. williamr@2: * Own. williamr@2: */ williamr@2: HBufC* iEmptyText; williamr@2: williamr@2: /** williamr@2: * The invalid text. Used in the view state when none of the elements in the williamr@2: * list are available. williamr@2: * Own. williamr@2: */ williamr@2: HBufC* iInvalidText; williamr@2: williamr@2: /** williamr@2: * Resource id for the empty note. williamr@2: */ williamr@2: TInt iEmptyNoteResourceId; williamr@2: williamr@2: // the following members are not owned williamr@2: /** williamr@2: * Query value for the popup field. williamr@2: * Not own. williamr@2: */ williamr@2: MAknQueryValue* iValue; williamr@2: williamr@2: /** williamr@2: * Observer for receiving events from the popup field. williamr@2: * Not own. williamr@2: */ williamr@2: MAknPopupFieldObserver* iObserver; williamr@2: williamr@2: // the following values are member variables williamr@2: /** williamr@2: * Enumeration representing form mode values. williamr@2: */ williamr@2: EAknFormMode iFormMode; williamr@2: williamr@2: /** williamr@2: * Timeout for the empty tone. williamr@2: */ williamr@2: CAknNoteDialog::TTimeout iEmptyNoteTimeout; williamr@2: williamr@2: /** williamr@2: * Tone for the empty note. williamr@2: */ williamr@2: CAknNoteDialog::TTone iEmptyNoteTone; williamr@2: williamr@2: /** williamr@2: * Selection array for the popup field. williamr@2: */ williamr@2: TAknDesCArrayDecorator iDecorator; williamr@2: williamr@2: /** williamr@2: * Enumeration representing selection mode values. williamr@2: */ williamr@2: EAknPopupFieldSelectionMode iSelectionMode; williamr@2: williamr@2: /** williamr@2: * Maximum number of items in selection array. williamr@2: */ williamr@2: TInt iMaxNoLines; williamr@2: // NOTE: use Extension() to extend this class. williamr@2: private: williamr@2: CAknPopupFieldExtension* iExtension; williamr@2: TInt iSpare[3]; williamr@2: }; williamr@2: williamr@2: #endif // AKNPOPUPFIELD_H