fep/aknfep/src/AknFepUiInputStateJapaneseBase.cpp
changeset 36 a7632c26d895
parent 35 0f326f2e628e
child 42 b3eaa440ab06
equal deleted inserted replaced
35:0f326f2e628e 36:a7632c26d895
     1 /*
       
     2 * Copyright (c) 2002-2004 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:            Provides the TAknFepUiInputStateJapaneseBase methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 
       
    26 
       
    27 
       
    28 
       
    29 // INCLUDE FILES
       
    30 #include "AknFepUiInputStateJapaneseBase.h"
       
    31 #include "AknFepUIManagerStateInterface.h"   //MAknFepUIManagerStateInterface
       
    32 #include "AknFepManagerUIInterface.h"        //MAknFepManagerUIInterface
       
    33 #include "AknFepCaseManager.h"               // CAknFepCaseManager
       
    34 #include "AknFepGlobalEnums.h"
       
    35 #include "AknFepPanic.h"
       
    36 
       
    37 #include <PtiDefs.h>                // keys
       
    38 #include <avkon.rsg>
       
    39 
       
    40 // CONSTANTS
       
    41 #define EFirstHalfUpperChar  0x0041
       
    42 #define ELastHalfUpperChar   0x005A
       
    43 #define EFirstFullUpperChar  0xff21
       
    44 #define ELastFullUpperChar   0xff3A
       
    45 #define EFirstHalfLowerChar  0x0061
       
    46 #define ELastHalfLowerChar   0x007A
       
    47 #define EFirstFullLowerChar  0xff41
       
    48 #define ELastFullLowerChar   0xff5A
       
    49 
       
    50 /**
       
    51  *  TAknFepUiInputStateJapaneseBase class.
       
    52  *
       
    53  */
       
    54 //============================ MEMBER FUNCTIONS ==============================
       
    55 
       
    56 // ---------------------------------------------------------------------------
       
    57 // TAknFepUiInputStateJapaneseBase::TAknFepUiInputStateJapaneseBase
       
    58 // C++ default Constructor
       
    59 // ---------------------------------------------------------------------------
       
    60 //
       
    61 TAknFepUiInputStateJapaneseBase::
       
    62 TAknFepUiInputStateJapaneseBase(MAknFepUIManagerStateInterface* aOwner,
       
    63                                 MAknFepUICtrlContainerJapanese* aUIContainer)
       
    64     :TAknFepInputStateBase(aOwner)
       
    65     {
       
    66     iUIContainer = aUIContainer;
       
    67     if (aOwner)
       
    68         {
       
    69         aOwner->FepMan()->SendUIActivatedNotification();
       
    70         }
       
    71     }
       
    72 
       
    73 /**
       
    74  * MPtiObserver interface.
       
    75  */
       
    76 //============================ MEMBER FUNCTIONS ==============================
       
    77 
       
    78 // ---------------------------------------------------------------------------
       
    79 // TAknFepUiInputStateJapaneseBase::KeyTimerExpired
       
    80 // Call this function when Multitap timer of PtiEngine was time-out
       
    81 // ---------------------------------------------------------------------------
       
    82 //
       
    83 void TAknFepUiInputStateJapaneseBase::KeyTimerExpired()
       
    84     {
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------------------------
       
    88 // TAknFepUiInputStateJapaneseBase::LastWordInSelectionList
       
    89 // not-use Japanese state
       
    90 // ---------------------------------------------------------------------------
       
    91 //
       
    92 void TAknFepUiInputStateJapaneseBase::LastWordInSelectionList()
       
    93     {
       
    94     }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // TAknFepUiInputStateJapaneseBase::FirstWordInSelectionList
       
    98 // not-use Japanese state
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 void TAknFepUiInputStateJapaneseBase::FirstWordInSelectionList()
       
   102     {
       
   103     }
       
   104 
       
   105 /**
       
   106  *  TAknFepUiInputStateJapaneseBase class.
       
   107  *
       
   108  */
       
   109 //============================ MEMBER FUNCTIONS ==============================
       
   110 
       
   111 // ---------------------------------------------------------------------------
       
   112 // TAknFepUiInputStateJapaneseBase::HandleKeyL
       
   113 // Hnadling Keypress events. This Method is called by CAknFepUIManagerJapanese
       
   114 // ---------------------------------------------------------------------------
       
   115 //
       
   116 TBool TAknFepUiInputStateJapaneseBase::
       
   117     HandleKeyL(TInt aKey, TKeyPressLength aLength)
       
   118     {
       
   119     TBool ret = ETrue;
       
   120     if(iState == EInitial)
       
   121         {
       
   122         ret = EFalse;
       
   123         }
       
   124 
       
   125     if (iOwner->IsQwerty())
       
   126         {
       
   127         switch(aKey)
       
   128             {
       
   129             case EStdKeyLeftArrow:      /* 0x0e */
       
   130             case EStdKeyRightArrow:     /* 0x0f */
       
   131             case EStdKeyUpArrow:        /* 0x10 */
       
   132             case EStdKeyDownArrow:      /* 0x11 */
       
   133                 {
       
   134                 // Long and short keypress is same Handling
       
   135                 ret = HandleNaviKeyL(aKey, aLength);
       
   136                 }
       
   137                 break;
       
   138             case EKeyOK:
       
   139             case EStdKeyEnter:          /* 0x03 */
       
   140             case EStdKeyNkpEnter:       /* 0x88 */
       
   141             case EStdKeyDevice3:        /* 0xA7 */
       
   142                 {
       
   143                 ret = HandleAuxKeyL(aKey, aLength);
       
   144                 }
       
   145                 break;
       
   146             case EStdKeyBackspace:      /* 0x01 */
       
   147             case EStdKeyEscape:         /* 0x04 */
       
   148                 {
       
   149                 // Long and short keypress is same Handling
       
   150                 ret = HandleAuxKeyL(aKey, aLength);
       
   151                 }
       
   152                 break;
       
   153             case EStdKeySpace:
       
   154                 if( iState == EConversion
       
   155                  || iState == ECandidate
       
   156                  || iState == ECandidateRetroActive )
       
   157                     {
       
   158                     ret = HandleNaviKeyL(aKey, aLength);
       
   159                     }
       
   160                 else
       
   161                     {
       
   162                     ret = HandleNumericShortKeyL(aKey);
       
   163                     }
       
   164                 break;
       
   165             default:
       
   166                 // for Qwerty
       
   167                 if (aLength == EShortKeyPress
       
   168                  && IsQwertyKey(aKey))
       
   169                     {
       
   170                     ret = HandleNumericShortKeyL(aKey);
       
   171                     }
       
   172                 break;
       
   173             }
       
   174         }
       
   175     else
       
   176         {
       
   177         switch(aKey)
       
   178             {
       
   179             case EPtiKey0:
       
   180             case EPtiKey1:
       
   181             case EPtiKey2:
       
   182             case EPtiKey3:
       
   183             case EPtiKey4:
       
   184             case EPtiKey5:
       
   185             case EPtiKey6:
       
   186             case EPtiKey7:
       
   187             case EPtiKey8:
       
   188             case EPtiKey9:
       
   189             case EPtiKeyStar:
       
   190                 {
       
   191                 if(aLength == ELongKeyPress)
       
   192                     {
       
   193                     if (aKey != EPtiKeyStar)
       
   194                         {
       
   195                         ret = HandleNumericLongKeyL(aKey);
       
   196                         }
       
   197                     else
       
   198                         {
       
   199                         MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
       
   200                         if (fepMan->HashKeySelectionInUse())
       
   201                             {
       
   202                             ret = ETrue;
       
   203                             }
       
   204                         }
       
   205                     }
       
   206                 else if (aLength == EShortKeyPress)
       
   207                     {
       
   208                     ret = HandleNumericShortKeyL(aKey);
       
   209                     }
       
   210                 }
       
   211                 break;
       
   212             case EKeyLeftArrow:
       
   213             case EKeyRightArrow:
       
   214             case EKeyDownArrow:
       
   215             case EKeyUpArrow:
       
   216                 {
       
   217                 // Long and short keypress is same Handling
       
   218                 ret = HandleNaviKeyL(aKey, aLength);
       
   219                 }
       
   220                 break;
       
   221             case EKeyOK:
       
   222                 {
       
   223                 ret = HandleAuxKeyL(aKey, aLength);
       
   224                 }
       
   225                 break;
       
   226             case EKeyBackspace:
       
   227                 {
       
   228                 // Long and short keypress is same Handling
       
   229                 ret = HandleAuxKeyL(aKey, aLength);
       
   230                 }
       
   231                 break;
       
   232             default:
       
   233                 {
       
   234                 AknFepPanic(EAknFepPanicNotSupportKey);
       
   235                 }
       
   236                 break;
       
   237             }
       
   238         }
       
   239     return ret;
       
   240     }
       
   241 
       
   242 // ---------------------------------------------------------------------------
       
   243 // TAknFepUiInputStateJapaneseBase::HandleCommandL
       
   244 // Handling Command events. This Method is called by CAknFepUIManagerJapanese.
       
   245 // ---------------------------------------------------------------------------
       
   246 //
       
   247 void TAknFepUiInputStateJapaneseBase::HandleCommandL(TInt /*aCommandId*/)
       
   248     {
       
   249     }
       
   250 
       
   251 // ---------------------------------------------------------------------------
       
   252 // TAknFepUiInputStateJapaneseBase::operator=
       
   253 // A patch to force the vtable to be copied during an assignment.
       
   254 // ---------------------------------------------------------------------------
       
   255 //
       
   256 void TAknFepUiInputStateJapaneseBase::operator=(const TAknFepInputStateBase& aState)
       
   257     {
       
   258     Mem::Copy(this, &aState, sizeof(TAknFepUiInputStateJapaneseBase));
       
   259     }
       
   260 
       
   261 // ---------------------------------------------------------------------------
       
   262 // TAknFepUiInputStateJapaneseBase::HandleNumericKeyL
       
   263 // Handling short keypress events of the numeric and the star.
       
   264 // HandleKeyEventL() call this method.
       
   265 // ---------------------------------------------------------------------------
       
   266 //
       
   267 TBool TAknFepUiInputStateJapaneseBase::HandleNumericShortKeyL(TInt /*aKey*/)
       
   268     {
       
   269     return EFalse;
       
   270     }
       
   271 
       
   272 // ---------------------------------------------------------------------------
       
   273 // TAknFepUiInputStateJapaneseBase::HandleNumericLongKeyL
       
   274 // Handling Numeric long keypress event. HandleKeyEventL() call this method.
       
   275 // ---------------------------------------------------------------------------
       
   276 //
       
   277 TBool TAknFepUiInputStateJapaneseBase::HandleNumericLongKeyL(TInt /*aKey*/)
       
   278     {
       
   279     iOwner->ChangeState(EMultiCompletion);
       
   280     return EFalse;
       
   281     }
       
   282 
       
   283 // ---------------------------------------------------------------------------
       
   284 // TAknFepUiInputStateJapaneseBase::HandleNaviKeyL
       
   285 // Handling navigate keypress event. HandleKeyEventL() call this method.
       
   286 // ---------------------------------------------------------------------------
       
   287 //
       
   288 TBool TAknFepUiInputStateJapaneseBase::HandleNaviKeyL(TInt /*aKey*/,
       
   289                                                       TKeyPressLength /*aLength*/)
       
   290     {
       
   291     return EFalse;
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------------------------
       
   295 // TAknFepUiInputStateJapaneseBase::HandleAuxKeyL
       
   296 // Handling auxiliary keypress events including OK and Backspace.
       
   297 // HandleKeyEventL() call this method.
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 TBool TAknFepUiInputStateJapaneseBase::HandleAuxKeyL(TInt /*aKey*/,
       
   301                                                      TKeyPressLength /*aLength*/)
       
   302     {
       
   303     return EFalse;
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------------------------
       
   307 // TAknFepUiInputStateJapaneseBase::UpdateInlineEditingCharacterL
       
   308 // Update inline editing string
       
   309 // ---------------------------------------------------------------------------
       
   310 //
       
   311 TBool TAknFepUiInputStateJapaneseBase::UpdateInlineEditingCharacterL()
       
   312     {
       
   313     return EFalse;
       
   314     }
       
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 // TAknFepUiInputStateJapaneseBase::CommitInlineEditingCharacterL
       
   318 // Commit inline editing string
       
   319 // ---------------------------------------------------------------------------
       
   320 //
       
   321 TBool TAknFepUiInputStateJapaneseBase::CommitInlineEditingCharacterL()
       
   322     {
       
   323     return EFalse;
       
   324     }
       
   325 
       
   326 
       
   327 // ---------------------------------------------------------------------------
       
   328 // TAknFepUiInputStateJapaneseBase::UIContainer()
       
   329 // Getting UI container object
       
   330 // ---------------------------------------------------------------------------
       
   331 //
       
   332 
       
   333 MAknFepUICtrlContainerJapanese* TAknFepUiInputStateJapaneseBase::UIContainer()
       
   334     {
       
   335     return static_cast<MAknFepUICtrlContainerJapanese*>(iUIContainer);
       
   336     }
       
   337 
       
   338 // ---------------------------------------------------------------------------
       
   339 // TAknFepUiInputStateJapaneseBase::UpdateCase
       
   340 // Update character case
       
   341 // ---------------------------------------------------------------------------
       
   342 //
       
   343 void TAknFepUiInputStateJapaneseBase::UpdateCase(TPtrC& aChar)
       
   344     {
       
   345     CAknFepCaseManager* caseMan = iOwner->CaseMan();
       
   346     if (IsDiffrentCase(aChar))
       
   347         {
       
   348         caseMan->ManualCaseUpdate();
       
   349         }
       
   350     else
       
   351         {
       
   352         caseMan->UpdateCase(ENullNaviEvent);
       
   353         }
       
   354     }
       
   355 
       
   356 // ---------------------------------------------------------------------------
       
   357 // TAknFepUiInputStateJapaneseBase::IsDiffrentCase
       
   358 // Check whether last catacter case and current catacter case is same
       
   359 // ---------------------------------------------------------------------------
       
   360 //
       
   361 TBool TAknFepUiInputStateJapaneseBase::IsDiffrentCase(TPtrC& aChar) const
       
   362     {
       
   363     TBool ret = EFalse;
       
   364     CAknFepCaseManager* caseMan = iOwner->CaseMan();
       
   365     TInt currentCase = caseMan->CurrentCase();
       
   366     switch(currentCase)
       
   367         {
       
   368         case EAknEditorUpperCase:
       
   369             {
       
   370             if (IsLowerCase(aChar))
       
   371                 {
       
   372                 ret = ETrue;
       
   373                 }
       
   374             }
       
   375             break;
       
   376         case EAknEditorLowerCase:
       
   377             {
       
   378             if (IsUpperCase(aChar))
       
   379                 {
       
   380                 ret = ETrue;
       
   381                 }
       
   382             }
       
   383         case EAknEditorTextCase:
       
   384             break;
       
   385         default: // Panic
       
   386             {
       
   387             AknFepPanic(EAknFepPanicBadCase);
       
   388             }
       
   389             break;
       
   390         }
       
   391     return ret;
       
   392     }
       
   393 
       
   394 // ---------------------------------------------------------------------------
       
   395 // TAknFepUiInputStateJapaneseBase::IsUpperCase
       
   396 // Check a caracter case is upper
       
   397 // ---------------------------------------------------------------------------
       
   398 //
       
   399 TBool TAknFepUiInputStateJapaneseBase::IsUpperCase(TPtrC& aChar) const
       
   400     {
       
   401     if ((EFirstHalfUpperChar <= aChar[0] && aChar[0] <= ELastHalfUpperChar)
       
   402      || (EFirstFullUpperChar <= aChar[0] && aChar[0] <= ELastFullUpperChar))
       
   403         {
       
   404         return ETrue;
       
   405         }
       
   406     return EFalse;
       
   407     }
       
   408 
       
   409 // ---------------------------------------------------------------------------
       
   410 // TAknFepUiInputStateJapaneseBase::IsLowerCase
       
   411 // Check a caracter case is lower
       
   412 // ---------------------------------------------------------------------------
       
   413 //
       
   414 TBool TAknFepUiInputStateJapaneseBase::IsLowerCase(TPtrC& aChar) const
       
   415     {
       
   416     if ((EFirstHalfLowerChar <= aChar[0] && aChar[0] <= ELastHalfLowerChar)
       
   417      || (EFirstFullLowerChar <= aChar[0] && aChar[0] <= ELastFullLowerChar))
       
   418         {
       
   419         return ETrue;
       
   420         }
       
   421     return EFalse;
       
   422     }
       
   423 
       
   424 TBool TAknFepUiInputStateJapaneseBase::HandleQwertyShortKeyL(TInt /*aKey*/)
       
   425     {
       
   426     return EFalse;
       
   427     }
       
   428 
       
   429 TBool TAknFepUiInputStateJapaneseBase::IsNumberKey(const TInt aKey)
       
   430     {
       
   431     TBool response = EFalse;
       
   432     if (aKey >= EPtiKeyQwerty0 && aKey <= EPtiKeyQwerty9)
       
   433         {
       
   434         response = ETrue;
       
   435         }
       
   436     return response;
       
   437     }
       
   438 
       
   439 TBool TAknFepUiInputStateJapaneseBase::IsQwertyKey(const TInt aKey)
       
   440     {
       
   441     TBool response = EFalse;
       
   442     if ( (aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ) ||
       
   443         IsNumberKey( aKey ) ||
       
   444         aKey == EStdKeySpace ||
       
   445         aKey == EPtiKeyQwertyPlus ||
       
   446         aKey == EPtiKeyQwertyMinus ||
       
   447         aKey == EPtiKeyQwertyComma ||
       
   448         aKey == EPtiKeyQwertySemicolon ||
       
   449         aKey == EPtiKeyQwertyFullstop ||
       
   450         aKey == EPtiKeyQwertyHash ||
       
   451         aKey == EPtiKeyQwertySlash ||
       
   452         aKey == EPtiKeyQwertyApostrophe)
       
   453         {
       
   454         response = ETrue;
       
   455         }
       
   456     return response;
       
   457     }
       
   458 
       
   459 // End of file