classicui_plat/extended_editors_api/inc/AknPhoneNumberEditor.h
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2002 - 2005 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 #ifndef AKNPHONENUMBEREDITOR_H
       
    19 #define AKNPHONENUMBEREDITOR_H
       
    20 
       
    21 #include <babitflags.h>
       
    22 #include <eikbctrl.h>
       
    23 #include <fepbase.h>
       
    24 #include <gulutil.h>
       
    25 #include <eikdef.h>
       
    26 #include <eikccpu.h>
       
    27 #include <baclipb.h>
       
    28 #include <aknedstsobs.h>
       
    29 
       
    30 class CEikScrollBarFrame;
       
    31 class CAknPhedModel;
       
    32 class CAknPhedView;
       
    33 class CAknPhoneNumberEditorExtension;
       
    34 
       
    35 class CAknPhoneNumberEditor : public CEikBorderedControl, public MCoeFepAwareTextEditor, 
       
    36     public MCoeFepAwareTextEditor_Extension1, public MEikCcpuEditor
       
    37     {
       
    38 public:
       
    39     class TFormat
       
    40         {
       
    41     public:
       
    42         IMPORT_C TFormat();
       
    43         // MUST NOT BE USED; LAYOUT INFO CANNOT BE IN RESOURCES OR FACE VARIATION TROUBLE.
       
    44         IMPORT_C TFormat( TResourceReader& aReader ); 
       
    45         IMPORT_C TFormat( const TRect& aOuterRect, TInt aBorderType, TInt aNumLines, 
       
    46             TInt aBottomBaselineOffset, TInt aBaselineSeparation, const CFont* aFont );
       
    47     public:
       
    48         TRect iOuterRect;
       
    49         TInt iBorderType;
       
    50         TInt iNumLines;
       
    51         TInt iBottomBaselineOffset;
       
    52         TInt iBaselineSeparation;
       
    53         const CFont* iFont;
       
    54         };
       
    55 
       
    56 public:
       
    57     IMPORT_C CAknPhoneNumberEditor();
       
    58     IMPORT_C ~CAknPhoneNumberEditor();
       
    59     IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
       
    60     IMPORT_C void ConstructL( TInt aMaxChars, TInt aMaxLines, 
       
    61                               TInt aMaxFormats, const TDesC& aTruncation );
       
    62 
       
    63     // Format manipulation functions
       
    64     IMPORT_C void AddFormat( const TFormat& aFormat );
       
    65     IMPORT_C TInt CountFormats() const;
       
    66     IMPORT_C TFormat& Format( TInt aFormatIndex ) const;
       
    67     IMPORT_C TInt CurrentFormatIndex() const;
       
    68     IMPORT_C TBool WouldTextFitInFormat( TInt aFormatIndex ) const;
       
    69     IMPORT_C void SetFormat( TInt aFormatIndex );
       
    70 
       
    71     // Text access functions
       
    72     IMPORT_C TPtrC Text(TInt aFrom = 0) const;
       
    73     IMPORT_C void SetText( const TDesC& aText );
       
    74 
       
    75     // from CCoeControl
       
    76     IMPORT_C void SizeChanged();
       
    77     IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
       
    78                                           TEventCode aType );
       
    79     IMPORT_C TSize MinimumSize();
       
    80     IMPORT_C void FocusChanged( TDrawNow aDrawNow );
       
    81     IMPORT_C void Draw( const TRect& aRect ) const;
       
    82     IMPORT_C TCoeInputCapabilities InputCapabilities() const;
       
    83 
       
    84     // Edwin like interface
       
    85     IMPORT_C TInt TextLength() const;
       
    86     IMPORT_C TInt CursorPos() const;
       
    87     IMPORT_C TInt SelectionLength() const;
       
    88     IMPORT_C TCursorSelection Selection() const;
       
    89     IMPORT_C void ClearSelectionL();
       
    90     IMPORT_C void SetSelectionL( TInt aCursorPos,TInt aAnchorPos );
       
    91     IMPORT_C void SetCursorPosL( TInt aCursorPos,TBool aSelect );
       
    92     IMPORT_C void SelectAllL();
       
    93     IMPORT_C void GetText(TDes& aDes) const;
       
    94     IMPORT_C HBufC* GetTextInHBufL() const;
       
    95     IMPORT_C void SetTextL( const TDesC* aDes );
       
    96     // this is particularly important for when the front-end processor 
       
    97     // is inline-editing a CEikEdwin
       
    98     IMPORT_C void CancelFepTransaction(); 
       
    99     IMPORT_C void UpdateScrollBarsL();
       
   100     IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL();
       
   101     inline CEikScrollBarFrame* CreatePreAllocatedScrollBarFrameL();
       
   102     inline CEikScrollBarFrame* ScrollBarFrame();
       
   103     IMPORT_C virtual TInt LineCursorWidth() const;
       
   104     IMPORT_C TMargins8 Margins() const;
       
   105     IMPORT_C TInt AknEditorFlags() ;
       
   106     // Event reporting
       
   107     void StateChanged();
       
   108 
       
   109 private:
       
   110     TInt TargetCursorPos( TInt aCurrentPos );
       
   111     void DrawChanges();
       
   112     CEikScrollBarFrame* CreateScrollBarFrameL( TBool aPreAlloc );
       
   113     void CreateFepStateL();
       
   114 
       
   115 private: // from MCoeFepAwareTextEditor
       
   116     void StartFepInlineEditL( const TDesC& aInitialInlineText, 
       
   117              TInt aPositionOfInsertionPointInInlineText, 
       
   118              TBool aCursorVisibility, 
       
   119              const MFormCustomDraw* aCustomDraw, 
       
   120              MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, 
       
   121              MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit );
       
   122 
       
   123     void UpdateFepInlineTextL( const TDesC& aNewInlineText, 
       
   124                                TInt aPositionOfInsertionPointInInlineText );
       
   125 
       
   126     void SetInlineEditingCursorVisibilityL( TBool aCursorVisibility );
       
   127     void CancelFepInlineEdit();
       
   128     // with regard to the behaviour of the following functions when inline editing, 
       
   129     // note that the contents of the editor will be such that the text constituting 
       
   130     // the selection immediately prior to inline editing will be replaced by the 
       
   131     // inline text (CancelFepInlineEdit reinstates the previous selection)
       
   132     TInt DocumentLengthForFep() const;
       
   133     TInt DocumentMaximumLengthForFep() const;
       
   134     void SetCursorSelectionForFepL( const TCursorSelection& aCursorSelection );
       
   135     void GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const;
       
   136     void GetEditorContentForFep( TDes& aEditorContent, TInt aDocumentPosition, 
       
   137                                  TInt aLengthToRetrieve) const;
       
   138     void GetFormatForFep( TCharFormat& aFormat, TInt aDocumentPosition ) const;
       
   139     void GetScreenCoordinatesForFepL( TPoint& aLeftSideOfBaseLine, TInt& aHeight, 
       
   140                                       TInt& aAscent, TInt aDocumentPosition ) const;
       
   141     void DoCommitFepInlineEditL();
       
   142     MCoeFepAwareTextEditor_Extension1* Extension1( TBool& aSetToTrue );
       
   143 
       
   144 private: // from MCoeFepAwareTextEditor
       
   145     void SetStateTransferingOwnershipL( CState* aState, TUid aTypeSafetyUid );
       
   146     CState* State( TUid aTypeSafetyUid ); // this function does *not* transfer ownership
       
   147 
       
   148 private: // from MCoeFepAwareTextEditor
       
   149     IMPORT_C void MCoeFepAwareTextEditor_Reserved_2();
       
   150 
       
   151 private:  // from MCoeFepAwareTextEditor_Extension1
       
   152     IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_2();
       
   153     IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_3();
       
   154     IMPORT_C virtual void MCoeFepAwareTextEditor_Extension1_Reserved_4();
       
   155 
       
   156 public:
       
   157     IMPORT_C TInt ChangeEditorMode( TBool aDefaultMode = EFalse );   
       
   158     IMPORT_C TInt GetEditorMode() const;    
       
   159     IMPORT_C void ResetEditorToDefaultValues();  
       
   160 
       
   161 public: 
       
   162 // from CCoeControl  
       
   163     /**
       
   164      * Handle pointer events.
       
   165      * @param aPointerEvent, the pointer event.
       
   166      * @since 5.0
       
   167      */
       
   168     IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );  
       
   169 
       
   170     /**
       
   171      * Retrieves an object of the same type as that encapsulated in aId.
       
   172      * @param aId, encapsulated object type
       
   173      * @return Pointer to the object as the same type as in aId, if there is 
       
   174      * no object as the type, NULL will be returned.
       
   175      * @since 5.0
       
   176      */
       
   177     TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   178 
       
   179 // From MEikCcpuEditor
       
   180 
       
   181     /**
       
   182      * Tests whether the editor is focused.
       
   183      * 
       
   184      * @return If editor is focused, @c ETrue is returned.
       
   185      * @since 5.0
       
   186      */
       
   187     IMPORT_C TBool CcpuIsFocused() const;
       
   188 
       
   189     /**
       
   190      * Tests whether the selected text can be cut.
       
   191      * 
       
   192      * @return @c ETrue if it is possible to cut the selected text.
       
   193      * @since 5.0
       
   194      */
       
   195     IMPORT_C TBool CcpuCanCut() const;
       
   196 
       
   197     /**
       
   198      * Cuts selected text.
       
   199      * @since 5.0
       
   200      */
       
   201     IMPORT_C void CcpuCutL();
       
   202     
       
   203     /**
       
   204      * Tests whether the selected text can be copied.
       
   205      * 
       
   206      * @return @c ETrue if it is possible to copy the selected text.
       
   207      * @since 5.0
       
   208      */
       
   209     IMPORT_C TBool CcpuCanCopy() const;
       
   210 
       
   211     /**
       
   212      * Copies selected text.
       
   213      * @since 5.0
       
   214      */
       
   215     IMPORT_C void CcpuCopyL();
       
   216     
       
   217     /**
       
   218      * Tests whether text can be pasted from the clipboard.
       
   219      * 
       
   220      * @return @c ETrue if it is possible to paste the clipboard text.
       
   221      * @since 5.0
       
   222      */
       
   223     IMPORT_C TBool CcpuCanPaste() const;
       
   224 
       
   225     /**
       
   226      * Pastes text from the clipboard to the editor.
       
   227      * @since 5.0
       
   228      */
       
   229     IMPORT_C void CcpuPasteL();
       
   230     
       
   231     /**
       
   232      * Tests is it possible to undo previous operation.
       
   233      * 
       
   234      * @return @c ETrue if it is possible to undo previous operation.
       
   235      * @since 5.0
       
   236      */
       
   237     IMPORT_C TBool CcpuCanUndo() const;
       
   238 
       
   239     /**
       
   240      * Undoes the most recent text operation when the Edwin supports this
       
   241      * feature and when the undo store is not empty
       
   242      * @since 5.0
       
   243      */
       
   244     IMPORT_C void CcpuUndoL();
       
   245     
       
   246     /**
       
   247      * Open VKB .  
       
   248      */
       
   249     EXPORT_C void OpenVKB();
       
   250 
       
   251 
       
   252 private: 
       
   253 //new functions, for ccpu support 
       
   254     /**
       
   255      * Handle clipboard operation.
       
   256      * @param aIsCopy, ETrue means this is copy operation, otherwise 
       
   257      * it is cut operation 
       
   258      */
       
   259     void ClipboardL( TBool aIsCopy );
       
   260     
       
   261     /**
       
   262      * Enable or disable ccpu support.
       
   263      * @param aSupport, ETrue enable, EFalse disable     
       
   264      */
       
   265     void EnableCcpuSupportL( TBool aSupport );
       
   266     
       
   267     /**
       
   268      * Place text on clipboard.
       
   269      * @param aText, the text that will be put on clipboard
       
   270      */
       
   271     void PlaceDataOnClipboardL( const TDesC& aText );
       
   272 
       
   273     /**
       
   274      * Check if paste operation is valid or not. If paste is invalid, 
       
   275      * this function will leave.
       
   276      */
       
   277     void DoCanPasteL() const;
       
   278     
       
   279     /**
       
   280      * Report event to pen input method.
       
   281      * @param aStateEvent, MAknEdStateObserver::EAknEdwinStateEvent     
       
   282      */
       
   283     void ReportAknEdStateEventL( 
       
   284              MAknEdStateObserver::EAknEdwinStateEvent aStateEvent );
       
   285     /**
       
   286      * close VKB .    
       
   287      */
       
   288     void CloseVKB( );
       
   289 private:
       
   290     CAknPhoneNumberEditorExtension* iExtension; 
       
   291     TInt iNumFormats;
       
   292     TInt iCurrentFormatIndex;
       
   293     CAknPhedModel* iModel;
       
   294     CAknPhedView* iView;
       
   295     TInt iTargetCursorPos;
       
   296     TBitFlags32 iFlags;
       
   297     CEikScrollBarFrame* iSBFrame;
       
   298     CState* iFepState;
       
   299     };
       
   300 
       
   301 
       
   302 inline CEikScrollBarFrame* CAknPhoneNumberEditor::CreatePreAllocatedScrollBarFrameL()
       
   303     { return CreateScrollBarFrameL( ETrue );}
       
   304 inline CEikScrollBarFrame* CAknPhoneNumberEditor::ScrollBarFrame()
       
   305     { return ( ( CEikScrollBarFrame* const )iSBFrame ); }
       
   306 
       
   307 
       
   308 #endif