44
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 HWR engine
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
//FEP INCLUDES
|
|
19 |
#include <AknFepGlobalEnums.h>
|
|
20 |
#include <aknfeppeninputenums.h>
|
|
21 |
#include <PtiHwrRecognizer.h>
|
|
22 |
#include <e32property.h>
|
|
23 |
#include <AknFepInternalPSKeys.h>
|
|
24 |
#include <PtiDefs.h>
|
|
25 |
|
|
26 |
//USER INCLUDES
|
|
27 |
#include "peninputfingerhwrengine.h"
|
|
28 |
#include "peninputfingerhwrdatastore.h"
|
|
29 |
|
|
30 |
// CONSTANT DEFINITION HEADER
|
|
31 |
#include "peninputfingerhwrstoreconstants.h"
|
|
32 |
|
|
33 |
// ---------------------------------------------------------------------------
|
|
34 |
// SplitString()
|
|
35 |
// ---------------------------------------------------------------------------
|
|
36 |
//
|
|
37 |
static TInt SplitString( const TPtrC &aPtr,
|
|
38 |
TUint16 aSeperator,
|
|
39 |
RPointerArray<HBufC>& aStringArray )
|
|
40 |
{
|
|
41 |
// phrase input mode
|
|
42 |
TInt start = 0;
|
|
43 |
TInt length = 0;
|
|
44 |
|
|
45 |
for ( TInt i = 0; i < aPtr.Length(); i++ )
|
|
46 |
{
|
|
47 |
if ( aPtr[i] == aSeperator )
|
|
48 |
{
|
|
49 |
TPtrC segment( aPtr.Ptr() + start, length );
|
|
50 |
TRAP_IGNORE( aStringArray.AppendL( segment.AllocL() ) );
|
|
51 |
start += ( length + 1 );
|
|
52 |
length = 0;
|
|
53 |
}
|
|
54 |
else
|
|
55 |
{
|
|
56 |
length++;
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
if ( length )
|
|
61 |
{
|
|
62 |
TPtrC segm( aPtr.Ptr() + start, length );
|
|
63 |
TRAP_IGNORE( aStringArray.AppendL( segm.AllocL() ) );
|
|
64 |
}
|
|
65 |
|
|
66 |
return aStringArray.Count();
|
|
67 |
}
|
|
68 |
|
|
69 |
// ---------------------------------------------------------------------------
|
|
70 |
// Symbian constructor
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
CAknFepHwrEngine* CAknFepHwrEngine::NewL( CPtiEngine* aPtiEngine,
|
|
74 |
CPeninputFingerHwrDataStore* aOwner )
|
|
75 |
{
|
|
76 |
CAknFepHwrEngine* self = new ( ELeave ) CAknFepHwrEngine();
|
|
77 |
|
|
78 |
CleanupStack::PushL( self );
|
|
79 |
self->ConstructL( aPtiEngine, aOwner );
|
|
80 |
CleanupStack::Pop( self );//self
|
|
81 |
|
|
82 |
return self;
|
|
83 |
}
|
|
84 |
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
// destructor
|
|
87 |
// ---------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
CAknFepHwrEngine::~CAknFepHwrEngine()
|
|
90 |
{
|
|
91 |
if( iOwnPtiEngine )
|
|
92 |
{
|
|
93 |
delete iPtiEngine;
|
|
94 |
}
|
|
95 |
delete iCustomKeymap;
|
|
96 |
|
|
97 |
delete iIdle;
|
|
98 |
|
|
99 |
iNeedPermittedRanges.Close();
|
|
100 |
}
|
|
101 |
|
|
102 |
// ---------------------------------------------------------------------------
|
|
103 |
// Do recoginize by engine
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
//
|
|
106 |
void CAknFepHwrEngine::DoRecognizeL( const RArray<TPoint>& aTraceData,
|
|
107 |
RPointerArray<HBufC>& aCandidates )
|
|
108 |
{
|
|
109 |
if ( !iRecognizer)
|
|
110 |
{
|
|
111 |
DoIdleConstructL();
|
|
112 |
}
|
|
113 |
|
|
114 |
TPoint ctrlStrokeEndMark = iOwner->StrokeEndMarkFromControl();
|
|
115 |
|
|
116 |
if ( ctrlStrokeEndMark != iRecognizer->StrokeEndMark() )
|
|
117 |
{
|
|
118 |
ConvertStrokeEndMark( CONST_CAST( RArray<TPoint>&, aTraceData ),
|
|
119 |
iOwner->StrokeEndMarkFromControl(),
|
|
120 |
iRecognizer->StrokeEndMark() );
|
|
121 |
iOwner->SetStrokeEndMark(); // make control's stroke end mark info same to engine
|
|
122 |
}
|
|
123 |
|
|
124 |
aCandidates.ResetAndDestroy();
|
|
125 |
|
|
126 |
TInt primaryCount = iRecognizer->Recognize( aTraceData, aCandidates );
|
|
127 |
|
|
128 |
// filter recognized candidate, set start position for all ranges
|
|
129 |
TPtrC ptr( KSeparator );
|
|
130 |
|
|
131 |
// remove uncessary aux candidate, including range separator
|
|
132 |
for ( TInt i=0; i < aCandidates.Count(); i++ )
|
|
133 |
{
|
|
134 |
if ( aCandidates[i]->Compare( KGestureBackspace ) == 0 )
|
|
135 |
{
|
|
136 |
// convert backspace returned by engine, to make sure it display correctly.
|
|
137 |
*aCandidates[i] = KDisplayBackspace;
|
|
138 |
break;
|
|
139 |
}
|
|
140 |
}
|
|
141 |
|
|
142 |
// remove uncessary primary candidate
|
|
143 |
TInt totallyCount = aCandidates.Count();
|
|
144 |
TInt removePos = iTotalCandidateNum;
|
|
145 |
|
|
146 |
for ( TInt i = removePos; i < totallyCount; i++ )
|
|
147 |
{
|
|
148 |
delete aCandidates[removePos];
|
|
149 |
aCandidates.Remove( removePos );
|
|
150 |
}
|
|
151 |
|
|
152 |
// not allowing '-' to be the first char in chinese range
|
|
153 |
// not allowing '/' to be the first char in English and Number range
|
|
154 |
TPtrC dashPtr( KDash );
|
|
155 |
TPtrC solidusPtr( KSolidus );
|
|
156 |
if ( ( iPremaryRange == ERangeNative ) &&
|
|
157 |
( aCandidates[0]->Compare( dashPtr ) == 0 ) )
|
|
158 |
{
|
|
159 |
*aCandidates[0] = *aCandidates[1];
|
|
160 |
*aCandidates[1] = dashPtr;
|
|
161 |
}
|
|
162 |
else if ( ( ( iPremaryRange == ERangeEnglish ) ||
|
|
163 |
( iPremaryRange == ERangeNumber ) )
|
|
164 |
&& ( aCandidates[0]->Compare( solidusPtr ) == 0 ) )
|
|
165 |
{
|
|
166 |
*aCandidates[0] = *aCandidates[1];
|
|
167 |
*aCandidates[1] = solidusPtr;
|
|
168 |
}
|
|
169 |
}
|
|
170 |
|
|
171 |
|
|
172 |
// ---------------------------------------------------------------------------
|
|
173 |
// Do predictive using trigger string
|
|
174 |
// ---------------------------------------------------------------------------
|
|
175 |
//
|
|
176 |
void CAknFepHwrEngine::DoPredictiveL( const TDesC& aTriggerStr,
|
|
177 |
RPointerArray<HBufC>& aPredictives,
|
|
178 |
TBool aNextPage )
|
|
179 |
{
|
|
180 |
// predictive only valid for Chinese
|
|
181 |
if ( ( iLanguage != ELangPrcChinese ) &&
|
|
182 |
( iLanguage != ELangTaiwanChinese ) &&
|
|
183 |
( iLanguage != ELangHongKongChinese ) )
|
|
184 |
{
|
|
185 |
return;
|
|
186 |
}
|
|
187 |
|
|
188 |
// activate correct pti language according to given language
|
|
189 |
if ( !aNextPage )
|
|
190 |
{
|
|
191 |
iPtiEngine->SetCandidatePageLength( KPredictiveCountPerPage );
|
|
192 |
|
|
193 |
aPredictives.ResetAndDestroy();
|
|
194 |
if( !iPtiEngine->SetPredictiveChineseChar( aTriggerStr ) )
|
|
195 |
{
|
|
196 |
return;
|
|
197 |
}
|
|
198 |
}
|
|
199 |
else
|
|
200 |
{
|
|
201 |
if ( !iPtiEngine->NextCandidatePage() )
|
|
202 |
{
|
|
203 |
return;
|
|
204 |
}
|
|
205 |
}
|
|
206 |
|
|
207 |
TPtrC ptr = iPtiEngine->CandidatePage();
|
|
208 |
|
|
209 |
if ( ( iPtiEngine->InputMode() == EPtiEnginePinyinVkb ) ||
|
|
210 |
( iPtiEngine->InputMode() == EPtiEngineStrokeByPhrase ) ||
|
|
211 |
( iPtiEngine->InputMode() == EPtiEngineZhuyinVkb ) )
|
|
212 |
{
|
|
213 |
SplitString( ptr, KSegment, aPredictives );
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
217 |
TInt predictiveCandidateNum = ptr.Length();
|
|
218 |
|
|
219 |
for ( TInt i=0; i<predictiveCandidateNum; i++ )
|
|
220 |
{
|
|
221 |
aPredictives.Append( ptr.Mid( i,1 ).AllocL() );
|
|
222 |
}
|
|
223 |
}
|
|
224 |
}
|
|
225 |
|
|
226 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
227 |
// ---------------------------------------------------------------------------
|
|
228 |
// Do predictive for auto complete in English range
|
|
229 |
// ---------------------------------------------------------------------------
|
|
230 |
//
|
|
231 |
void CAknFepHwrEngine::DoEngPredictiveL( const TDesC& aTriggerStr,
|
|
232 |
RPointerArray<HBufC>& aPredictives)
|
|
233 |
{
|
|
234 |
|
|
235 |
aPredictives.ResetAndDestroy();
|
|
236 |
CDesCArray* cands = new (ELeave) CDesCArrayFlat(16);
|
|
237 |
CleanupStack::PushL(cands);
|
|
238 |
iPtiEngine->ClearCurrentWord();
|
|
239 |
iPtiEngine->SetCurrentWord(aTriggerStr);
|
|
240 |
|
|
241 |
// Get auto complete candidates
|
|
242 |
iPtiEngine->GetCandidateListL(*cands);
|
|
243 |
for ( TInt i = 1; i < cands->Count(); i++ )
|
|
244 |
{
|
|
245 |
// Don't show the first predictive
|
|
246 |
aPredictives.Append( (*cands)[i].AllocL() );
|
|
247 |
}
|
|
248 |
|
|
249 |
CleanupStack::PopAndDestroy( cands ); //cands
|
|
250 |
}
|
|
251 |
#endif
|
|
252 |
|
|
253 |
// ---------------------------------------------------------------------------
|
|
254 |
// Set primary and auxiliary ranges for hwr engine
|
|
255 |
// ---------------------------------------------------------------------------
|
|
256 |
//
|
|
257 |
void CAknFepHwrEngine::SetRanges( const RArray<TInt>& aPermittedRanges )
|
|
258 |
{
|
|
259 |
TRAP_IGNORE( SetRangesL( aPermittedRanges ) );
|
|
260 |
}
|
|
261 |
|
|
262 |
// ---------------------------------------------------------------------------
|
|
263 |
// Set primary and auxiliary ranges for hwr engine
|
|
264 |
// ---------------------------------------------------------------------------
|
|
265 |
//
|
|
266 |
void CAknFepHwrEngine::SetRangesL( const RArray<TInt>& aPermittedRanges )
|
|
267 |
{
|
|
268 |
ASSERT( aPermittedRanges.Count() > 0 );
|
|
269 |
|
|
270 |
if ( !iRecognizer )
|
|
271 |
{
|
|
272 |
iNeedPermittedRanges.Reset();
|
|
273 |
|
|
274 |
for ( TInt i = 0; i < aPermittedRanges.Count(); i++ )
|
|
275 |
{
|
|
276 |
iNeedPermittedRanges.Append( aPermittedRanges[i] );
|
|
277 |
}
|
|
278 |
|
|
279 |
iNeedSetRange = ETrue;
|
|
280 |
return;
|
|
281 |
}
|
|
282 |
else
|
|
283 |
{
|
|
284 |
iPremaryRange = aPermittedRanges[0];
|
|
285 |
iRangeCount = aPermittedRanges.Count();
|
|
286 |
|
|
287 |
SetCandidatesMaxCount( KCandidateCount );
|
|
288 |
|
|
289 |
|
|
290 |
TRecognitionRange range;
|
|
291 |
SetRecognitionRange( aPermittedRanges[0], range );
|
|
292 |
|
|
293 |
|
|
294 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
295 |
if(iPremaryRange == ERangeEnglish)
|
|
296 |
{
|
|
297 |
iPtiEngine->ActivateLanguageL( ELangEnglish, EPtiEngineQwertyPredictive );
|
|
298 |
iPtiEngine->HandleCommandL( EPtiCommandEnableAutoCompletion );
|
|
299 |
}
|
|
300 |
else
|
|
301 |
{
|
|
302 |
iPtiEngine->HandleCommandL( EPtiCommandDisableAutoCompletion );
|
|
303 |
|
|
304 |
switch ( iLanguage )
|
|
305 |
{
|
|
306 |
case ELangPrcChinese:
|
|
307 |
{
|
|
308 |
if ( iPtiEngine->ActivateLanguageL( iLanguage, EPtiEnginePinyinVkb ) != KErrNone )
|
|
309 |
{
|
|
310 |
iPtiEngine->ActivateLanguageL( iLanguage, EPtiEnginePinyin );
|
|
311 |
}
|
|
312 |
}
|
|
313 |
break;
|
|
314 |
case ELangHongKongChinese:
|
|
315 |
{
|
|
316 |
if ( iPtiEngine->ActivateLanguageL( iLanguage, EPtiEngineStrokeByPhrase ) != KErrNone )
|
|
317 |
{
|
|
318 |
iPtiEngine->ActivateLanguageL( ELangHongKongChinese, EPtiEngineStroke );
|
|
319 |
}
|
|
320 |
}
|
|
321 |
break;
|
|
322 |
case ELangTaiwanChinese:
|
|
323 |
{
|
|
324 |
if ( iPtiEngine->ActivateLanguageL( iLanguage, EPtiEngineZhuyinVkb ) != KErrNone )
|
|
325 |
{
|
|
326 |
iPtiEngine->ActivateLanguageL( ELangTaiwanChinese, EPtiEngineZhuyin );
|
|
327 |
}
|
|
328 |
}
|
|
329 |
break;
|
|
330 |
default:
|
|
331 |
return;
|
|
332 |
}
|
|
333 |
}
|
|
334 |
#endif //RD_INTELLIGENT_TEXT_INPUT
|
|
335 |
|
|
336 |
iRecognizer->SetRange( range );
|
|
337 |
SetCase( iCase );
|
|
338 |
}
|
|
339 |
}
|
|
340 |
|
|
341 |
|
|
342 |
// ---------------------------------------------------------------------------------------------
|
|
343 |
// Set case
|
|
344 |
// ---------------------------------------------------------------------------------------------
|
|
345 |
//
|
|
346 |
void CAknFepHwrEngine::SetCase( const TInt aCase )
|
|
347 |
{
|
|
348 |
iCase = aCase;
|
|
349 |
|
|
350 |
if ( !iRecognizer )
|
|
351 |
{
|
|
352 |
iNeedSetCase = ETrue;
|
|
353 |
}
|
|
354 |
else
|
|
355 |
{
|
|
356 |
// set letter to lower first when LowerCase
|
|
357 |
// set letter to upper first when UpperCase and TextCase
|
|
358 |
if ( aCase == ECaseLower )
|
|
359 |
{
|
|
360 |
iRecognizer->SetFirstLetterOrder( ELowerFirst );
|
|
361 |
}
|
|
362 |
else
|
|
363 |
{
|
|
364 |
iRecognizer->SetFirstLetterOrder( EUpperFirst );
|
|
365 |
}
|
|
366 |
}
|
|
367 |
}
|
|
368 |
|
|
369 |
// ---------------------------------------------------------------------------------------------
|
|
370 |
// Set number mode for hwr engine
|
|
371 |
// ---------------------------------------------------------------------------------------------
|
|
372 |
//
|
|
373 |
void CAknFepHwrEngine::SetNumberMode( const TAknEditorNumericKeymap& aNumberMode )
|
|
374 |
{
|
|
375 |
iNumberMode = aNumberMode;
|
|
376 |
|
|
377 |
if ( !iRecognizer )
|
|
378 |
{
|
|
379 |
iNeedSetNumberMode = ETrue;
|
|
380 |
}
|
|
381 |
else
|
|
382 |
{
|
|
383 |
iRecognizer->SetNumberMode( aNumberMode );
|
|
384 |
if( aNumberMode != EKeymapFromResource )
|
|
385 |
{
|
|
386 |
ResetCustomKeyMap();
|
|
387 |
}
|
|
388 |
}
|
|
389 |
}
|
|
390 |
|
|
391 |
// ---------------------------------------------------------------------------------------------
|
|
392 |
// Get stroke end mark from hwr engine
|
|
393 |
// ---------------------------------------------------------------------------------------------
|
|
394 |
//
|
|
395 |
TPoint CAknFepHwrEngine::StrokeEndMark() const
|
|
396 |
{
|
|
397 |
if ( iRecognizer )
|
|
398 |
{
|
|
399 |
return iRecognizer->StrokeEndMark();
|
|
400 |
}
|
|
401 |
else
|
|
402 |
{
|
|
403 |
return TPoint( KDefaultStrokeEndMarkX, KDefaultStrokeEndMarkY );
|
|
404 |
}
|
|
405 |
}
|
|
406 |
|
|
407 |
// ---------------------------------------------------------------------------------------------
|
|
408 |
// Set primary candidate num for hwr engine
|
|
409 |
// ---------------------------------------------------------------------------------------------
|
|
410 |
//
|
|
411 |
TInt CAknFepHwrEngine::SetPrimaryCandidateNum( const TInt aNum )
|
|
412 |
{
|
|
413 |
if ( iRecognizer )
|
|
414 |
{
|
|
415 |
return iRecognizer->SetCandidateNum( aNum );
|
|
416 |
}
|
|
417 |
else
|
|
418 |
{
|
|
419 |
return KErrGeneral;
|
|
420 |
}
|
|
421 |
}
|
|
422 |
|
|
423 |
// ---------------------------------------------------------------------------------------------
|
|
424 |
// Set total candidate num that should be shown
|
|
425 |
// ---------------------------------------------------------------------------------------------
|
|
426 |
//
|
|
427 |
void CAknFepHwrEngine::SetCandidatesMaxCount( const TInt aCount )
|
|
428 |
{
|
|
429 |
iTotalCandidateNum = aCount;
|
|
430 |
}
|
|
431 |
|
|
432 |
// ---------------------------------------------------------------------------------------------
|
|
433 |
// Set language
|
|
434 |
// ---------------------------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
void CAknFepHwrEngine::SetLanguageL( const TInt aLanguage )
|
|
437 |
{
|
|
438 |
if ( ( iLanguage == aLanguage ) ||
|
|
439 |
( aLanguage != ELangPrcChinese &&
|
|
440 |
aLanguage != ELangHongKongChinese &&
|
|
441 |
aLanguage != ELangTaiwanChinese ) )
|
|
442 |
{
|
|
443 |
return;
|
|
444 |
}
|
|
445 |
|
|
446 |
iLanguage = aLanguage;
|
|
447 |
|
|
448 |
switch ( iLanguage )
|
|
449 |
{
|
|
450 |
case ELangPrcChinese:
|
|
451 |
{
|
|
452 |
if ( iPtiEngine->ActivateLanguageL( iLanguage, EPtiEnginePinyinVkb ) != KErrNone )
|
|
453 |
{
|
|
454 |
iPtiEngine->ActivateLanguageL( iLanguage, EPtiEnginePinyin );
|
|
455 |
}
|
|
456 |
}
|
|
457 |
break;
|
|
458 |
case ELangHongKongChinese:
|
|
459 |
if ( iPtiEngine->ActivateLanguageL( iLanguage, EPtiEngineStrokeByPhrase ) != KErrNone )
|
|
460 |
{
|
|
461 |
iPtiEngine->ActivateLanguageL( ELangHongKongChinese, EPtiEngineStroke );
|
|
462 |
}
|
|
463 |
break;
|
|
464 |
case ELangTaiwanChinese:
|
|
465 |
if ( iPtiEngine->ActivateLanguageL( iLanguage, EPtiEngineZhuyinVkb ) != KErrNone )
|
|
466 |
{
|
|
467 |
iPtiEngine->ActivateLanguageL( ELangTaiwanChinese, EPtiEngineZhuyin );
|
|
468 |
}
|
|
469 |
break;
|
|
470 |
default:
|
|
471 |
return;
|
|
472 |
}
|
|
473 |
|
|
474 |
iRecognizer = NULL;
|
|
475 |
|
|
476 |
if( !iIdle->IsActive() )
|
|
477 |
{
|
|
478 |
iIdle->Start( TCallBack( BackgroundTaskL, this ) );
|
|
479 |
}
|
|
480 |
}
|
|
481 |
|
|
482 |
// ---------------------------------------------------------------------------
|
|
483 |
// Set recognition range for hwr engine
|
|
484 |
// ---------------------------------------------------------------------------
|
|
485 |
//
|
|
486 |
void CAknFepHwrEngine::SetCustomKeymapL( const TDesC& aKeyMap )
|
|
487 |
{
|
|
488 |
ResetCustomKeyMap();
|
|
489 |
|
|
490 |
iCustomKeymap = HBufC::NewL( aKeyMap.Length() + KNumberString().Length() );
|
|
491 |
iCustomKeymap->Des().Copy( KNumberString() );
|
|
492 |
iCustomKeymap->Des().Append( aKeyMap );
|
|
493 |
}
|
|
494 |
|
|
495 |
// ---------------------------------------------------------------------------
|
|
496 |
// Set recognition range for hwr engine
|
|
497 |
// ---------------------------------------------------------------------------
|
|
498 |
//
|
|
499 |
void CAknFepHwrEngine::ResetCustomKeyMap()
|
|
500 |
{
|
|
501 |
delete iCustomKeymap;
|
|
502 |
iCustomKeymap = NULL;
|
|
503 |
}
|
|
504 |
|
|
505 |
// ---------------------------------------------------------------------------------------------
|
|
506 |
// CAknFepHwrEngine::BackgroundConstructL
|
|
507 |
// Do background construct.
|
|
508 |
// ---------------------------------------------------------------------------------------------
|
|
509 |
//
|
|
510 |
TBool CAknFepHwrEngine::BackgroundTaskL( TAny* aPtr )
|
|
511 |
{
|
|
512 |
CAknFepHwrEngine* self = static_cast<CAknFepHwrEngine*>( aPtr );
|
|
513 |
self->DoIdleConstructL();
|
|
514 |
return EFalse;
|
|
515 |
}
|
|
516 |
|
|
517 |
// ---------------------------------------------------------------------------
|
|
518 |
// Set hand writing area size
|
|
519 |
// ---------------------------------------------------------------------------
|
|
520 |
//
|
|
521 |
TInt CAknFepHwrEngine::SetInputAreaSize(TSize& aSize)
|
|
522 |
{
|
|
523 |
return iRecognizer ? iRecognizer->SetInputAreaSize(aSize) : KErrNotFound;
|
|
524 |
}
|
|
525 |
|
|
526 |
// ---------------------------------------------------------------------------
|
|
527 |
// Set hand writing screen size
|
|
528 |
// ---------------------------------------------------------------------------
|
|
529 |
//
|
|
530 |
TInt CAknFepHwrEngine::SetScreenSize(TSize& aSize)
|
|
531 |
{
|
|
532 |
return iRecognizer ? iRecognizer->SetScreenSize(aSize) : KErrNotFound;
|
|
533 |
}
|
|
534 |
|
|
535 |
// ---------------------------------------------------------------------------
|
|
536 |
// C++ constructor
|
|
537 |
// ---------------------------------------------------------------------------
|
|
538 |
//
|
|
539 |
CAknFepHwrEngine::CAknFepHwrEngine()
|
|
540 |
{
|
|
541 |
iNeedSetNumberMode = EFalse;
|
|
542 |
iNeedSetCase = EFalse;
|
|
543 |
iNeedSetRange = EFalse;
|
|
544 |
iRecognizer = NULL;
|
|
545 |
iOwnPtiEngine = EFalse;
|
|
546 |
}
|
|
547 |
|
|
548 |
// ---------------------------------------------------------------------------
|
|
549 |
// Second phase constructor
|
|
550 |
// ---------------------------------------------------------------------------
|
|
551 |
//
|
|
552 |
void CAknFepHwrEngine::ConstructL( CPtiEngine* aPtiEngine,
|
|
553 |
CPeninputFingerHwrDataStore* aOwner )
|
|
554 |
{
|
|
555 |
if( !aPtiEngine )
|
|
556 |
{
|
|
557 |
iPtiEngine = CPtiEngine::NewL( ETrue );
|
|
558 |
iOwnPtiEngine = ETrue;
|
|
559 |
}
|
|
560 |
else
|
|
561 |
{
|
|
562 |
iPtiEngine = aPtiEngine;
|
|
563 |
}
|
|
564 |
|
|
565 |
iIdle = CIdle::NewL( CActive::EPriorityIdle );
|
|
566 |
iOwner = aOwner;
|
|
567 |
}
|
|
568 |
|
|
569 |
// ---------------------------------------------------------------------------
|
|
570 |
// Set recognition range for hwr engine
|
|
571 |
// ---------------------------------------------------------------------------
|
|
572 |
//
|
|
573 |
void CAknFepHwrEngine::SetRecognitionRange( const TInt aRange,
|
|
574 |
TRecognitionRange& aRecognitionRange )
|
|
575 |
{
|
|
576 |
aRecognitionRange.iLanguage = TLanguage( iLanguage );
|
|
577 |
|
|
578 |
switch ( aRange )
|
|
579 |
{
|
|
580 |
case ERangeNative:
|
|
581 |
{
|
|
582 |
if ( iLanguage == ELangPrcChinese )
|
|
583 |
{
|
|
584 |
aRecognitionRange.iSubRange = EPtiRangePRCChinese;
|
|
585 |
}
|
|
586 |
else if ( iLanguage == ELangHongKongChinese )
|
|
587 |
{
|
|
588 |
aRecognitionRange.iSubRange = EPtiRangeHKChinese;
|
|
589 |
}
|
|
590 |
else
|
|
591 |
{
|
|
592 |
aRecognitionRange.iSubRange = EPtiRangeTWChinese;
|
|
593 |
}
|
|
594 |
}
|
|
595 |
break;
|
|
596 |
case ERangeEnglish:
|
|
597 |
{
|
|
598 |
aRecognitionRange.iLanguage = ELangEnglish;
|
|
599 |
aRecognitionRange.iSubRange = EPtiRangeLatin;
|
|
600 |
}
|
|
601 |
break;
|
|
602 |
case ERangeNumber:
|
|
603 |
{
|
|
604 |
aRecognitionRange.iSubRange = EPtiRangeNumber;
|
|
605 |
}
|
|
606 |
break;
|
|
607 |
default:
|
|
608 |
break;
|
|
609 |
}
|
|
610 |
}
|
|
611 |
|
|
612 |
// ---------------------------------------------------------------------------------------------
|
|
613 |
// CAknFepHwrEngine::DoIdleConstructL
|
|
614 |
// Do background construct.
|
|
615 |
// ---------------------------------------------------------------------------------------------
|
|
616 |
//
|
|
617 |
void CAknFepHwrEngine::DoIdleConstructL()
|
|
618 |
{
|
|
619 |
if ( iRecognizer )
|
|
620 |
{
|
|
621 |
return;
|
|
622 |
}
|
|
623 |
|
|
624 |
iRecognizer = iPtiEngine->GetHwrRecognizerL( TLanguage( iLanguage ) );
|
|
625 |
|
|
626 |
iOwner->SetStrokeEndMark();
|
|
627 |
SetPrimaryCandidateNum( KPremaryCandidateCount );
|
|
628 |
|
|
629 |
if ( iNeedSetRange )
|
|
630 |
{
|
|
631 |
SetRanges( iNeedPermittedRanges );
|
|
632 |
iNeedPermittedRanges.Reset();
|
|
633 |
iNeedSetRange = EFalse;
|
|
634 |
}
|
|
635 |
|
|
636 |
if ( iNeedSetCase )
|
|
637 |
{
|
|
638 |
SetCase( iCase );
|
|
639 |
iNeedSetCase = EFalse;
|
|
640 |
}
|
|
641 |
|
|
642 |
if ( iNeedSetNumberMode )
|
|
643 |
{
|
|
644 |
SetNumberMode( TAknEditorNumericKeymap( iNumberMode ) );
|
|
645 |
iNeedSetNumberMode = EFalse;
|
|
646 |
}
|
|
647 |
}
|
|
648 |
|
|
649 |
// ---------------------------------------------------------------------------
|
|
650 |
// Convert stroke end mark
|
|
651 |
// ---------------------------------------------------------------------------
|
|
652 |
//
|
|
653 |
void CAknFepHwrEngine::ConvertStrokeEndMark( RArray<TPoint>& aTraceData,
|
|
654 |
TPoint aPnt1, TPoint aPnt2 )
|
|
655 |
{
|
|
656 |
TInt count = aTraceData.Count();
|
|
657 |
|
|
658 |
for ( TInt i = 0; i < count; i++ )
|
|
659 |
{
|
|
660 |
if ( aTraceData[i] == aPnt1 )
|
|
661 |
{
|
|
662 |
aTraceData.Remove( i );
|
|
663 |
aTraceData.Insert( aPnt2, i );
|
|
664 |
}
|
|
665 |
}
|
|
666 |
}
|
|
667 |
|
|
668 |
// ---------------------------------------------------------------------------
|
|
669 |
// Reset Keyboard type to original type
|
|
670 |
// ---------------------------------------------------------------------------
|
|
671 |
//
|
|
672 |
void CAknFepHwrEngine::ResetKeyboardType()
|
|
673 |
{
|
|
674 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
675 |
RProperty::Set( KPSUidAknFep, KAknFepVirtualKeyboardType, iKeyboardType );
|
|
676 |
#endif
|
|
677 |
}
|
|
678 |
|
|
679 |
// ---------------------------------------------------------------------------
|
|
680 |
// Set Keyboard type to Qwerty
|
|
681 |
// ---------------------------------------------------------------------------
|
|
682 |
//
|
|
683 |
void CAknFepHwrEngine::SetKeyboardToQwerty()
|
|
684 |
{
|
|
685 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
686 |
RProperty::Set( KPSUidAknFep, KAknFepVirtualKeyboardType, EPtiKeyboardQwerty4x12 );
|
|
687 |
#endif
|
|
688 |
}
|
|
689 |
|
|
690 |
// ---------------------------------------------------------------------------
|
|
691 |
// Get Keyboard type
|
|
692 |
// ---------------------------------------------------------------------------
|
|
693 |
//
|
|
694 |
void CAknFepHwrEngine::GetKeyboardType()
|
|
695 |
{
|
|
696 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
697 |
RProperty::Get( KPSUidAknFep, KAknFepVirtualKeyboardType, iKeyboardType );
|
|
698 |
#endif
|
|
699 |
}
|
|
700 |
|
|
701 |
|
|
702 |
|
|
703 |
//End Of File
|