textinput/peninputarc/src/peninputlayoutcontrol/peninputinputcontextfield.cpp
changeset 0 eb1f2e154e89
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2005-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 for CFepInputContextField
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "peninputlayout.h"
       
    21 #include "peninputinputcontextfield.h"
       
    22 
       
    23 
       
    24 // CONSTANTS
       
    25 
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS =============================
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CFepInputContextField::NewL
       
    31 // Two-phased constructor.
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 EXPORT_C CFepInputContextField* CFepInputContextField::NewL(TRect aRect,
       
    35                                       CFepUiLayout* aUiLayout,TInt aControlId)
       
    36     {
       
    37     CFepInputContextField* self = new (ELeave) CFepInputContextField(aRect,
       
    38                                                         aUiLayout,aControlId);
       
    39     
       
    40     CleanupStack::PushL(self);
       
    41     self->ConstructL();
       
    42     CleanupStack::Pop(self);
       
    43 
       
    44     return self;
       
    45     }
       
    46 
       
    47 
       
    48 // ---------------------------------------------------------------------------
       
    49 // CFepInputContextField::CFepInputContextField
       
    50 // C++ default constructor can NOT contain any code, that
       
    51 // might leave.
       
    52 // ---------------------------------------------------------------------------
       
    53 EXPORT_C CFepInputContextField::CFepInputContextField(TRect aRect, CFepUiLayout* aUiLayout,
       
    54                                                       TInt aControlId):
       
    55             CFepLayoutEditAreaBase(aRect,aUiLayout,aControlId)
       
    56     {
       
    57     SetControlType(ECtrlInputContextArea);
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------------------------
       
    61 // CFepInputContextField::ConstructL
       
    62 // Symbian 2nd phase constructor can leave.
       
    63 // ---------------------------------------------------------------------------
       
    64 EXPORT_C void CFepInputContextField::ConstructL()
       
    65     {
       
    66     BaseConstructL();
       
    67     }
       
    68 
       
    69 // Destructor
       
    70 EXPORT_C CFepInputContextField::~CFepInputContextField()
       
    71     {
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 // CFepInputContextField::SetTextL
       
    76 // Gets the text from the current control and puts it into
       
    77 // the edit area.
       
    78 // (other items were commented in a header).
       
    79 // ---------------------------------------------------------------------------
       
    80 //
       
    81 EXPORT_C void CFepInputContextField::SetTextL(const TFepInputContextFieldData& aData)
       
    82     {
       
    83     CFepLayoutEditAreaBase::SetTextL( aData );
       
    84     }
       
    85 
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // Handle pointer up event
       
    89 // ---------------------------------------------------------------------------
       
    90 //
       
    91 EXPORT_C CFepUiBaseCtrl* CFepInputContextField::HandlePointerUpEventL(const TPoint& aPt)
       
    92     {
       
    93    
       
    94     if ( !CFepLayoutEditAreaBase::HandlePointerUpEventL(aPt) )
       
    95         {
       
    96         return NULL;
       
    97         }
       
    98 
       
    99     TPtrC eventData((const TUint16 *)&iSelectedCompositionText,sizeof(iSelectedCompositionText));
       
   100     ReportEvent(EEventICFSelectionChanged,eventData);
       
   101     
       
   102     UiLayout()->SetAppEditorCursor(iSelectedCompositionText);
       
   103     
       
   104     return this;    
       
   105     }
       
   106     
       
   107 // ---------------------------------------------------------------------------
       
   108 // Handle pointer up event
       
   109 // ---------------------------------------------------------------------------
       
   110 //
       
   111 EXPORT_C CFepUiBaseCtrl* CFepInputContextField::HandlePointerDownEventL(const TPoint& aPt)
       
   112     {
       
   113     iLastInsertPos = PositionOfInsertionPointOnWindow();
       
   114     
       
   115     if ( !CFepLayoutEditAreaBase::HandlePointerDownEventL(aPt) )
       
   116         {
       
   117         return NULL;
       
   118         }
       
   119     
       
   120     return this;    
       
   121     }
       
   122 
       
   123 EXPORT_C void CFepInputContextField::UpdateContent(const TCursorSelection& aCursorSel)
       
   124     {
       
   125     TInt cursorPos = aCursorSel.iCursorPos;
       
   126     if (cursorPos < 0 )
       
   127         {
       
   128         cursorPos = 0;
       
   129         }
       
   130     else if (cursorPos > iBuffer->Length())
       
   131         {
       
   132         cursorPos = iBuffer->Length();
       
   133         }   
       
   134     UpdateCursorSelection(TCursorSelection(cursorPos, aCursorSel.iAnchorPos));    
       
   135     
       
   136     TPtrC eventData((const TUint16 *)&iSelectedCompositionText,sizeof(iSelectedCompositionText));
       
   137     ReportEvent(EEventICFSelectionChanged,eventData);
       
   138     UiLayout()->SetAppEditorCursor(iSelectedCompositionText);
       
   139     }
       
   140 //  End of File