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@2: * 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 williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.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(__EIKSECED_H__) williamr@2: #define __EIKSECED_H__ williamr@2: williamr@2: #if !defined(__EIKDEF_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__EIKBCTRL_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #include williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class TResourceReader; williamr@2: class CEikSecretEditorExtension; williamr@2: class MAknsControlContext; williamr@2: williamr@2: /** williamr@2: * A single line text editor which displays an asterisk for every williamr@2: * character entered. williamr@2: * williamr@2: * The editor is suitable for editing confidential information such as williamr@2: * a password. You can paste to the editor but no other clipboard williamr@2: * functions are available. williamr@2: * williamr@2: * The editor has an associated resource struct SECRETED and control williamr@2: * factory identifier EEikCtSecretEd. williamr@2: */ williamr@2: class CEikSecretEditor : public CEikBorderedControl, public MCoeFepAwareTextEditor, public MCoeFepAwareTextEditor_Extension1 williamr@2: { williamr@2: public: williamr@2: enum { williamr@2: /** williamr@2: * The maximum number of characters in the displayed williamr@2: * text buffer. williamr@2: */ williamr@2: EMaxSecEdBufLength = 32, williamr@2: /** williamr@2: * Indicates the maximum number of characters which may be entered into williamr@2: * the editor. williamr@2: * williamr@2: * Editors additionally have a maximum length, see SetMaxLength(), williamr@2: * which must not exceed this value. williamr@2: */ williamr@2: EMaxSecEdSecArrayLength = 255 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Settable features for Secret Editor. See SetFeature(). williamr@2: * williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: enum TFeatureId williamr@2: { williamr@2: /** Disables VKB. Non-zero (or ETrue) parameter disables VKB, williamr@2: 0 (or EFalse) enables VKB. When disabled, williamr@2: editor doesn't request PenInputServer to start VKB */ williamr@2: EDisablePenInput williamr@2: }; williamr@2: williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Default constructor. williamr@2: * williamr@2: * This constructs a editor with a border type of williamr@2: * TGulBorder::ESingleGray. williamr@2: * williamr@2: * This function should be used as the first stage in two stage williamr@2: * construction, followed by a call to either ConstructFromResourceL() or williamr@2: * SetMaxLength(). williamr@2: */ williamr@2: IMPORT_C CEikSecretEditor(); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CEikSecretEditor(); williamr@2: williamr@2: public: // from CCoeControl williamr@2: /** williamr@2: * Second-phase construction from a resource file. williamr@2: * williamr@2: * This function reads the number of characters which may be entered by williamr@2: * the user into the editor from a SECRETED resource. You should call williamr@2: * either this function or SetMaxLength() before drawing the editor and williamr@2: * offering key events, otherwise the editor will not accept text input. williamr@2: * williamr@2: * @param aReader A resource file reader. williamr@2: * @panic EIKCTL 13 If the value read from resource is greater than williamr@2: * EMaxSecEdLength. williamr@2: */ williamr@2: IMPORT_C virtual void ConstructFromResourceL(TResourceReader& aReader); williamr@2: williamr@2: /** williamr@2: * Gets the editor's minimum size in pixels. williamr@2: * williamr@2: * Overrides CCoeControl::MinimumSize(). williamr@2: * williamr@2: * @return The editor's minimum size in pixels. williamr@2: */ williamr@2: IMPORT_C virtual TSize MinimumSize(); williamr@2: williamr@2: /** williamr@2: * Responds to key presses. williamr@2: * williamr@2: * Overrides CCoeControl::OfferKeyEventL(). williamr@2: * williamr@2: * @param aKeyEvent The key event. williamr@2: * @param aType Not used. williamr@2: * @return Indicates whether or not the key event was consumed. williamr@2: */ williamr@2: IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); williamr@2: williamr@2: /** williamr@2: * Gets the list of logical colours used to draw the editor. williamr@2: * williamr@2: * Overrides CCoeControl::GetColorUseListL(). williamr@2: * williamr@2: * @param aColorUseList On return, the colour list. williamr@2: */ williamr@2: IMPORT_C virtual void GetColorUseListL(CArrayFix& aColorUseList) const; // not available before Release 005u williamr@2: williamr@2: /** williamr@2: * Handles a change to the editor's resources. williamr@2: * williamr@2: * The types of resources handled are those which are shared across the williamr@2: * environment, e.g. colours or fonts. williamr@2: * williamr@2: * Calls CEikBorderedControl::HandleResourceChange(). williamr@2: * williamr@2: * @param aType A message UID value. williamr@2: */ williamr@2: IMPORT_C virtual void HandleResourceChange(TInt aType); // not available before Release 005u williamr@2: williamr@2: /** williamr@2: * Gets the editor's input capabilities. williamr@2: * williamr@2: * Overrides CCoeControl::InputCapabilities(). williamr@2: * williamr@2: * If this function is overrided in a subclass, the subclass should williamr@2: * obtain this class' InputCapabilities' object provider through williamr@2: * TCoeInputCapabilities::ObjectProvider() and set that as a part of williamr@2: * the subclass' InputCapabilities object provider chain to ensure williamr@2: * maximum functionality. williamr@2: * williamr@2: * @return The editor's input capabilities. The ESecretText and williamr@2: * ENavigation flags are set. williamr@2: */ williamr@2: IMPORT_C virtual TCoeInputCapabilities InputCapabilities() const; williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * 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: IMPORT_C void FocusChanged( TDrawNow aDrawNow ); williamr@2: williamr@2: public: // specific williamr@2: /** williamr@2: * Gets the editor's text string. williamr@2: * williamr@2: * This may be called from the container class when the model data williamr@2: * should be updated according to the text contained in the editor. williamr@2: * williamr@2: * @param aText On return, the editor's text. This is what is stored in williamr@2: * memory, not what is displayed. This descriptor must be capable of williamr@2: * holding the maxlength of the internal buffer. williamr@2: * williamr@2: */ williamr@2: IMPORT_C void GetText(TDes& aText) const; williamr@2: williamr@2: /** williamr@2: * Set the contents of the character buffer. williamr@2: * williamr@2: * @param aText The text to be set as the contents of the character buffer. williamr@2: */ williamr@2: IMPORT_C virtual void SetText(const TDesC& aText); williamr@2: williamr@2: /** williamr@2: * Set the initial display of the secret editor. williamr@2: * Calling this routine doesn't affect the actual character buffer. williamr@2: * williamr@2: * @param aNumberOfCharacters Must be >=0 and <= EMaxSecEdBufLength. williamr@2: */ williamr@2: IMPORT_C virtual void InitializeDisplay(TInt aNumberOfChars); williamr@2: williamr@2: /** williamr@2: * Clears the editor's text string removing any trace of it from memory. williamr@2: */ williamr@2: IMPORT_C void Reset(); williamr@2: williamr@2: /** williamr@2: * Set the maximum length of the editor. williamr@2: * williamr@2: * This is the maximum number of characters which may be entered by the williamr@2: * user into the editor. williamr@2: * williamr@2: * @param aMaxLength The maximum number of characters which may be williamr@2: * entered. williamr@2: * @panic EIKCTL 13 If aMaxLength is greater than EMaxSecEdLength. williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetMaxLength(TInt aMaxLength); williamr@2: williamr@2: /** williamr@2: * Sets the font that is used to draw the text in this editor. williamr@2: * williamr@2: * @param aFont A pointer to a CFont object that is used to draw the williamr@2: * text in this editor. williamr@2: */ williamr@2: IMPORT_C void AknSetFont(const CFont &aFont); williamr@2: williamr@2: /** williamr@2: * Sets the alignment of the editor. williamr@2: * williamr@2: * @param aAlign The editor's alignment. williamr@2: */ williamr@2: IMPORT_C void AknSetAlignment(const CGraphicsContext::TTextAlign &aAlign); williamr@2: williamr@2: /** williamr@2: * Changes default and current input mode of a secret editor. By default williamr@2: * input mode in the secret editor is alpha input mode williamr@2: * (EAknEditorSecretAlphaInputMode). By using this method the default input williamr@2: * mode can be changed to numeric input mode (EAknEditorNumericInputMode). williamr@2: * williamr@2: * @since 2.1 williamr@2: * @param aInputMode Default input mode in the secret editor. williamr@2: * Only EAknEditorNumericInputMode and EAknEditorSecretAlphaInputMode williamr@2: * are supported. williamr@2: */ williamr@2: IMPORT_C void SetDefaultInputMode(TInt aInputMode); williamr@2: williamr@2: /** williamr@2: * Returns the current maximum length of the internal buffer. williamr@2: * williamr@2: * @return the current maximum length of the internal buffer. williamr@2: */ williamr@2: IMPORT_C TInt MaxLength() const; williamr@2: williamr@2: /** williamr@2: * Access method for getting at the buffer without copying out from it. williamr@2: * williamr@2: * @return Non-modifiable descriptor reference to the contained buffer. williamr@2: */ williamr@2: IMPORT_C const TDesC& Buffer() const; williamr@2: williamr@2: /** williamr@2: * Method to reveal (or hide) the currently input editor contents. williamr@2: * williamr@2: * @param aReveal - if ETrue, reveals the contents; if EFalse hides them. williamr@2: */ williamr@2: IMPORT_C void RevealSecretText( TBool aReveal ); williamr@2: williamr@2: /** williamr@2: * Method for enabling/disabling special character table from williamr@2: * the secret editor. By default the SCT is enabled in the secret williamr@2: * editors. williamr@2: * ConstructFromResourceL need to be called before this method. williamr@2: * williamr@2: * @since 3.2 williamr@2: * williamr@2: * @param aEnable Boolean value for enabling or disabling the special williamr@2: * character table. williamr@2: */ williamr@2: IMPORT_C void EnableSCT( TBool aEnable = ETrue ); williamr@2: williamr@2: /** williamr@2: * Set the skin control context to be used with this secret editor. If this williamr@2: * method is not called, the control context available through MOP (if any) williamr@2: * is used. If @c NULL control context is specified, no control context is williamr@2: * used at all. williamr@2: * williamr@2: * @since 2.0 williamr@2: * williamr@2: * @param aContext The background control context used to draw the williamr@2: * background of this editor or @c NULL. Ownership is not transferred. williamr@2: */ williamr@2: IMPORT_C void SetSkinBackgroundControlContextL( MAknsControlContext* aContext ); williamr@2: williamr@2: // for cursor support williamr@2: TPoint CursorPos(); williamr@2: void EnableCursor( TBool aEnable ); williamr@2: williamr@2: protected: // inherited williamr@2: // methods to enable CAknNumericSecretEditor to inherit from CEikSecretEditor williamr@2: /** williamr@2: * Appends a character to the editor. williamr@2: * williamr@2: * @param aKeyCode The character to append. williamr@2: */ williamr@2: IMPORT_C virtual void AppendCharacterL( TInt aKeyCode ); williamr@2: williamr@2: /** williamr@2: * Updates and redraws the editor. williamr@2: */ williamr@2: IMPORT_C virtual void Update(); williamr@2: williamr@2: void InsertSecretChar(); williamr@2: williamr@2: /** williamr@2: * Responds to changes to the size and position of williamr@2: * the contents of this control. williamr@2: * williamr@2: * Overrides CCoeControl::SizeChanged(). williamr@2: */ williamr@2: IMPORT_C void SizeChanged(); williamr@2: williamr@2: private: // virtual williamr@2: IMPORT_C virtual void Draw(const TRect& aRect) const; williamr@2: williamr@2: private: // from MCoeFepAwareTextEditor williamr@2: IMPORT_C void StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit); williamr@2: IMPORT_C void UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText); williamr@2: IMPORT_C void SetInlineEditingCursorVisibilityL(TBool aCursorVisibility); williamr@2: IMPORT_C void CancelFepInlineEdit(); williamr@2: IMPORT_C TInt DocumentLengthForFep() const; williamr@2: IMPORT_C TInt DocumentMaximumLengthForFep() const; williamr@2: IMPORT_C void SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection); williamr@2: IMPORT_C void GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const; williamr@2: IMPORT_C void GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const; williamr@2: IMPORT_C void GetFormatForFep(TCharFormat& aFormat, TInt aDocumentPosition) const; williamr@2: IMPORT_C void GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, TInt aDocumentPosition) const; williamr@2: IMPORT_C void DoCommitFepInlineEditL(); williamr@2: IMPORT_C MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue); williamr@2: IMPORT_C void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid); williamr@2: IMPORT_C CState* State(TUid aTypeSafetyUid); // this function does *not* transfer ownership williamr@2: williamr@2: private: williamr@2: void OverflowAlert(); williamr@2: williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void Reserved_1(); williamr@2: IMPORT_C void Reserved_2(); williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: // from MCoeFepAwareTextEditor williamr@2: IMPORT_C void MCoeFepAwareTextEditor_Reserved_2(); williamr@2: private: // from MCoeFepAwareTextEditor_Extension1 williamr@2: IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_2(); williamr@2: IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_3(); williamr@2: IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_4(); williamr@2: williamr@2: private: // specific williamr@2: void InsertChar(); williamr@2: TInt CharsFitOnEditor() const; williamr@2: IMPORT_C virtual MCoeFepAwareTextEditor_Extension1::CState* CreateFepStateL(); williamr@2: void CalculateAscent(); williamr@2: void ReportUpdate(); williamr@2: williamr@2: // for cursor support williamr@2: void SetCursorFormat(); williamr@2: void UpdateCursor(); williamr@2: void InitCRedirectionListenerL(); williamr@2: williamr@2: private: williamr@2: typedef TBuf TSecEdBuf; williamr@2: protected: williamr@2: HBufC* iSecCharArr; williamr@2: TInt iSecPos; williamr@2: TSecEdBuf iBuf; williamr@2: TInt iMaxLen; williamr@2: TInt iCharWidth; williamr@2: TInt iAscent; williamr@2: TBool iBufferFull; williamr@2: williamr@2: public: // timer methods williamr@2: void StartTimer(); williamr@2: private: williamr@2: static TInt TimerCallback(TAny* aThis); williamr@2: private: williamr@2: CPeriodic* iTimer; williamr@2: const CFont *iFont; williamr@2: CGraphicsContext::TTextAlign iAlign; williamr@2: TBool iRevealSecretText; // holds the state of whether text is shown or not williamr@2: CEikSecretEditorExtension* iExtension; williamr@2: CState* iFepState; williamr@2: HBufC* iInlineEditText; williamr@2: williamr@2: public: williamr@2: /** williamr@2: * Sets the colors for text and background as skin IDs. williamr@2: * williamr@2: * @since 3.0 williamr@2: * @param aAknSkinIDForTextColor ID for text color. williamr@2: * @param aAknSkinIDForBgColor ID for background color. williamr@2: */ williamr@2: IMPORT_C void SetSkinTextColorL(TInt aAknSkinIDForTextColor, TInt aAknSkinIdForBgColor=KErrNotFound); williamr@2: williamr@2: /** williamr@2: * Used for setting various flag-like features to the editor. williamr@2: * williamr@2: * @param aFeatureId The feature id, see TFeatureId williamr@2: * @param aFeatureParam The feature parameter. This is usually williamr@2: * enabled or disabled. For more info, see williamr@2: * the feature documentation in TFeatureId. williamr@2: * @return KErrNone if the feature modification succeeded williamr@2: * @since S60 5.0 williamr@2: **/ williamr@2: IMPORT_C TInt SetFeature( TInt aFeatureId, TInt aFeatureParam ); williamr@2: williamr@2: /** williamr@2: * Used to getting feature statuses. williamr@2: * williamr@2: * @param aFeatureId The feature id, see TFeatureId williamr@2: * @param aFeatureParam On return, the parameter for the feature williamr@2: * (usually non-zero for an enabled feature williamr@2: * and zero for disabled) williamr@2: * @return KErrNone if the feature is supported and fetching its value williamr@2: * succeeded williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: IMPORT_C TInt GetFeature( TInt aFeatureId, TInt& aFeatureParam ) const; williamr@2: williamr@2: /** williamr@2: * Used for checking if the editor supports a feature. williamr@2: * For features, see TFeatureId. williamr@2: * williamr@2: * @param aFeatureId williamr@2: * @return ETrue if the feature is supported williamr@2: * @since S60 5.0 williamr@2: */ williamr@2: IMPORT_C TBool SupportsFeature( TInt aFeatureId ) const; williamr@2: }; williamr@2: williamr@2: #endif