S60 3rd Edition API Reference: ptikeymappings.h Source File

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 #start_since SINCE_3_1_SDK
00034 
00038 NONSHARABLE_CLASS(CPtiQwertyKeymappingsExtension) : public CBase
00039         {
00040         public:
00041                 static CPtiQwertyKeymappingsExtension* NewL();
00042                 ~CPtiQwertyKeymappingsExtension();              
00043         
00044         private:
00045                 CPtiQwertyKeymappingsExtension();
00046         
00047         public:
00048                 TUint16 iLastChar;             // for Vietnamese                        
00049                 TInt16 iLastTone;          // for Vietnamese
00050                 TUint16 iReplaced;             // for Vietnamese
00051                 TPtiTextCase iVowelCase;   // for Vietnamese
00052                 TPtiKey iLastToneKey;      // for Vietnamese                    
00053         };
00054 #end_since SINCE_3_1_SDK
00055 
00056 //
00057 // TPtiKeyMapping
00058 //
00059 
00060 class TPtiKeyMapping
00061         {
00062         public: 
00063                 TInt iIndex;
00064                 TInt iNumChars;
00065         };
00066 
00067 //
00068 // MPtiKeyMappings
00069 //
00070 class MPtiKeyMappings
00071         {
00072         public:
00073                 virtual ~MPtiKeyMappings() {}
00074                 
00087                 virtual TUint16 StartMapping(TPtiKey aKey,
00088                                                  TPtiTextCase aCase,
00089                                                                          TPtiEngineInputMode aMode = EPtiEngineInputModeNone) = 0;
00090                 virtual TUint16 NextKey(TPtiKey aKey, TBool &aAppend, TPtiTextCase aCase) = 0;
00091                 virtual TPtiKey CurrentKey() = 0;
00092                 virtual TInt ReplaceKeyMapL(TPtiKey aKey, TDesC& aMap, TPtiTextCase aCase) = 0;
00093                 virtual TPtiKey KeyForCharacter(TUint16 aChar) = 0;
00094                 
00103                 virtual TPtrC GetAll(TPtiTextCase aCase) = 0;                                   
00104         };
00105 
00106 
00107 
00108 class CPtiMappings : public CBase
00109         {
00110         public:
00111                 ~CPtiMappings();
00112                 
00118                 inline TPtrC Data() const;
00119                 inline TInt DataSize() const;
00120                 virtual TInt WriteData(TInt16* aDest);
00121                 virtual TInt ChunkDataSize() const;
00122 
00123         protected:
00124                 TPtiKey iCurrentKey;
00125                 TInt iCurrentInternal;
00126                 TInt iCurrentChar;
00127                 RArray<TPtiKeyMapping> iMaps;
00128                 HBufC* iData;
00129                 TInt iReserved_1;
00130         };
00131 
00132 //
00133 // CPtiKeyMappings
00134 // 
00135 
00136 NONSHARABLE_CLASS(CPtiKeyMappings) : public CPtiMappings, public MPtiKeyMappings
00137         {
00138         public: 
00139                 IMPORT_C static CPtiKeyMappings* NewL(TDesC& aData);
00140                 IMPORT_C static CPtiKeyMappings* NewL(TInt16* aData);           
00141                 IMPORT_C ~CPtiKeyMappings();
00142                 
00151                 IMPORT_C TUint16 StartMapping(TPtiKey aKey,
00152                                                  TPtiTextCase aCase,
00153                                                                          TPtiEngineInputMode aMode = EPtiEngineInputModeNone);                                                                           
00154                                                                          
00155                 IMPORT_C TUint16 NextKey(TPtiKey aKey, TBool &aAppend, TPtiTextCase aCase);
00156                 
00162                 inline TPtiKey CurrentKey();
00163                 
00173                 IMPORT_C TInt ReplaceKeyMapL(TPtiKey aKey, TDesC& aMap, TPtiTextCase aCase);
00174                 
00182                 IMPORT_C TPtiKey KeyForCharacter(TUint16 aChar);
00183                 
00191                 IMPORT_C void GetDataForKey(TPtiKey aKey, TDes& aResult, TPtiTextCase aCase);
00192                                                                 
00201                 TPtrC GetAll(TPtiTextCase aCase);                                                       
00202 
00203         private:                
00204                 CPtiKeyMappings();
00205                 void ConstructL(TDesC& aData);
00206                 void ConstructL(TInt16* aData);
00207                 TUint16 NextChar(TPtiTextCase aCase);
00208                 void KeyCodeToInternal(TPtiKey aKey);
00209                 TPtiKey InternalToKeyCode(TInt aInternal);
00210         };
00211 
00212 
00213 
00214 NONSHARABLE_CLASS(CPtiQwertyKeyMappings) : public CPtiMappings, public MPtiKeyMappings
00215         {
00216         private:
00217                 CPtiQwertyKeyMappings();
00218         public:  
00219                 IMPORT_C static CPtiQwertyKeyMappings* NewL(TDesC& aData);
00220                 IMPORT_C static CPtiQwertyKeyMappings* NewL(TInt16* aData);             
00221                 IMPORT_C ~CPtiQwertyKeyMappings();
00222                 
00231                 IMPORT_C TUint16 StartMapping(TPtiKey aKey,
00232                                                   TPtiTextCase aCase,
00233                                                                           TPtiEngineInputMode aMode = EPtiEngineInputModeNone);
00234                 IMPORT_C TUint16 NextKey(TPtiKey aKey, TBool &aAppend, TPtiTextCase aCase);
00235                 
00241                 inline TPtiKey CurrentKey();
00242                 
00252                 IMPORT_C TInt ReplaceKeyMapL(TPtiKey aKey, TDesC& aMap, TPtiTextCase aCase);
00253                 
00261                 IMPORT_C TPtiKey KeyForCharacter(TUint16 aChar);
00262                 
00270                 IMPORT_C void GetDataForKey(TPtiKey aKey, TDes& aResult, TPtiTextCase aCase);
00271                 
00272                 inline TBool DeadKeyRootFlag() const;
00273                 inline TUint16 DeadKeyRootChar() const;
00274                 TInt WriteData(TInt16* aDest);
00275                 TInt ChunkDataSize() const;
00276                 inline TBool VowelSequenceFlag() const;
00277                 inline TUint16 VowelSequenceResult() const;
00278                 inline void ClearVowelSequence();
00279                 inline TInt16 DeadKey() const;
00280                 inline void ClearDeadKey();
00281 #start_since SINCE_3_1_SDK
00282 
00285                 inline void ClearLastChar();
00289                 inline void SetLastChar(TInt aLastChar);
00293                 inline TInt GetLastChar() const;
00297                 inline TUint16 ReplacedCharacter();
00301                 inline void SetLastKey(TPtiKey aKey);
00305                 inline TPtiTextCase VowelCase() const;
00309                 inline void ResetVietnameseVowelSequenceAndToneMarks();
00313                 inline TPtiKey LastKey() const;
00314 #end_since SINCE_3_1_SDK
00315 
00323                 TPtrC GetAll(TPtiTextCase aCase);                                                       
00324 
00325 #start_since SINCE_3_1_SDK              
00326 
00329                 inline void SetFlag(TInt aFlag);
00333                 inline void ResetFlag(TInt aFlag);                      
00334 
00335         public:
00339                 enum
00340                         {
00341                         EDeadKeyRootFlag = 0x01,
00342                         EVowelSeqFlag    = 0x02,
00343                         EPrevKeyInUpperCase = 0x04,
00344                         ETrackVietnameseToneMarksAndVowels = 0x08
00345                         };
00346 #end_since SINCE_3_1_SDK
00347                                                 
00348         private:                        
00349                 void ConstructL(TDesC& aData);
00350                 void ConstructL(TInt16* aData);
00351                 TUint16 NextChar(TPtiTextCase aCase);
00352                 void KeyCodeToInternal(TPtiKey aKey);
00353                 TPtiKey InternalToKeyCode(TInt aInternal);
00354                 TUint16 GetDeadKeyChar(TInt aStartIndex);
00355                 inline TInt DeadKeyIndex(TUint16 aDeadKeyUnicode);
00356                 inline TBool IsDeadKeyCode(TUint16 aChar) const;
00357                 inline TBool IsModeControlChar(TUint16 aChar) const;
00358                 TUint16 GetCharForMode(TPtiEngineInputMode aMode, TInt aIndex, TInt aNumChars, TBool aSkipFirst); 
00359                 TBool DoesModeCharMatchToInputMode(TUint16 aChar, TPtiEngineInputMode aMode) const;
00360                 TUint16 VowelSequence(TPtiKey aKey1, TPtiKey aKey2, TPtiTextCase aCase) const;  
00361                 TUint16 VietnameseToneMark(TUint16 aPrevChar, TPtiKey aKey);
00362                 TUint16 RepeatingVowelSequence(TPtiKey aKey);
00363                 TPtiKey VowelSeqRootKey(TUint16 aChar);
00364 
00365         private:
00366                 RArray<TPtiKeyMapping> iDeadKeyMaps;
00367                 HBufC* iDeadKeyData;                    
00368                 TInt16 iDeadKey;
00369                 TInt16 iDeadKeyRootChar;
00370                 TInt16 iVowelSeqResult;
00371                 TPtiKey iLastKey;
00372                 TInt iFlags;
00373                 CPtiQwertyKeymappingsExtension* iExtension;
00374         };
00375 
00376 
00377 inline TPtiKey CPtiKeyMappings::CurrentKey()
00378         {
00379         return iCurrentKey;
00380         }
00381 
00382 
00383 
00384 inline TPtrC CPtiMappings::Data() const
00385         {
00386         if (iData)
00387                 {
00388                 return iData->Des();
00389                 }
00390 
00391         return TPtrC();
00392         }
00393 
00394 
00395 inline TInt CPtiMappings::DataSize() const
00396         {
00397         if (iData)
00398                 {
00399                 return iData->Size();
00400                 }
00401 
00402         return 0;
00403         }
00404 
00405 
00406 
00407 inline TPtiKey CPtiQwertyKeyMappings::CurrentKey()
00408         {
00409         return iCurrentKey;
00410         }
00411 
00412 
00413 inline TInt CPtiQwertyKeyMappings::DeadKeyIndex(TUint16 aDeadKeyUnicode)
00414         {
00415         return (aDeadKeyUnicode & 0x00ff);
00416         }
00417 
00418 
00419 inline TBool CPtiQwertyKeyMappings::IsDeadKeyCode(TUint16 aChar) const
00420         {
00421         if (((aChar & 0xff00) == 0xf000) &&
00422             ((aChar & 0xff) <= 5))
00423                 {
00424                 return ETrue;   
00425                 }
00426                 
00427         return EFalse;  
00428         }
00429 
00430 
00431 inline TBool CPtiQwertyKeyMappings::DeadKeyRootFlag() const
00432         {
00433         return (iFlags & EDeadKeyRootFlag) != 0;                
00434         }
00435 
00436 
00437 inline TBool CPtiQwertyKeyMappings::IsModeControlChar(TUint16 aChar) const
00438         {
00439         if ((aChar == KPtiPinyinMarker) ||
00440                 (aChar == KPtiStrokeMarker) ||
00441                 (aChar == KPtiZhuyinMarker) ||
00442                 (aChar == KPtiCangjieMarker))
00443                 {       
00444                 return ETrue;
00445                 }
00446 
00447         return EFalse;
00448         }
00449 
00450 
00451 inline TBool CPtiQwertyKeyMappings::VowelSequenceFlag() const
00452         {
00453         return (iFlags & EVowelSeqFlag) != 0;
00454         }
00455 
00456 
00457 inline void CPtiQwertyKeyMappings::SetFlag(TInt aFlag)
00458         {
00459         iFlags |= aFlag;        
00460         }
00461 
00462 inline void CPtiQwertyKeyMappings::ResetFlag(TInt aFlag)
00463         {       
00464         iFlags &= ~aFlag;       
00465         }
00466 
00467 
00468 inline TUint16 CPtiQwertyKeyMappings::VowelSequenceResult() const
00469         {
00470         return iVowelSeqResult;
00471         }
00472 
00473 
00474 inline void CPtiQwertyKeyMappings::ClearVowelSequence()
00475         {
00476         iLastKey = EPtiKeyNone;
00477         }
00478         
00479         
00480 inline TUint16 CPtiQwertyKeyMappings::DeadKeyRootChar() const
00481         {
00482         return iDeadKeyRootChar;        
00483         }
00484         
00485         
00486 inline TInt16 CPtiQwertyKeyMappings::DeadKey() const
00487         {
00488         return iDeadKey;        
00489         }       
00490 
00491 
00492 inline void CPtiQwertyKeyMappings::ClearDeadKey()
00493         {
00494         iDeadKey = 0;
00495         }
00496         
00497 #start_since SINCE_3_1_SDK      
00498 inline void CPtiQwertyKeyMappings::ClearLastChar()
00499         {
00500         iExtension->iLastChar = 0;
00501         }
00502 
00503         
00504 inline void CPtiQwertyKeyMappings::SetLastChar(TInt aLastChar)
00505         {
00506         iExtension->iLastChar = (TUint16)aLastChar;
00507         }
00508         
00509         
00510 inline TInt CPtiQwertyKeyMappings::GetLastChar() const
00511         {
00512         return iExtension->iLastChar;
00513         }
00514         
00515         
00516 inline TUint16 CPtiQwertyKeyMappings::ReplacedCharacter()
00517         {       
00518         return iExtension->iReplaced;
00519         }
00520 
00521                 
00522 inline void CPtiQwertyKeyMappings::SetLastKey(TPtiKey aKey)
00523         {
00524         iLastKey = aKey;        
00525         }
00526                 
00527 
00528 inline TPtiTextCase CPtiQwertyKeyMappings::VowelCase() const
00529         {
00530         return iExtension->iVowelCase;
00531         }
00532 
00533 
00534 inline void CPtiQwertyKeyMappings::ResetVietnameseVowelSequenceAndToneMarks()
00535         {
00536         iExtension->iLastChar = 0;
00537         iExtension->iReplaced = 0;
00538         iExtension->iLastTone = 0;
00539         iVowelSeqResult = 0;
00540         iLastKey = EPtiKeyNone;
00541         ResetFlag(EVowelSeqFlag);
00542         }
00543         
00544 
00545 inline TPtiKey CPtiQwertyKeyMappings::LastKey() const
00546         {
00547         return iLastKey;
00548         }
00549 #end_since SINCE_3_1_SDK
00550         
00551         
00552 // _PTI_KEY_MAPPINGS_H
00553 #endif
00554 

Copyright © Nokia Corporation 2001-2007
Back to top