|
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 TBuf<2> newText; |
|
148 // Get the last character from the current editor |
|
149 TText prevChar = fepMan->PreviousChar(); |
|
150 |
|
151 // Judge if the last character needs to be converted |
|
152 if ( NeedsVietnameseBkDelSupport(prevChar, newText) ) |
|
153 { |
|
154 // Delete the prev character and send the new character to editor |
|
155 ((CAknFepManager*)fepMan)->RemovePreviousCharacterL(); |
|
156 fepMan->NewCharacterL(newText); |
|
157 fepMan->CommitInlineEditL(); |
|
158 // Stop looping for backspace operation |
|
159 if( toneMgr->IsLooping() ) |
|
160 { |
|
161 toneMgr->StopToneMarkLooping(); |
|
162 } |
|
163 return ETrue; |
|
164 } |
|
165 else |
|
166 { |
|
167 if ( prevChar ) |
|
168 { |
|
169 ((CAknFepManager*)fepMan)->RemovePreviousCharacterL(); |
|
170 } |
|
171 else |
|
172 { |
|
173 return EFalse; |
|
174 } |
|
175 |
|
176 bHandled = EFalse; |
|
177 } |
|
178 } |
|
179 |
|
180 if(!bHandled && toneMgr->IsLooping()) |
|
181 { |
|
182 toneMgr->StopToneMarkLooping(); |
|
183 } |
|
184 |
|
185 return bHandled ? ETrue : TAknFepInputStateInitialMultitapBase::HandleKeyL(aKey, aLength); |
|
186 } |
|
187 |
|
188 void TAknFepInputStateInitialVietnameseMultitap::KeyTimerExpired() |
|
189 { |
|
190 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
191 CAknFepUIManagerWestern* uiMan = static_cast<CAknFepUIManagerWestern*>(iOwner); |
|
192 CAknFepVietnameseToneManager* toneMgr = uiMan->VietnameseToneManager(); |
|
193 CPtiEngine* ptiEng = fepMan->PtiEngine(); |
|
194 |
|
195 // Try commit inline editting and clean up for future input attemps |
|
196 TRAP_IGNORE(fepMan->CommitInlineEditL()); |
|
197 |
|
198 toneMgr->StopToneMarkLooping(); |
|
199 ptiEng->ClearCurrentWord(); |
|
200 } |
|
201 |
|
202 TBool TAknFepInputStateInitialVietnameseMultitap::NeedsVietnameseBkDelSupport( |
|
203 TText aGlyphToDelete, TDes& aNewText) |
|
204 { |
|
205 TBool needBkDelSupport(EFalse); |
|
206 |
|
207 const TInt KMatrixColumn = sizeof(VietToneMatrix) / sizeof(TText) / KNumberOfToneMarks; |
|
208 |
|
209 aNewText.Zero(); |
|
210 |
|
211 // Loop of the ToneMatrix columns starts from 1 because the first column of the ToneMatrix stores the vowels |
|
212 for (TUint i = 1; (i < KMatrixColumn) && (!needBkDelSupport); ++i) |
|
213 { |
|
214 for (TUint j = 0; j < KNumberOfToneMarks; ++j) |
|
215 { |
|
216 if (VietToneMatrix[i][j] == aGlyphToDelete) |
|
217 { |
|
218 needBkDelSupport = ETrue; |
|
219 aNewText.Append(VietVowelList[i - 1]); |
|
220 break; |
|
221 } |
|
222 } |
|
223 } |
|
224 |
|
225 return needBkDelSupport; |
|
226 } |
|
227 |
|
228 // End of file |