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