textinput/peninputvkbcn/src/peninputvkbuistatecompositionwithchars.cpp
changeset 0 eb1f2e154e89
child 12 5e18d8c489d6
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     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:  Implementation of the vkb ui state machine (compositionnochars)
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // user includes
       
    20 #include "peninputvkbevent.h"
       
    21 #include "peninputvkbuistatecompositionwithchars.h"
       
    22 #include "peninputvkblayout.h"
       
    23 #include "peninputvkbwindow.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // Implementation of Class CAknFepVkbUiStateCompositionWithChars
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // CAknFepVkbUiStateCompositionWithChars::CAknFepVkbUiStateCompositionWithChars
       
    31 // (other items were commented in a header).
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CAknFepVkbUiStateCompositionWithChars::CAknFepVkbUiStateCompositionWithChars(
       
    35                                             MAknFepVkbUiStateMgr* aUiStateMgr, 
       
    36                                             MAknFepVkbLayoutContext* aContext)
       
    37     :CAknFepVkbUiState(aUiStateMgr,aContext)
       
    38     {
       
    39     }
       
    40        
       
    41 // -----------------------------------------------------------------------------
       
    42 // CAknFepVkbUiStateCompositionWithChars::NewL
       
    43 // (other items were commented in a header).
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 CAknFepVkbUiStateCompositionWithChars* CAknFepVkbUiStateCompositionWithChars::
       
    47                                        NewL(MAknFepVkbUiStateMgr* aUiStateMgr, 
       
    48                                             MAknFepVkbLayoutContext* aContext)
       
    49     {
       
    50     CAknFepVkbUiStateCompositionWithChars* self = new ( ELeave ) 
       
    51                                       CAknFepVkbUiStateCompositionWithChars(aUiStateMgr,aContext);
       
    52     CleanupStack::PushL(self);
       
    53     self->ConstructL(); 
       
    54     CleanupStack::Pop();
       
    55     return self;
       
    56     }  
       
    57       
       
    58 // -----------------------------------------------------------------------------
       
    59 // CAknFepVkbUiStateCompositionWithChars::~CAknFepVkbUiStateCompositionWithChars
       
    60 // (other items were commented in a header).
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 CAknFepVkbUiStateCompositionWithChars::~CAknFepVkbUiStateCompositionWithChars()
       
    64     {
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // CAknFepVkbUiStateCompositionWithChars::HandleKeyEventL
       
    69 // (other items were commented in a header).
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 TBool CAknFepVkbUiStateCompositionWithChars::HandleKeyEventL(const TRawEvent& aData)     
       
    73     {
       
    74     if ( static_cast<CAknFepVkbLayout*>(iContext)->Window()->FocusedControlID()
       
    75           == EAknFepVkbCtrlIdCompositionField && aData.Type() == TRawEvent::EKeyUp)
       
    76         {
       
    77         if (aData.ScanCode() == EStdKeyLeftArrow)
       
    78             {
       
    79             //static_cast<CAknFepVkbLayout*>(iContext)->Window()->UpdateCompositionFieldCursor(ETrue);
       
    80             return ETrue;
       
    81             }
       
    82         else if (aData.ScanCode() == EStdKeyRightArrow)
       
    83             {
       
    84             //static_cast<CAknFepVkbLayout*>(iContext)->Window()->UpdateCompositionFieldCursor(EFalse);
       
    85             return ETrue;
       
    86             }
       
    87         }
       
    88     return EFalse;
       
    89     }
       
    90 
       
    91 // -----------------------------------------------------------------------------
       
    92 // CAknFepVkbUiStateCompositionWithChars::HandleVkbEvent
       
    93 // (other items were commented in a header).
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 TBool CAknFepVkbUiStateCompositionWithChars::HandleVkbEvent(TInt /*aEventType*/,
       
    97                                                             const TDesC& aEventData)
       
    98     {
       
    99     TKeyEvent* event = (TKeyEvent*) aEventData.Ptr();
       
   100     if ( ! IsFilterUnicode(event->iScanCode) )
       
   101         {
       
   102         if ( !iContext->CompositionFieldStringLength() ) // if no chars
       
   103             {
       
   104             iContext->SendEventToVkbControl(EVkbEventStandby2Composition,NULL);        
       
   105             }
       
   106             
       
   107         return EFalse; 
       
   108         }
       
   109     else 
       
   110         {
       
   111         if ( !iContext->CompositionFieldStringLength() ) // if no chars
       
   112             {
       
   113             iUiStateMgr->SetCurrentUiState(iUiStateMgr->UiStateStandbycn());
       
   114             iContext->ForceEditGainFocus(EInputContextFieldGetFocus);    
       
   115             return SendKey(aEventData);        
       
   116             }        
       
   117         return ETrue;    
       
   118         }    
       
   119     }
       
   120     
       
   121 // -----------------------------------------------------------------------------
       
   122 // CAknFepVkbUiStateCompositionWithChars::HandleBackEvent
       
   123 // (other items were commented in a header).
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 TBool CAknFepVkbUiStateCompositionWithChars::HandleBackEvent(TInt /*aEventType*/,
       
   127                                                              const TDesC& aEventData)
       
   128     {
       
   129     TInt lengthPendown = iContext->RequestData(EAknFepDataTypeLengthWhenButtondownOnBack);
       
   130     
       
   131     TInt* data = (TInt*) aEventData.Ptr();
       
   132     
       
   133     //Get the flag of pen up or timer out, true when timer out, false when pen up
       
   134     data++;
       
   135     
       
   136     if ( 1 >= iContext->CompositionFieldStringLength() ) // if no chars
       
   137         {
       
   138         iContext->SendEventToVkbControl(EVkbEventComposition2Standby,NULL);
       
   139         
       
   140         if ( *data == EFalse )  // pen up
       
   141             {
       
   142             iUiStateMgr->SetCurrentUiState(iUiStateMgr->UiStateStandbycn());                       
       
   143             iContext->ForceEditGainFocus(EInputContextFieldGetFocus);              
       
   144             }            
       
   145         }
       
   146     return EFalse;  // If no chars, needn't send to composition again
       
   147         
       
   148     }
       
   149     
       
   150 // -----------------------------------------------------------------------------
       
   151 // CAknFepVkbUiStateCompositionWithChars::HandleEnterSpaceEvent
       
   152 // (other items were commented in a header).
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 TBool CAknFepVkbUiStateCompositionWithChars::HandleEnterSpaceEvent(TInt aEventType, 
       
   156                                                                    const TDesC& aEventData)  
       
   157     {
       
   158     TInt layoutType = iContext->RequestData(EAknFepDataTypeIMLayout);
       
   159     
       
   160     if ( !iContext->CompositionFieldStringLength() )  // If no chars
       
   161         {
       
   162         iUiStateMgr->SetCurrentUiState(iUiStateMgr->UiStateStandbycn());
       
   163         iContext->ForceEditGainFocus(EInputContextFieldGetFocus);    
       
   164         return SendKey(aEventData);
       
   165         }
       
   166     else  // If have chars
       
   167         {
       
   168         if ( aEventType == EVkbEventKeyEnter)
       
   169             {
       
   170             return EFalse;
       
   171             }
       
   172         if  ( ( layoutType == EAknFepVkbImCnZhuyin || layoutType == EAknFepVkbImCnStroke || 
       
   173                 layoutType == EAknFepVkbImCnPinyin || layoutType == EAknFepVkbImCnCangjie) && 
       
   174                 ( aEventType == EVkbEventKeySpace))
       
   175             {
       
   176             return EFalse;
       
   177             }
       
   178         else{
       
   179             return ETrue;    
       
   180             }            
       
   181         }        
       
   182     }        
       
   183            
       
   184 // -----------------------------------------------------------------------------
       
   185 // CAknFepVkbUiStateCompositionWithChars::HandleTabEvent
       
   186 // (other items were commented in a header).
       
   187 // -----------------------------------------------------------------------------
       
   188 //
       
   189 TBool CAknFepVkbUiStateCompositionWithChars::HandleTabEvent(TInt /*aEventType*/, 
       
   190                                                                       const TDesC& aEventData)  
       
   191     {
       
   192     TInt layoutType = iContext->RequestData(EAknFepDataTypeIMLayout);
       
   193     
       
   194     if ( !iContext->CompositionFieldStringLength() )  // If no chars
       
   195         {
       
   196         iUiStateMgr->SetCurrentUiState(iUiStateMgr->UiStateStandbycn());
       
   197         iContext->ForceEditGainFocus(EInputContextFieldGetFocus);    
       
   198         return SendKey(aEventData);
       
   199         }
       
   200     return ETrue;
       
   201     }     
       
   202     
       
   203 // -----------------------------------------------------------------------------
       
   204 // CAknFepVkbUiStateCompositionNoChars::HandleArrowKeyEvent
       
   205 // (other items were commented in a header).
       
   206 // -----------------------------------------------------------------------------
       
   207 //
       
   208 TBool CAknFepVkbUiStateCompositionWithChars::HandleArrowKeyEvent(TInt /*aEventType*/, 
       
   209                                                                  const TDesC& aEventData)
       
   210     {
       
   211     return EFalse;
       
   212     }          
       
   213 // End Of File