epoc32/include/mw/eikseced.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(__EIKSECED_H__)
    20 #define __EIKSECED_H__
    21 
    22 #if !defined(__EIKDEF_H__)
    23 #include <eikdef.h>
    24 #endif
    25 
    26 #if !defined(__EIKBCTRL_H__)
    27 #include <eikbctrl.h>
    28 #endif
    29 
    30 #include <fepbase.h>
    31 
    32 // FORWARD DECLARATIONS
    33 class TResourceReader;
    34 class CEikSecretEditorExtension;
    35 class MAknsControlContext;
    36 
    37 /**
    38  * A single line text editor which displays an asterisk for every
    39  * character entered. 
    40  * 
    41  * The editor is suitable for editing confidential information such as
    42  * a password. You can paste to the editor but no other clipboard
    43  * functions are available.
    44  * 
    45  * The editor has an associated resource struct SECRETED and control
    46  * factory identifier EEikCtSecretEd.
    47  */
    48 class CEikSecretEditor : public CEikBorderedControl, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1
    49 	{
    50 public:
    51     enum { 
    52         /**
    53          * The maximum number of characters in the displayed
    54          * text buffer.
    55          */
    56         EMaxSecEdBufLength = 32,
    57         /**
    58          * Indicates the maximum number of characters which may be entered into
    59          * the editor. 
    60          * 
    61          * Editors additionally have a maximum length, see SetMaxLength(),
    62          * which must not exceed this value.
    63          */
    64         EMaxSecEdSecArrayLength = 255
    65         };
    66             
    67     /**
    68      * Settable features for Secret Editor. See SetFeature().
    69      *
    70      * @since S60 5.0
    71      */
    72     enum TFeatureId
    73         {
    74         /** Disables VKB. Non-zero (or ETrue) parameter disables VKB, 
    75             0 (or EFalse) enables VKB. When disabled, 
    76             editor doesn't request PenInputServer to start VKB */ 
    77         EDisablePenInput
    78         };    
    79         
    80         
    81 public:
    82     /**
    83      * Default constructor.
    84      * 
    85      * This constructs a editor with a border type of
    86      * TGulBorder::ESingleGray.
    87      * 
    88      * This function should be used as the first stage in two stage
    89      * construction, followed by a call to either ConstructFromResourceL() or
    90      * SetMaxLength().
    91      */
    92     IMPORT_C CEikSecretEditor();
    93 
    94     /**
    95      * Destructor.
    96      */
    97     IMPORT_C ~CEikSecretEditor();
    98     
    99 public:    // from CCoeControl
   100     /**
   101      * Second-phase construction from a resource file. 
   102      * 
   103      * This function reads the number of characters which may be entered by
   104      * the user into the editor from a SECRETED resource. You should call
   105      * either this function or SetMaxLength() before drawing the editor and
   106      * offering key events, otherwise the editor will not accept text input.
   107      * 
   108      * @param aReader A resource file reader.
   109      * @panic EIKCTL 13  If the value read from resource is greater than
   110      * EMaxSecEdLength.
   111      */
   112     IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader);
   113     
   114     /**
   115      * Gets the editor's minimum size in pixels.
   116      * 
   117      * Overrides CCoeControl::MinimumSize().
   118      * 
   119      * @return The editor's minimum size in pixels.
   120      */
   121     IMPORT_C virtual TSize MinimumSize();
   122     
   123     /**
   124      * Responds to key presses.
   125      * 
   126      * Overrides CCoeControl::OfferKeyEventL().
   127      * 
   128      * @param aKeyEvent The key event.
   129      * @param aType Not used.
   130      * @return Indicates whether or not the key event was consumed.
   131      */
   132     IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
   133     
   134     /**
   135      * Gets the list of logical colours used to draw the editor.
   136      * 
   137      * Overrides CCoeControl::GetColorUseListL().
   138      * 
   139      * @param aColorUseList On return, the colour list.
   140      */
   141     IMPORT_C virtual void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const; // not available before Release 005u
   142     
   143     /**
   144      * Handles a change to the editor's resources. 
   145      * 
   146      * The types of resources handled are those which are shared across the
   147      * environment, e.g. colours or fonts.
   148      * 
   149      * Calls CEikBorderedControl::HandleResourceChange().
   150      * 
   151      * @param aType A message UID value.
   152      */
   153     IMPORT_C virtual void HandleResourceChange(TInt aType);    // not available before Release 005u
   154 
   155     /**
   156      * Gets the editor's input capabilities.
   157      * 
   158      * Overrides CCoeControl::InputCapabilities().
   159      * 
   160      * If this function is overrided in a subclass, the subclass should
   161      * obtain this class' InputCapabilities' object provider through
   162      * TCoeInputCapabilities::ObjectProvider() and set that as a part of
   163      * the subclass' InputCapabilities object provider chain to ensure
   164      * maximum functionality.
   165      * 
   166      * @return The editor's input capabilities. The ESecretText and
   167      * ENavigation flags are set.
   168      */
   169     IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const;
   170 
   171     /**
   172      * From @c CCoeControl.
   173      * 
   174      * Handles pointer events.
   175      *
   176      * @param aPointerEvent The pointer event.
   177      */
   178     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
   179     
   180     IMPORT_C void FocusChanged( TDrawNow aDrawNow );
   181     
   182 public:    // specific
   183     /**
   184      * Gets the editor's text string.
   185      * 
   186      * This may be called from the container class when the model data
   187      * should be updated according to the text contained in the editor.
   188      * 
   189      * @param aText On return, the editor's text. This is what is stored in
   190      * memory, not what is displayed. This descriptor must be capable of
   191      * holding the maxlength of the internal buffer.
   192      * 
   193      */
   194     IMPORT_C void GetText(TDes& aText) const;
   195 
   196     /**
   197      * Set the contents of the character buffer.
   198      *
   199      * @param aText The text to be set as the contents of the character buffer.
   200      */
   201     IMPORT_C virtual void SetText(const TDesC& aText);
   202     
   203     /**
   204      * Set the initial display of the secret editor.
   205      * Calling this routine doesn't affect the actual character buffer.
   206      * 
   207      * @param aNumberOfCharacters Must be >=0 and <= EMaxSecEdBufLength.
   208      */
   209     IMPORT_C virtual void InitializeDisplay(TInt aNumberOfChars);
   210     
   211     /**
   212      * Clears the editor's text string removing any trace of it from memory.
   213      */
   214     IMPORT_C void Reset();
   215 
   216     /**
   217      * Set the maximum length of the editor.
   218      * 
   219      * This is the maximum number of characters which may be entered by the
   220      * user into the editor.
   221      * 
   222      * @param aMaxLength The maximum number of characters which may be
   223      * entered.
   224      * @panic EIKCTL 13 If aMaxLength is greater than EMaxSecEdLength.
   225      * 
   226      */
   227     IMPORT_C void SetMaxLength(TInt aMaxLength);
   228 
   229     /**
   230      * Sets the font that is used to draw the text in this editor.
   231      * 
   232      * @param aFont A pointer to a CFont object that is used to draw the
   233      * text in this editor.
   234      */
   235     IMPORT_C void AknSetFont(const CFont &aFont);
   236 
   237     /**
   238      * Sets the alignment of the editor.
   239      *
   240      * @param aAlign The editor's alignment.
   241      */
   242     IMPORT_C void AknSetAlignment(const CGraphicsContext::TTextAlign &aAlign);
   243 
   244     /**
   245      * Changes default and current input mode of a secret editor. By default
   246      * input mode in the secret editor is alpha input mode 
   247      * (EAknEditorSecretAlphaInputMode). By using this method the default input
   248      * mode can be changed to numeric input mode (EAknEditorNumericInputMode).
   249      *
   250      * @since 2.1
   251      * @param aInputMode Default input mode in the secret editor.  
   252      *   Only EAknEditorNumericInputMode and EAknEditorSecretAlphaInputMode
   253      *   are supported.
   254      */
   255     IMPORT_C void SetDefaultInputMode(TInt aInputMode);
   256 
   257     /**
   258      * Returns the current maximum length of the internal buffer.
   259      *
   260      * @return the current maximum length of the internal buffer.
   261      */
   262     IMPORT_C TInt MaxLength() const;
   263 
   264     /**
   265      * Access method for getting at the buffer without copying out from it.
   266      *
   267      * @return Non-modifiable descriptor reference to the contained buffer.
   268      */
   269     IMPORT_C const TDesC& Buffer() const;
   270 
   271     /**
   272      * Method to reveal (or hide) the currently input editor contents.
   273      *
   274      * @param aReveal - if ETrue, reveals the contents; if EFalse hides them.
   275      */
   276     IMPORT_C void RevealSecretText( TBool aReveal );
   277 
   278     /**
   279      * Method for enabling/disabling special character table from 
   280      * the secret editor. By default the SCT is enabled in the secret
   281      * editors.
   282      * ConstructFromResourceL need to be called before this method.
   283      * 
   284      * @since 3.2
   285      *
   286      * @param aEnable Boolean value for enabling or disabling the special
   287      *   character table.
   288      */
   289     IMPORT_C void EnableSCT( TBool aEnable = ETrue );
   290 
   291     /**
   292      * Set the skin control context to be used with this secret editor. If this
   293      * method is not called, the control context available through MOP (if any)
   294      * is used. If @c NULL control context is specified, no control context is
   295      * used at all.
   296      *
   297      * @since 2.0
   298      *
   299      * @param aContext The background control context used to draw the
   300      *   background of this editor or @c NULL. Ownership is not transferred.
   301      */
   302     IMPORT_C void SetSkinBackgroundControlContextL( MAknsControlContext* aContext );
   303     
   304     // for cursor support
   305     TPoint CursorPos();
   306     void EnableCursor( TBool aEnable );    
   307 
   308 protected:    // inherited
   309     // methods to enable CAknNumericSecretEditor to inherit from CEikSecretEditor
   310     /**
   311      * Appends a character to the editor.
   312      *
   313      * @param aKeyCode The character to append.
   314      */
   315     IMPORT_C virtual void AppendCharacterL( TInt aKeyCode );
   316     
   317     /**
   318      * Updates and redraws the editor.
   319      */
   320     IMPORT_C virtual void Update();
   321     
   322     void InsertSecretChar();
   323     
   324     /**
   325      * Responds to changes to the size and position of
   326      * the contents of this control.
   327      * 
   328      * Overrides CCoeControl::SizeChanged().
   329      */
   330     IMPORT_C void SizeChanged();
   331     
   332 private: // virtual
   333     IMPORT_C virtual void Draw(const TRect& aRect) const;
   334 
   335 private: // from MCoeFepAwareTextEditor
   336     IMPORT_C void StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit);
   337     IMPORT_C void UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText);
   338     IMPORT_C void SetInlineEditingCursorVisibilityL(TBool aCursorVisibility);
   339     IMPORT_C void CancelFepInlineEdit();
   340     IMPORT_C TInt DocumentLengthForFep() const;
   341     IMPORT_C TInt DocumentMaximumLengthForFep() const;
   342     IMPORT_C void SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection);
   343     IMPORT_C void GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const;
   344     IMPORT_C void GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const;
   345     IMPORT_C void GetFormatForFep(TCharFormat& aFormat, TInt aDocumentPosition) const;
   346     IMPORT_C void GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, TInt aDocumentPosition) const;
   347     IMPORT_C void DoCommitFepInlineEditL();
   348     IMPORT_C MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue);
   349     IMPORT_C void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid);
   350     IMPORT_C CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership
   351 
   352 private:
   353     void OverflowAlert();
   354 
   355 private: // from CCoeControl
   356     IMPORT_C void Reserved_1();
   357     IMPORT_C void Reserved_2();
   358 private:
   359     /**
   360     * From CAknControl
   361     */
   362     IMPORT_C void* ExtensionInterface( TUid aInterface );
   363 private: // from MCoeFepAwareTextEditor
   364     IMPORT_C void MCoeFepAwareTextEditor_Reserved_2();
   365 private:  // from MCoeFepAwareTextEditor_Extension1
   366     IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_2();
   367     IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_3();
   368     IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_4();
   369 
   370 private: // specific
   371     void InsertChar();
   372     TInt CharsFitOnEditor() const;
   373     IMPORT_C virtual MCoeFepAwareTextEditor_Extension1::CState* CreateFepStateL();
   374     void CalculateAscent();
   375     void ReportUpdate();
   376     
   377     // for cursor support    
   378     void SetCursorFormat();    
   379     void UpdateCursor();
   380     void InitCRedirectionListenerL();
   381     
   382 private:
   383     typedef TBuf<EMaxSecEdBufLength> TSecEdBuf;
   384 protected:
   385     HBufC* iSecCharArr;
   386     TInt iSecPos;
   387     TSecEdBuf iBuf;
   388     TInt iMaxLen;
   389     TInt iCharWidth;
   390     TInt iAscent;
   391     TBool iBufferFull;
   392 
   393 public: // timer methods
   394     void StartTimer();
   395 private:
   396     static TInt TimerCallback(TAny* aThis);
   397 private:
   398     CPeriodic* iTimer;
   399     const CFont *iFont;
   400     CGraphicsContext::TTextAlign iAlign;
   401     TBool iRevealSecretText; // holds the state of whether text is shown or not
   402     CEikSecretEditorExtension* iExtension;
   403     CState* iFepState;
   404     HBufC* iInlineEditText;
   405 
   406 public:
   407     /**
   408      * Sets the colors for text and background as skin IDs.
   409      * 
   410      * @since 3.0
   411      * @param aAknSkinIDForTextColor ID for text color.
   412      * @param aAknSkinIDForBgColor ID for background color.
   413      */
   414     IMPORT_C void SetSkinTextColorL(TInt aAknSkinIDForTextColor, TInt aAknSkinIdForBgColor=KErrNotFound);
   415     
   416     /**
   417      * Used for setting various flag-like features to the editor.
   418      *
   419      * @param aFeatureId The feature id, see TFeatureId
   420      * @param aFeatureParam The feature parameter. This is usually
   421      *                      enabled or disabled. For more info, see
   422      *                      the feature documentation in TFeatureId.
   423      * @return KErrNone if the feature modification succeeded
   424      * @since S60 5.0
   425      **/
   426     IMPORT_C TInt SetFeature( TInt aFeatureId, TInt aFeatureParam );
   427      
   428     /**
   429      * Used to getting feature statuses.
   430      *
   431      * @param aFeatureId The feature id, see TFeatureId
   432      * @param aFeatureParam On return, the parameter for the feature
   433      *                      (usually non-zero for an enabled feature
   434      *                      and zero for disabled)
   435      * @return KErrNone if the feature is supported and fetching its value
   436      *                  succeeded
   437      * @since S60 5.0
   438      */
   439     IMPORT_C TInt GetFeature( TInt aFeatureId, TInt& aFeatureParam ) const;
   440 
   441     /**
   442      * Used for checking if the editor supports a feature.
   443      * For features, see TFeatureId.
   444      *
   445      * @param aFeatureId
   446      * @return ETrue if the feature is supported
   447      * @since S60 5.0
   448      */
   449     IMPORT_C TBool SupportsFeature( TInt aFeatureId ) const;    
   450     };
   451 
   452 #endif