williamr@2: /* williamr@2: * Copyright (c) 1997-1999 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: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKLBED_H__) williamr@2: #define __EIKLBED_H__ williamr@2: williamr@2: #if !defined(__E32BASE_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__EIKLBM_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__W32STD_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__COEDEF_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__COECNTRL_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@4: #include williamr@2: williamr@2: class CEikEdwin; williamr@2: class CParaFormatLayer; williamr@2: class CCharFormatLayer; williamr@2: williamr@2: /** williamr@2: * The MEikListBoxEditor class specifies an interface to a text editor which can be used inside williamr@2: * a list box. williamr@2: * williamr@2: * @since ER5U williamr@2: */ williamr@2: class MEikListBoxEditor williamr@2: { williamr@2: public: williamr@2: /** williamr@2: * Returns a pointer to the current editable item text. williamr@2: */ williamr@2: virtual TPtrC ItemText() = 0; williamr@2: williamr@2: /** williamr@2: * Creates the editor inside the list box aContainer. The editor occupies the rectangle aRect williamr@2: * and is used to editor the contents of the item at index aItemIndex up to a maximum length of williamr@2: * aMaxLength characters.. williamr@2: */ williamr@2: virtual void StartEditingL(const CCoeControl& aContainer,const TRect& aRect,TInt aItemIndex,TInt aMaxLength) = 0; williamr@2: williamr@2: /** williamr@2: * Stops editing and deletes the item editor. williamr@2: */ williamr@2: virtual void StopEditingL() = 0; williamr@2: williamr@2: /** williamr@2: * Updates the list box model with the new item contents. williamr@2: */ williamr@2: virtual TBool UpdateModelL() = 0; williamr@2: williamr@2: /** williamr@2: * Deletes the editor. williamr@2: */ williamr@2: virtual void Release() = 0; williamr@2: private: williamr@2: IMPORT_C virtual void MEikListBoxEditor_Reserved_1(); williamr@2: }; williamr@2: williamr@2: class MListBoxEditorObserver williamr@2: { williamr@2: public: williamr@2: virtual TKeyResponse HandleListBoxEditorEventL(MEikListBoxEditor* aListBoxEditor, const TKeyEvent& aKeyEvent)=0; williamr@2: }; williamr@2: williamr@2: /** williamr@2: * The @c CEikListBoxTextEditor implements a text list box item editor. This williamr@2: * editor is used inside of listbox items for editing the list box item text. williamr@2: * williamr@2: * @since ER5U williamr@2: */ williamr@2: class CEikListBoxTextEditor : public CAknControl, public MEikListBoxEditor williamr@2: { williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: * williamr@2: * @param aModel Model class of the list box. williamr@2: */ williamr@2: IMPORT_C CEikListBoxTextEditor(MListBoxModel* aModel); williamr@2: williamr@2: /** williamr@2: * Destructor williamr@2: */ williamr@2: IMPORT_C ~CEikListBoxTextEditor(); williamr@2: williamr@2: /** williamr@2: * Sets font to the text editor williamr@2: * williamr@2: * @param aFont New font for the text editor. williamr@2: */ williamr@2: IMPORT_C void SetFont(const CFont* aFont); williamr@2: williamr@2: /** williamr@2: * Gets text editor instance as @c CEikEdwin. williamr@2: * williamr@2: * @return CEikEdwin* Pointer to the text editor base class instance. williamr@2: */ williamr@2: IMPORT_C CEikEdwin* Editor(); williamr@2: williamr@2: /** williamr@2: * Sets observer to the text editor. williamr@2: * williamr@2: * @param aObserver The list box editor observer interface. williamr@2: */ williamr@2: IMPORT_C void SetListBoxEditorObserver(MListBoxEditorObserver* aObserver); williamr@2: williamr@2: public: // from MEikListBoxEditor williamr@2: williamr@2: /** williamr@2: * From @c MEikListBoxEditor. williamr@2: * This function returns the text of the list box item. williamr@2: * williamr@2: * @return TPtrC Pointer descriptor to the list box item text. williamr@2: */ williamr@2: IMPORT_C TPtrC ItemText(); williamr@2: williamr@2: /** williamr@2: * From @c MEikListBoxEditor. williamr@2: * This function creates text editor inside the williamr@2: * list box item and starts editing of the item text. The list box item can williamr@2: * contain partly editable text. This text is between '\\n' chars and this williamr@2: * control does not modify it. williamr@2: * williamr@2: * @param aContainer Container class of the list box. williamr@2: * @param aRect Retangle of the list box item. williamr@2: * @param aItemIndex Index of the list box item where text editor will be williamr@2: * created. williamr@2: * @param aMaxLength Maximum length of editor in characters. williamr@2: */ williamr@2: IMPORT_C void StartEditingL(const CCoeControl& aContainer, williamr@2: const TRect& aRect, williamr@2: TInt aItemIndex, williamr@2: TInt aMaxLength); williamr@2: williamr@2: /** williamr@2: * From @c MEikListBoxEditor. williamr@2: * Stops editing the current item and deletes the text editor. williamr@2: */ williamr@2: IMPORT_C void StopEditingL(); williamr@2: williamr@2: /** williamr@2: * From @c MEikListBoxEditor. williamr@2: * Updates the list box model with new text from text editor. If text is williamr@2: * partly editable, string between '\n' chars is not updated. williamr@2: * williamr@2: * @return TBool @c EFalse if editing is not currently on otherwise @c ETrue williamr@2: */ williamr@2: IMPORT_C TBool UpdateModelL(); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * Handles key press events. Called by the control framework. williamr@2: * williamr@2: * @param aKeyEvent The key event williamr@2: * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or williamr@2: * @c EEventKeyDown. williamr@2: * @return TKeyResponse Indicates whether or not the key event was used by williamr@2: * this control. williamr@2: */ williamr@2: IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, williamr@2: TEventCode aType); williamr@2: williamr@2: public: // From CCoeControl williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * Handles pointer events. williamr@2: * williamr@2: * @param aPointerEvent The pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: protected: // from MEikListBoxEditor williamr@2: williamr@2: /** williamr@2: * From @c MEikListBoxEditor. williamr@2: * Deletes the editor. williamr@2: */ williamr@2: IMPORT_C void Release(); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Gets the list box model. williamr@2: * williamr@2: * @return MListBoxModel* Pointer to the list box model instance. williamr@2: */ williamr@2: IMPORT_C MListBoxModel* ListBoxModel(); williamr@2: williamr@2: /** williamr@2: * Function for getting the list box item index that holds the text editor. williamr@2: * williamr@2: * @return TInt Index of the list box item that holds the text editor. williamr@2: */ williamr@2: IMPORT_C TInt ItemIndex() const; williamr@2: williamr@2: private: // from MEikListBoxEditor williamr@2: williamr@2: IMPORT_C void MEikListBoxEditor_Reserved_1(); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * This function writes the internal state of the control and its components williamr@2: * to @c aStream in debug mode. Does nothing in release mode. williamr@2: * williamr@2: * @param aWriteStream Stream where control and its components internal williamr@2: * state will be written. williamr@2: */ williamr@2: IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const; williamr@2: williamr@2: private: williamr@2: williamr@2: void UseFontL(CEikEdwin& editor, const CFont& aFont); williamr@2: williamr@2: TPtrC EditableItemText(TRect* aRect=NULL); 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: private: williamr@2: MListBoxEditorObserver* iEditorObserver; williamr@2: MListBoxModel* iModel; williamr@2: CEikEdwin* iEditor; williamr@2: TInt iItemIndex; williamr@2: CFont* iFont; williamr@2: TInt iItemPos; williamr@2: TInt iItemLen; williamr@2: CParaFormatLayer* iParaFormatLayer; williamr@2: CCharFormatLayer* iCharFormatLayer; williamr@2: TInt iSpare[2]; williamr@2: }; williamr@2: williamr@2: #endif williamr@2: williamr@2: williamr@2: // End of File