44
|
1 |
/*
|
|
2 |
* Copyright (c) 2002 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 TAknFepInputStateEntryThaiPredictive methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
#include "AknFepUiInputStateEntryThaiPredictive.h"
|
|
31 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
32 |
#include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface
|
|
33 |
#include "AknFepManager.h"
|
|
34 |
#include "AknFepPanic.h"
|
|
35 |
#include "AknFepCaseManager.h"
|
|
36 |
|
|
37 |
#include <PtiEngine.h> //CPtiEngine
|
|
38 |
#include <PtiDefs.h> //keys
|
|
39 |
#include <e32keys.h>
|
|
40 |
#include <aknfep.rsg>
|
|
41 |
|
|
42 |
TAknFepInputStateEntryThaiPredictive::
|
|
43 |
TAknFepInputStateEntryThaiPredictive(MAknFepUIManagerStateInterface* aOwner)
|
|
44 |
:TAknFepInputStateEntryWesternPredictive(aOwner)
|
|
45 |
{
|
|
46 |
//this class insists on the existence of a case manager
|
|
47 |
__ASSERT_DEBUG(iOwner->CaseMan(), AknFepPanic(EAknFepPanicNoCaseManager));
|
|
48 |
|
|
49 |
iState = EEntry;
|
|
50 |
iMatchState = EWordMatchNone;
|
|
51 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
52 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
53 |
ptiengine->SetInputMode(EPtiEnginePredictive);
|
|
54 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
55 |
TBool isUnlimitedEditor = EFalse;
|
|
56 |
ptiengine->SetMaxLengthForAutoCompletedCandidates(fepMan->EditorFreeSpaceForAutoWordCompletion(isUnlimitedEditor ));
|
|
57 |
// To set the input mode
|
|
58 |
if(fepMan->IsAutoCompleteOn())
|
|
59 |
{
|
|
60 |
TRAP_IGNORE(ptiengine->HandleCommandL(EPtiCommandEnableAutoCompletion));
|
|
61 |
}
|
|
62 |
else
|
|
63 |
{
|
|
64 |
TRAP_IGNORE(ptiengine->HandleCommandL(EPtiCommandDisableAutoCompletion));
|
|
65 |
}
|
|
66 |
|
|
67 |
TPtiKeyboardType keyboard = fepMan->KeyboardLayout();
|
|
68 |
ptiengine->SetKeyboardType(keyboard);
|
|
69 |
TBool isNumberCandidateShown = fepMan->IsAdvancedPredictiveNumberCandidateShown();
|
|
70 |
TRAP_IGNORE(ptiengine->HandleCommandL( EPtiCommandSetNumberCandidateStatus, &isNumberCandidateShown ));
|
|
71 |
#else
|
|
72 |
ptiengine->ClearCurrentWord();
|
|
73 |
#ifdef RD_PRED_AW_COMPLETION
|
|
74 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
75 |
// To set the input mode
|
|
76 |
if(fepMan->IsAutoCompleteOn())
|
|
77 |
{
|
|
78 |
ptiengine->SetInputMode(EPtiEngineWordCompletion);
|
|
79 |
}
|
|
80 |
else
|
|
81 |
#endif // RD_PRED_AW_COMPLETION
|
|
82 |
{
|
|
83 |
ptiengine->SetInputMode(EPtiEnginePredictive);
|
|
84 |
}
|
|
85 |
#endif // RD_INTELLIGENT_TEXT_INPUT
|
|
86 |
ptiengine->SetCase(EPtiCaseLower);
|
|
87 |
}
|
|
88 |
|
|
89 |
TBool TAknFepInputStateEntryThaiPredictive::HandleKeyL(TInt aKey, TKeyPressLength aLength)
|
|
90 |
{
|
|
91 |
TBool response = ETrue;
|
|
92 |
|
|
93 |
switch (aKey)
|
|
94 |
{
|
|
95 |
case EPtiKey1: //fall through
|
|
96 |
case EPtiKey2:
|
|
97 |
case EPtiKey3:
|
|
98 |
case EPtiKey4:
|
|
99 |
case EPtiKey5:
|
|
100 |
case EPtiKey6:
|
|
101 |
case EPtiKey7:
|
|
102 |
case EPtiKey8:
|
|
103 |
case EPtiKey9:
|
|
104 |
case EPtiKey0:
|
|
105 |
response = HandleStandardNumericKeysL(aKey, aLength);
|
|
106 |
break;
|
|
107 |
case EPtiKeyStar:
|
|
108 |
if ( aLength == ELongKeyPress )
|
|
109 |
{
|
|
110 |
response = HandleStarKeyL(aLength);
|
|
111 |
}
|
|
112 |
else
|
|
113 |
{
|
|
114 |
response = HandleStandardNumericKeysL(aKey, aLength);
|
|
115 |
}
|
|
116 |
break;
|
|
117 |
case EKeyDownArrow:
|
|
118 |
response = HandleDownKeyL();
|
|
119 |
break;
|
|
120 |
case EKeyUpArrow:
|
|
121 |
response = HandleUpKeyL();
|
|
122 |
break;
|
|
123 |
case EKeyRightArrow: // fall through
|
|
124 |
case EKeyLeftArrow:
|
|
125 |
case EKeyBackspace:
|
|
126 |
response = HandleNaviKeysL(aKey, aLength);
|
|
127 |
break;
|
|
128 |
default:
|
|
129 |
response = EFalse;
|
|
130 |
break;
|
|
131 |
}
|
|
132 |
return response;
|
|
133 |
}
|
|
134 |
|
|
135 |
TBool TAknFepInputStateEntryThaiPredictive::HandleDownKeyL()
|
|
136 |
{
|
|
137 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
138 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
139 |
|
|
140 |
if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
|
|
141 |
{
|
|
142 |
return EFalse;
|
|
143 |
}
|
|
144 |
else
|
|
145 |
{
|
|
146 |
if (fepMan->IsFlagSet(CAknFepManager::EFlagNoMatches))
|
|
147 |
{
|
|
148 |
//no more matches
|
|
149 |
fepMan->PlaySound(EAvkonSIDWarningTone);
|
|
150 |
}
|
|
151 |
else if (ptiengine->NumberOfCandidates()<=1)
|
|
152 |
{
|
|
153 |
// only one match
|
|
154 |
if (iMatchState == EWordMatchFirst || iMatchState == EWordMatchNone)
|
|
155 |
{
|
|
156 |
fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_EMPTY);
|
|
157 |
iMatchState = EWordMatchLast;
|
|
158 |
}
|
|
159 |
}
|
|
160 |
else
|
|
161 |
{
|
|
162 |
// > 1 match
|
|
163 |
if (iMatchState == EWordMatchLast && !(ptiengine->LastEnteredKey() == EPtiKey1))
|
|
164 |
{
|
|
165 |
fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_SPELL_PREVIOUS);
|
|
166 |
}
|
|
167 |
else if (iMatchState == EWordMatchFirst || iMatchState == EWordMatchNone)
|
|
168 |
{
|
|
169 |
fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_EMPTY_PREVIOUS);
|
|
170 |
iMatchState = EWordMatchStd;
|
|
171 |
}
|
|
172 |
TPtrC newText = ptiengine->NextCandidate();
|
|
173 |
fepMan->UpdateInlineEditL(newText, 0);
|
|
174 |
}
|
|
175 |
}
|
|
176 |
return ETrue;
|
|
177 |
}
|
|
178 |
|
|
179 |
TBool TAknFepInputStateEntryThaiPredictive::HandleUpKeyL()
|
|
180 |
{
|
|
181 |
MAknFepManagerUIInterface* fepMan = iOwner->FepMan();
|
|
182 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
183 |
if (!(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction)))
|
|
184 |
{
|
|
185 |
return EFalse;
|
|
186 |
}
|
|
187 |
|
|
188 |
#ifdef RD_INTELLIGENT_TEXT_INPUT
|
|
189 |
TInt lastCandidateIndex = ptiengine->NumberOfCandidates() -1;
|
|
190 |
if(lastCandidateIndex >= 0)
|
|
191 |
{
|
|
192 |
// Get last word on list
|
|
193 |
fepMan->LaunchCandidatePopupListL( lastCandidateIndex );
|
|
194 |
}
|
|
195 |
else
|
|
196 |
{
|
|
197 |
TInt wordIndexToSelect = 0;
|
|
198 |
// Get next word on list (wrap around if at end)
|
|
199 |
ptiengine->HandleCommandL( EPtiCommandUserActionGetCurrentIndexOfCandidates,
|
|
200 |
&wordIndexToSelect );
|
|
201 |
wordIndexToSelect < lastCandidateIndex ? wordIndexToSelect++ : wordIndexToSelect = 0;
|
|
202 |
fepMan->LaunchCandidatePopupListL( wordIndexToSelect );
|
|
203 |
}
|
|
204 |
|
|
205 |
#else
|
|
206 |
if (!( (iMatchState == EWordMatchFirst) || !(fepMan->IsFlagSet(CAknFepManager::EFlagInsideInlineEditingTransaction))))
|
|
207 |
{
|
|
208 |
if (iMatchState == EWordMatchLast || iMatchState == EWordMatchAfterLast)
|
|
209 |
{
|
|
210 |
fepMan->UpdateCbaL(R_AKNFEP_SOFTKEYS_EMPTY_PREVIOUS);
|
|
211 |
}
|
|
212 |
iMatchState = EWordMatchStd;
|
|
213 |
TPtrC prevText = ptiengine->PreviousCandidate();
|
|
214 |
fepMan->UpdateInlineEditL(prevText, 0);
|
|
215 |
}
|
|
216 |
|
|
217 |
#endif //RD_INTELLIGENT_TEXT_INPUT
|
|
218 |
return ETrue;
|
|
219 |
}
|
|
220 |
|
|
221 |
// End of file
|