|
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 predictive input qwertystroke phrase state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 #include "AknFepUiInputStatePredictiveInputQwertyStrokePhrase.h" |
|
30 #include "AknFepUICtrlCandidatePane.h" |
|
31 #include "AknFepUiCtrlContainerChinese.h" |
|
32 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
33 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
34 #include "AknFepManager.h" //FepMan flag |
|
35 |
|
36 #include <PtiEngine.h> //CPtiEngine |
|
37 |
|
38 TAknFepInputStatePredictiveInputQwertyStrokePhrase:: |
|
39 TAknFepInputStatePredictiveInputQwertyStrokePhrase( |
|
40 MAknFepUIManagerStateInterface* aOwner, |
|
41 MAknFepUICtrlContainerChinese* aUIContainer) |
|
42 :TAknFepInputStateCandidateQwertyBaseChinesePhrase(aOwner, aUIContainer) |
|
43 { |
|
44 iState = EPredictiveInput; |
|
45 |
|
46 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
47 // set container window position to follow cursor |
|
48 TPoint baseLine = TPoint(0,0); |
|
49 TInt height = 0; |
|
50 TInt ascent = 0; |
|
51 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
52 if (ret == KErrNone) |
|
53 { |
|
54 uiContainer->SetContainerPosition(baseLine, height); |
|
55 } |
|
56 |
|
57 uiContainer->FocusCandidatePane(ETrue); |
|
58 uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate); |
|
59 |
|
60 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
61 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
62 // for some reason needs to feed back to ptiengine current Chinese phrase just before get the prediction |
|
63 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
|
64 candidatePane->SelectFirstPhrase(); |
|
65 ptiengine->SetPredictiveChineseChar(text); |
|
66 |
|
67 TRAPD(ignore,ptiengine->GetChinesePhraseCandidatesL(*(candidatePane->CandidateArray()))); |
|
68 if (ignore == KErrNone) |
|
69 { |
|
70 candidatePane->SplitPhraseCandidatesIntoPages(); |
|
71 uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate); |
|
72 candidatePane->SetCandidateBuffer(); |
|
73 |
|
74 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
75 uiContainer->CandidatePane()->IsFirstPage()); |
|
76 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
77 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
78 |
|
79 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
80 UIContainer()->ShowVerticalScrollArrows(multiplePages); |
|
81 uiContainer->CandidatePane()->ShowCandidateOrdinals(ETrue); |
|
82 UpdateIndicator(); |
|
83 } |
|
84 } |
|
85 |
|
86 TBool TAknFepInputStatePredictiveInputQwertyStrokePhrase::HandleKeyL(TInt aKey, |
|
87 TKeyPressLength aLength) |
|
88 { |
|
89 TBool ret = ETrue; |
|
90 |
|
91 if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) || |
|
92 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
93 { |
|
94 iOwner->FepMan()->TryCloseUiL(); |
|
95 ret = EFalse; |
|
96 } |
|
97 else if (IsValidEntryKey(aKey)) |
|
98 { |
|
99 iOwner->FepMan()->TryCloseUiL(); |
|
100 ret = EFalse; |
|
101 } |
|
102 else if(aKey == EStdKeyBackspace) |
|
103 { |
|
104 iOwner->FepMan()->TryCloseUiL(); |
|
105 } |
|
106 else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress) // launch sct table |
|
107 { |
|
108 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
109 if (fepMan->IsAbleToLaunchSCT()) |
|
110 { |
|
111 fepMan->LaunchSpecialCharacterTableL(); |
|
112 } |
|
113 } |
|
114 else if (aKey == EStdKeyEnter) |
|
115 { |
|
116 iOwner->FepMan()->TryCloseUiL(); |
|
117 iOwner->ChangeState(EQwerty); |
|
118 return EFalse; |
|
119 } |
|
120 else if(iOwner->IsValidChineseInputKeyQwerty(aKey)) |
|
121 { |
|
122 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
123 // it is needed when we use phrase input engine, otherwise it seems not cleared |
|
124 ptiengine->ClearCurrentWord(); |
|
125 ptiengine->ResetToneMark(); |
|
126 |
|
127 iOwner->ChangeState(EEntry); |
|
128 ret = EFalse; //passes to entry state to handle the key |
|
129 } |
|
130 else |
|
131 { |
|
132 ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey, aLength); |
|
133 } |
|
134 |
|
135 return ret; |
|
136 } |
|
137 |
|
138 TBool TAknFepInputStatePredictiveInputQwertyStrokePhrase::IsValidEntryKey(TInt aKey) |
|
139 { |
|
140 TBool response = ETrue; |
|
141 |
|
142 if ((aKey >= EPtiKeyQwertyA && aKey <= EPtiKeyQwertyZ) || |
|
143 (aKey >= EStdKeyLeftArrow && aKey <= EStdKeyDownArrow) || |
|
144 (aKey >= EPtiKeyQwerty0 && aKey <= EPtiKeyQwerty9) || |
|
145 aKey == EStdKeyBackspace || aKey == EStdKeyLeftFunc || |
|
146 aKey == EStdKeyDevice1 || aKey == EStdKeyDevice3 || |
|
147 aKey == EStdKeyDevice0) |
|
148 { |
|
149 response = EFalse; |
|
150 } |
|
151 |
|
152 return response; |
|
153 } |
|
154 // --------------------------------------------------------------------------- |
|
155 // TAknFepInputStatePredictiveInputQwertyStrokePhrase::HandleCommandL |
|
156 // Handling Command |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void TAknFepInputStatePredictiveInputQwertyStrokePhrase::HandleCommandL( |
|
160 TInt aCommandId ) |
|
161 { |
|
162 TPtrC text = UIContainer()->CandidatePane()->CurrentPhraseCandidate( ); |
|
163 switch ( aCommandId ) |
|
164 { |
|
165 // Handle the event frome command. |
|
166 case EAknSoftkeySelect: |
|
167 // case (TUint16)EAknSoftkeySelect: //the Selected in soft CBA |
|
168 if ( text.Length( ) ) |
|
169 { |
|
170 MAknFepManagerUIInterface* fepMan = iOwner->FepMan( ); |
|
171 fepMan->NewTextL( text ); |
|
172 fepMan->CommitInlineEditL( ); |
|
173 iOwner->PtiEngine()->SetPredictiveChineseChar( text ); |
|
174 if ( fepMan->IsFlagSet( CAknFepManager::EFlagEditorFull ) ) |
|
175 { |
|
176 fepMan->ClearFlag( CAknFepManager::EFlagEditorFull ); |
|
177 iOwner->FepMan()->TryCloseUiL( ); |
|
178 } |
|
179 else |
|
180 { |
|
181 iOwner->ChangeState( EPredictiveCandidate ); |
|
182 } |
|
183 } |
|
184 break; |
|
185 default: |
|
186 TAknFepInputStateChineseBase::HandleCommandL( aCommandId ); |
|
187 break; |
|
188 } |
|
189 } |
|
190 // End of file |