|
1 /* |
|
2 * Copyright (c) 2002-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: Implementation of Pinyin and Stroke phrase candidate state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 // System includes |
|
30 #include <PtiEngine.h> |
|
31 #include <PtiUserDicEntry.h> |
|
32 #include <aknnotewrappers.h> //CAknWarningNote |
|
33 |
|
34 const TInt KMinCandidateCount = 1; |
|
35 // User includes |
|
36 #include "AknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase.h" |
|
37 #include "AknFepUiInputStateCandidateQwertyBaseChinesePhrase.h" |
|
38 #include "AknFepUiCtrlContainerChinese.h" |
|
39 #include "AknFepUICtrlCandidatePane.h" |
|
40 #include "AknFepUICtrlInputPane.h" |
|
41 #include "aknfepuictrleditpane.h" //phrase creation |
|
42 #include "AknFepUIManagerStateInterface.h" |
|
43 #include "AknFepManager.h" |
|
44 #include <aknfep.rsg> |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // AknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase:: |
|
48 // TAknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase |
|
49 // (other items were commented in a header). |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 TAknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase:: |
|
53 TAknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase(MAknFepUIManagerStateInterface* aOwner, |
|
54 MAknFepUICtrlContainerChinese* aUIContainer) |
|
55 :TAknFepInputMiniQwertyPinyinPhraseBase(aOwner, aUIContainer) |
|
56 { |
|
57 iState = ECandidate; |
|
58 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
59 |
|
60 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
61 uiContainer->CandidatePane()->IsFirstPage()); |
|
62 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
63 TBool showHorizontalScrollArrows = multiplePages || bufLength > KMinCandidateCount; |
|
64 |
|
65 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
66 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
67 uiContainer->FocusCandidatePane(ETrue); |
|
68 uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue); |
|
69 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
70 UIContainer()->EditPaneWindow()->DisableCursor(); |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // AknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase::HandleKeyL |
|
75 // (other items were commented in a header). |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 TBool TAknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase::HandleKeyL(TInt aKey, |
|
79 TKeyPressLength aLength) |
|
80 { |
|
81 TInt selected = UIContainer()->CandidatePane()->SelectedIndex(); |
|
82 TInt numbertotal = UIContainer()->CandidatePane()->VisibleCandidateCount(); |
|
83 |
|
84 if ( iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagQwertyChrKeyDepressed ) |
|
85 || iOwner->FepMan()->IsFlagSet( CAknFepManager::EFlagShiftKeyDepressed ) ) |
|
86 { |
|
87 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
88 return ETrue; |
|
89 } |
|
90 TBool ret = EFalse; |
|
91 switch ( aKey ) |
|
92 { |
|
93 case EStdKeySpace: |
|
94 { |
|
95 if ( ECangJie ==iOwner->FepMan()->InputMode() ) |
|
96 { |
|
97 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate(); |
|
98 if ( text.Length() ) |
|
99 { |
|
100 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
101 fepMan->NewTextL( text ); |
|
102 fepMan->CommitInlineEditL(); |
|
103 iOwner->PtiEngine()->SetPredictiveChineseChar( text ); |
|
104 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) ) |
|
105 { |
|
106 fepMan->ClearFlag( CAknFepManager::EFlagEditorFull ); |
|
107 iOwner->FepMan()->TryCloseUiL(); |
|
108 } |
|
109 else |
|
110 { |
|
111 UIContainer()->EditPaneWindow()->SetChangeState(ETrue); |
|
112 iOwner->ChangeState( EPredictiveCandidate ); |
|
113 } |
|
114 } |
|
115 } |
|
116 else |
|
117 { |
|
118 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
119 } |
|
120 ret = ETrue; |
|
121 } |
|
122 break; |
|
123 case EStdKeyBackspace: |
|
124 { |
|
125 UIContainer()->CandidatePane()->SetCandidateBuffer(); |
|
126 UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EManualChangeState ); |
|
127 UIContainer()->EditPaneWindow()->SetChangeState( ETrue ); |
|
128 iOwner->ChangeState( EMiniQwertyEdit ); |
|
129 iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_OK_SELECT_CANCEL ); |
|
130 ret = ETrue; |
|
131 } |
|
132 break; |
|
133 case EStdKeyLeftArrow: |
|
134 { |
|
135 if ( selected == 0 ) |
|
136 { |
|
137 UIContainer()->CandidatePane()->SelectIndex( numbertotal - 1 ); |
|
138 } |
|
139 else |
|
140 { |
|
141 UIContainer()->CandidatePane()->SelectIndex( selected - 1 ); |
|
142 } |
|
143 UpdateIndicator(); |
|
144 ret = ETrue; |
|
145 } |
|
146 break; |
|
147 case EStdKeyRightArrow: |
|
148 { |
|
149 if ( selected == numbertotal - 1 ) |
|
150 { |
|
151 UIContainer()->CandidatePane()->SelectIndex( 0 ); |
|
152 } |
|
153 else |
|
154 { |
|
155 UIContainer()->CandidatePane()->SelectIndex( selected + 1 ); |
|
156 } |
|
157 UpdateIndicator(); |
|
158 ret = ETrue; |
|
159 } |
|
160 break; |
|
161 case EStdKeyDownArrow: |
|
162 { |
|
163 ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength); |
|
164 } |
|
165 break; |
|
166 case EStdKeyUpArrow: |
|
167 { |
|
168 if ( UIContainer()->CandidatePane()->IsFirstPage() ) |
|
169 { |
|
170 UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EManualChangeState ); |
|
171 iOwner->ChangeState( EMiniQwertyEdit ); |
|
172 return ETrue; |
|
173 } |
|
174 else |
|
175 { |
|
176 UIContainer()->CandidatePane()->PreviousCandidatePage(); |
|
177 UIContainer()->CandidatePane()->SetCandidateBuffer(); |
|
178 UIContainer()->CandidatePane()->SelectFirstPhrase(); |
|
179 UpdateIndicator(); |
|
180 } |
|
181 ret = ETrue; |
|
182 } |
|
183 break; |
|
184 case EStdKeyEnter: |
|
185 { |
|
186 if ( EStroke == iOwner->FepMan()->InputMode() || |
|
187 ECangJie == iOwner->FepMan()->InputMode() || |
|
188 EPinyin == iOwner->FepMan()->InputMode() ) |
|
189 { |
|
190 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
191 } |
|
192 ret = ETrue; |
|
193 } |
|
194 break; |
|
195 case EStdKeyDevice0: |
|
196 case EStdKeyDevice3: |
|
197 { |
|
198 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate(); |
|
199 if ( text.Length() && aLength != ELongKeyPress ) |
|
200 { |
|
201 if ( !CommitInlineEEPL( text ) ) |
|
202 { |
|
203 DoActionAfterCommit(); |
|
204 } |
|
205 else |
|
206 { |
|
207 if ( CheckFirstGroupStroke() ) |
|
208 { |
|
209 RefreshUI( EFalse ); |
|
210 UIContainer()->CandidatePane()->SelectFirstPhrase(); |
|
211 } |
|
212 else |
|
213 { |
|
214 UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EAutoChangeStateFromCandidate ); |
|
215 iOwner->ChangeState( EMiniQwertyEdit ); |
|
216 } |
|
217 } |
|
218 } |
|
219 } |
|
220 ret = ETrue; |
|
221 break; |
|
222 case EKeyLeftCtrl: |
|
223 case EKeyRightCtrl: |
|
224 case EKeyLeftShift: |
|
225 { |
|
226 iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone ); |
|
227 ret = ETrue; |
|
228 } |
|
229 break; |
|
230 case EKeyRightShift: |
|
231 { |
|
232 ret = ETrue; |
|
233 } |
|
234 break; |
|
235 default: |
|
236 return TAknFepInputMiniQwertyPinyinPhraseBase::HandleKeyL( |
|
237 aKey, aLength ); |
|
238 } |
|
239 return ret; |
|
240 } |
|
241 // --------------------------------------------------------------------------- |
|
242 // TAknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase::HandleCommandL |
|
243 // Handling Command |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void TAknFepUiInputStateCandidateMiniQwertyPinyinAndStrokePhrase::HandleCommandL( |
|
247 TInt aCommandId ) |
|
248 { |
|
249 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate( ); |
|
250 switch ( aCommandId ) |
|
251 { |
|
252 // Handle the event frome command. |
|
253 case EAknSoftkeySelect: |
|
254 // case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
255 if ( text.Length( ) ) |
|
256 { |
|
257 if ( !CommitInlineEEPL( text ) ) |
|
258 { |
|
259 DoActionAfterCommit( ); |
|
260 } |
|
261 else |
|
262 { |
|
263 if ( CheckFirstGroupStroke( ) ) |
|
264 { |
|
265 RefreshUI( EFalse ); |
|
266 UIContainer()->CandidatePane()->SelectFirstPhrase( ); |
|
267 } |
|
268 else |
|
269 { |
|
270 UIContainer()->EditPaneWindow()->SetAutoChangeStateFlag( EAutoChangeStateFromCandidate ); |
|
271 iOwner->ChangeState( EMiniQwertyEdit ); |
|
272 } |
|
273 } |
|
274 } |
|
275 break; |
|
276 default: |
|
277 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
278 break; |
|
279 } |
|
280 } |
|
281 |
|
282 // End of file |