|
1 /* |
|
2 * Copyright (c) 2003-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: Predective text input engine API header |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef _CSYMBOLLIST_H_HEADER_INCLUDED |
|
21 #define _CSYMBOLLIST_H_HEADER_INCLUDED |
|
22 |
|
23 // system includes |
|
24 #include <badesca.h> |
|
25 #include <f32file.h> |
|
26 #include <s32strm.h> |
|
27 |
|
28 // user includes |
|
29 #include "PtiHwrRecognizer.h" |
|
30 |
|
31 class CSymbol:public CBase |
|
32 { |
|
33 |
|
34 friend class CSymbolList; |
|
35 |
|
36 public: |
|
37 /* |
|
38 *Two phase constructor, create instance of implementation by |
|
39 * supplied resolution parameters. |
|
40 * |
|
41 * @param aStream The stream which contain the data to construct a CSymbol |
|
42 * @return CSymbol* pointer if successful, otherwise NULL. |
|
43 */ |
|
44 static CSymbol* NewL(RReadStream& aStream); |
|
45 |
|
46 /* |
|
47 *Two phase constructor, create instance of implementation by |
|
48 * supplied resolution parameters. |
|
49 * |
|
50 * @param aText The text of a symbol |
|
51 * @param aModel The pointer vector of a symbol |
|
52 * @param aHelpline |
|
53 * @param aBaseLine |
|
54 * @param aRange The range the symbol belongs to |
|
55 * @return CSymbol* pointer if successful, otherwise NULL. |
|
56 */ |
|
57 static CSymbol* NewL(const TDesC& aText, const RArray<TPoint>& aModel, int aHelpline, int aBaseLine, const THwrUdmRange& aRange); |
|
58 |
|
59 /** |
|
60 * Destructor |
|
61 */ |
|
62 ~CSymbol(); |
|
63 |
|
64 /* |
|
65 * Check whether the two symbols are the same |
|
66 * |
|
67 * @param aFirst The first symbol |
|
68 * @param aSecond The second symbol |
|
69 * @return Positive. if fist symbol is greater than the second symbol. |
|
70 * Negative. if fist symbol is less than the second symbol. |
|
71 * Zero, if both symbols have the same text and the their ranges are the same. |
|
72 */ |
|
73 static TInt SymbolOrderDescending(const CSymbol& aFirst, const CSymbol& aSecond); |
|
74 |
|
75 /* |
|
76 * Check whether the symbol match the aRange |
|
77 * |
|
78 * @param aRange The range to be matched. |
|
79 * @return ETrue if matched, otherwise EFalse. |
|
80 */ |
|
81 TBool Match ( const THwrUdmRange& aRange ); |
|
82 |
|
83 private: |
|
84 |
|
85 /* |
|
86 * Externalize to a stream |
|
87 * |
|
88 * @param aStream The stream to Externalize |
|
89 * @return None. |
|
90 */ |
|
91 void ExternalizeL(RWriteStream& aStream); |
|
92 |
|
93 /* |
|
94 * Internalize to a stream |
|
95 * |
|
96 * @param aStream The stream to internalize |
|
97 * @return None. |
|
98 */ |
|
99 void InternalizeL(RReadStream& aStream); |
|
100 |
|
101 /** |
|
102 * C++ default constructor |
|
103 */ |
|
104 CSymbol(); |
|
105 |
|
106 /** |
|
107 * Symbian 2nd phase constructor. |
|
108 * |
|
109 * @return None |
|
110 */ |
|
111 void ConstructL(const TDesC& aText, const RArray<TPoint>& aModel, int aHelpline, int aBaseLine,const THwrUdmRange& aRange); |
|
112 |
|
113 /** |
|
114 * Symbian 2nd phase constructor. |
|
115 * |
|
116 * @return None |
|
117 */ |
|
118 void ConstructL(RReadStream& aStream); |
|
119 |
|
120 private: |
|
121 |
|
122 int iHelpLine; |
|
123 |
|
124 int iBaseLine; |
|
125 |
|
126 HBufC* iSymbolName; |
|
127 |
|
128 // used only for preset models. |
|
129 TUint iPresetCode; |
|
130 |
|
131 TPoint* iPointVector; |
|
132 |
|
133 TInt iPointVectorLen; |
|
134 |
|
135 THwrUdmRange iRange; |
|
136 }; |
|
137 |
|
138 class CSymbolList :public CBase |
|
139 { |
|
140 friend class CSymbolList; |
|
141 public: |
|
142 /* |
|
143 *Two phase constructor, create instance of implementation by |
|
144 * supplied resolution parameters. |
|
145 * |
|
146 * @param aFilePath The file which contain the data to construct a CSymbol |
|
147 * @return CSymbolList* pointer if successful, otherwise NULL. |
|
148 */ |
|
149 static CSymbolList* NewL(const TDesC& aFilePath, CSymbolList* aPresetList ); |
|
150 |
|
151 /** |
|
152 * Destructor |
|
153 */ |
|
154 virtual ~CSymbolList(); |
|
155 |
|
156 /** |
|
157 * Set character model |
|
158 * |
|
159 * @param aText Set text for this symbol |
|
160 * @param aModel Array of points where the character's model is stored. |
|
161 * @return None |
|
162 */ |
|
163 void SetSymbolModelL(const TDesC& aText, const RArray<TPoint>& aModel, TInt aHelpLine, TInt aBaseLine,const THwrUdmRange& aRange ); |
|
164 |
|
165 /** |
|
166 * Check if symbol exist. |
|
167 * |
|
168 * @param aText The symbol which is checked |
|
169 * @param aRange The range this symbol belongs to |
|
170 * @return TBool True means this symbol has model |
|
171 * False means this symbol doesn't has model yet |
|
172 */ |
|
173 TBool CheckSymbolModel(const TDesC& aChar,const THwrUdmRange& aRange ); |
|
174 |
|
175 /** |
|
176 * Get symbol model |
|
177 * |
|
178 * @param aText Get this symbol's model |
|
179 * @param aModel Array of points where the symbol's model is stored. |
|
180 * @param aRange The range this symbol belongs to |
|
181 * @return None |
|
182 */ |
|
183 void GetSymbolModelL(const TDesC& aChar, RArray<TPoint>& aModel, TUint& aUnicode, const THwrUdmRange& aRange ); |
|
184 |
|
185 /** |
|
186 * Delete symbol model |
|
187 * |
|
188 * @param aText Delete this symbol's model |
|
189 * @param aRange The range this symbol belongs to |
|
190 * @return None |
|
191 */ |
|
192 void DeleteSymbolModelL(const TDesC& aChar,const THwrUdmRange& aRange ); |
|
193 |
|
194 /** |
|
195 * Get text list of all the symbol models |
|
196 * |
|
197 * @param aList The text list. |
|
198 * @param aRange The range this symbol belongs to |
|
199 * @return None |
|
200 */ |
|
201 void GetModelTextListL(RPointerArray<HBufC>& aList,const THwrUdmRange& aRange ); |
|
202 |
|
203 /** |
|
204 * Change the text of an existing symbol model |
|
205 * |
|
206 * @param aOldText The text of an existing symbol model |
|
207 * @param aNewText The new text of the symbol model |
|
208 * @param aRange The range this symbol belongs to |
|
209 * @return None |
|
210 */ |
|
211 void ChangeSymbolTextL(const TDesC& aOldText, const TDesC& aNewText,const THwrUdmRange& aRange ); |
|
212 |
|
213 /** |
|
214 * Get the index array that matched the aRange |
|
215 * |
|
216 * @param aList The index array of the matched symbols. |
|
217 * @param aRange The range this symbol belongs to |
|
218 * @return None |
|
219 */ |
|
220 void GetModelIndexListL( RArray<TInt>& aList, const THwrUdmRange& aRange); |
|
221 |
|
222 /** |
|
223 * Get the symbol contents for the specified index |
|
224 * |
|
225 * @param aIndex The index array of the matched symbols. |
|
226 * @param aSymbolName The name of the symbol |
|
227 * @param aModel The stroke for the symbol |
|
228 * @return KErrNone if success; |
|
229 */ |
|
230 TInt GetSymbolDataRef(TInt aIndex, TPtrC& aSymbolName,RArray<TPoint>& aModel, TInt& aHelpLine, TInt& aBaseLine ); |
|
231 |
|
232 /** |
|
233 * Save preset shortcuts. |
|
234 * |
|
235 * @param aUnicode The assigned preset text. |
|
236 * @param aShortcut The shortcut to be save. |
|
237 */ |
|
238 void SavePresetShortcutL( TUint aUnicode, const TDesC& aShortcut ) ; |
|
239 |
|
240 /** |
|
241 * Return all unicodes of preset text stored in PTI engine |
|
242 * |
|
243 * @param aPresets All preset text's unicodes are stored in this array. |
|
244 */ |
|
245 void GetAllPresetSymbolsL( RArray<TUint>& aPresets ) ; |
|
246 |
|
247 /** |
|
248 * Get trails assigned to a preset text. |
|
249 * |
|
250 * @param aUnicode The unicode of the preset text. |
|
251 * @param aModel Store trails of the preset text. |
|
252 * @param aShortcut Indicate whether the preset text has been assigned to a shortcut text. |
|
253 * If KNullDesC, it is not in use. |
|
254 */ |
|
255 void GetPresetSymbolByUnicodeL( TUint aUnicode, RArray<TPoint>& aModel, TDes& aShortcut ) ; |
|
256 |
|
257 /* |
|
258 * ExternalizeL to a file |
|
259 * |
|
260 * @return None. |
|
261 */ |
|
262 void ExternalizeL(); |
|
263 |
|
264 private: |
|
265 |
|
266 /** |
|
267 * Symbian 2nd phase constructor. |
|
268 * @param aFilePath The file which contain the symbol model |
|
269 * @return None |
|
270 */ |
|
271 void ConstructL(const TDesC& aFilePath); |
|
272 |
|
273 /** |
|
274 * C++ default constructor |
|
275 */ |
|
276 CSymbolList( CSymbolList* aPresetList ); |
|
277 |
|
278 /** |
|
279 * Get the index for the specified aText & aRange. |
|
280 * @param aText The text of a symbol model |
|
281 * @param aIndex To store the index of the symbol model |
|
282 * @param aRange The range this symbol belongs to |
|
283 * @return KErrNone if finding the symbol model |
|
284 */ |
|
285 TInt GetSymbolIndex(const TDesC& aText, TInt& aIndex,const THwrUdmRange& aRange ); |
|
286 |
|
287 /* |
|
288 * Internalize from a file |
|
289 * |
|
290 * @param aFile The file to internalize |
|
291 * @return None. |
|
292 */ |
|
293 void InternalizeL(const TDesC& aFile); |
|
294 |
|
295 |
|
296 /** |
|
297 * Call RMutex.Signal() in cleanupstack. |
|
298 * |
|
299 * @return None |
|
300 */ |
|
301 static void SignalMutex( TAny* aMutex ); |
|
302 private: |
|
303 |
|
304 RPointerArray<CSymbol> iSymbolList; |
|
305 |
|
306 HBufC* iFilePath; |
|
307 |
|
308 RFs iRfs; |
|
309 |
|
310 RMutex iMutex; |
|
311 |
|
312 CSymbolList* iPresetModels; |
|
313 |
|
314 }; |
|
315 |
|
316 |
|
317 #endif /* _CSYMBOLLIST_H_HEADER_INCLUDED */ |