|
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 TAknFepInputStateCandidateBase methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStateCandidateBase.h" |
|
31 |
|
32 #include "AknFepUiCtrlContainerChinese.h" |
|
33 #include "AknFepUICtrlCandidatePane.h" |
|
34 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
35 #include "AknFepManagerUIInterface.h" |
|
36 #include "AknFepManager.h" //FepMan flag |
|
37 |
|
38 #include <PtiEngine.h> //CPtiEngine |
|
39 |
|
40 TAknFepInputStateCandidateBase::TAknFepInputStateCandidateBase( |
|
41 MAknFepUIManagerStateInterface* aOwner, |
|
42 MAknFepUICtrlContainerChinese* aUIContainer) |
|
43 :TAknFepInputStateChineseBase(aOwner, aUIContainer) |
|
44 { |
|
45 } |
|
46 |
|
47 void TAknFepInputStateCandidateBase::HandleCommandL(TInt /*aCommandID*/) |
|
48 { |
|
49 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
50 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
51 |
|
52 // get cursor position |
|
53 TPoint baseLine = TPoint(0,0); |
|
54 TInt height = 0; |
|
55 TInt ascent = 0; |
|
56 |
|
57 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
58 if (ret == KErrNone) |
|
59 { |
|
60 uiContainer->SetContainerPosition(baseLine, height); |
|
61 } |
|
62 |
|
63 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
64 uiContainer->Enable(ETrue); |
|
65 } |
|
66 |
|
67 TBool TAknFepInputStateCandidateBase::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/) |
|
68 { |
|
69 if (aKey == EPtiKeyStar) |
|
70 { |
|
71 iOwner->FepMan()->TryCloseUiL(); |
|
72 return EFalse; |
|
73 } |
|
74 if(!( HandleVerticalNavigation(aKey) || HandleHorizontalNavigation(aKey) )) |
|
75 { |
|
76 // it may be one of the 'valid' numbers.. |
|
77 TInt index = MapKeyToIndex(aKey); |
|
78 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
79 |
|
80 if(candidatePane->SelectIndex(index) || aKey == EKeyOK) |
|
81 { |
|
82 TPtrC text = candidatePane->CurrentCandidate(); |
|
83 if(text.Length()) |
|
84 { |
|
85 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
86 fepMan->NewCharacterL(text); |
|
87 fepMan->CommitInlineEditL(); |
|
88 |
|
89 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
90 { |
|
91 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
92 iOwner->FepMan()->TryCloseUiL(); |
|
93 } |
|
94 else |
|
95 { |
|
96 iOwner->ChangeState(EPredictiveCandidate); |
|
97 } |
|
98 } |
|
99 else |
|
100 { |
|
101 // No candidates available. Back to Entry state. |
|
102 iOwner->ChangeState(EEntry); |
|
103 } |
|
104 } |
|
105 } |
|
106 return ETrue; |
|
107 } |
|
108 |
|
109 TBool TAknFepInputStateCandidateBase::HandleHorizontalNavigation(TInt aKey) |
|
110 { |
|
111 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
112 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
113 TBool response = EFalse; |
|
114 |
|
115 // Do navigation... |
|
116 if (aKey == EKeyLeftArrow) |
|
117 { |
|
118 if(!candidatePane->SelectPrev()) |
|
119 { |
|
120 ptiengine->PreviousCandidatePage(); |
|
121 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
122 candidatePane->SelectLast(); |
|
123 } |
|
124 response = ETrue; |
|
125 } |
|
126 else if (aKey == EKeyRightArrow) |
|
127 { |
|
128 if(!candidatePane->SelectNext()) |
|
129 { |
|
130 ptiengine->NextCandidatePage(); |
|
131 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
132 candidatePane->SelectFirst(); |
|
133 } |
|
134 response = ETrue; |
|
135 } |
|
136 return response; |
|
137 } |
|
138 |
|
139 TBool TAknFepInputStateCandidateBase::HandleVerticalNavigation(TInt aKey) |
|
140 { |
|
141 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
142 |
|
143 if (aKey == EKeyDownArrow) |
|
144 { |
|
145 ptiengine->NextCandidatePage(); |
|
146 } |
|
147 else if (aKey == EKeyUpArrow) |
|
148 { |
|
149 ptiengine->PreviousCandidatePage(); |
|
150 } |
|
151 else |
|
152 { |
|
153 return EFalse; |
|
154 } |
|
155 |
|
156 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
157 candidatePane->SelectFirst(); |
|
158 candidatePane->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
159 return ETrue; |
|
160 } |
|
161 |
|
162 // End of file |