|
1 /* |
|
2 * Copyright (c) 2006-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: Class to hold the character to key mappings |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef __CPCS_KEY_MAP_ALGORITHM_2_H__ |
|
19 #define __CPCS_KEY_MAP_ALGORITHM_2_H__ |
|
20 |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <e32property.h> |
|
25 #include <PtiDefs.h> |
|
26 #include "CPcsDefs.h" |
|
27 |
|
28 class CPcsAlgorithm2; |
|
29 class CPsQuery; |
|
30 class CPtiEngine; |
|
31 class CPtiKeyMapData; |
|
32 |
|
33 class TKeyMappingData |
|
34 { |
|
35 public: |
|
36 TPtiKey iKey; // key |
|
37 RArray<TInt> iKeyMappingArray; // All the characters mapped to the key |
|
38 }; |
|
39 |
|
40 // CLASS DECLARATION |
|
41 class CPcsKeyMap : public CBase |
|
42 { |
|
43 |
|
44 public: |
|
45 |
|
46 /** |
|
47 * Two phase construction |
|
48 */ |
|
49 static CPcsKeyMap* NewL(CPcsAlgorithm2* aAlgorithm); |
|
50 |
|
51 /** |
|
52 * Destructor |
|
53 */ |
|
54 virtual ~CPcsKeyMap(); |
|
55 |
|
56 /** |
|
57 * Convert functions to get the key string from query and/or chars string |
|
58 */ |
|
59 void GetMixedKeyStringForQueryL(CPsQuery& aSrcQuery, TDes& aDestStr) const; |
|
60 void GetMixedKeyStringForDataL(CPsQuery& aSrcQuery, const TDesC& aSrcData, TDes& aDestStr) const; |
|
61 |
|
62 /** |
|
63 * Returns the numeric key id corresponding to a specific character |
|
64 */ |
|
65 TPtiKey KeyForCharacter(TText aChar, TKeyboardModes aKbMode) const; |
|
66 |
|
67 /** |
|
68 * Returns ETrue if this language is supported |
|
69 */ |
|
70 TBool IsLanguageSupportedL(const TUint32 aLanguage); |
|
71 |
|
72 void ReconstructKeymapL(); |
|
73 |
|
74 /** |
|
75 * Returns the pool Id for a key |
|
76 */ |
|
77 TInt PoolIdForCharacter(TChar aChar, TKeyboardModes aKbMode ); |
|
78 |
|
79 /** |
|
80 * Returns total number of pools |
|
81 */ |
|
82 TInt PoolCount(); |
|
83 |
|
84 /** |
|
85 * Returns true if the characters "0" and " " are on the same key |
|
86 */ |
|
87 TBool GetSpaceAndZeroOnSameKey( TKeyboardModes aMode ); |
|
88 |
|
89 private: |
|
90 |
|
91 /** |
|
92 * Constructor |
|
93 */ |
|
94 CPcsKeyMap(); |
|
95 |
|
96 /** |
|
97 * Second phase constructor |
|
98 */ |
|
99 void ConstructL(CPcsAlgorithm2* aAlgorithm); |
|
100 |
|
101 /** |
|
102 * Set flags to indicate if space and zero are on same key. |
|
103 * Keymappings must be constructed before calling this. |
|
104 */ |
|
105 void SetSpaceAndZeroOnSameKey(); |
|
106 |
|
107 /** |
|
108 * Helper function to construct keyboard specific mappings |
|
109 */ |
|
110 void ConstructForItutKeyboardL(); |
|
111 void ConstructForQwertyKeyboardL(TPtiKeyboardType aKbType); |
|
112 |
|
113 /** |
|
114 * Helper function to populate Itut key mappings |
|
115 */ |
|
116 void AddKeyMapforItutL(TLanguage aLanguage); |
|
117 |
|
118 void AddDataForItutKeyboardL(CPtiKeyMapData* aPtiKeyMapData, |
|
119 TPtiKey aKey, TKeyMappingData& aKeyDataList); |
|
120 /** |
|
121 * Helper function to populate 4x10 Qwerty Keyboard key mappings |
|
122 */ |
|
123 void AddKeyMapForQwertyKeyboardL(TLanguage aLanguage, TPtiKeyboardType aKbType); |
|
124 |
|
125 void AddDataForQwertyKeyboardL( |
|
126 CPtiKeyMapData* aPtiKeyMapData, |
|
127 TPtiKeyboardType aKbType, |
|
128 TPtiKey aKey, |
|
129 TKeyMappingData& aKeyDataList); |
|
130 |
|
131 /** |
|
132 * Create list of PTI keys for the given keyboard type |
|
133 */ |
|
134 void CreateKeyListFromKeyBindingTable( RArray<TPtiKey>& aKeyArray, TPtiKeyboardType aKbType ); |
|
135 |
|
136 void ResetKeyMap(); |
|
137 |
|
138 /** |
|
139 * Function to construct key mappings for a particula language |
|
140 * |
|
141 */ |
|
142 void ConstructKeymapL(); |
|
143 |
|
144 /** |
|
145 * Select keyboard types according to available physical keyboard(s) |
|
146 */ |
|
147 void SetupKeyboardTypesL(); |
|
148 |
|
149 /** |
|
150 * |
|
151 * Construct keymaps |
|
152 */ |
|
153 void ConstructConcreteKeyMapL(); |
|
154 |
|
155 /** |
|
156 * |
|
157 * Add keymap for keyboard by type and language |
|
158 * @ aKeyboardType, the current keyboard type. |
|
159 * @ aLanguage, the keymap construct language. |
|
160 */ |
|
161 void AddKeyMapforConcreteKeyboardL( TLanguage aLanguage ); |
|
162 |
|
163 /** |
|
164 * In case the given character is a Chinese characer, give the first |
|
165 * character of it's first spelling using the current spelling mode. |
|
166 * Otherwise, the character is returned unmodified. |
|
167 */ |
|
168 TChar FirstCharFromSpellingL( TChar aChar ) const; |
|
169 |
|
170 TInt PoolIdForKey(TPtiKey aKey, TKeyboardModes aKbMode) const; |
|
171 |
|
172 /** |
|
173 * Gets predictive keyboard mapping data for given match mode. |
|
174 * @param aMode Matching mode for which keymappings are asked. |
|
175 * @return Mapping table for the given mode. NULL if asked for non-predictive mode. |
|
176 */ |
|
177 const RPointerArray<TKeyMappingData>* KeyMappings( TKeyboardModes aMode ) const; |
|
178 |
|
179 /** |
|
180 * Resolve any ambiguity from the given keyboard mode. |
|
181 * Keyboard mode "predictive default keyboard" will be replaced by |
|
182 * "ITU-T predictive" or "QWERTY predictive", depending on the configuration |
|
183 * of the device. Predictive keyboard modes, which can't be supported |
|
184 * in this device, are replaced with "non-predictive" mode. |
|
185 */ |
|
186 TKeyboardModes ResolveKeyboardMode( TKeyboardModes aKbMode ) const; |
|
187 |
|
188 /** |
|
189 * Get the default charcter for the given key in given keyboard. |
|
190 * The default character is used to construct the compare string for |
|
191 * predictive mode. |
|
192 */ |
|
193 TText DefaultCharForKey( TPtiKey aKey, TKeyboardModes aKbMode ) const; |
|
194 |
|
195 private: |
|
196 /** |
|
197 * PTI engine istance. Owned. |
|
198 */ |
|
199 CPtiEngine* iPtiEngine; |
|
200 |
|
201 /** |
|
202 * Algorithm instacne pointer. NOT owned. |
|
203 */ |
|
204 CPcsAlgorithm2* iAlgorithm; |
|
205 |
|
206 /** |
|
207 * Array to hold the list of languages not supported |
|
208 */ |
|
209 RArray<TLanguage> iLanguageNotSupported; |
|
210 |
|
211 /** |
|
212 * Type of keyboard used in ITU-T search mode. Typically this is standard ITU-T |
|
213 * 12-key keypad. |
|
214 */ |
|
215 TPtiKeyboardType iItutKeyboardType; |
|
216 |
|
217 /** |
|
218 * PTI keys of the ITU-T keyboard. |
|
219 */ |
|
220 RArray<TPtiKey> iItutKeys; |
|
221 |
|
222 /** |
|
223 * Contains all the ITU-T keys and the characters mapped to each key. Owned. |
|
224 */ |
|
225 RPointerArray<TKeyMappingData> iItutKeyMappings; |
|
226 |
|
227 /** |
|
228 * True if "0" and " " are on the same key in the ITU-T mode |
|
229 */ |
|
230 TBool iSpaceAndZeroOnSameKeyOnItut; |
|
231 |
|
232 /** |
|
233 * Type of keyboard used in QWERTY search mode. Typically this is either 3x11 or 4x10 QWERTY |
|
234 * or EPtiKeyboardNone if there's no any kind of QWERTY available. This may also be |
|
235 * half-QWERTY. |
|
236 */ |
|
237 TPtiKeyboardType iQwertyKeyboardType; |
|
238 |
|
239 /** |
|
240 * PTI keys of the QWERTY keyboard. |
|
241 */ |
|
242 RArray<TPtiKey> iQwertyKeys; |
|
243 |
|
244 /** |
|
245 * Contains all the QWERTY keys and the characters mapped to each key. Owned. |
|
246 */ |
|
247 RPointerArray<TKeyMappingData> iQwertyKeyMappings; |
|
248 |
|
249 /** |
|
250 * True if "0" and " " are on the same key in the QWERTY mode |
|
251 */ |
|
252 TBool iSpaceAndZeroOnSameKeyOnQwerty; |
|
253 |
|
254 /** |
|
255 * Flag to indicate if the default multi-matching mode is ITU-T or QWERTY mode. |
|
256 * ETrue, if ITU-T is defualt and EFalse if QWERTY is default. |
|
257 */ |
|
258 TBool iItutIsDefault; |
|
259 }; |
|
260 |
|
261 #endif // __CPCS_KEY_MAP_ALGORITHM_2_H__ |
|
262 |
|
263 // End of file |