|
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 TAknFepInputStatePredictiveCandidate methods. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 #include "AknFepUiInputStatePredictiveCandidate.h" |
|
31 #include "AknFepUICtrlCandidatePane.h" |
|
32 #include "AknFepUiCtrlContainerChinese.h" |
|
33 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
34 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
35 |
|
36 #include <PtiEngine.h> //CPtiEngine |
|
37 |
|
38 TAknFepInputStatePredictiveCandidate::TAknFepInputStatePredictiveCandidate( |
|
39 MAknFepUIManagerStateInterface* aOwner, |
|
40 MAknFepUICtrlContainerChinese* aUIContainer) |
|
41 :TAknFepInputStateCandidateBase(aOwner, aUIContainer) |
|
42 { |
|
43 iState = EPredictiveCandidate; |
|
44 |
|
45 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
46 |
|
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 ptiengine->SetCandidatePageLength(MAknFepUICtrlContainerChinese::ELayoutInput); |
|
62 |
|
63 // for some reason needs to feed back to ptiengine current Chinese char just before get the prediction |
|
64 TPtrC text = uiContainer->CandidatePane()->CurrentCandidate(); |
|
65 uiContainer->CandidatePane()->SelectFirst(); |
|
66 ptiengine->SetPredictiveChineseChar(text); |
|
67 |
|
68 uiContainer->CandidatePane()->SetCandidateBuffer(ptiengine->CandidatePage()); |
|
69 |
|
70 TBool multiplePages = ptiengine->MoreCandidatePages(); |
|
71 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
72 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
73 |
|
74 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
75 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
76 uiContainer->CandidatePane()->ShowCandidateOrdinals(EFalse); |
|
77 // Do standard candidate pane init... |
|
78 } |
|
79 |
|
80 |
|
81 TBool TAknFepInputStatePredictiveCandidate::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
82 { |
|
83 TBool ret = ETrue; |
|
84 if(aLength == ELongKeyPress) |
|
85 { |
|
86 return ret; |
|
87 } |
|
88 if(iOwner->IsValidChineseInputKey(aKey)) |
|
89 { |
|
90 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
91 // it is needed when we use phrase input engine, otherwise it seems not cleared |
|
92 ptiengine->ClearCurrentWord(); |
|
93 ptiengine->ResetToneMark(); |
|
94 |
|
95 iOwner->ChangeState(EEntry); |
|
96 ret = EFalse; //passes to entry state to handle the key |
|
97 } |
|
98 if(!HandleVerticalNavigation(aKey)) |
|
99 { |
|
100 if (aKey == EKeyLeftArrow || aKey == EKeyRightArrow || aKey == EKeyOK) |
|
101 { |
|
102 iOwner->ChangeState(EPredictiveInput); |
|
103 ret = EFalse; //passes to predictive input state to handle the key |
|
104 } |
|
105 else if(aKey == EKeyBackspace) |
|
106 { |
|
107 iOwner->FepMan()->TryCloseUiL(); |
|
108 } |
|
109 else if (aKey == EPtiKeyStar) |
|
110 { |
|
111 ret = TAknFepInputStateCandidateBase::HandleKeyL(aKey, aLength); |
|
112 } |
|
113 } |
|
114 return ret; |
|
115 } |
|
116 |
|
117 // End of file |