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 |
{
|
|
92 |
if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
|
|
93 |
{ // 'new' inline edit
|
|
94 |
ptiengine->ClearCurrentWord();
|
|
95 |
fepMan->StartInlineEditL();
|
|
96 |
fepMan->SetInlineEditingCursorVisibilityL(ETrue);
|
|
97 |
}
|
|
98 |
|
|
99 |
TPtrC aText = ptiengine->AppendKeyPress((TPtiKey)aKey);
|
|
100 |
fepMan->UpdateInlineEditL(aText, aText.Length());
|
|
101 |
|
|
102 |
// Force commit when buffer length is 511. Needs to be commited in order to
|
|
103 |
// prevent ptiengines iTextBuffer overflow. Even though it is very unlikely
|
|
104 |
// case
|
|
105 |
if(aText.Length() >= 254)
|
|
106 |
{
|
|
107 |
if (CommitOrNot(aText.Right(CAknFepManager::ESingleCharacter), aKey))
|
|
108 |
{
|
|
109 |
TPtrC text = ptiengine->DeleteKeyPress();
|
|
110 |
fepMan->UpdateInlineEditL(text, text.Length());
|
|
111 |
fepMan->CommitInlineEditL();
|
|
112 |
|
|
113 |
ptiengine->ClearCurrentWord();
|
|
114 |
|
|
115 |
TPtrC newText = ptiengine->AppendKeyPress((TPtiKey)aKey);
|
|
116 |
fepMan->StartInlineEditL();
|
|
117 |
fepMan->UpdateInlineEditL(newText, newText.Length());
|
|
118 |
}
|
|
119 |
else if(aText.Length() >= 255)
|
|
120 |
{// force commit
|
|
121 |
fepMan->CommitInlineEditL();
|
|
122 |
}
|
|
123 |
}
|
|
124 |
else
|
|
125 |
{
|
|
126 |
fepMan->UpdateInlineEditL(aText, aText.Length());
|
|
127 |
}
|
|
128 |
}
|
|
129 |
}
|
|
130 |
}
|
|
131 |
else // long keypress
|
|
132 |
{
|
|
133 |
|
|
134 |
if (aKey == EPtiKeyStar)
|
|
135 |
{
|
|
136 |
|
|
137 |
/*ptiengine->DeleteKeyPress();
|
|
138 |
TPtrC text = ptiengine->PreviousCandidate();
|
|
139 |
fepMan->UpdateInlineEditL(text, text.Length());
|
|
140 |
fepMan->CommitInlineEditL();
|
|
141 |
ptiengine->ClearCurrentWord(); */
|
|
142 |
|
|
143 |
//fepMan->LaunchSelectModeMenuL();
|
|
144 |
|
|
145 |
if (fepMan->IsAbleToLaunchSCT())
|
|
146 |
{
|
|
147 |
fepMan->LaunchSpecialCharacterTableL();
|
|
148 |
}
|
|
149 |
|
|
150 |
}
|
|
151 |
else
|
|
152 |
{
|
|
153 |
// Insert number through long key press.
|
|
154 |
if (aKey != EKeyBackspace)
|
|
155 |
{
|
|
156 |
if (!fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
|
|
157 |
{
|
|
158 |
// No edit transaction going on, we have ended here because of long
|
|
159 |
// key press created editor on UI or some other similar non-standard situation.
|
|
160 |
// We can't handle key press, so just consume it.
|
|
161 |
return ETrue;
|
|
162 |
}
|
|
163 |
|
|
164 |
TPtrC text = ptiengine->PreviousCandidate();
|
|
165 |
fepMan->UpdateInlineEditL(text, text.Length());
|
|
166 |
fepMan->CommitInlineEditL();
|
|
167 |
ptiengine->ClearCurrentWord();
|
|
168 |
ret = EFalse;
|
|
169 |
}
|
|
170 |
else if (aKey == EKeyBackspace)
|
|
171 |
{
|
|
172 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))
|
|
173 |
{
|
|
174 |
fepMan->CommitInlineEditL();
|
|
175 |
ptiengine->ClearCurrentWord();
|
|
176 |
fepMan->TryCloseUiL();
|
|
177 |
}
|
|
178 |
ret = EFalse;
|
|
179 |
}
|
|
180 |
else
|
|
181 |
{
|
|
182 |
ret = EFalse;
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
}
|
|
187 |
return ret;
|
|
188 |
}
|
|
189 |
|
|
190 |
// Decides wheather text should be commited or not. Makes comparison between latest key input
|
|
191 |
// and "seed" jamos. if latest input match with one of "seed" jamos and star or hash key cannot make
|
|
192 |
// any changes to input, then commit.
|
|
193 |
// NOTE; the "seed" jamos are characters that are printed on keymat. Narat geul engine compiles all
|
|
194 |
// the hanguls from 12 jamos.
|
|
195 |
TBool TAknFepInputStateInitialKoreanMultitap::CommitOrNot(TPtrC aData, TInt aKey)
|
|
196 |
{
|
|
197 |
TBool commit = EFalse;
|
|
198 |
TBuf<CAknFepManager::EMaximumFepWordLength> mappings;
|
|
199 |
TInt len;
|
|
200 |
|
|
201 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
202 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
203 |
|
|
204 |
ptiengine->MappingDataForKey((TPtiKey)aKey, mappings, ptiengine->Case());
|
|
205 |
len = mappings.Length();
|
|
206 |
|
|
207 |
for (TInt i = 0; i < len; i++ )
|
|
208 |
{
|
|
209 |
if(aData.Compare(mappings.Left(i + 1)) == 0)
|
|
210 |
{
|
|
211 |
commit = ETrue;
|
|
212 |
break;
|
|
213 |
}
|
|
214 |
}
|
|
215 |
|
|
216 |
return commit;
|
|
217 |
}
|
|
218 |
|
|
219 |
// End of file
|