author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:34:44 +0300 | |
branch | RCL_3 |
changeset 50 | 5a1685599b76 |
parent 44 | ecbabf52600f |
child 56 | 8152b1f1763a |
permissions | -rw-r--r-- |
44 | 1 |
/* |
2 |
* Copyright (c) 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: |
|
15 |
* Provides the TAknFepInputStateInitialKoreanMultitap methods. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
#include "AknFepUiInputStateInitialKoreanMultitap.h" |
|
20 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
21 |
#include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
22 |
#include "AknFepCaseManager.h" |
|
23 |
#include "AknFepUiIndicInputManager.h" |
|
24 |
#include "AknFepManager.h" |
|
25 |
||
26 |
#include <PtiEngine.h> |
|
27 |
#include <PtiDefs.h> |
|
28 |
||
29 |
TAknFepInputStateInitialKoreanMultitap::TAknFepInputStateInitialKoreanMultitap(MAknFepUIManagerStateInterface* aOwner) |
|
30 |
:TAknFepInputStateInitialMultitapBase(aOwner) |
|
31 |
{ |
|
32 |
iState = EInitial; |
|
33 |
||
34 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
35 |
CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
36 |
||
37 |
TPtiTextCase caseMode = ptiengine->Case(); |
|
38 |
||
39 |
#ifdef RD_INTELLIGENT_TEXT_INPUT |
|
40 |
TRAP_IGNORE(ptiengine->ActivateLanguageL(ELangKorean, EPtiEngineMultitappingKorean)) |
|
41 |
ptiengine->SetInputMode(EPtiEngineMultitappingKorean); |
|
42 |
#else |
|
43 |
TRAP_IGNORE(ptiengine->ActivateLanguageL(ELangKorean, EPtiEngineMultitapping)) |
|
44 |
ptiengine->SetInputMode(EPtiEngineMultitapping); |
|
45 |
#endif //RD_INTELLIGENT_TEXT_INPUT |
|
46 |
||
47 |
ptiengine->SetCase(caseMode); |
|
48 |
} |
|
49 |
||
50 |
TBool TAknFepInputStateInitialKoreanMultitap::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
51 |
{ |
|
52 |
||
53 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
54 |
CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
55 |
TBool ret = ETrue; |
|
56 |
||
57 |
if(aLength == EShortKeyPress) |
|
58 |
{ |
|
59 |
||
60 |
if(aKey == EKeyBackspace) |
|
61 |
{ |
|
62 |
// Narat Geul engine tries first to disassemble hangul to jamos. if disassembly is not possible, |
|
63 |
// then clear character. |
|
64 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
65 |
{ |
|
66 |
TPtrC newText = ptiengine->DeleteKeyPress(); |
|
67 |
fepMan->UpdateInlineEditL(newText, newText.Length()); |
|
68 |
||
69 |
if (newText.Length() == 0) |
|
70 |
{ |
|
71 |
fepMan->CancelInlineEdit(); |
|
72 |
ptiengine->ClearCurrentWord(); |
|
73 |
} |
|
74 |
} |
|
75 |
else |
|
76 |
{ |
|
77 |
ret = EFalse; |
|
78 |
} |
|
79 |
} |
|
80 |
else |
|
81 |
{ |
|
82 |
||
83 |
if(aKey == EKeyLeftArrow || |
|
84 |
aKey == EKeyRightArrow || |
|
85 |
aKey == EKeyDownArrow || |
|
86 |
aKey == EKeyUpArrow) |
|
87 |
{ |
|
88 |
ret = EFalse; |
|
89 |
} |
|
90 |
else |
|
91 |
{ |
|
50
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
92 |
|
44 | 93 |
if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))) |
94 |
{ // 'new' inline edit |
|
95 |
ptiengine->ClearCurrentWord(); |
|
96 |
fepMan->StartInlineEditL(); |
|
97 |
fepMan->SetInlineEditingCursorVisibilityL(ETrue); |
|
98 |
} |
|
50
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
99 |
|
44 | 100 |
TPtrC aText = ptiengine->AppendKeyPress((TPtiKey)aKey); |
50
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
101 |
|
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
102 |
// Get Fep manager pointer |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
103 |
CAknFepManager* fepManager = static_cast<CAknFepManager*>(fepMan); |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
104 |
|
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
105 |
// When reaching the max length of the editor in the Hangul mode, |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
106 |
// the current texts will be committed. |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
107 |
if( fepManager->IsTextExceedLeghthEditor(aText.Length())) |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
108 |
{ |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
109 |
fepMan->CommitInlineEditL(); |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
110 |
ptiengine->ClearCurrentWord(); |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
111 |
return ETrue; |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
112 |
} |
5a1685599b76
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
113 |
|
44 | 114 |
fepMan->UpdateInlineEditL(aText, aText.Length()); |
115 |
||
116 |
// Force commit when buffer length is 511. Needs to be commited in order to |
|
117 |
// prevent ptiengines iTextBuffer overflow. Even though it is very unlikely |
|
118 |
// case |
|
119 |
if(aText.Length() >= 254) |
|
120 |
{ |
|
121 |
if (CommitOrNot(aText.Right(CAknFepManager::ESingleCharacter), aKey)) |
|
122 |
{ |
|
123 |
TPtrC text = ptiengine->DeleteKeyPress(); |
|
124 |
fepMan->UpdateInlineEditL(text, text.Length()); |
|
125 |
fepMan->CommitInlineEditL(); |
|
126 |
||
127 |
ptiengine->ClearCurrentWord(); |
|
128 |
||
129 |
TPtrC newText = ptiengine->AppendKeyPress((TPtiKey)aKey); |
|
130 |
fepMan->StartInlineEditL(); |
|
131 |
fepMan->UpdateInlineEditL(newText, newText.Length()); |
|
132 |
} |
|
133 |
else if(aText.Length() >= 255) |
|
134 |
{// force commit |
|
135 |
fepMan->CommitInlineEditL(); |
|
136 |
} |
|
137 |
} |
|
138 |
else |
|
139 |
{ |
|
140 |
fepMan->UpdateInlineEditL(aText, aText.Length()); |
|
141 |
} |
|
142 |
} |
|
143 |
} |
|
144 |
} |
|
145 |
else // long keypress |
|
146 |
{ |
|
147 |
||
148 |
if (aKey == EPtiKeyStar) |
|
149 |
{ |
|
150 |
||
151 |
/*ptiengine->DeleteKeyPress(); |
|
152 |
TPtrC text = ptiengine->PreviousCandidate(); |
|
153 |
fepMan->UpdateInlineEditL(text, text.Length()); |
|
154 |
fepMan->CommitInlineEditL(); |
|
155 |
ptiengine->ClearCurrentWord(); */ |
|
156 |
||
157 |
//fepMan->LaunchSelectModeMenuL(); |
|
158 |
||
159 |
if (fepMan->IsAbleToLaunchSCT()) |
|
160 |
{ |
|
161 |
fepMan->LaunchSpecialCharacterTableL(); |
|
162 |
} |
|
163 |
||
164 |
} |
|
165 |
else |
|
166 |
{ |
|
167 |
// Insert number through long key press. |
|
168 |
if (aKey != EKeyBackspace) |
|
169 |
{ |
|
170 |
if (!fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
171 |
{ |
|
172 |
// No edit transaction going on, we have ended here because of long |
|
173 |
// key press created editor on UI or some other similar non-standard situation. |
|
174 |
// We can't handle key press, so just consume it. |
|
175 |
return ETrue; |
|
176 |
} |
|
177 |
||
178 |
TPtrC text = ptiengine->PreviousCandidate(); |
|
179 |
fepMan->UpdateInlineEditL(text, text.Length()); |
|
180 |
fepMan->CommitInlineEditL(); |
|
181 |
ptiengine->ClearCurrentWord(); |
|
182 |
ret = EFalse; |
|
183 |
} |
|
184 |
else if (aKey == EKeyBackspace) |
|
185 |
{ |
|
186 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)) |
|
187 |
{ |
|
188 |
fepMan->CommitInlineEditL(); |
|
189 |
ptiengine->ClearCurrentWord(); |
|
190 |
fepMan->TryCloseUiL(); |
|
191 |
} |
|
192 |
ret = EFalse; |
|
193 |
} |
|
194 |
else |
|
195 |
{ |
|
196 |
ret = EFalse; |
|
197 |
} |
|
198 |
} |
|
199 |
||
200 |
} |
|
201 |
return ret; |
|
202 |
} |
|
203 |
||
204 |
// Decides wheather text should be commited or not. Makes comparison between latest key input |
|
205 |
// and "seed" jamos. if latest input match with one of "seed" jamos and star or hash key cannot make |
|
206 |
// any changes to input, then commit. |
|
207 |
// NOTE; the "seed" jamos are characters that are printed on keymat. Narat geul engine compiles all |
|
208 |
// the hanguls from 12 jamos. |
|
209 |
TBool TAknFepInputStateInitialKoreanMultitap::CommitOrNot(TPtrC aData, TInt aKey) |
|
210 |
{ |
|
211 |
TBool commit = EFalse; |
|
212 |
TBuf<CAknFepManager::EMaximumFepWordLength> mappings; |
|
213 |
TInt len; |
|
214 |
||
215 |
CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
216 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
217 |
||
218 |
ptiengine->MappingDataForKey((TPtiKey)aKey, mappings, ptiengine->Case()); |
|
219 |
len = mappings.Length(); |
|
220 |
||
221 |
for (TInt i = 0; i < len; i++ ) |
|
222 |
{ |
|
223 |
if(aData.Compare(mappings.Left(i + 1)) == 0) |
|
224 |
{ |
|
225 |
commit = ETrue; |
|
226 |
break; |
|
227 |
} |
|
228 |
} |
|
229 |
||
230 |
return commit; |
|
231 |
} |
|
232 |
||
233 |
// End of file |