|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Provides the TAknFepUiInputStateInitialFullNumber methods. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // INCLUDE FILES |
|
30 #include "AknFepUiInputStateInitialFullNumber.h" |
|
31 #include "AknFepUIManagerStateInterface.h" // MAknFepUIManagerStateInterface |
|
32 #include "AknFepManagerUIInterface.h" // MAknFepManagerUIInterface |
|
33 #include "AknFepManager.h" |
|
34 |
|
35 #include <PtiEngine.h> |
|
36 #include <featmgr.h> //FeatureManager |
|
37 #include <PtiCompositionDataIF.h> // MPtiEngineCompositionDataInterface |
|
38 #include <jplangutil.h> |
|
39 |
|
40 // CONSTANTS |
|
41 const TInt KNumAllowedIdleNumericChars = 21; |
|
42 |
|
43 _LIT(KAknFepPlainNumbers, "1234567890"); |
|
44 const TUint16 KAllAllowedNumericChars[] = |
|
45 {'*','+','p','w','#','1','2','3','4','5','6','7','8','9','0', ';','.',',','-','E','?'}; |
|
46 const TKeyEvent KEventsForSecondPass[] = |
|
47 { |
|
48 {42, EStdKeyNkpAsterisk, 3, 0}, |
|
49 {43, EStdKeyNkpPlus, 3, 0}, |
|
50 {112, 80, EModifierAutorepeatable, 0}, |
|
51 {119, 87, EModifierAutorepeatable, 0}, |
|
52 {35, EStdKeyHash, EModifierAutorepeatable, 0}, |
|
53 {EPtiKey1, EPtiKey1, EModifierAutorepeatable, 0}, |
|
54 {EPtiKey2, EPtiKey2, EModifierAutorepeatable, 0}, |
|
55 {EPtiKey3, EPtiKey3, EModifierAutorepeatable, 0}, |
|
56 {EPtiKey4, EPtiKey4, EModifierAutorepeatable, 0}, |
|
57 {EPtiKey5, EPtiKey5, EModifierAutorepeatable, 0}, |
|
58 {EPtiKey6, EPtiKey6, EModifierAutorepeatable, 0}, |
|
59 {EPtiKey7, EPtiKey7, EModifierAutorepeatable, 0}, |
|
60 {EPtiKey8, EPtiKey8, EModifierAutorepeatable, 0}, |
|
61 {EPtiKey9, EPtiKey9, EModifierAutorepeatable, 0}, |
|
62 {EPtiKey0, EPtiKey0, EModifierAutorepeatable, 0}, |
|
63 {59, EStdKeySemiColon, EModifierAutorepeatable, 0}, |
|
64 {46, 122, EModifierAutorepeatable, 0}, |
|
65 {44, 121, EModifierAutorepeatable, 0}, |
|
66 {45, 130, EModifierAutorepeatable, 0}, |
|
67 {101, 69, EModifierAutorepeatable|EModifierLeftShift, 0}, |
|
68 {63, EStdKeyForwardSlash, EModifierAutorepeatable|EModifierLeftShift, 0} |
|
69 }; |
|
70 |
|
71 /** |
|
72 * AknFepUiInputStateInitialFullNumber class. |
|
73 * |
|
74 */ |
|
75 //============================ MEMBER FUNCTIONS ============================== |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // TAknFepUiInputStateInitialFullNumber::TAknFepUiInputStateInitialFullNumber |
|
79 // C++ default Constructor |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 TAknFepUiInputStateInitialFullNumber::TAknFepUiInputStateInitialFullNumber( |
|
83 MAknFepUIManagerStateInterface* aOwner, |
|
84 MAknFepUICtrlContainerJapanese* aUIContainer) |
|
85 :TAknFepUiInputStateInitialJapaneseBase(aOwner, aUIContainer) |
|
86 { |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // TAknFepUiInputStateInitialFullNumber::InitializeStateL |
|
91 // Initialize State |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void TAknFepUiInputStateInitialFullNumber::InitializeStateL() |
|
95 { |
|
96 TAknFepUiInputStateInitialJapaneseBase::InitializeStateL(); |
|
97 |
|
98 // Setup PtiEngine |
|
99 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
100 const TWidthChar width = iOwner->FepMan()->CharacterWidth(); |
|
101 TPtiEngineInputMode inputmode = EPtiEngineInputModeNone; |
|
102 switch(width) |
|
103 { |
|
104 case EHalfWidthChar: |
|
105 inputmode = (iOwner->IsQwerty())? |
|
106 EPtiEngineQwerty |
|
107 : EPtiEngineNumeric; |
|
108 break; |
|
109 |
|
110 case EFullWidthChar: |
|
111 inputmode = (iOwner->IsQwerty())? |
|
112 EPtiEngineFullWidthNumericQwerty |
|
113 : EPtiEngineFullWidthNumeric; |
|
114 break; |
|
115 |
|
116 default: // no operation |
|
117 break; |
|
118 } |
|
119 if (inputmode != EPtiEngineInputModeNone) |
|
120 { |
|
121 ptiEngine->SetInputMode(inputmode); |
|
122 |
|
123 if (inputmode == EPtiEngineNumeric) |
|
124 { |
|
125 TRAP_IGNORE(ptiEngine->SetExternalKeyMapL(EPtiEngineNumeric, EPtiKeyStar, |
|
126 (TDesC&)iOwner->NumberModeKeyMapping(), |
|
127 EPtiCaseLower)) |
|
128 } |
|
129 } |
|
130 |
|
131 ptiEngine->ClearCurrentWord(); |
|
132 } |
|
133 |
|
134 TBool TAknFepUiInputStateInitialFullNumber::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
135 { |
|
136 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
137 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
138 TBool rtn = EFalse; |
|
139 |
|
140 switch(ptiengine->InputMode()) |
|
141 { |
|
142 case EPtiEngineNumeric: // non-Qwerty number input |
|
143 rtn = HandleOwnKeyL(aKey, aLength); |
|
144 break; |
|
145 case EPtiEngineQwerty: // Qwerty number input |
|
146 case EPtiEngineFullWidthNumericQwerty: // Qwerty full-width number input |
|
147 rtn = HandleQwertyKeyL(aKey, aLength, fepMan->CharacterWidth()); |
|
148 break; |
|
149 case EPtiEngineFullWidthNumeric: // non-Qwerty full-width number input |
|
150 rtn = TAknFepUiInputStateInitialJapaneseBase::HandleKeyL(aKey, aLength); |
|
151 break; |
|
152 default: |
|
153 break; |
|
154 } |
|
155 return rtn; |
|
156 } |
|
157 |
|
158 TBool TAknFepUiInputStateInitialFullNumber::HandleOwnKeyL(TInt aKey, TKeyPressLength aLength) |
|
159 { |
|
160 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
161 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
162 |
|
163 if (aLength == ELongKeyPress) |
|
164 { |
|
165 switch (aKey) |
|
166 { |
|
167 case EKeyRightArrow: |
|
168 case EKeyLeftArrow: |
|
169 case EKeyDownArrow: |
|
170 case EKeyUpArrow: |
|
171 case EKeyBackspace: |
|
172 return EFalse; |
|
173 case EPtiKeyStar: |
|
174 if (!fepMan->HashKeySelectionInUse() |
|
175 && fepMan->EditSubmenuInUse()) |
|
176 { |
|
177 fepMan->LaunchSpecialCharacterTableL(); |
|
178 } |
|
179 default: |
|
180 return ETrue; |
|
181 } |
|
182 } |
|
183 |
|
184 if(aKey == EPtiKeyStar) |
|
185 { |
|
186 TBool append = EFalse; |
|
187 if (aLength == EShortKeyPress) |
|
188 { |
|
189 if (fepMan->EditSubmenuInUse()) |
|
190 { |
|
191 if (fepMan->IsOnlyNumericPermitted()) |
|
192 { |
|
193 append = ETrue; |
|
194 } |
|
195 else |
|
196 { |
|
197 fepMan->ClearCcpuFlag(CAknFepManager::ECcpuStateIgnoreStarUp); |
|
198 } |
|
199 } |
|
200 else |
|
201 { |
|
202 if (fepMan->IsAbleToLaunchSCT()) |
|
203 { |
|
204 fepMan->LaunchSpecialCharacterTableL(); |
|
205 } |
|
206 else |
|
207 { |
|
208 append = ETrue; |
|
209 } |
|
210 } |
|
211 } |
|
212 else |
|
213 { |
|
214 if (fepMan->EditSubmenuInUse() && fepMan->IsAbleToLaunchSCT()) |
|
215 { |
|
216 fepMan->LaunchSpecialCharacterTableL(); |
|
217 } |
|
218 } |
|
219 if (append) |
|
220 { |
|
221 iData = aKey; |
|
222 TPtrC text = ptiengine->AppendKeyPress((TPtiKey)aKey); |
|
223 |
|
224 // star key is inactive if keymapping is empty. |
|
225 if (text.Length() > 0 && text[0] != 0) |
|
226 { |
|
227 fepMan->NewCharacterL(text); |
|
228 |
|
229 // Commit immediately if there is only one character associated to the key. |
|
230 TBuf<CAknFepManager::EMaximumFepWordLength> mapdata; |
|
231 ptiengine->MappingDataForKey((TPtiKey)aKey, mapdata, ptiengine->Case()); |
|
232 if (mapdata.Length() <= 1) |
|
233 { |
|
234 fepMan->CommitInlineEditL(); |
|
235 ptiengine->ClearCurrentWord(); |
|
236 iData = 0; |
|
237 } |
|
238 } |
|
239 } |
|
240 |
|
241 return ETrue; |
|
242 } |
|
243 |
|
244 if(iData) |
|
245 { |
|
246 fepMan->CommitInlineEditL(); |
|
247 ptiengine->ClearCurrentWord(); |
|
248 |
|
249 iData = 0; |
|
250 } |
|
251 return EFalse; |
|
252 } |
|
253 |
|
254 TBool TAknFepUiInputStateInitialFullNumber::HandleQwertyKeyL(TInt aKey, |
|
255 TKeyPressLength /*aLength*/, const TWidthChar aWidth) |
|
256 { |
|
257 TBool rtn = EFalse; |
|
258 |
|
259 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
260 CAknFepCaseManager* caseMan = iOwner->CaseMan(); |
|
261 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
262 |
|
263 fepMan->ClearFlag(CAknFepManager::EFlagNoActionDuringShiftKeyPress); |
|
264 |
|
265 if ( fepMan->IsOnlyNumericPermitted() ) |
|
266 { |
|
267 if (aKey == EStdKeySpace || aKey == EStdKeyEnter) |
|
268 { |
|
269 // return Consumed |
|
270 return ETrue; |
|
271 } |
|
272 if (!IsQwertyKey(aKey)) |
|
273 { |
|
274 // return Not Consumed |
|
275 return EFalse; |
|
276 } |
|
277 |
|
278 TChar chr(0); |
|
279 TKeyEvent numKey; |
|
280 |
|
281 ptiengine->AppendKeyPress((TPtiKey)aKey); |
|
282 const MPtiEngineCompositionDataInterface* data = ptiengine->CompositionData(); |
|
283 TPtrC text = data->CompletedString(); |
|
284 if (text.Length() > 0 && text[0] != 0) |
|
285 { |
|
286 TChar compchar = text[0]; |
|
287 if (aWidth == EFullWidthChar) |
|
288 { |
|
289 TBuf<2> halfstring; |
|
290 TInt convlen = JPLangUtil::ConvertFullToHalfWidth( |
|
291 text.Left(1), halfstring); |
|
292 if (convlen > 0) |
|
293 { |
|
294 compchar = halfstring[0]; |
|
295 } |
|
296 } |
|
297 for (TInt i = 0; i < KNumAllowedIdleNumericChars; i++) |
|
298 { |
|
299 |
|
300 if (compchar == KAllAllowedNumericChars[i]) |
|
301 { |
|
302 numKey = KEventsForSecondPass[i]; |
|
303 chr = KAllAllowedNumericChars[i]; |
|
304 break; |
|
305 } |
|
306 } |
|
307 } |
|
308 |
|
309 if ((chr != 0) && |
|
310 ((iOwner->NumberModeKeyMapping().Locate(chr) != KErrNotFound) || |
|
311 (KAknFepPlainNumbers().Locate(chr) != KErrNotFound)) || |
|
312 fepMan->IsAllowedKeymappingForNumberMode(chr)) |
|
313 { |
|
314 if (aWidth == EFullWidthChar) |
|
315 { |
|
316 // Full-width characters are committed immediately. |
|
317 fepMan->NewCharacterL(text); |
|
318 fepMan->CommitInlineEditL(); |
|
319 } |
|
320 else |
|
321 { |
|
322 // If editor is in number mode and incoming key press would produce |
|
323 // any of the allowed number mode characters, |
|
324 // resend suitable key event let it pass through FEP. That way phone idle |
|
325 // receives the event too. This also takes care of remapping |
|
326 // different qwerty keymap layouts to edwin events. |
|
327 fepMan->SetFlag(CAknFepManager::EFlagPassNextKey); |
|
328 CCoeEnv::Static()->SimulateKeyEventL(numKey, EEventKey); |
|
329 } |
|
330 } |
|
331 ptiengine->ClearCurrentWord(); |
|
332 |
|
333 return ETrue; |
|
334 } |
|
335 |
|
336 return rtn; |
|
337 } |
|
338 |
|
339 |
|
340 |
|
341 // Functions from MPtiObserver interface |
|
342 void TAknFepUiInputStateInitialFullNumber::KeyTimerExpired() |
|
343 { |
|
344 if (iData) |
|
345 { |
|
346 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
347 TRAP_IGNORE(fepMan->CommitInlineEditL()) |
|
348 |
|
349 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
350 ptiengine->ClearCurrentWord(); |
|
351 |
|
352 iData = 0; |
|
353 } |
|
354 } |
|
355 |
|
356 // End of file |