44
|
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 base chinese phrase state
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
#include "AknFepUiInputStateCandidateQwertyBaseChinesePhrase.h"
|
|
30 |
#include "AknFepUiCtrlContainerChinese.h"
|
|
31 |
#include "AknFepUICtrlCandidatePane.h"
|
|
32 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
33 |
#include "AknFepManagerUIInterface.h"
|
|
34 |
#include "AknFepManager.h" //FepMan flag
|
|
35 |
#include "AknFepUICtrlPinyinPopup.h"
|
|
36 |
|
|
37 |
#include <PtiEngine.h> //CPtiEngine
|
|
38 |
|
|
39 |
const TUint16 KSegment = 0x0020;
|
|
40 |
|
|
41 |
TAknFepInputStateCandidateQwertyBaseChinesePhrase::
|
|
42 |
TAknFepInputStateCandidateQwertyBaseChinesePhrase(
|
|
43 |
MAknFepUIManagerStateInterface* aOwner,
|
|
44 |
MAknFepUICtrlContainerChinese* aUIContainer)
|
|
45 |
:TAknFepInputStateChineseBase(aOwner, aUIContainer)
|
|
46 |
{
|
|
47 |
}
|
|
48 |
|
|
49 |
TBool TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/)
|
|
50 |
{
|
|
51 |
if(aKey == EStdKeyDevice1)
|
|
52 |
{
|
|
53 |
iOwner->FepMan()->TryCloseUiL();
|
|
54 |
}
|
|
55 |
|
|
56 |
else if(!( HandleVerticalNavigation(aKey) || HandleHorizontalNavigation(aKey) ))
|
|
57 |
{
|
|
58 |
TInt index = 0;
|
|
59 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
60 |
// it may be one of the 'valid' numbers..
|
|
61 |
TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout();
|
|
62 |
if ( EPtiKeyboardQwerty4x10 == keyboardtype ||
|
|
63 |
EPtiKeyboardQwerty3x11 == keyboardtype ||
|
|
64 |
EPtiKeyboardHalfQwerty == keyboardtype ||
|
|
65 |
EPtiKeyboardCustomQwerty == keyboardtype)
|
|
66 |
{
|
|
67 |
MPtiLanguage *lang = NULL;
|
|
68 |
RArray < TPtiNumericKeyBinding > keybinding;
|
|
69 |
TBool validnumkey = EFalse;
|
|
70 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
71 |
|
|
72 |
if( ptiengine != NULL )
|
|
73 |
{
|
|
74 |
lang = ptiengine->CurrentLanguage();
|
|
75 |
}
|
|
76 |
if( ptiengine && lang )
|
|
77 |
{
|
|
78 |
TRAP_IGNORE(ptiengine->GetNumericModeKeysForQwertyL(lang->LanguageCode(),
|
|
79 |
keybinding, keyboardtype));
|
|
80 |
TInt numericKeysCount = keybinding.Count();
|
|
81 |
TInt candidateCount = UIContainer()->CandidatePane()->VisibleCandidateCount();
|
|
82 |
while ( numericKeysCount-- )
|
|
83 |
{
|
|
84 |
TPtiNumericKeyBinding numKeyBind = keybinding[numericKeysCount];
|
|
85 |
if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= ( 0x31 + candidateCount - 1 ))
|
|
86 |
|
|
87 |
&&(aKey == numKeyBind.iKey))
|
|
88 |
{
|
|
89 |
index = numKeyBind.iChar - EPtiKey0 -1;
|
|
90 |
validnumkey = ETrue;
|
|
91 |
break;
|
|
92 |
}
|
|
93 |
}
|
|
94 |
}
|
|
95 |
keybinding.Reset();
|
|
96 |
|
|
97 |
if (!validnumkey)
|
|
98 |
{
|
|
99 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
100 |
return ETrue;
|
|
101 |
}
|
|
102 |
|
|
103 |
}
|
|
104 |
else
|
|
105 |
{
|
|
106 |
#endif
|
|
107 |
index = MapKeyToIndex(aKey);
|
|
108 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
109 |
}
|
|
110 |
#endif
|
|
111 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
112 |
|
|
113 |
if(candidatePane->SelectIndex(index) || aKey == EStdKeyDevice3 || aKey == EStdKeyEnter)
|
|
114 |
{
|
|
115 |
TPtrC text = candidatePane->CurrentPhraseCandidate();
|
|
116 |
if(text.Length())
|
|
117 |
{
|
|
118 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
119 |
fepMan->NewTextL(text);
|
|
120 |
fepMan->CommitInlineEditL();
|
|
121 |
iOwner->PtiEngine()->SetPredictiveChineseChar(text);
|
|
122 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull))
|
|
123 |
{
|
|
124 |
fepMan->ClearFlag(CAknFepManager::EFlagEditorFull);
|
|
125 |
iOwner->FepMan()->TryCloseUiL();
|
|
126 |
}
|
|
127 |
else
|
|
128 |
{
|
|
129 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
130 |
if ( EPtiKeyboardQwerty4x10 == iOwner->FepMan()->KeyboardLayout() ||
|
|
131 |
EPtiKeyboardHalfQwerty == iOwner->FepMan()->KeyboardLayout() ||
|
|
132 |
EPtiKeyboardQwerty3x11 == iOwner->FepMan()->KeyboardLayout() )
|
|
133 |
{
|
|
134 |
UIContainer()->PinyinPopupWindow()->SetChangeState( ETrue );
|
|
135 |
iOwner->ChangeState(EPredictiveCandidate);
|
|
136 |
}
|
|
137 |
#endif
|
|
138 |
}
|
|
139 |
}
|
|
140 |
else
|
|
141 |
{
|
|
142 |
// No candidates available. Back to Entry state.
|
|
143 |
iOwner->ChangeState(EEntry);
|
|
144 |
}
|
|
145 |
}
|
|
146 |
}
|
|
147 |
return ETrue;
|
|
148 |
}
|
|
149 |
|
|
150 |
TBool TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleHorizontalNavigation(TInt aKey)
|
|
151 |
{
|
|
152 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
153 |
TBool response = EFalse;
|
|
154 |
|
|
155 |
// Do navigation...
|
|
156 |
if (aKey == EStdKeyLeftArrow)
|
|
157 |
{
|
|
158 |
if (candidatePane->SelectedIndex() == 0 &&
|
|
159 |
candidatePane->IsFirstPage() )
|
|
160 |
{
|
|
161 |
return ETrue;
|
|
162 |
}
|
|
163 |
|
|
164 |
if(!candidatePane->SelectPrev())
|
|
165 |
{
|
|
166 |
candidatePane->PreviousCandidatePage();
|
|
167 |
candidatePane->SetCandidateBuffer();
|
|
168 |
candidatePane->SelectLastPhrase();
|
|
169 |
}
|
|
170 |
response = ETrue;
|
|
171 |
}
|
|
172 |
else if (aKey == EStdKeyRightArrow)
|
|
173 |
{
|
|
174 |
if ( candidatePane->IsLastPage() &&
|
|
175 |
(candidatePane->SelectedIndex() == candidatePane->VisibleCandidateCount() - 1))
|
|
176 |
{
|
|
177 |
return ETrue;
|
|
178 |
}
|
|
179 |
|
|
180 |
if(!candidatePane->SelectNext())
|
|
181 |
{
|
|
182 |
candidatePane->NextCandidatePage();
|
|
183 |
candidatePane->SetCandidateBuffer();
|
|
184 |
candidatePane->SelectFirstPhrase();
|
|
185 |
}
|
|
186 |
response = ETrue;
|
|
187 |
}
|
|
188 |
if (response)
|
|
189 |
{
|
|
190 |
UpdateIndicator();
|
|
191 |
}
|
|
192 |
return response;
|
|
193 |
}
|
|
194 |
|
|
195 |
TBool TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleVerticalNavigation(TInt aKey)
|
|
196 |
{
|
|
197 |
MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane();
|
|
198 |
|
|
199 |
if (aKey == EStdKeyDownArrow || aKey == EStdKeySpace)
|
|
200 |
{
|
|
201 |
if (candidatePane->IsLastPage())
|
|
202 |
{
|
|
203 |
return ETrue;
|
|
204 |
}
|
|
205 |
if ( iState != EPredictiveCandidate &&
|
|
206 |
iState != EPredictiveInput )
|
|
207 |
{
|
|
208 |
if ( candidatePane->NeedGetNewCandidatePage() )
|
|
209 |
{
|
|
210 |
if ( !iOwner->PtiEngine()->NextCandidatePage( ) )
|
|
211 |
{
|
|
212 |
if ( candidatePane->IsLastPage() )
|
|
213 |
{
|
|
214 |
iOwner->FepMan()->PlaySound( EAvkonSIDErrorTone );
|
|
215 |
return ETrue;
|
|
216 |
}
|
|
217 |
}
|
|
218 |
else
|
|
219 |
{
|
|
220 |
CDesCArrayFlat* phraseCandidates = candidatePane->CandidateArray();
|
|
221 |
RPointerArray<HBufC> list;
|
|
222 |
TRAP_IGNORE(
|
|
223 |
GetNewCandidatesL( iOwner->PtiEngine()->CandidatePage( ), list );
|
|
224 |
for (TInt i = 0; i < list.Count( ); ++i )
|
|
225 |
{
|
|
226 |
phraseCandidates->AppendL( *(list[i]) );
|
|
227 |
}
|
|
228 |
list.ResetAndDestroy();)
|
|
229 |
}
|
|
230 |
}
|
|
231 |
}
|
|
232 |
candidatePane->NextCandidatePage();
|
|
233 |
}
|
|
234 |
else if (aKey == EStdKeyUpArrow)
|
|
235 |
{
|
|
236 |
if (candidatePane->IsFirstPage())
|
|
237 |
{
|
|
238 |
return ETrue;
|
|
239 |
}
|
|
240 |
candidatePane->PreviousCandidatePage();
|
|
241 |
}
|
|
242 |
else
|
|
243 |
{
|
|
244 |
return EFalse;
|
|
245 |
}
|
|
246 |
candidatePane->SetCandidateBuffer();
|
|
247 |
candidatePane->SelectFirstPhrase();
|
|
248 |
UpdateIndicator();
|
|
249 |
return ETrue;
|
|
250 |
}
|
|
251 |
|
|
252 |
void TAknFepInputStateCandidateQwertyBaseChinesePhrase::UpdateIndicator()
|
|
253 |
{
|
|
254 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
255 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
256 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
257 |
|
|
258 |
if (candidatePane->IsFirstPage())
|
|
259 |
{
|
|
260 |
uiContainer->CandidatePane()->ShowUpScrollArrows(EFalse);
|
|
261 |
}
|
|
262 |
else
|
|
263 |
{
|
|
264 |
uiContainer->CandidatePane()->ShowUpScrollArrows(ETrue);
|
|
265 |
}
|
|
266 |
|
|
267 |
if (candidatePane->IsLastPage())
|
|
268 |
{
|
|
269 |
uiContainer->CandidatePane()->ShowDownScrollArrows(EFalse);
|
|
270 |
}
|
|
271 |
else
|
|
272 |
{
|
|
273 |
uiContainer->CandidatePane()->ShowDownScrollArrows(ETrue);
|
|
274 |
}
|
|
275 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
276 |
if(iOwner->FepMan()->KeyboardLayout() == EPtiKeyboardQwerty4x10)
|
|
277 |
{
|
|
278 |
if(candidatePane->VisibleCandidateCount()==1)
|
|
279 |
{
|
|
280 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
|
|
281 |
uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse);
|
|
282 |
}
|
|
283 |
else
|
|
284 |
{
|
|
285 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue);
|
|
286 |
uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue);
|
|
287 |
}
|
|
288 |
}
|
|
289 |
else
|
|
290 |
{
|
|
291 |
#endif
|
|
292 |
if (candidatePane->SelectedIndex() == 0 &&
|
|
293 |
candidatePane->IsFirstPage() )
|
|
294 |
{
|
|
295 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(EFalse);
|
|
296 |
}
|
|
297 |
else
|
|
298 |
{
|
|
299 |
uiContainer->CandidatePane()->ShowLeftScrollArrows(ETrue);
|
|
300 |
}
|
|
301 |
|
|
302 |
if (candidatePane->IsLastPage() &&
|
|
303 |
(candidatePane->SelectedIndex() == candidatePane->VisibleCandidateCount() - 1))
|
|
304 |
{
|
|
305 |
uiContainer->CandidatePane()->ShowRightScrollArrows(EFalse);
|
|
306 |
}
|
|
307 |
else
|
|
308 |
{
|
|
309 |
uiContainer->CandidatePane()->ShowRightScrollArrows(ETrue);
|
|
310 |
}
|
|
311 |
}
|
|
312 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
313 |
}
|
|
314 |
#endif
|
|
315 |
|
|
316 |
// ---------------------------------------------------------------------------
|
|
317 |
// TAknFepInputStateCandidateQwertyBaseChinesePhrase::MapKeyToIndexSelectCandidate
|
|
318 |
// Check the select candidate numeric key is valid or not
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
322 |
TBool TAknFepInputStateCandidateQwertyBaseChinesePhrase::MapKeyToIndexSelectCandidate(
|
|
323 |
TInt aKey,TInt& aIndex )
|
|
324 |
{
|
|
325 |
TBool validnumkey = EFalse;
|
|
326 |
MPtiLanguage *lang= NULL;
|
|
327 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
328 |
TPtiKeyboardType keyboardtype = iOwner->FepMan()->KeyboardLayout();
|
|
329 |
if (EPtiKeyboardQwerty4x10 == keyboardtype || EPtiKeyboardQwerty3x11
|
|
330 |
== keyboardtype || EPtiKeyboardHalfQwerty == keyboardtype
|
|
331 |
|| EPtiKeyboardCustomQwerty == keyboardtype)
|
|
332 |
{
|
|
333 |
RArray <TPtiNumericKeyBinding> keybinding;
|
|
334 |
|
|
335 |
if( ptiengine != NULL )
|
|
336 |
{
|
|
337 |
lang = ptiengine->CurrentLanguage();
|
|
338 |
}
|
|
339 |
if ( ptiengine && lang )
|
|
340 |
{
|
|
341 |
TRAP_IGNORE(ptiengine->GetNumericModeKeysForQwertyL(lang->LanguageCode(), keybinding, keyboardtype));
|
|
342 |
TInt numericKeysCount = keybinding.Count();
|
|
343 |
while ( numericKeysCount-- )
|
|
344 |
{
|
|
345 |
TPtiNumericKeyBinding numKeyBind =
|
|
346 |
keybinding[numericKeysCount];
|
|
347 |
if ( (numKeyBind.iChar >= 0x31 && numKeyBind.iChar <= 0x36)
|
|
348 |
&&(aKey == numKeyBind.iKey))
|
|
349 |
{
|
|
350 |
aIndex = numKeyBind.iChar - EPtiKey0 - 1;
|
|
351 |
validnumkey = ETrue;
|
|
352 |
break;
|
|
353 |
}
|
|
354 |
}
|
|
355 |
}
|
|
356 |
keybinding.Reset();
|
|
357 |
if ( !validnumkey )
|
|
358 |
{
|
|
359 |
iOwner->FepMan()->PlaySound(EAvkonSIDErrorTone);
|
|
360 |
}
|
|
361 |
}
|
|
362 |
else
|
|
363 |
{
|
|
364 |
aIndex = MapKeyToIndex(aKey);
|
|
365 |
}
|
|
366 |
return validnumkey ;
|
|
367 |
}
|
|
368 |
#endif
|
|
369 |
// ---------------------------------------------------------------------------
|
|
370 |
// TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleCommandL
|
|
371 |
// Handling Command
|
|
372 |
// ---------------------------------------------------------------------------
|
|
373 |
//
|
|
374 |
void TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleCommandL(
|
|
375 |
TInt aCommandId )
|
|
376 |
{
|
|
377 |
TAknFepInputStateChineseBase::HandleCommandL( aCommandId );
|
|
378 |
}
|
|
379 |
|
|
380 |
void TAknFepInputStateCandidateQwertyBaseChinesePhrase::GetNewCandidatesL(const TDesC& aSource,
|
|
381 |
RPointerArray<HBufC>& aList)
|
|
382 |
{
|
|
383 |
TInt start = 0;
|
|
384 |
TInt length = 0;
|
|
385 |
|
|
386 |
for (TInt ii = 0; ii < aSource.Length(); ii++)
|
|
387 |
{
|
|
388 |
if (aSource[ii] == KSegment)
|
|
389 |
{
|
|
390 |
TPtrC segment(aSource.Ptr() + start, length);
|
|
391 |
aList.AppendL(segment.AllocL());
|
|
392 |
start += (length + 1);
|
|
393 |
length = 0;
|
|
394 |
}
|
|
395 |
else
|
|
396 |
{
|
|
397 |
length++;
|
|
398 |
}
|
|
399 |
}
|
|
400 |
|
|
401 |
if (length)
|
|
402 |
{
|
|
403 |
TPtrC segm(aSource.Ptr() + start, length);
|
|
404 |
aList.AppendL(segm.AllocL());
|
|
405 |
}
|
|
406 |
}
|
|
407 |
|
|
408 |
// End of file
|