|
1 /* |
|
2 * Copyright (c) 2002-2004 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 TAknFepUiInputStateCandidateHiraganaKanji methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 // INCLUDE FILES |
|
31 |
|
32 |
|
33 #include "AknFepUiInputStateCandidateHiraganaKanji.h" |
|
34 #include "AknFepUIManagerStateInterface.h" // MAknFepUIManagerStateInterface |
|
35 #include "AknFepManagerUIInterface.h" // MAknFepManagerUIInterface |
|
36 #include "AknFepUICtrlContainerJapanese.h" // MAknFepUICtrlContainerJapanese |
|
37 #include "AknFepUICtrlCandidatePaneInterface.h" |
|
38 // MAknFepUICtrlCandidatePaneInterface |
|
39 #include "AknFepGlobalEnums.h" |
|
40 #include "AknFepPanic.h" |
|
41 |
|
42 #include <PtiDefs.h> // keys |
|
43 #include <PtiEngine.h> |
|
44 #include <PtiCompositionDataIF.h> // MPtiEngineCompositionDataInterfac |
|
45 #include <AknFep.rsg> |
|
46 |
|
47 // CONSTANTS |
|
48 |
|
49 /** |
|
50 * TAknFepUiInputStateCandidateHiraganaKanji class. |
|
51 * |
|
52 */ |
|
53 //============================ MEMBER FUNCTIONS ============================== |
|
54 |
|
55 // --------------------------------------------------------------------------- |
|
56 // TAknFepUiInputStateCandidateHiraganaKanji:: |
|
57 // TAknFepUiInputStateCandidateHiraganaKanji |
|
58 // C++ default Constructor |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 TAknFepUiInputStateCandidateHiraganaKanji::TAknFepUiInputStateCandidateHiraganaKanji( |
|
62 MAknFepUIManagerStateInterface* aOwner, |
|
63 MAknFepUICtrlContainerJapanese* aUIContainer) |
|
64 |
|
65 :TAknFepUiInputStateEntryJapaneseMultitap(aOwner, aUIContainer) |
|
66 { |
|
67 iState = ECandidate; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // TAknFepUiInputStateInitialJapaneseBase::InitializeStateL |
|
72 // Initialize State |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void TAknFepUiInputStateCandidateHiraganaKanji::InitializeStateL() |
|
76 { |
|
77 iOwner->SetInlineEditUnderlineVisibility(ETrue); |
|
78 |
|
79 // Get index number to show at first |
|
80 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
81 TInt index; |
|
82 CDesCArrayFlat* candidateArray = iOwner->CandidateArray(); |
|
83 ptiEngine->GetCandidateListL(*candidateArray); |
|
84 ptiEngine->HandleCommandL(EPtiCommandUserActionGetCurrentIndexOfCandidates, &index); |
|
85 |
|
86 UpdateCandidateListL(index); |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // TAknFepUiInputStateCandidateHiraganaKanji::CloseUI |
|
91 // Closing UI |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void TAknFepUiInputStateCandidateHiraganaKanji::CloseUI() |
|
95 { |
|
96 UIContainer()-> |
|
97 CandidatePane(MAknFepUICtrlContainerJapanese::EJapaneseCandidatePane)-> |
|
98 HideWindow(); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // TAknFepUiInputStateCandidateHiraganaKanji::HandleNumericKeyL |
|
103 // Handling short keypress events of the numeric and the star |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 TBool TAknFepUiInputStateCandidateHiraganaKanji::HandleNumericShortKeyL(TInt /*aKey*/) |
|
107 { |
|
108 // This state doesn't handle numeric key. |
|
109 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
110 ptiEngine->HandleCommandL(EPtiCommandUserActionAllComplete); |
|
111 CloseUI(); |
|
112 iOwner->ChangeState(EMultiCompletion); |
|
113 return EFalse; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // TAknFepUiInputStateCandidateHiraganaKanji::HandleNaviKeyL |
|
118 // Handling Navigate keypress event |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 TBool TAknFepUiInputStateCandidateHiraganaKanji::HandleNaviKeyL(TInt aKey, |
|
122 TKeyPressLength /*aLength*/) |
|
123 { |
|
124 TBool ret = EFalse; |
|
125 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
126 MAknFepUICtrlCandidatePaneInterface* candidatePane = |
|
127 UIContainer()->CandidatePane(MAknFepUICtrlContainerJapanese:: |
|
128 EJapaneseCandidatePane); |
|
129 TAknFepUICtrlScroll direction = EScrollNone; |
|
130 TPtiEngineCommand ptiCommand = EPtiCommandNone; |
|
131 |
|
132 switch(aKey) |
|
133 { |
|
134 case EKeyLeftArrow: |
|
135 case EKeyRightArrow: |
|
136 case EStdKeyLeftArrow: /* 0x0e */ |
|
137 case EStdKeyRightArrow: /* 0x0f */ |
|
138 { // Change Conversion state |
|
139 CloseUI(); |
|
140 iOwner->ChangeState(EConversion); |
|
141 ret = EFalse; |
|
142 } |
|
143 break; |
|
144 case EKeyDownArrow: |
|
145 case EKeyUpArrow: |
|
146 case EStdKeyDownArrow: /* 0x11 */ |
|
147 case EStdKeyUpArrow: /* 0x10 */ |
|
148 case EStdKeySpace: |
|
149 { // The highlight of candidate is moved up/down |
|
150 // aKey == EKeyDownArrow |
|
151 ptiCommand = EPtiCommandUserActionConvert; |
|
152 direction = EScrollDown; |
|
153 // aKey == EKeyUpArrow |
|
154 if (aKey == EKeyUpArrow || aKey == EStdKeyUpArrow) |
|
155 { |
|
156 ptiCommand = EPtiCommandUserActionPrevious; |
|
157 direction = EScrollUp; |
|
158 } |
|
159 |
|
160 ptiEngine->HandleCommandL(ptiCommand); |
|
161 UpdateInlineEditingCharacterL(); |
|
162 candidatePane->MoveItem(direction); |
|
163 ret = ETrue; |
|
164 } |
|
165 break; |
|
166 default: |
|
167 break; |
|
168 } |
|
169 |
|
170 return ret; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // TAknFepUiInputStateCandidateHiraganaKanji::HandleAuxKeyL |
|
175 // Handling auxiliary keypress events including OK and Backspace |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TBool TAknFepUiInputStateCandidateHiraganaKanji::HandleAuxKeyL(TInt aKey, |
|
179 TKeyPressLength /*aLength*/) |
|
180 { |
|
181 MAknFepUICtrlCandidatePaneInterface* candidatePane = |
|
182 UIContainer()->CandidatePane(MAknFepUICtrlContainerJapanese:: |
|
183 EJapaneseCandidatePane); |
|
184 candidatePane->HideWindow(); |
|
185 switch(aKey) |
|
186 { |
|
187 case EKeyOK: |
|
188 case EStdKeyDevice3: /* 0xA7 */ |
|
189 case EStdKeyEnter: /* 0x03 */ |
|
190 case EStdKeyNkpEnter: /* 0x88 */ |
|
191 { |
|
192 iOwner->ChangeState(EMultiCompletion); |
|
193 } |
|
194 break; |
|
195 case EKeyBackspace: |
|
196 case EStdKeyBackspace: /* 0x01 */ |
|
197 case EStdKeyEscape: /* 0x04 */ |
|
198 { |
|
199 iOwner->ChangeState(EConversion); |
|
200 } |
|
201 break; |
|
202 default: // Panic |
|
203 { |
|
204 AknFepPanic(EAknFepPanicNotSupportKey); |
|
205 } |
|
206 break; |
|
207 } |
|
208 return EFalse; |
|
209 } |
|
210 |
|
211 |
|
212 // --------------------------------------------------------------------------- |
|
213 // TAknFepUiInputStateCandidateHiraganaKanji::UpdateCandidateListL |
|
214 // Update candidate list |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 void TAknFepUiInputStateCandidateHiraganaKanji::UpdateCandidateListL(TInt aIndex /*=0*/) |
|
218 { |
|
219 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
220 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
221 CDesCArrayFlat* candidateArray = iOwner->CandidateArray(); |
|
222 MAknFepUICtrlCandidatePaneInterface* candidatePane = |
|
223 UIContainer()->CandidatePane(MAknFepUICtrlContainerJapanese:: |
|
224 EJapaneseCandidatePane); |
|
225 const MPtiEngineCompositionDataInterface* data = ptiEngine->CompositionData(); |
|
226 // Check ComposirionData |
|
227 __ASSERT_DEBUG( data->CompletedString().Length() < 0, |
|
228 RDebug::Print( |
|
229 _L("In TAknFepUiInputStateCandidateHiraganaKanji::TAknFepUiInputStateCandidateHiraganaKanji INVALID DATA: ConvertingString!"))); |
|
230 |
|
231 // Get coordinate of input area |
|
232 TPoint leftSideOfBaseLine; |
|
233 TInt height; |
|
234 TInt ascent; |
|
235 TInt documentOffset = data->CursorPosition(); |
|
236 if (data->NumberOfPhrase() > 0) |
|
237 { |
|
238 TPtrC8 clauseChar = data->LengthOfPhrase(); |
|
239 documentOffset = clauseChar[0]; |
|
240 } |
|
241 fepMan->GetScreenCoordinatesL(leftSideOfBaseLine, height, ascent, documentOffset); |
|
242 |
|
243 // The showing candidate pop-up list |
|
244 candidatePane->SetWindowPosition(leftSideOfBaseLine, height, ascent); |
|
245 candidatePane->ShowCandidateListL(candidateArray, aIndex, |
|
246 R_AKNFEP_SOFTKEYS_EMPTY_EMPTY_COMMIT); |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // TAknFepUiInputStateCandidateHiraganaKanji::HandleCommandL |
|
251 // Handling Command |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 void TAknFepUiInputStateCandidateHiraganaKanji::HandleCommandL(TInt aCommandId) |
|
255 { |
|
256 if(aCommandId == EAknFepResourceChanged) |
|
257 { |
|
258 // Get the current index number |
|
259 CPtiEngine* ptiEngine = iOwner->PtiEngine(); |
|
260 CDesCArrayFlat* candidateArray = iOwner->CandidateArray(); |
|
261 TInt index; |
|
262 ptiEngine->GetCandidateListL(*candidateArray); |
|
263 ptiEngine->HandleCommandL(EPtiCommandUserActionGetCurrentIndexOfCandidates, &index); |
|
264 |
|
265 CloseUI(); |
|
266 UpdateCandidateListL(index); |
|
267 } |
|
268 else |
|
269 { |
|
270 // Go through the event to base class. |
|
271 TAknFepUiInputStateEntryJapaneseMultitap::HandleCommandL(aCommandId); |
|
272 } |
|
273 } |
|
274 // End of file |