|
1 /* |
|
2 * Copyright (c) 2004 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 TAknFepInputStateCandidateBasePhrase methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStateCandidateBasePhrase.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 TAknFepInputStateCandidateBasePhrase::TAknFepInputStateCandidateBasePhrase( |
|
41 MAknFepUIManagerStateInterface* aOwner, |
|
42 MAknFepUICtrlContainerChinese* aUIContainer) |
|
43 :TAknFepInputStateCandidateBase(aOwner, aUIContainer) |
|
44 { |
|
45 } |
|
46 |
|
47 TBool TAknFepInputStateCandidateBasePhrase::HandleKeyL(TInt aKey, TKeyPressLength /*aLength*/) |
|
48 { |
|
49 if (aKey == EPtiKeyStar) |
|
50 { |
|
51 iOwner->FepMan()->TryCloseUiL(); |
|
52 return EFalse; |
|
53 } |
|
54 if(!( HandleVerticalNavigation(aKey) || HandleHorizontalNavigation(aKey) )) |
|
55 { |
|
56 // it may be one of the 'valid' numbers.. |
|
57 TInt index = MapKeyToIndex(aKey); |
|
58 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
59 |
|
60 if(candidatePane->SelectIndex(index) || aKey == EKeyOK) |
|
61 { |
|
62 TPtrC text = candidatePane->CurrentPhraseCandidate(); |
|
63 if(text.Length()) |
|
64 { |
|
65 MAknFepManagerUIInterface* fepMan = iOwner->FepMan(); |
|
66 fepMan->NewTextL(text); |
|
67 fepMan->CommitInlineEditL(); |
|
68 if (fepMan->IsFlagSet(CAknFepManager::EFlagEditorFull)) |
|
69 { |
|
70 fepMan->ClearFlag(CAknFepManager::EFlagEditorFull); |
|
71 iOwner->FepMan()->TryCloseUiL(); |
|
72 } |
|
73 else |
|
74 { |
|
75 iOwner->ChangeState(EPredictiveCandidate); |
|
76 } |
|
77 } |
|
78 else |
|
79 { |
|
80 // No candidates available. Back to Entry state. |
|
81 iOwner->ChangeState(EEntry); |
|
82 } |
|
83 } |
|
84 } |
|
85 return ETrue; |
|
86 } |
|
87 |
|
88 TBool TAknFepInputStateCandidateBasePhrase::HandleHorizontalNavigation(TInt aKey) |
|
89 { |
|
90 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
91 TBool response = EFalse; |
|
92 |
|
93 // Do navigation... |
|
94 if (aKey == EKeyLeftArrow) |
|
95 { |
|
96 if(!candidatePane->SelectPrev()) |
|
97 { |
|
98 candidatePane->PreviousCandidatePage(); |
|
99 candidatePane->SetCandidateBuffer(); |
|
100 candidatePane->SelectLastPhrase(); |
|
101 } |
|
102 response = ETrue; |
|
103 } |
|
104 else if (aKey == EKeyRightArrow) |
|
105 { |
|
106 if(!candidatePane->SelectNext()) |
|
107 { |
|
108 candidatePane->NextCandidatePage(); |
|
109 candidatePane->SetCandidateBuffer(); |
|
110 candidatePane->SelectFirstPhrase(); |
|
111 } |
|
112 response = ETrue; |
|
113 } |
|
114 return response; |
|
115 } |
|
116 |
|
117 TBool TAknFepInputStateCandidateBasePhrase::HandleVerticalNavigation(TInt aKey) |
|
118 { |
|
119 MAknFepUICtrlCandidatePane* candidatePane = UIContainer()->CandidatePane(); |
|
120 if (aKey == EKeyDownArrow) |
|
121 { |
|
122 candidatePane->NextCandidatePage(); |
|
123 } |
|
124 else if (aKey == EKeyUpArrow) |
|
125 { |
|
126 candidatePane->PreviousCandidatePage(); |
|
127 } |
|
128 else |
|
129 { |
|
130 return EFalse; |
|
131 } |
|
132 candidatePane->SetCandidateBuffer(); |
|
133 candidatePane->SelectFirstPhrase(); |
|
134 return ETrue; |
|
135 } |
|
136 |
|
137 // End of file |