|
1 /* |
|
2 * Copyright (c) 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: |
|
15 * Provides the TAknFepInputStatePredictiveCandidateQwertyZhuyinPhrase methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStatePredictiveCandidateQwertyZhuyinPhrase.h" |
|
31 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
32 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
33 #include "AknFepUICtrlCandidatePane.h" |
|
34 #include "AknFepManager.h" //FepMan flag |
|
35 |
|
36 #include <PtiEngine.h> //CPtiEngine |
|
37 |
|
38 TAknFepInputStatePredictiveCandidateQwertyZhuyinPhrase:: |
|
39 TAknFepInputStatePredictiveCandidateQwertyZhuyinPhrase( |
|
40 MAknFepUIManagerStateInterface* aOwner, |
|
41 MAknFepUICtrlContainerChinese* aUIContainer) |
|
42 :TAknFepInputStateCandidateQwertyChinesePhrase(aOwner, aUIContainer) |
|
43 { |
|
44 iState = EPredictiveCandidate; |
|
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 uiContainer->FocusCandidatePane(ETrue); |
|
57 |
|
58 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
59 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
60 // for some reason needs to feed back to ptiengine current Chinese phrase just before get the prediction |
|
61 candidatePane->SelectFirstPhrase(); |
|
62 |
|
63 TRAPD(ignore,ptiengine->GetChinesePhraseCandidatesL(*(candidatePane->CandidateArray()))); |
|
64 if (ignore == KErrNone) |
|
65 { |
|
66 candidatePane->SplitPhraseCandidatesIntoPages(); |
|
67 uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutCandidate); |
|
68 candidatePane->SetCandidateBuffer(); |
|
69 |
|
70 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
71 uiContainer->CandidatePane()->IsFirstPage()); |
|
72 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
73 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
74 |
|
75 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
76 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
77 candidatePane->ShowCandidateOrdinals(EFalse); |
|
78 UpdateIndicator(); |
|
79 } |
|
80 } |
|
81 |
|
82 TBool TAknFepInputStatePredictiveCandidateQwertyZhuyinPhrase::HandleKeyL(TInt aKey, |
|
83 TKeyPressLength aLength) |
|
84 { |
|
85 TBool ret = ETrue; |
|
86 |
|
87 if (iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyShiftMode) || |
|
88 iOwner->FepMan()->IsFlagSet(CAknFepManager::EFlagQwertyChrKeyDepressed)) |
|
89 { |
|
90 iOwner->FepMan()->TryCloseUiL(); |
|
91 return EFalse; |
|
92 } |
|
93 if(aKey == EStdKeyBackspace) |
|
94 { |
|
95 iOwner->FepMan()->TryCloseUiL(); |
|
96 } |
|
97 else if(aKey == EStdKeyLeftFunc && aLength == EShortKeyPress) |
|
98 { |
|
99 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
100 if (fepMan->IsAbleToLaunchSCT()) |
|
101 { |
|
102 fepMan->LaunchSpecialCharacterTableL(); |
|
103 } |
|
104 } |
|
105 else if(iOwner->IsQwertyZhuyinToneMarkKey(aKey)) |
|
106 { |
|
107 iOwner->FepMan()->TryCloseUiL(); |
|
108 return EFalse; |
|
109 } |
|
110 else if(iOwner->IsValidChineseInputKeyQwerty(aKey)) |
|
111 { |
|
112 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
113 // it is needed when we use phrase input engine, otherwise it seems not cleared |
|
114 ptiengine->ClearCurrentWord(); |
|
115 ptiengine->ResetToneMark(); |
|
116 |
|
117 iOwner->ChangeState(EEntry); |
|
118 ret = EFalse; //passes to entry state to handle the key |
|
119 } |
|
120 else if (aKey == EStdKeyEnter || aKey == EStdKeySpace) |
|
121 { |
|
122 iOwner->FepMan()->TryCloseUiL(); |
|
123 iOwner->ChangeState(EQwerty); |
|
124 return EFalse; |
|
125 } |
|
126 else if(!HandleVerticalNavigation(aKey)) |
|
127 { |
|
128 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
129 |
|
130 if (aKey == EStdKeyLeftArrow ) |
|
131 { |
|
132 if (candidatePane->SelectedIndex() == 0 && |
|
133 candidatePane->IsFirstPage()) |
|
134 { |
|
135 return ETrue; |
|
136 } |
|
137 else |
|
138 { |
|
139 iOwner->ChangeState(EPredictiveInput); |
|
140 return EFalse; |
|
141 } |
|
142 } |
|
143 else if (aKey == EStdKeyRightArrow) |
|
144 { |
|
145 if (candidatePane->IsLastPage() && |
|
146 (candidatePane->SelectedIndex() == candidatePane->VisibleCandidateCount() - 1)) |
|
147 { |
|
148 return ETrue; |
|
149 } |
|
150 else |
|
151 { |
|
152 iOwner->ChangeState(EPredictiveInput); |
|
153 return EFalse; |
|
154 } |
|
155 } |
|
156 else |
|
157 { |
|
158 ret = TAknFepInputStateCandidateQwertyChinesePhrase::HandleKeyL(aKey, aLength); |
|
159 } |
|
160 } |
|
161 |
|
162 return ret; |
|
163 } |
|
164 |
|
165 // End of file |