emailuis/uicomponents/src/fstextinputfield.cpp
changeset 0 8466d47a6819
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Implementation of the CFsTextInputField class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "emailtrace.h"
       
    20 #include <txtrich.h>
       
    21 
       
    22 #include "fstextinputfield.h"
       
    23 #include "fstextinputvisual.h"
       
    24 #include "fstextinputfieldobserver.h"
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 // ---------------------------------------------------------------------------
       
    29 // Constructor
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CFsTextInputField::CFsTextInputField( MFsTextInputFieldObserver& aObserver ) 
       
    33     : iObserver( aObserver ), iFsTextInputMode( ENotAtomicInput )
       
    34     {
       
    35     FUNC_LOG;
       
    36     //No implementation needed
       
    37     }
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // Two phased constructor
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CFsTextInputField::ConstructL()
       
    44     {
       
    45     FUNC_LOG;
       
    46     CEikRichTextEditor::ConstructL( NULL,
       
    47                                     0,
       
    48                                     0,
       
    49                                     CEikEdwin::EOwnsWindow|
       
    50                                     CEikEdwin::EInclusiveSizeFixed,
       
    51                                     EGulFontControlBold|EGulFontControlItalic|
       
    52                                     EGulFontControlUnderline|
       
    53                                     EGulFontControlStrikethrough|
       
    54                                     EGulFontControlTextColor|
       
    55                                     EGulFontControlPrintPos );
       
    56     }
       
    57 
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // Constructs and returns object of CFsTextInputField class
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 CFsTextInputField* CFsTextInputField::NewL(
       
    64     MFsTextInputFieldObserver& aObserver )
       
    65     {
       
    66     FUNC_LOG;
       
    67     CFsTextInputField* self = CFsTextInputField::NewLC( aObserver );
       
    68     CleanupStack::Pop( self );
       
    69     return self;
       
    70     }
       
    71 
       
    72 // ---------------------------------------------------------------------------
       
    73 // Constructs and returns object of CFsTextInputField class
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 CFsTextInputField* CFsTextInputField::NewLC(
       
    77     MFsTextInputFieldObserver& aObserver )
       
    78     {
       
    79     FUNC_LOG;
       
    80     CFsTextInputField* self = new ( ELeave ) CFsTextInputField( aObserver );
       
    81     CleanupStack::PushL( self );
       
    82     self->ConstructL();
       
    83     return self;
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------------------------
       
    87 // Destructor
       
    88 // ---------------------------------------------------------------------------
       
    89 //
       
    90 CFsTextInputField::~CFsTextInputField()
       
    91     {
       
    92     FUNC_LOG;
       
    93     //No implementation needed.
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // Set Text input mode
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CFsTextInputField::SetTextInputMode( const TFsTextInputMode aMode )
       
   101     {
       
   102     FUNC_LOG;
       
   103     iFsTextInputMode = aMode;
       
   104     }
       
   105 
       
   106 // ---------------------------------------------------------------------------
       
   107 // Returns Text input mode
       
   108 // ---------------------------------------------------------------------------
       
   109 //
       
   110 CFsTextInputField::TFsTextInputMode CFsTextInputField::TextInputMode() const
       
   111     {
       
   112     FUNC_LOG;
       
   113     return iFsTextInputMode;
       
   114     }
       
   115 
       
   116 // ---------------------------------------------------------------------------
       
   117 // From CEikRichTextEditor
       
   118 // Function receives key events.
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 TKeyResponse CFsTextInputField::OfferKeyEventL( 
       
   122     const TKeyEvent &aKeyEvent, 
       
   123     TEventCode aType )
       
   124     {
       
   125     FUNC_LOG;
       
   126     TKeyResponse result( EKeyWasNotConsumed );
       
   127     
       
   128     if ( ( aKeyEvent.iCode == EKeyBackspace ) &&
       
   129          ( iFsTextInputMode == EAtomicInput ) &&
       
   130          !( IsReadOnly() ) )
       
   131         {
       
   132         RichText()->Reset();
       
   133         HandleTextChangedL();
       
   134         SetCursorPosL( 0, EFalse );
       
   135         result = EKeyWasConsumed;
       
   136         }
       
   137     else
       
   138         {
       
   139         result = CEikRichTextEditor::OfferKeyEventL( aKeyEvent, aType );
       
   140         }
       
   141     return result;
       
   142     }
       
   143 
       
   144 // ---------------------------------------------------------------------------
       
   145 // From CEikRichTextEditor
       
   146 // Invoked when changes in text filed content are made.
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 void CFsTextInputField::EditObserver ( TInt aStartEdit, TInt aEditLength )
       
   150     {
       
   151     FUNC_LOG;
       
   152     CEikRichTextEditor::EditObserver( aStartEdit, aEditLength );
       
   153     // <cmail>
       
   154     TRAP_IGNORE( iObserver.HandleTextInputEventL( this,
       
   155         MFsTextInputFieldObserver::EEventTextUpdated ) );
       
   156 	// </cmail>
       
   157     }
       
   158 
       
   159