|
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 candidate qwerty chinese base state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 #include "AknFepUiInputStateCandidateQwertyChineseBase.h" |
|
30 #include "AknFepUICtrlCandidatePane.h" |
|
31 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
32 #include "AknFepManagerUIInterface.h" |
|
33 #include "AknFepManager.h" //FepMan flag |
|
34 |
|
35 #include <PtiEngine.h> //CPtiEngine |
|
36 |
|
37 const TInt KMaxCandidateCountFromCore = 6; |
|
38 |
|
39 TAknFepInputStateCandidateQwertyChineseBase::TAknFepInputStateCandidateQwertyChineseBase( |
|
40 MAknFepUIManagerStateInterface* aOwner, |
|
41 MAknFepUICtrlContainerChinese* aUIContainer) |
|
42 :TAknFepInputStateChineseBase(aOwner, aUIContainer) |
|
43 { |
|
44 } |
|
45 |
|
46 TBool TAknFepInputStateCandidateQwertyChineseBase::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/) |
|
47 { |
|
48 if(aKey == EStdKeyDevice1) |
|
49 { |
|
50 iOwner->FepMan()->TryCloseUiL(); |
|
51 } |
|
52 else if(!( HandleVerticalNavigation(aKey) || HandleHorizontalNavigation(aKey) )) |
|
53 { |
|
54 // it may be one of the 'valid' numbers.. |
|
55 TInt index = MapKeyToIndex(aKey); |
|
56 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
57 |
|
58 if(candidatePane->SelectIndex(index) || aKey == EStdKeyDevice3 || aKey == EStdKeyEnter) |
|
59 { |
|
60 TPtrC text = candidatePane->CurrentCandidate(); |
|
61 if(text.Length()) |
|
62 { |
|
63 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
64 fepMan->NewCharacterL(text); |
|
65 fepMan->CommitInlineEditL(); |
|
66 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
67 { |
|
68 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
69 iOwner->FepMan()->TryCloseUiL(); |
|
70 } |
|
71 else |
|
72 { |
|
73 iOwner->ChangeState(EPredictiveInput); |
|
74 } |
|
75 } |
|
76 else |
|
77 { |
|
78 // No candidates available. Back to Entry state. |
|
79 iOwner->ChangeState(EEntry); |
|
80 } |
|
81 } |
|
82 } |
|
83 return ETrue; |
|
84 } |
|
85 |
|
86 TBool TAknFepInputStateCandidateQwertyChineseBase::HandleHorizontalNavigation(TInt aKey) |
|
87 { |
|
88 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
89 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
90 TBool response = EFalse; |
|
91 |
|
92 // Do navigation... |
|
93 if (aKey == EStdKeyLeftArrow) |
|
94 { |
|
95 if (candidatePane->SelectedIndex() == 0 && |
|
96 ptiengine->NumberOfCandidates() == 0) |
|
97 { |
|
98 return ETrue; |
|
99 } |
|
100 |
|
101 if(!candidatePane->SelectPrev()) |
|
102 { |
|
103 ptiengine->PreviousCandidatePage(); |
|
104 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
105 candidatePane->SelectLast(); |
|
106 } |
|
107 response = ETrue; |
|
108 } |
|
109 else if (aKey == EStdKeyRightArrow) |
|
110 { |
|
111 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
112 |
|
113 if (bufLength != KMaxCandidateCountFromCore && |
|
114 candidatePane->SelectedIndex() == (bufLength -1)) |
|
115 { |
|
116 return ETrue; |
|
117 } |
|
118 |
|
119 if(!candidatePane->SelectNext()) |
|
120 { |
|
121 ptiengine->NextCandidatePage(); |
|
122 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
123 candidatePane->SelectFirst(); |
|
124 } |
|
125 response = ETrue; |
|
126 } |
|
127 if (response) |
|
128 { |
|
129 UpdateIndicator(); |
|
130 } |
|
131 |
|
132 return response; |
|
133 } |
|
134 |
|
135 TBool TAknFepInputStateCandidateQwertyChineseBase::HandleVerticalNavigation(TInt aKey) |
|
136 { |
|
137 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
138 |
|
139 if (aKey == EStdKeyDownArrow || aKey == EStdKeySpace) |
|
140 { |
|
141 if (iOwner->PtiEngine()->CandidatePage().Length() != |
|
142 KMaxCandidateCountFromCore) |
|
143 { |
|
144 return ETrue; |
|
145 } |
|
146 |
|
147 ptiengine->NextCandidatePage(); |
|
148 } |
|
149 else if (aKey == EStdKeyUpArrow) |
|
150 { |
|
151 if (ptiengine->NumberOfCandidates() == 0) |
|
152 { |
|
153 return ETrue; |
|
154 } |
|
155 |
|
156 ptiengine->PreviousCandidatePage(); |
|
157 } |
|
158 else |
|
159 { |
|
160 return EFalse; |
|
161 } |
|
162 |
|
163 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
164 candidatePane->SelectFirst(); |
|
165 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
166 UpdateIndicator(); |
|
167 return ETrue; |
|
168 } |
|
169 |
|
170 void TAknFepInputStateCandidateQwertyChineseBase::UpdateIndicator() |
|
171 { |
|
172 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
173 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
174 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
175 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
176 |
|
177 if (ptiengine->NumberOfCandidates() == 0) |
|
178 { |
|
179 uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse); |
|
180 } |
|
181 else |
|
182 { |
|
183 uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue); |
|
184 } |
|
185 |
|
186 uiContainer->CandidatePane()->ShowDownScrollArrows |
|
187 (bufLength == KMaxCandidateCountFromCore ? ETrue : EFalse); |
|
188 |
|
189 if (candidatePane->SelectedIndex() == 0 && |
|
190 ptiengine->NumberOfCandidates() == 0) |
|
191 { |
|
192 uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse); |
|
193 } |
|
194 else |
|
195 { |
|
196 uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue); |
|
197 } |
|
198 |
|
199 if (bufLength != KMaxCandidateCountFromCore && |
|
200 candidatePane->SelectedIndex() == (bufLength -1)) |
|
201 { |
|
202 uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse); |
|
203 } |
|
204 else |
|
205 { |
|
206 uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue); |
|
207 } |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // TAknFepInputStateCandidateQwertyChineseBase::HandleCommandL |
|
212 // Handling Command |
|
213 // --------------------------------------------------------------------------- |
|
214 // |
|
215 void TAknFepInputStateCandidateQwertyChineseBase::HandleCommandL( |
|
216 TInt aCommandId ) |
|
217 { |
|
218 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
219 } |
|
220 // End of file |