|
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 CAknFepUIInputStateEntryQwertyPinyinPhrase methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
31 #include "AknFepUiCtrlContainerChinese.h" |
|
32 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
33 #include "AknFepUICtrlCandidatePane.h" |
|
34 #include "AknFepUICtrlInputPane.h" |
|
35 #include "AknFepUiInputStateEntryQwertyPinyinPhrase.h" |
|
36 #include "AknFepManager.h" |
|
37 |
|
38 #include <PtiEngine.h> //CPtiEngine |
|
39 #include <e32keys.h> //keys |
|
40 #include <avkon.rsg> |
|
41 |
|
42 const TInt KInputPaneLength = 32; |
|
43 _LIT(KSep, "'"); |
|
44 _LIT(KReplace, ""); |
|
45 |
|
46 TAknFepInputStateEntryQwertyPinyinPhrase::TAknFepInputStateEntryQwertyPinyinPhrase( |
|
47 MAknFepUIManagerStateInterface* aOwner, |
|
48 MAknFepUICtrlContainerChinese* aUIContainer) |
|
49 :TAknFepInputStateEntryQwertyBaseChinesePhrase(aOwner,aUIContainer) |
|
50 { |
|
51 iOwner->PtiEngine()->SetInputMode(EPtiEnginePinyinPhraseQwerty); |
|
52 iOwner->PtiEngine()->SetCase(EPtiCaseLower); |
|
53 } |
|
54 |
|
55 TBool TAknFepInputStateEntryQwertyPinyinPhrase::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
56 { |
|
57 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
58 TBool ret = ETrue; |
|
59 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
60 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
61 |
|
62 if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress) |
|
63 { |
|
64 if(ptiengine->IncrementToneMark(ETrue)) |
|
65 { |
|
66 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
67 uiContainer->CandidatePane()->IsFirstPage()); |
|
68 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
69 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
70 |
|
71 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
72 uiContainer->CandidatePane()->IsFirstPage())); |
|
73 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
74 uiContainer->InputPane()->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
75 SetInputPaneToneMark(); |
|
76 RefreshUI(); |
|
77 } |
|
78 } |
|
79 else if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagShiftKeyDepressed) || |
|
80 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
81 { |
|
82 ret = ETrue; |
|
83 } |
|
84 else if(aLength == EShortKeyPress && iOwner->IsValidChineseInputKeyQwerty(aKey) ) |
|
85 { |
|
86 if (!uiContainer->IsEnabled() && |
|
87 (aKey == EPtiKeyQwertyI || aKey == EPtiKeyQwertyU || aKey == EPtiKeyQwertyV)) |
|
88 { |
|
89 iOwner->FepMan()->UpdateCbaL(NULL); |
|
90 iOwner->ChangeState(EQwerty); |
|
91 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
92 return ret; |
|
93 } |
|
94 |
|
95 TInt stringBeforeLength(0); |
|
96 TInt stringAfterLength(0); |
|
97 |
|
98 stringBeforeLength = ptiengine->GetPhoneticSpelling(1).Length(); |
|
99 stringAfterLength = ptiengine->AppendKeyPress((TPtiKey)aKey).Length(); |
|
100 |
|
101 if (stringBeforeLength != stringAfterLength) |
|
102 { |
|
103 if (ptiengine->GetPhoneticSpelling(1).Length() == 1) |
|
104 { |
|
105 iOwner->FepMan()->UpdateCbaL(R_AVKON_SOFTKEYS_EMPTY); |
|
106 } |
|
107 |
|
108 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
109 uiContainer->CandidatePane()->IsFirstPage()); |
|
110 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
111 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
112 |
|
113 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
114 uiContainer->CandidatePane()->IsFirstPage())); |
|
115 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
116 SetInputPaneToneMark(); |
|
117 uiContainer->InputPane()->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
118 |
|
119 RefreshUI(); |
|
120 } |
|
121 else |
|
122 { |
|
123 iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone); |
|
124 } |
|
125 |
|
126 if (ptiengine->GetPhoneticSpelling(1).Length() == 0) |
|
127 { |
|
128 iOwner->FepMan()->UpdateCbaL(NULL); |
|
129 } |
|
130 } |
|
131 else if(aKey == EStdKeyBackspace) |
|
132 { |
|
133 if (iOwner->PtiEngine()->DeleteKeyPress().Length()) |
|
134 { |
|
135 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
136 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
137 uiContainer->CandidatePane()->IsFirstPage())); |
|
138 SetInputPaneToneMark(); |
|
139 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
140 RefreshUI(); |
|
141 } |
|
142 else |
|
143 { |
|
144 iOwner->FepMan()->TryCloseUiL(); |
|
145 if (aLength == ELongKeyPress) |
|
146 { |
|
147 iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue); |
|
148 } |
|
149 } |
|
150 } |
|
151 else if (aKey == EStdKeyEnter) |
|
152 { |
|
153 TBuf<KInputPaneLength> currentText; |
|
154 inputPane->GetText(currentText); |
|
155 |
|
156 while(currentText.Find(KSep)> 0) |
|
157 { |
|
158 currentText.Replace(currentText.Find(KSep), 1,KReplace); |
|
159 } |
|
160 |
|
161 |
|
162 if(currentText.Length()) |
|
163 { |
|
164 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
165 fepMan->NewTextL(currentText); |
|
166 fepMan->CommitInlineEditL(); |
|
167 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
168 { |
|
169 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
170 iOwner->FepMan()->TryCloseUiL(); |
|
171 } |
|
172 else |
|
173 { |
|
174 iOwner->FepMan()->TryCloseUiL(); |
|
175 } |
|
176 } |
|
177 } |
|
178 else if (aKey == EStdKeySpace) |
|
179 { |
|
180 TInt index = MapKeyToIndex(EStdKeyDevice3); |
|
181 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
182 |
|
183 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
|
184 if(text.Length()) |
|
185 { |
|
186 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
187 fepMan->NewTextL(text); |
|
188 fepMan->CommitInlineEditL(); |
|
189 iOwner->PtiEngine()->SetPredictiveChineseChar(text); |
|
190 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
191 { |
|
192 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
193 iOwner->FepMan()->TryCloseUiL(); |
|
194 } |
|
195 else |
|
196 { |
|
197 iOwner->ChangeState(EPredictiveInput); |
|
198 } |
|
199 } |
|
200 else |
|
201 { |
|
202 // No candidates available. Back to Entry state. |
|
203 iOwner->ChangeState(EEntry); |
|
204 } |
|
205 } |
|
206 else |
|
207 { |
|
208 ret = TAknFepInputStateEntryQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength); |
|
209 } |
|
210 |
|
211 return ret; |
|
212 } |
|
213 |
|
214 // End of file |