textinput/ptienginev2/inc/PtiEngine.inl
changeset 0 eb1f2e154e89
child 11 c8fb4cf7b3ae
equal deleted inserted replaced
-1:000000000000 0:eb1f2e154e89
       
     1 /*
       
     2 * Copyright (c) 2003 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:   Inline methods for CPtiEngineImpl
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "PtiCore.h"
       
    21 #include "PtiLanguage.h"
       
    22 
       
    23 // ---------------------------------------------------------------------------
       
    24 // CPtiEngineImpl::IsCoreForInputMode
       
    25 // 
       
    26 // ---------------------------------------------------------------------------
       
    27 // 
       
    28 inline TBool CPtiEngineImpl::IsCoreForInputMode(TPtiEngineInputMode aMode) const
       
    29 	{
       
    30 	if ((iCurrentLanguage) && (iCurrentLanguage->GetCore(aMode)))
       
    31 		{
       
    32 		return ETrue;
       
    33 		}
       
    34 
       
    35 	return EFalse;
       
    36 	}
       
    37 
       
    38 // ---------------------------------------------------------------------------
       
    39 // CPtiEngineImpl::IsCore
       
    40 // 
       
    41 // ---------------------------------------------------------------------------
       
    42 // 
       
    43 inline TBool CPtiEngineImpl::IsCore() const
       
    44 	{
       
    45 	if ((iCurrentLanguage) && (iCurrentLanguage->GetCore(iInputMode)))
       
    46 		{
       
    47 		return ETrue;
       
    48 		}
       
    49 
       
    50 	return EFalse;
       
    51 	}
       
    52 
       
    53 // ---------------------------------------------------------------------------
       
    54 // CPtiEngineImpl::Core
       
    55 // 
       
    56 // ---------------------------------------------------------------------------
       
    57 //    
       
    58 inline CPtiCore* CPtiEngineImpl::Core() const
       
    59 	{
       
    60 	return static_cast<CPtiCore*>(iCurrentLanguage->GetCore(iInputMode));
       
    61 	}
       
    62 
       
    63 // ---------------------------------------------------------------------------
       
    64 // CPtiEngineImpl::CoreForInputMode
       
    65 // 
       
    66 // ---------------------------------------------------------------------------
       
    67 //    
       
    68 inline CPtiCore* CPtiEngineImpl::CoreForInputMode(TPtiEngineInputMode aMode) const
       
    69 	{
       
    70 	return static_cast<CPtiCore*>(iCurrentLanguage->GetCore(aMode));
       
    71 	}
       
    72 
       
    73 // ---------------------------------------------------------------------------
       
    74 // CPtiEngineImpl::CurrentLanguage
       
    75 // 
       
    76 // ---------------------------------------------------------------------------
       
    77 //    
       
    78 inline MPtiLanguage* CPtiEngineImpl::CurrentLanguage() 
       
    79 	{
       
    80 	return iCurrentLanguage;
       
    81 	}
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CPtiEngineImpl::CurrentWord
       
    85 // 
       
    86 // ---------------------------------------------------------------------------
       
    87 //    
       
    88 inline TPtrC CPtiEngineImpl::CurrentWord()
       
    89 	{
       
    90 	return iTextBuffer;	
       
    91 	}
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CPtiEngineImpl::InputMode
       
    95 // 
       
    96 // ---------------------------------------------------------------------------
       
    97 //    
       
    98 inline TPtiEngineInputMode CPtiEngineImpl::InputMode() const
       
    99 	{
       
   100 	return iInputMode;
       
   101 	}
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CPtiEngineImpl::SetCase
       
   105 // 
       
   106 // ---------------------------------------------------------------------------
       
   107 //    
       
   108 inline void CPtiEngineImpl::SetCase(TPtiTextCase aCase)
       
   109 	{
       
   110 	iCase = aCase;
       
   111 	}
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CPtiEngineImpl::Case
       
   115 // 
       
   116 // ---------------------------------------------------------------------------
       
   117 //    
       
   118 inline TPtiTextCase CPtiEngineImpl::Case() const
       
   119 	{
       
   120 	return iCase;
       
   121 	}
       
   122 
       
   123 // ---------------------------------------------------------------------------
       
   124 // CPtiEngineImpl::NumberOfLanguages
       
   125 // 
       
   126 // ---------------------------------------------------------------------------
       
   127 //    
       
   128 inline TInt CPtiEngineImpl::NumberOfLanguages() const
       
   129 	{
       
   130 	// iLanguages is always available if CPtiEngineImpl::NewL succeeded,
       
   131 	// so this can be done safely.
       
   132 	return iLanguages->Count() - 1;  // Remove Numeric from count.
       
   133 	}
       
   134 
       
   135 // ---------------------------------------------------------------------------
       
   136 // CPtiEngineImpl::LastEnteredKey
       
   137 // 
       
   138 // ---------------------------------------------------------------------------
       
   139 //    
       
   140 inline TPtiKey CPtiEngineImpl::LastEnteredKey() const
       
   141 	{
       
   142 	if (iInputSequence.Length() > 0)
       
   143 		{
       
   144 		return (TPtiKey)iInputSequence[iInputSequence.Length() - 1];
       
   145 		}
       
   146 	return EPtiKeyNone;
       
   147 	}
       
   148 
       
   149 // ---------------------------------------------------------------------------
       
   150 // CPtiEngineImpl::CurrentInputSequence
       
   151 // 
       
   152 // ---------------------------------------------------------------------------
       
   153 //    
       
   154 inline TPtrC8 CPtiEngineImpl::CurrentInputSequence() const
       
   155 	{
       
   156 	return TPtrC8(iInputSequence);
       
   157 	}
       
   158 
       
   159 // ---------------------------------------------------------------------------
       
   160 // CPtiEngineImpl::SetObserver
       
   161 // 
       
   162 // ---------------------------------------------------------------------------
       
   163 //    
       
   164 inline void CPtiEngineImpl::SetObserver(MPtiObserver* aObserver)
       
   165 	{
       
   166 	iObserver = aObserver;
       
   167 	}
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CPtiEngineImpl::Observer
       
   171 // 
       
   172 // ---------------------------------------------------------------------------
       
   173 //    
       
   174 inline MPtiObserver* CPtiEngineImpl::Observer()
       
   175 	{
       
   176 	return iObserver;
       
   177 	}
       
   178 
       
   179 // ---------------------------------------------------------------------------
       
   180 // CPtiEngineImpl::ClearBuffers
       
   181 // 
       
   182 // ---------------------------------------------------------------------------
       
   183 //    
       
   184 inline void CPtiEngineImpl::ClearBuffers()
       
   185 	{
       
   186 	iInputSequence.Zero();
       
   187 	iTextBuffer.Zero();
       
   188 	iCaseBuffer.Zero();
       
   189 	}
       
   190 
       
   191 // ---------------------------------------------------------------------------
       
   192 // CPtiEngineImpl::IsChinese
       
   193 // 
       
   194 // ---------------------------------------------------------------------------
       
   195 //    
       
   196 inline TBool CPtiEngineImpl::IsChinese() const
       
   197 	{
       
   198 	if ((iCurrentLanguage) && ((iCurrentLanguage->LanguageCode() == ELangPrcChinese) ||
       
   199 		(iCurrentLanguage->LanguageCode() == ELangTaiwanChinese) ||
       
   200 		(iCurrentLanguage->LanguageCode() == ELangHongKongChinese)))
       
   201 		{
       
   202 		return ETrue;
       
   203 		}
       
   204 
       
   205 	return EFalse;
       
   206 	}
       
   207 
       
   208 // ---------------------------------------------------------------------------
       
   209 // CPtiEngineImpl::IsToneMarkOrSeparator
       
   210 // 
       
   211 // ---------------------------------------------------------------------------
       
   212 //    
       
   213 inline TBool CPtiEngineImpl::IsToneMarkOrSeparator(TInt aChar) const
       
   214 	{
       
   215 	if (iInputMode == EPtiEngineZhuyinByPhrase || 
       
   216 	        iInputMode == EPtiEngineZhuyinPhraseHalfQwerty)
       
   217 		{
       
   218 		if ((aChar == KPtiEngineChineseSeparator) ||
       
   219 			(aChar == KPtiZhuyinTone0) ||
       
   220 			(aChar == KPtiZhuyinTone1) ||
       
   221 			(aChar == KPtiZhuyinTone2) ||
       
   222 			(aChar == KPtiZhuyinTone3) ||
       
   223 			(aChar == KPtiZhuyinTone4))
       
   224 			{
       
   225 			return ETrue;
       
   226 			}
       
   227 		}
       
   228 	else
       
   229 		{
       
   230 		if ((aChar == KPtiEngineChineseSeparator) ||
       
   231 			(aChar == KPtiPinyinTone0) ||
       
   232 			(aChar == KPtiPinyinTone1) ||
       
   233 			(aChar == KPtiPinyinTone2) ||
       
   234 			(aChar == KPtiPinyinTone3) ||
       
   235 			(aChar == KPtiPinyinTone4))
       
   236 			{
       
   237 			return ETrue;
       
   238 			}
       
   239 		}
       
   240 		
       
   241 	return EFalse;
       
   242 	}
       
   243 
       
   244 // ---------------------------------------------------------------------------
       
   245 // CPtiEngineImpl::SupportsUserDictionaries
       
   246 // 
       
   247 // ---------------------------------------------------------------------------
       
   248 //    
       
   249 inline TBool CPtiEngineImpl::SupportsUserDictionaries(CPtiCore* aCore)
       
   250 	{
       
   251 	if (aCore)
       
   252 		{
       
   253 		MPtiCoreInfo *info = aCore->GetCoreInfo();
       
   254 		if (info &&	(info->CapsBits() & ESupportUserDictionaries))
       
   255 			{
       
   256 			return ETrue;
       
   257 			}
       
   258 		}
       
   259 
       
   260 	return EFalse;
       
   261 	}
       
   262 			
       
   263 // ---------------------------------------------------------------------------
       
   264 // CPtiEngineImpl::IsModeChineseQwerty
       
   265 // 
       
   266 // ---------------------------------------------------------------------------
       
   267 // 		
       
   268 inline TBool CPtiEngineImpl::IsModeChineseQwerty(TPtiEngineInputMode aMode) const
       
   269 	{
       
   270 	if ((aMode == EPtiEnginePinyinQwerty) ||	
       
   271 		(aMode == EPtiEnginePinyinPhraseQwerty) ||
       
   272 		(aMode == EPtiEngineStrokeQwerty) ||
       
   273 		(aMode == EPtiEngineStrokePhraseQwerty) ||		
       
   274 		(aMode == EPtiEngineZhuyinQwerty) ||
       
   275 		(aMode == EPtiEngineZhuyinPhraseQwerty) ||
       
   276 		(aMode == EPtiEngineNormalCangjieQwerty) ||
       
   277         (aMode == EPtiEngineEasyCangjieQwerty) ||
       
   278         (aMode == EPtiEngineInputModeZhuyinMiniQwertyFind)||
       
   279 		(aMode == EPtiEngineAdvCangjieQwerty)||
       
   280 		(aMode == EPtiEnginePinyinPhraseHalfQwerty)||
       
   281 		(aMode == EPtiEngineStrokePhraseHalfQwerty)||
       
   282 		(aMode == EPtiEngineZhuyinPhraseHalfQwerty))  				
       
   283 		{
       
   284 		return ETrue;	
       
   285 		}
       
   286 		
       
   287 	return EFalse;	
       
   288 	}
       
   289 		
       
   290 // ---------------------------------------------------------------------------
       
   291 // CPtiEngineImpl::AllowCapitalize
       
   292 // 
       
   293 // ---------------------------------------------------------------------------
       
   294 // 		
       
   295 inline TBool CPtiEngineImpl::AllowCapitalize(TUint16 aChar) const
       
   296 	{
       
   297 	if (iInputMode == EPtiEngineQwerty)
       
   298 		{
       
   299 		// Following lower case characters are behind shift in some 
       
   300 		// keymappings and should not be capitalized by PtiEngine.
       
   301 		if (Case() == EPtiCaseUpper &&
       
   302 		   (aChar == 0x00e9 || aChar == 0x00f9 || aChar == 0x00ec))		
       
   303 			{
       
   304 			return EFalse;
       
   305 			}				
       
   306 		}
       
   307 
       
   308 	return ETrue;	
       
   309 	}	
       
   310 	
       
   311 
       
   312 // ---------------------------------------------------------------------------
       
   313 // CPtiEngineImpl::CaseSequence
       
   314 // 
       
   315 // ---------------------------------------------------------------------------
       
   316 // 		
       
   317 inline TPtrC8 CPtiEngineImpl::CaseSequence()
       
   318     {
       
   319     return iCaseBuffer;	    
       
   320     }
       
   321 		
       
   322 // End of file