|
1 /* |
|
2 * Copyright (c) 2007 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: CTruiEngine class of TrainingUI |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_TRUIENGINE_H |
|
20 #define C_TRUIENGINE_H |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <badesca.h> |
|
24 |
|
25 const TInt KShortcutMaxLength = 164; |
|
26 class CPtiEngine; |
|
27 class MTruiEngine; |
|
28 class TLanguageRelation; |
|
29 class CEikonEnv; |
|
30 |
|
31 /** |
|
32 * CTruiEngine view class. |
|
33 * |
|
34 */ |
|
35 class CTruiEngine : public CBase |
|
36 { |
|
37 public: |
|
38 /** |
|
39 * Two phase construction. |
|
40 * |
|
41 * @return Pointer to CTruiEngine's instance |
|
42 */ |
|
43 static CTruiEngine* NewL( CEikonEnv* aEikonEnv ); |
|
44 |
|
45 /** |
|
46 * Two phase construction. |
|
47 * |
|
48 * @return Pointer to CTruiEngine's instance |
|
49 */ |
|
50 static CTruiEngine* NewLC( CEikonEnv* aEikonEnv ); |
|
51 |
|
52 /** |
|
53 * Destroy the object and release all memory objects |
|
54 */ |
|
55 virtual ~CTruiEngine(); |
|
56 |
|
57 /** |
|
58 * Get the current input language |
|
59 * |
|
60 * @return Current input language |
|
61 */ |
|
62 inline TLanguage InputLanguage() const; |
|
63 |
|
64 //Language Script |
|
65 /** |
|
66 * Set current language script |
|
67 * |
|
68 * @param aIndex The index of language script in the array named iSupportedScript |
|
69 */ |
|
70 void SetLanguageScriptByIndexL( TInt aIndex ); |
|
71 |
|
72 /** |
|
73 * Get name list of all supported language scripts |
|
74 * |
|
75 * @return CDesCArray* The name list |
|
76 */ |
|
77 inline const CDesCArray* LanguageScriptName(); |
|
78 |
|
79 /** |
|
80 * Get id of supported language script |
|
81 * |
|
82 * @return RArray<Tint> list of the script id |
|
83 */ |
|
84 inline const RArray<TInt>& SupportedLanguageScript(); |
|
85 |
|
86 /** |
|
87 * Get enum ID of the current language script |
|
88 * |
|
89 * @return ID of the current language |
|
90 */ |
|
91 inline TInt CurrentLanguageScript() const; |
|
92 |
|
93 //Character Range |
|
94 /** |
|
95 * Set current character range |
|
96 * |
|
97 * @param aIndex The index of character range in the array named iSupportedRange |
|
98 */ |
|
99 void SetCharacterRangeByIndexL( TInt aIndex ); |
|
100 |
|
101 /** |
|
102 * Get name list of all supported character range |
|
103 * |
|
104 * @return CDesCArray* The name list |
|
105 */ |
|
106 CDesCArray* GetCharacterRangeName(); |
|
107 |
|
108 /** |
|
109 * Get enum ID of the current character range |
|
110 * |
|
111 * @return TInt ID of the character range |
|
112 */ |
|
113 TInt GetCurrentCharacterRange(); |
|
114 |
|
115 /** |
|
116 * Get enum ID of the supported character ranges |
|
117 * |
|
118 * @return Reference to the array saving IDs of the supported range |
|
119 */ |
|
120 inline const RArray<TInt>& GetCurrentSupportedRangesId(); |
|
121 |
|
122 /** |
|
123 * Transform character range to engine's subrange |
|
124 */ |
|
125 void SetSubrange(); |
|
126 |
|
127 //Character Set |
|
128 |
|
129 /** |
|
130 * Get current character set |
|
131 * |
|
132 * @return HBufC* The string contained character set |
|
133 */ |
|
134 const HBufC* CharacterSet(); |
|
135 |
|
136 /** |
|
137 * Check if character has model |
|
138 * |
|
139 * @param aLanguageScript Where the character is come from |
|
140 * @param aChar The character which is checked |
|
141 * @return TBool True means this character has model |
|
142 * False means this character doesn't has model yet |
|
143 */ |
|
144 TBool CheckCharacterModel( const TDesC& aChar ); |
|
145 |
|
146 /** |
|
147 * Get character model |
|
148 * |
|
149 * @param aChar Get this character's model |
|
150 * @param aModel Array of points where the character's model is stored. |
|
151 */ |
|
152 void GetCharacterModelL( const TDesC& aChar, RArray<TPoint>& aModel ); |
|
153 |
|
154 /** |
|
155 * Set character model |
|
156 * |
|
157 * @param aChar Set model to this character |
|
158 * @param aModel Array of points where the character's model is stored. |
|
159 * @param aSimilarMsg Text exists in the HWREngine with the similar model. |
|
160 * @return none, if the symbol model is invalid, leave with KErrAlreadyExists |
|
161 */ |
|
162 void SetCharacterModelL( const TDesC& aChar, |
|
163 RArray<TPoint>& aModel, |
|
164 TDes& aSimilarMsg ); |
|
165 |
|
166 /** |
|
167 * Delete character model |
|
168 * |
|
169 * @param aChar Delete this character's model |
|
170 * @return TInt Error value. If no error occurred, KErrNone is returned |
|
171 */ |
|
172 TInt DeleteCharacterModel( const TDesC& aChar ); |
|
173 |
|
174 //Shortcut |
|
175 |
|
176 /** |
|
177 * Check if shortcut has model |
|
178 * |
|
179 * @param aText The shortcut which is checked |
|
180 * @return TBool True means this shortcut has model |
|
181 * False means this shortcut doesn't has model yet |
|
182 */ |
|
183 TBool CheckShortcutModel( const TDesC& aText ); |
|
184 |
|
185 /** |
|
186 * Change the text of an existing shortcut |
|
187 * |
|
188 * @param aOldText The text of an existing shortcut |
|
189 * @param aNewText The new text of the shortcut |
|
190 */ |
|
191 void ChangeShortcutTextL( const TDesC& aNewText ); |
|
192 |
|
193 /** |
|
194 * Set current editing shortcut |
|
195 * |
|
196 * @param sShortcut text of the shortcut |
|
197 * @return TInt Error value. If no error occurred, KErrNone is returned |
|
198 */ |
|
199 TInt SetShortcut( const TDesC& aText ); |
|
200 |
|
201 /** |
|
202 * Get current edited shortcut |
|
203 * |
|
204 * @return TDes shortcut text |
|
205 */ |
|
206 inline TDes& Shortcut(); |
|
207 |
|
208 /** |
|
209 * Get all shortcuts from HWR engine |
|
210 * |
|
211 * @return Pointer to iShortcutList to contain all existing shortcut |
|
212 */ |
|
213 inline CDesCArray* ShortcutTextList(); |
|
214 |
|
215 /** |
|
216 * Save shortcut text and its assigned character model into PTI Engine |
|
217 * |
|
218 * @param aText Save this Shortcut's model |
|
219 * @param aModel Array of points where the Shortcut's model is stored. |
|
220 * @param aSimilarMsg Text exists in the HWREngine with the similar model. |
|
221 * @return none, if the symbol model is invalid, leave with KErrAlreadyExists |
|
222 */ |
|
223 void SaveShortcutL( const TDesC& aText, |
|
224 RArray<TPoint>& aModel, |
|
225 TDes& aSimilarMsg ); |
|
226 |
|
227 /** |
|
228 * Delete Shortcut model |
|
229 * |
|
230 * @param aText Delete this Shortcut's model |
|
231 * @return TInt Error value. If no error occurred, KErrNone is returned |
|
232 */ |
|
233 TInt DeleteShortcut( const TDesC& aText ); |
|
234 |
|
235 /** |
|
236 * Update Shortcut list |
|
237 * |
|
238 */ |
|
239 void UpdateShortcutListL(); |
|
240 |
|
241 /** |
|
242 * Set edit state |
|
243 * |
|
244 * @param aNew: ETrue, perform the function of adding new shortcut. |
|
245 * EFalse, perform the function of editting old shortcut. |
|
246 */ |
|
247 inline void NewShortcut( TBool aNew ); |
|
248 |
|
249 /** |
|
250 * Get edit state |
|
251 * |
|
252 */ |
|
253 inline TBool NewShortcut(); |
|
254 |
|
255 /** |
|
256 * Set if display shortcut wizard view. |
|
257 * |
|
258 * @param aIsDisplay ETrue: Display shortcut wizard view |
|
259 */ |
|
260 inline void SetDisplayWizard( TBool aIsDisplay ); |
|
261 |
|
262 /** |
|
263 * Get if display shortcut wizard view |
|
264 * |
|
265 * @return ETrue: Display shortcut wizard view |
|
266 */ |
|
267 inline TBool DisplayWizard() const; |
|
268 |
|
269 /** |
|
270 * Set the current selected index |
|
271 * |
|
272 * @param aSelectedIndex currently selected index of shortcuts |
|
273 */ |
|
274 inline void SetCurrentSelectedIndex( TInt aSelectedIndex ); |
|
275 |
|
276 /** |
|
277 * Get the current selected index |
|
278 * |
|
279 * @return aSelectedIndex currently selected index of shortcuts |
|
280 */ |
|
281 inline TInt CurrentSelectedIndex(); |
|
282 |
|
283 /** |
|
284 * Get guiding line pos |
|
285 * |
|
286 * @param aSize The size of WritingBox |
|
287 * @param aTop The vertical coordinate of top guiding line |
|
288 * @param aBottom The vertical coordinate of bottom guiding line |
|
289 * @return TInt Error value. If no error occurred, KErrNone is returned |
|
290 */ |
|
291 TInt GetGuidingLinePos( const TSize& aSize, TInt& aTop , TInt& aBottom); |
|
292 |
|
293 /** |
|
294 * Get the number of the maximum of shortcuts |
|
295 * |
|
296 * @return TInt The number of the maximum of shortcuts |
|
297 */ |
|
298 TInt MaxShortCutLength(); |
|
299 |
|
300 /** |
|
301 * Get trails assigned to the specified shortcut. |
|
302 * |
|
303 * @param aText The specified shortcut text |
|
304 * @param aModel Trails of the shortcut. |
|
305 * @param aUnicode The assigned preset text if it is a preset shortcut, |
|
306 * otherwise, it is 0; |
|
307 */ |
|
308 void GetShortcutModelL( const TDesC& aText, RArray<TPoint>& aModel, TUint& aUnicode ); |
|
309 |
|
310 /** |
|
311 * Save preset shortcuts. |
|
312 * |
|
313 * @param aUnicode The assigned preset text. |
|
314 * @param aShortcut The shortcut to be save. |
|
315 */ |
|
316 void SavePresetShortcutL( TUint aUnicode, const TDesC& aShortcut ); |
|
317 |
|
318 /** |
|
319 * Get trails assigned to a preset text. |
|
320 * |
|
321 * @param aUnicode The unicode of the preset text. |
|
322 * @param aModel Store trails of the preset text. |
|
323 * @param aShortcut Indicate whether the preset text has been assigned to a shortcut text. |
|
324 * If KNullDesC, it is not in use. |
|
325 */ |
|
326 void GetPresetSymbolByUnicodeL( TUint aUnicode, RArray<TPoint>& aModel, TDes& aShortcut ); |
|
327 |
|
328 /** |
|
329 * Return all unicodes of preset text stored in PTI engine |
|
330 * |
|
331 * @param aPresets All preset text's unicodes are stored in this array. |
|
332 */ |
|
333 void GetAllPresetSymbolsL( RArray<TUint>& aPresets ); |
|
334 |
|
335 private: |
|
336 |
|
337 /** |
|
338 * Perform the first phase of two phase construction. |
|
339 */ |
|
340 CTruiEngine( CEikonEnv* aEikonEnv ); |
|
341 |
|
342 /** |
|
343 * Perform the second phase construction of a CTruidemoAppUi object |
|
344 */ |
|
345 void ConstructL(); |
|
346 |
|
347 /** |
|
348 * Initialize the table used to map language to language script |
|
349 * @param aResourceId ResourceId of Language script set. |
|
350 * @param aLanguageRelation Store the mappint relation. |
|
351 */ |
|
352 void InitLanguageRelationL( TInt aResourceId, |
|
353 RArray<TLanguageRelation>& aLanguageRelation ); |
|
354 |
|
355 /** |
|
356 * Initialize the supported language script. |
|
357 * @param aSupportedScript Store the suppotred script. |
|
358 * @param aEngine PtiEngine from which get supported input language. |
|
359 * @param aLanguageRelation Mapping relation used to convert language |
|
360 * into language script. |
|
361 */ |
|
362 void InitSupportedLanguageScriptL( RArray<TInt>& aSupportedScript, |
|
363 CPtiEngine* aEngine, |
|
364 const RArray<TLanguageRelation>& aLanguageRelation ); |
|
365 |
|
366 /** |
|
367 * Get the active language script from the active input language |
|
368 * @param aLanguageCode Currently active input language code. |
|
369 * @param aLanguageRelation Mapping relation used to convert language |
|
370 * into language script. |
|
371 */ |
|
372 TInt GetActiveLanguageScript( TInt aLanguageCode, |
|
373 const RArray<TLanguageRelation>& aLanguageRelation ); |
|
374 |
|
375 /** |
|
376 * Get the resourc id of lower case of Cyrillic according to the current input language |
|
377 * @param aLanguage Currently input language. |
|
378 * @return resource id |
|
379 */ |
|
380 TInt CyrillicLowerResourceId( TLanguage aLanguage ); |
|
381 |
|
382 /** |
|
383 * Get the resourc id of upper case of Cyrillic according to the current input language |
|
384 * @param aLanguage Currently input language. |
|
385 * @return resource id |
|
386 */ |
|
387 TInt CyrillicUpperResourceId( TLanguage aLanguage ); |
|
388 |
|
389 private: |
|
390 |
|
391 /** |
|
392 * Current edited shortcut |
|
393 */ |
|
394 TBuf<KShortcutMaxLength> iShortcut; |
|
395 |
|
396 /** |
|
397 * Array of all supported language script |
|
398 * Own |
|
399 */ |
|
400 RArray<TInt> iSupportedScript; |
|
401 |
|
402 /** |
|
403 * Current language script |
|
404 */ |
|
405 TInt iCurrentScript; |
|
406 |
|
407 /** |
|
408 * Array of all supported character range |
|
409 * Own |
|
410 */ |
|
411 RArray<TInt> iSupportedRange; |
|
412 |
|
413 /** |
|
414 * Array of the name of all supported character range |
|
415 * Own |
|
416 */ |
|
417 CDesCArray* iRangeName; |
|
418 |
|
419 /** |
|
420 * Current character range |
|
421 */ |
|
422 TInt iCurrentRange; |
|
423 |
|
424 /** |
|
425 * String of character set |
|
426 * Own |
|
427 */ |
|
428 HBufC* iCharacterSet; |
|
429 |
|
430 /** |
|
431 * Array of the shortcut |
|
432 * Own |
|
433 */ |
|
434 CDesCArray* iShortcutList; |
|
435 |
|
436 /** |
|
437 * Indicate if current edited shortcut is new created |
|
438 */ |
|
439 TBool iNewShortcut; |
|
440 |
|
441 /** |
|
442 * The currently selected index of shortcuts |
|
443 */ |
|
444 TInt iSelectedShortcut; |
|
445 |
|
446 /** |
|
447 * PtiEngine |
|
448 * Own |
|
449 */ |
|
450 CPtiEngine* iEngine; |
|
451 |
|
452 /** |
|
453 * Interface trui used in PtiEngine |
|
454 * Not own |
|
455 */ |
|
456 MTruiEngine* iPtiEngine; |
|
457 |
|
458 /** |
|
459 * Current subrange |
|
460 */ |
|
461 TInt iSubrange; |
|
462 |
|
463 /** |
|
464 * Pointer to eikon enviroment. |
|
465 * Not own |
|
466 */ |
|
467 CEikonEnv* iEnv; |
|
468 |
|
469 /** |
|
470 * Check if need to display shortcut wizard view |
|
471 */ |
|
472 TBool iIsDisplay; |
|
473 |
|
474 /** |
|
475 * Current input language |
|
476 */ |
|
477 TLanguage iInputLanguage; |
|
478 }; |
|
479 |
|
480 #include "truiengine.inl" |
|
481 |
|
482 #endif // C_TRUIENGINE_H |
|
483 |
|
484 |