epoc32/include/mw/eiklbed.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
     1 /*
     2 * Copyright (c) 1997-1999 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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18    
    19 #if !defined(__EIKLBED_H__)
    20 #define __EIKLBED_H__
    21 
    22 #if !defined(__E32BASE_H__)
    23 #include <e32base.h>
    24 #endif
    25 
    26 #if !defined(__EIKLBM_H__)
    27 #include <eiklbm.h>
    28 #endif
    29 
    30 #if !defined(__W32STD_H__)
    31 #include <w32std.h>
    32 #endif
    33 
    34 #if !defined(__COEDEF_H__)
    35 #include <coedef.h>
    36 #endif
    37 
    38 #if !defined(__COECNTRL_H__)
    39 #include <coecntrl.h>
    40 #endif
    41 
    42 #include <akncontrol.h>
    43 
    44 class CEikEdwin;
    45 class CParaFormatLayer;
    46 class CCharFormatLayer;
    47 
    48 /**
    49  * The MEikListBoxEditor class specifies an interface to a text editor which can be used inside
    50  * a list box.
    51  *
    52  * @since ER5U
    53  */
    54 class MEikListBoxEditor
    55 	{
    56 public:
    57     /**
    58      * Returns a pointer to the current editable item text.
    59      */
    60 	virtual TPtrC ItemText() = 0;
    61 
    62     /**
    63      * Creates the editor inside the list box aContainer. The editor occupies the rectangle aRect
    64      * and is used to editor the contents of the item at index aItemIndex up to a maximum length of
    65      * aMaxLength characters..
    66      */
    67 	virtual void StartEditingL(const CCoeControl& aContainer,const TRect& aRect,TInt aItemIndex,TInt aMaxLength) = 0;
    68 
    69     /**
    70      * Stops editing and deletes the item editor. 
    71      */
    72 	virtual void StopEditingL() = 0;
    73 
    74     /**
    75 	 * Updates the list box model with the new item contents.
    76 	 */
    77 	virtual TBool UpdateModelL() = 0;
    78 
    79 	/**
    80 	 * Deletes the editor.
    81 	 */
    82 	virtual void Release() = 0;
    83 private:
    84 	IMPORT_C virtual void MEikListBoxEditor_Reserved_1();
    85 	};
    86 
    87 class MListBoxEditorObserver
    88 	{
    89 public:
    90 	virtual TKeyResponse HandleListBoxEditorEventL(MEikListBoxEditor* aListBoxEditor, const TKeyEvent& aKeyEvent)=0;
    91 	};
    92 
    93 /**
    94 * The @c CEikListBoxTextEditor implements a text list box item editor. This 
    95 * editor is used inside of listbox items for editing the list box item text.  
    96 *
    97 * @since ER5U
    98 */
    99 class CEikListBoxTextEditor : public CAknControl, public MEikListBoxEditor
   100 	{
   101 public:
   102 
   103     /**
   104      * C++ default constructor.
   105      *
   106      * @param aModel Model class of the list box.
   107      */
   108 	IMPORT_C CEikListBoxTextEditor(MListBoxModel* aModel);
   109 	
   110     /**
   111      * Destructor
   112      */
   113 	IMPORT_C ~CEikListBoxTextEditor();
   114 
   115     /**
   116      * Sets font to the text editor
   117      *
   118      * @param aFont New font for the text editor.
   119      */
   120 	IMPORT_C void SetFont(const CFont* aFont);
   121 
   122     /**
   123      * Gets text editor instance as @c CEikEdwin.
   124      *
   125      * @return CEikEdwin* Pointer to the text editor base class instance. 
   126      */
   127 	IMPORT_C CEikEdwin* Editor();
   128 
   129     /**
   130      * Sets observer to the text editor. 
   131      *
   132      * @param aObserver The list box editor observer interface.
   133      */
   134 	IMPORT_C void SetListBoxEditorObserver(MListBoxEditorObserver* aObserver);
   135 
   136 public: // from MEikListBoxEditor
   137 
   138     /**
   139      * From @c MEikListBoxEditor. 
   140      * This function returns the text of the list box item.
   141      *
   142      * @return TPtrC Pointer descriptor to the list box item text.
   143      */
   144 	IMPORT_C TPtrC ItemText();
   145 
   146 	/**
   147      * From @c MEikListBoxEditor. 
   148      * This function creates text editor inside the 
   149      * list box item and starts editing of the item text. The list box item can 
   150      * contain partly editable text. This text is between '\\n' chars and this
   151      * control does not modify it. 
   152      *
   153      * @param aContainer Container class of the list box.
   154      * @param aRect Retangle of the list box item.
   155      * @param aItemIndex Index of the list box item where text editor will be
   156      *					created.
   157      * @param aMaxLength Maximum length of editor in characters.
   158      */
   159 	IMPORT_C void StartEditingL(const CCoeControl& aContainer, 
   160 								const TRect& aRect, 
   161 								TInt aItemIndex, 
   162 								TInt aMaxLength);
   163 	
   164     /**
   165      * From @c MEikListBoxEditor. 
   166      * Stops editing the current item and deletes the text editor. 
   167      */
   168 	IMPORT_C void StopEditingL();
   169 
   170     /**
   171      * From @c MEikListBoxEditor. 
   172      * Updates the list box model with new text from text editor. If text is 
   173      * partly editable, string between '\n' chars is not updated.
   174      *
   175      * @return TBool @c EFalse if editing is not currently on otherwise @c ETrue
   176      */
   177 	IMPORT_C TBool UpdateModelL();
   178 
   179 	/**
   180      * From @c CCoeControl. 
   181      * Handles key press events. Called by the control framework.
   182      *
   183      * @param aKeyEvent The key event 
   184      * @param aType The type of key event: @c EEventKey, @c EEventKeyUp or 
   185      *              @c EEventKeyDown.
   186      * @return TKeyResponse Indicates whether or not the key event was used by 
   187      *                      this control.
   188      */
   189 	IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, 
   190 										 TEventCode aType);
   191 
   192 public: // From CCoeControl
   193 
   194     /**
   195      * From @c CCoeControl. 
   196      * Handles pointer events.
   197      *
   198      * @param aPointerEvent The pointer event.
   199      */	
   200     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   201     	
   202 protected: // from MEikListBoxEditor
   203 
   204     /**
   205      * From @c MEikListBoxEditor. 
   206      * Deletes the editor. 
   207      */
   208 	IMPORT_C void Release();
   209 
   210 protected:
   211 
   212     /**
   213      * Gets the list box model.
   214      *
   215      * @return MListBoxModel* Pointer to the list box model instance.
   216      */
   217 	IMPORT_C MListBoxModel* ListBoxModel();
   218 
   219     /**
   220      * Function for getting the list box item index that holds the text editor.
   221      *
   222      * @return TInt Index of the list box item that holds the text editor.
   223      */
   224 	IMPORT_C TInt ItemIndex() const;
   225 
   226 private: // from MEikListBoxEditor
   227 
   228 	IMPORT_C void MEikListBoxEditor_Reserved_1();
   229 
   230 protected:
   231 
   232     /**
   233      * This function writes the internal state of the control and its components
   234      * to @c aStream in debug mode. Does nothing in release mode. 
   235      *
   236      * @param aWriteStream Stream where control and its components internal 
   237      *                     state will be written.
   238      */
   239 	IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
   240 
   241 private:
   242 
   243 	void UseFontL(CEikEdwin& editor, const CFont& aFont);
   244 
   245 	TPtrC EditableItemText(TRect* aRect=NULL);
   246 
   247 private:
   248     /**
   249     * From CAknControl
   250     */
   251     IMPORT_C void* ExtensionInterface(TUid aInterface);
   252 
   253 private:
   254 	MListBoxEditorObserver* iEditorObserver;
   255 	MListBoxModel*  iModel;
   256 	CEikEdwin*		iEditor;
   257 	TInt            iItemIndex;
   258 	CFont*          iFont;
   259 	TInt			iItemPos;
   260 	TInt			iItemLen;
   261 	CParaFormatLayer* iParaFormatLayer;
   262 	CCharFormatLayer* iCharFormatLayer;
   263     TInt iSpare[2];
   264 	};
   265 
   266 #endif
   267 
   268 
   269 //  End of File