ptikeymappings.h

Go to the documentation of this file.
00001 /*
00002 * ============================================================================
00003 *  Name       : PtiKeyMappings.h
00004 *  Part of    : PtiEngine
00005 *  Description: PtiLanguage class definitions.
00006 *  Version:
00007 *
00008 *  Copyright © 2003 Nokia Corporation.
00009 *  This material, including documentation and any related 
00010 *  computer programs, is protected by copyright controlled by 
00011 *  Nokia Corporation. All rights are reserved. Copying, 
00012 *  including reproducing, storing,  adapting or translating, any 
00013 *  or all of this material requires the prior written consent of 
00014 *  Nokia Corporation. This material also contains confidential 
00015 *  information which may not be disclosed to others without the 
00016 *  prior written consent of Nokia Corporation.
00017 * ============================================================================
00018 */
00019 #ifndef _PTI_KEY_MAPPINGS_H
00020 #define _PTI_KEY_MAPPINGS_H
00021 
00022 #include <e32base.h>
00023 #include "PtiDefs.h"
00024 
00025 
00026 const TInt KPtiKeyDataDeadKeySeparator = 0xffff;
00027 const TInt KPtiPinyinMarker = 0x2460;
00028 const TInt KPtiStrokeMarker = 0x2461;
00029 const TInt KPtiZhuyinMarker = 0x2462;
00030 const TInt KPtiCangjieMarker = 0x2463;
00031 const TInt KPtiGetAllMarker = 0x2464;
00032 
00033 // 
00034 // CPtiQwertyKeymappingsExtension
00035 //
00036 
00037 NONSHARABLE_CLASS(CPtiQwertyKeymappingsExtension) : public CBase
00038         {
00039         public:
00040                 static CPtiQwertyKeymappingsExtension* NewL();
00041                 ~CPtiQwertyKeymappingsExtension();              
00042         
00043         private:
00044                 CPtiQwertyKeymappingsExtension();
00045         
00046         public:
00047                 TUint16 iLastChar;             // for Vietnamese                        
00048                 TInt16 iLastTone;          // for Vietnamese
00049                 TUint16 iReplaced;             // for Vietnamese
00050                 TPtiTextCase iVowelCase;   // for Vietnamese
00051                 TPtiKey iLastToneKey;      // for Vietnamese                    
00052         };
00053 
00054 
00055 //
00056 // TPtiKeyMapping
00057 //
00058 
00059 class TPtiKeyMapping
00060         {
00061         public: 
00062                 TInt iIndex;
00063                 TInt iNumChars;
00064         };
00065 
00066 //
00067 // MPtiKeyMappings
00068 //
00069 class MPtiKeyMappings
00070         {
00071         public:
00072                 virtual ~MPtiKeyMappings() {}
00073                 
00086                 virtual TUint16 StartMapping(TPtiKey aKey,
00087                                                  TPtiTextCase aCase,
00088                                                                          TPtiEngineInputMode aMode = EPtiEngineInputModeNone) = 0;
00089                 virtual TUint16 NextKey(TPtiKey aKey, TBool &aAppend, TPtiTextCase aCase) = 0;
00090                 virtual TPtiKey CurrentKey() = 0;
00091                 virtual TInt ReplaceKeyMapL(TPtiKey aKey, TDesC& aMap, TPtiTextCase aCase) = 0;
00092                 virtual TPtiKey KeyForCharacter(TUint16 aChar) = 0;
00093                 
00102                 virtual TPtrC GetAll(TPtiTextCase aCase) = 0;                                   
00103         };
00104 
00105 
00106 
00107 class CPtiMappings : public CBase
00108         {
00109         public:
00110                 ~CPtiMappings();
00111                 
00117                 inline TPtrC Data() const;
00118                 inline TInt DataSize() const;
00119                 virtual TInt WriteData(TInt16* aDest);
00120                 virtual TInt ChunkDataSize() const;
00121 
00122         protected:
00123                 TPtiKey iCurrentKey;
00124                 TInt iCurrentInternal;
00125                 TInt iCurrentChar;
00126                 RArray<TPtiKeyMapping> iMaps;
00127                 HBufC* iData;
00128                 TInt iReserved_1;
00129         };
00130 
00131 //
00132 // CPtiKeyMappings
00133 // 
00134 
00135 NONSHARABLE_CLASS(CPtiKeyMappings) : public CPtiMappings, public MPtiKeyMappings
00136         {
00137         public: 
00138                 IMPORT_C static CPtiKeyMappings* NewL(TDesC& aData);
00139                 IMPORT_C static CPtiKeyMappings* NewL(TInt16* aData);           
00140                 IMPORT_C ~CPtiKeyMappings();
00141                 
00150                 IMPORT_C TUint16 StartMapping(TPtiKey aKey,
00151                                                  TPtiTextCase aCase,
00152                                                                          TPtiEngineInputMode aMode = EPtiEngineInputModeNone);                                                                           
00153                                                                          
00154                 IMPORT_C TUint16 NextKey(TPtiKey aKey, TBool &aAppend, TPtiTextCase aCase);
00155                 
00161                 inline TPtiKey CurrentKey();
00162                 
00172                 IMPORT_C TInt ReplaceKeyMapL(TPtiKey aKey, TDesC& aMap, TPtiTextCase aCase);
00173                 
00181                 IMPORT_C TPtiKey KeyForCharacter(TUint16 aChar);
00182                 
00190                 IMPORT_C void GetDataForKey(TPtiKey aKey, TDes& aResult, TPtiTextCase aCase);
00191                                                                 
00200                 TPtrC GetAll(TPtiTextCase aCase);                                                       
00201 
00202         private:                
00203                 CPtiKeyMappings();
00204                 void ConstructL(TDesC& aData);
00205                 void ConstructL(TInt16* aData);
00206                 TUint16 NextChar(TPtiTextCase aCase);
00207                 void KeyCodeToInternal(TPtiKey aKey);
00208                 TPtiKey InternalToKeyCode(TInt aInternal);
00209         };
00210 
00211 
00212 
00213 NONSHARABLE_CLASS(CPtiQwertyKeyMappings) : public CPtiMappings, public MPtiKeyMappings
00214         {
00215         private:
00216                 CPtiQwertyKeyMappings();
00217         public:  
00218                 IMPORT_C static CPtiQwertyKeyMappings* NewL(TDesC& aData);
00219                 IMPORT_C static CPtiQwertyKeyMappings* NewL(TInt16* aData);             
00220                 IMPORT_C ~CPtiQwertyKeyMappings();
00221                 
00230                 IMPORT_C TUint16 StartMapping(TPtiKey aKey,
00231                                                   TPtiTextCase aCase,
00232                                                                           TPtiEngineInputMode aMode = EPtiEngineInputModeNone);
00233                 IMPORT_C TUint16 NextKey(TPtiKey aKey, TBool &aAppend, TPtiTextCase aCase);
00234                 
00240                 inline TPtiKey CurrentKey();
00241                 
00251                 IMPORT_C TInt ReplaceKeyMapL(TPtiKey aKey, TDesC& aMap, TPtiTextCase aCase);
00252                 
00260                 IMPORT_C TPtiKey KeyForCharacter(TUint16 aChar);
00261                 
00269                 IMPORT_C void GetDataForKey(TPtiKey aKey, TDes& aResult, TPtiTextCase aCase);
00270                 
00271                 inline TBool DeadKeyRootFlag() const;
00272                 inline TUint16 DeadKeyRootChar() const;
00273                 TInt WriteData(TInt16* aDest);
00274                 TInt ChunkDataSize() const;
00275                 inline TBool VowelSequenceFlag() const;
00276                 inline TUint16 VowelSequenceResult() const;
00277                 inline void ClearVowelSequence();
00278                 inline TInt16 DeadKey() const;
00279                 inline void ClearDeadKey();
00280                 inline void ClearLastChar();
00281                 inline void SetLastChar(TInt aLastChar);
00282                 inline TInt GetLastChar() const;
00283                 inline TUint16 ReplacedCharacter();
00284                 inline void SetLastKey(TPtiKey aKey);
00285                 inline TPtiTextCase VowelCase() const;
00286                 inline void ResetVietnameseVowelSequenceAndToneMarks();
00287                 inline TPtiKey LastKey() const;
00288 
00297                 TPtrC GetAll(TPtiTextCase aCase);                                                       
00298                 
00299                 inline void SetFlag(TInt aFlag);
00300                 inline void ResetFlag(TInt aFlag);                      
00301 
00302         public:
00303                 enum
00304                         {
00305                         EDeadKeyRootFlag = 0x01,
00306                         EVowelSeqFlag    = 0x02,
00307                         EPrevKeyInUpperCase = 0x04,
00308                         ETrackVietnameseToneMarksAndVowels = 0x08
00309                         };
00310                                                 
00311         private:                        
00312                 void ConstructL(TDesC& aData);
00313                 void ConstructL(TInt16* aData);
00314                 TUint16 NextChar(TPtiTextCase aCase);
00315                 TBool KeyCodeToInternal(TPtiKey aKey);
00316                 TPtiKey InternalToKeyCode(TInt aInternal);
00317                 TUint16 GetDeadKeyChar(TInt aStartIndex);
00318                 inline TInt DeadKeyIndex(TUint16 aDeadKeyUnicode);
00319                 inline TBool IsDeadKeyCode(TUint16 aChar) const;
00320                 inline TBool IsModeControlChar(TUint16 aChar) const;
00321                 TUint16 GetCharForMode(TPtiEngineInputMode aMode, TInt aIndex, TInt aNumChars, TBool aSkipFirst); 
00322                 TBool DoesModeCharMatchToInputMode(TUint16 aChar, TPtiEngineInputMode aMode) const;
00323                 TUint16 VowelSequence(TPtiKey aKey1, TPtiKey aKey2, TPtiTextCase aCase) const;  
00324                 TUint16 VietnameseToneMark(TUint16 aPrevChar, TPtiKey aKey);
00325                 TUint16 RepeatingVowelSequence(TPtiKey aKey);
00326                 TPtiKey VowelSeqRootKey(TUint16 aChar);
00327 
00328         private:
00329                 RArray<TPtiKeyMapping> iDeadKeyMaps;
00330                 HBufC* iDeadKeyData;                    
00331                 TInt16 iDeadKey;
00332                 TInt16 iDeadKeyRootChar;
00333                 TInt16 iVowelSeqResult;
00334                 TPtiKey iLastKey;
00335                 TInt iFlags;
00336                 CPtiQwertyKeymappingsExtension* iExtension;
00337         };
00338 
00339 
00340 inline TPtiKey CPtiKeyMappings::CurrentKey()
00341         {
00342         return iCurrentKey;
00343         }
00344 
00345 
00346 
00347 inline TPtrC CPtiMappings::Data() const
00348         {
00349         if (iData)
00350                 {
00351                 return iData->Des();
00352                 }
00353 
00354         return TPtrC();
00355         }
00356 
00357 
00358 inline TInt CPtiMappings::DataSize() const
00359         {
00360         if (iData)
00361                 {
00362                 return iData->Size();
00363                 }
00364 
00365         return 0;
00366         }
00367 
00368 
00369 
00370 inline TPtiKey CPtiQwertyKeyMappings::CurrentKey()
00371         {
00372         return iCurrentKey;
00373         }
00374 
00375 
00376 inline TInt CPtiQwertyKeyMappings::DeadKeyIndex(TUint16 aDeadKeyUnicode)
00377         {
00378         return (aDeadKeyUnicode & 0x00ff);
00379         }
00380 
00381 
00382 inline TBool CPtiQwertyKeyMappings::IsDeadKeyCode(TUint16 aChar) const
00383         {
00384         if (((aChar & 0xff00) == 0xf000) &&
00385             ((aChar & 0xff) <= 5))
00386                 {
00387                 return ETrue;   
00388                 }
00389                 
00390         return EFalse;  
00391         }
00392 
00393 
00394 inline TBool CPtiQwertyKeyMappings::DeadKeyRootFlag() const
00395         {
00396         return (iFlags & EDeadKeyRootFlag) != 0;                
00397         }
00398 
00399 
00400 inline TBool CPtiQwertyKeyMappings::IsModeControlChar(TUint16 aChar) const
00401         {
00402         if ((aChar == KPtiPinyinMarker) ||
00403                 (aChar == KPtiStrokeMarker) ||
00404                 (aChar == KPtiZhuyinMarker) ||
00405                 (aChar == KPtiCangjieMarker))
00406                 {       
00407                 return ETrue;
00408                 }
00409 
00410         return EFalse;
00411         }
00412 
00413 
00414 inline TBool CPtiQwertyKeyMappings::VowelSequenceFlag() const
00415         {
00416         return (iFlags & EVowelSeqFlag) != 0;
00417         }
00418 
00419 
00420 inline void CPtiQwertyKeyMappings::SetFlag(TInt aFlag)
00421         {
00422         iFlags |= aFlag;        
00423         }
00424 
00425 inline void CPtiQwertyKeyMappings::ResetFlag(TInt aFlag)
00426         {       
00427         iFlags &= ~aFlag;       
00428         }
00429 
00430 
00431 inline TUint16 CPtiQwertyKeyMappings::VowelSequenceResult() const
00432         {
00433         return iVowelSeqResult;
00434         }
00435 
00436 
00437 inline void CPtiQwertyKeyMappings::ClearVowelSequence()
00438         {
00439         iLastKey = EPtiKeyNone;
00440         }
00441         
00442         
00443 inline TUint16 CPtiQwertyKeyMappings::DeadKeyRootChar() const
00444         {
00445         return iDeadKeyRootChar;        
00446         }
00447         
00448         
00449 inline TInt16 CPtiQwertyKeyMappings::DeadKey() const
00450         {
00451         return iDeadKey;        
00452         }       
00453 
00454 
00455 inline void CPtiQwertyKeyMappings::ClearDeadKey()
00456         {
00457         iDeadKey = 0;
00458         }
00459         
00460         
00461 inline void CPtiQwertyKeyMappings::ClearLastChar()
00462         {
00463         iExtension->iLastChar = 0;
00464         }
00465 
00466         
00467 inline void CPtiQwertyKeyMappings::SetLastChar(TInt aLastChar)
00468         {
00469         iExtension->iLastChar = (TUint16)aLastChar;
00470         }
00471         
00472         
00473 inline TInt CPtiQwertyKeyMappings::GetLastChar() const
00474         {
00475         return iExtension->iLastChar;
00476         }
00477         
00478         
00479 inline TUint16 CPtiQwertyKeyMappings::ReplacedCharacter()
00480         {       
00481         return iExtension->iReplaced;
00482         }
00483 
00484                 
00485 inline void CPtiQwertyKeyMappings::SetLastKey(TPtiKey aKey)
00486         {
00487         iLastKey = aKey;        
00488         }
00489                 
00490 
00491 inline TPtiTextCase CPtiQwertyKeyMappings::VowelCase() const
00492         {
00493         return iExtension->iVowelCase;
00494         }
00495 
00496 
00497 inline void CPtiQwertyKeyMappings::ResetVietnameseVowelSequenceAndToneMarks()
00498         {
00499         iExtension->iLastChar = 0;
00500         iExtension->iReplaced = 0;
00501         iExtension->iLastTone = 0;
00502         iVowelSeqResult = 0;
00503         iLastKey = EPtiKeyNone;
00504         ResetFlag(EVowelSeqFlag);
00505         }
00506         
00507 
00508 inline TPtiKey CPtiQwertyKeyMappings::LastKey() const
00509         {
00510         return iLastKey;
00511         }
00512         
00513         
00514 // _PTI_KEY_MAPPINGS_H
00515 #endif
00516 

Copyright © Nokia Corporation 2001-2008
Back to top