44
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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 TAknFepInputStateInitialVietnameseMultitap methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
#include "AknFepUIInputStateInitialVietnameseMultitap.h"
|
|
31 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
32 |
|
|
33 |
#include "AknFepCaseManager.h"
|
|
34 |
#include "AknFepVietnameseToneManager.h"
|
|
35 |
|
|
36 |
#include <uikon.hrh>
|
|
37 |
|
|
38 |
#include <PtiEngine.h>
|
|
39 |
#include <PtiDefs.h>
|
|
40 |
#include <aknSctDialog.h>
|
|
41 |
#include <avkon.rsg>
|
|
42 |
#include <aknfep.rsg>
|
|
43 |
|
|
44 |
#include "AknFepUiManagerWestern.h"
|
|
45 |
|
|
46 |
TAknFepInputStateInitialVietnameseMultitap::
|
|
47 |
TAknFepInputStateInitialVietnameseMultitap(MAknFepUIManagerStateInterface* aOwner)
|
|
48 |
:TAknFepInputStateInitialMultitapBase(aOwner)
|
|
49 |
{
|
|
50 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
51 |
TPtiTextCase caseMode = ptiengine->Case();
|
|
52 |
ptiengine->SetCase(caseMode);
|
|
53 |
}
|
|
54 |
|
|
55 |
TBool TAknFepInputStateInitialVietnameseMultitap::HandleKeyL(TInt aKey, TKeyPressLength aLength)
|
|
56 |
{
|
|
57 |
TBool bHandled = EFalse;
|
|
58 |
|
|
59 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
60 |
CAknFepUIManagerWestern* uiMan = static_cast<CAknFepUIManagerWestern*>(iOwner);
|
|
61 |
CAknFepVietnameseToneManager* toneMgr = uiMan->VietnameseToneManager();
|
|
62 |
CPtiEngine* ptiEng = fepMan->PtiEngine();
|
|
63 |
|
|
64 |
toneMgr->SetFepManager(fepMan);
|
|
65 |
|
|
66 |
if (aKey == EPtiKeyStar)
|
|
67 |
{
|
|
68 |
if (aLength == EShortKeyPress)
|
|
69 |
{
|
|
70 |
if (!toneMgr->IsLooping())
|
|
71 |
{
|
|
72 |
// Start looping status
|
|
73 |
if (toneMgr->StartToneMarkLooping())
|
|
74 |
{
|
|
75 |
// Save the vowel for undo back deletion
|
|
76 |
toneMgr->SetDeletedVowel(fepMan->PreviousChar());
|
|
77 |
|
|
78 |
((CAknFepManager*)fepMan)->RemovePreviousCharacterL(); // remove previous char
|
|
79 |
}
|
|
80 |
}
|
|
81 |
|
|
82 |
// Process the interim looping state
|
|
83 |
if (toneMgr->IsLooping())
|
|
84 |
{
|
|
85 |
// Get current tone mark
|
|
86 |
TText toneVowel = toneMgr->GetVowelWithToneMark();
|
|
87 |
toneMgr->IncrementToneMark();
|
|
88 |
|
|
89 |
TBuf<CAknFepManager::ESingleCharacter> aChr;
|
|
90 |
aChr.Append(toneVowel);
|
|
91 |
|
|
92 |
// Update inline character(s)
|
|
93 |
fepMan->CancelInlineEdit();
|
|
94 |
fepMan->NewCharacterL(aChr);
|
|
95 |
|
|
96 |
// Reset the engine timer so that we can get timer expired message
|
|
97 |
// We send the * key, and clear it in the next loop
|
|
98 |
ptiEng->ClearCurrentWord();
|
|
99 |
ptiEng->AppendKeyPress((TPtiKey)aKey);
|
|
100 |
|
|
101 |
bHandled = ETrue;
|
|
102 |
|
|
103 |
if (fepMan->EditSubmenuInUse())
|
|
104 |
{
|
|
105 |
// Looping tone marks, supress edit-menu.
|
|
106 |
fepMan->SetCcpuFlag(CAknFepManager::ECcpuStateIgnoreStarUp);
|
|
107 |
}
|
|
108 |
}
|
|
109 |
}
|
|
110 |
else if (aLength == ELongKeyPress)
|
|
111 |
{
|
|
112 |
// Reset the key event so that the TAknFepInputStateInitialMultitapBase will
|
|
113 |
// parse this event as a short key event, default reaction is to launch SCT
|
|
114 |
aLength = EShortKeyPress;
|
|
115 |
|
|
116 |
if (toneMgr->IsLooping())
|
|
117 |
{
|
|
118 |
// Remove the previous EShortKeyPress message
|
|
119 |
fepMan->CancelInlineEdit();
|
|
120 |
toneMgr->StopToneMarkLooping();
|
|
121 |
|
|
122 |
// Undo the backdeletion
|
|
123 |
TText bkChr = toneMgr->GetDeletedVowel();
|
|
124 |
|
|
125 |
TBuf<CAknFepManager::ESingleCharacter> aChr;
|
|
126 |
aChr.Append(bkChr);
|
|
127 |
|
|
128 |
fepMan->NewCharacterL(aChr);
|
|
129 |
fepMan->CommitInlineEditL();
|
|
130 |
|
|
131 |
if (fepMan->EditSubmenuInUse() && fepMan->IsAbleToLaunchSCT())
|
|
132 |
{
|
|
133 |
fepMan->LaunchSpecialCharacterTableL();
|
|
134 |
return ETrue;
|
|
135 |
}
|
|
136 |
}
|
|
137 |
else if (fepMan->EditSubmenuInUse())
|
|
138 |
{
|
|
139 |
aLength = ELongKeyPress;
|
|
140 |
}
|
|
141 |
}
|
|
142 |
}
|
|
143 |
|
|
144 |
// Implementation for the Vietnamese back deletion
|
|
145 |
if (aKey == EKeyBackspace)
|
|
146 |
{
|
|
147 |
// Key looping should be cancelled as pressing backspace key
|
|
148 |
toneMgr->StopKeyLooping();
|
|
149 |
|
|
150 |
TBuf<2> newText;
|
|
151 |
// Get the last character from the current editor
|
|
152 |
TText prevChar = fepMan->PreviousChar();
|
|
153 |
|
|
154 |
// Judge if the last character needs to be converted
|
|
155 |
if ( NeedsVietnameseBkDelSupport(prevChar, newText) )
|
|
156 |
{
|
|
157 |
// Delete the prev character and send the new character to editor
|
|
158 |
((CAknFepManager*)fepMan)->RemovePreviousCharacterL();
|
|
159 |
fepMan->NewCharacterL(newText);
|
|
160 |
fepMan->CommitInlineEditL();
|
|
161 |
// Stop looping for backspace operation
|
|
162 |
if( toneMgr->IsLooping() )
|
|
163 |
{
|
|
164 |
toneMgr->StopToneMarkLooping();
|
|
165 |
}
|
|
166 |
return ETrue;
|
|
167 |
}
|
|
168 |
else
|
|
169 |
{
|
|
170 |
if ( prevChar )
|
|
171 |
{
|
|
172 |
((CAknFepManager*)fepMan)->RemovePreviousCharacterL();
|
|
173 |
}
|
|
174 |
else
|
|
175 |
{
|
|
176 |
return EFalse;
|
|
177 |
}
|
|
178 |
|
|
179 |
bHandled = EFalse;
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
if( aLength == EShortKeyPress )
|
|
184 |
{
|
|
185 |
if( toneMgr->IsKeyLooping( aKey ) )
|
|
186 |
{
|
|
187 |
if( toneMgr->ToneMarkIndex() != KErrNotFound )
|
|
188 |
{
|
|
189 |
// Get current tone mark
|
|
190 |
TText toneVowel;
|
|
191 |
if( toneMgr->GetLoopingToneMarkVowel( toneVowel ) )
|
|
192 |
{
|
|
193 |
// remove two previous chars
|
|
194 |
((CAknFepManager*)fepMan)->RemovePreviousCharacterL();
|
|
195 |
((CAknFepManager*)fepMan)->RemovePreviousCharacterL();
|
|
196 |
|
|
197 |
TBuf<CAknFepManager::ESingleCharacter> aChr;
|
|
198 |
aChr.Append(toneVowel);
|
|
199 |
|
|
200 |
// Update inline character(s)
|
|
201 |
fepMan->CancelInlineEdit();
|
|
202 |
fepMan->NewCharacterL(aChr);
|
|
203 |
|
|
204 |
toneMgr->SetLoopingCombined( ETrue );
|
|
205 |
bHandled = ETrue;
|
|
206 |
}
|
|
207 |
|
|
208 |
// Reset the engine timer so that we can get timer expired message
|
|
209 |
// We send the * key, and clear it in the next loop
|
|
210 |
ptiEng->ClearCurrentWord();
|
|
211 |
ptiEng->AppendKeyPress((TPtiKey)EPtiKeyStar);
|
|
212 |
}
|
|
213 |
else
|
|
214 |
{
|
|
215 |
if( toneMgr->IsLoopingCombined() )
|
|
216 |
{
|
|
217 |
// remove tone mark
|
|
218 |
TBuf<2> newText;
|
|
219 |
// Get the last character from the current editor
|
|
220 |
TText prevChar = fepMan->PreviousChar();
|
|
221 |
|
|
222 |
// Judge if the last character needs to be converted
|
|
223 |
if ( NeedsVietnameseBkDelSupport(prevChar, newText) )
|
|
224 |
{
|
|
225 |
// Delete the prev character and send the new character to editor
|
|
226 |
((CAknFepManager*)fepMan)->RemovePreviousCharacterL();
|
|
227 |
fepMan->NewCharacterL(newText);
|
|
228 |
fepMan->CommitInlineEditL();
|
|
229 |
}
|
|
230 |
|
|
231 |
toneMgr->SetLoopingCombined( EFalse );
|
|
232 |
}
|
|
233 |
}
|
|
234 |
}
|
|
235 |
else
|
|
236 |
{
|
|
237 |
// Key looping is not supported with Backspace key
|
|
238 |
// Otherwise the process of deleting a2222 is wrong
|
|
239 |
if ( aKey != EKeyBackspace )
|
|
240 |
{
|
|
241 |
toneMgr->StartKeyLooping( aKey );
|
|
242 |
}
|
|
243 |
}
|
|
244 |
}
|
|
245 |
else
|
|
246 |
{
|
|
247 |
// Key looping should be cancelled as long pressing key
|
|
248 |
// Otherwise a22 can not be inputted by press a, long press 2 and long press 2.
|
|
249 |
toneMgr->StopKeyLooping();
|
|
250 |
}
|
|
251 |
|
|
252 |
if(!bHandled && toneMgr->IsLooping())
|
|
253 |
{
|
|
254 |
toneMgr->StopToneMarkLooping();
|
|
255 |
}
|
|
256 |
|
|
257 |
return bHandled ? ETrue : TAknFepInputStateInitialMultitapBase::HandleKeyL(aKey, aLength);
|
|
258 |
}
|
|
259 |
|
|
260 |
void TAknFepInputStateInitialVietnameseMultitap::KeyTimerExpired()
|
|
261 |
{
|
|
262 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
263 |
CAknFepUIManagerWestern* uiMan = static_cast<CAknFepUIManagerWestern*>(iOwner);
|
|
264 |
CAknFepVietnameseToneManager* toneMgr = uiMan->VietnameseToneManager();
|
|
265 |
CPtiEngine* ptiEng = fepMan->PtiEngine();
|
|
266 |
|
|
267 |
// Try commit inline editting and clean up for future input attemps
|
|
268 |
TRAP_IGNORE(fepMan->CommitInlineEditL());
|
|
269 |
|
|
270 |
toneMgr->StopToneMarkLooping();
|
|
271 |
toneMgr->StopKeyLooping();
|
|
272 |
ptiEng->ClearCurrentWord();
|
|
273 |
}
|
|
274 |
|
|
275 |
TBool TAknFepInputStateInitialVietnameseMultitap::NeedsVietnameseBkDelSupport(
|
|
276 |
TText aGlyphToDelete, TDes& aNewText)
|
|
277 |
{
|
|
278 |
TBool needBkDelSupport(EFalse);
|
|
279 |
|
|
280 |
const TInt KMatrixColumn = sizeof(VietToneMatrix) / sizeof(TText) / KNumberOfToneMarks;
|
|
281 |
|
|
282 |
aNewText.Zero();
|
|
283 |
|
|
284 |
// Loop of the ToneMatrix columns starts from 1 because the first column of the ToneMatrix stores the vowels
|
|
285 |
for (TUint i = 1; (i < KMatrixColumn) && (!needBkDelSupport); ++i)
|
|
286 |
{
|
|
287 |
for (TUint j = 0; j < KNumberOfToneMarks; ++j)
|
|
288 |
{
|
|
289 |
if (VietToneMatrix[i][j] == aGlyphToDelete)
|
|
290 |
{
|
|
291 |
needBkDelSupport = ETrue;
|
|
292 |
aNewText.Append(VietVowelList[i - 1]);
|
|
293 |
break;
|
|
294 |
}
|
|
295 |
}
|
|
296 |
}
|
|
297 |
|
|
298 |
return needBkDelSupport;
|
|
299 |
}
|
|
300 |
|
|
301 |
// End of file
|