|
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 entry qwertybase chinese phrase state |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 #include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface |
|
30 #include "AknFepUiCtrlContainerChinese.h" |
|
31 #include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface |
|
32 #include "AknFepUICtrlCandidatePane.h" |
|
33 #include "AknFepUICtrlInputPane.h" |
|
34 #include "AknFepUiInputStateEntryQwertyBaseChinesePhrase.h" |
|
35 |
|
36 #include <PtiEngine.h> //CPtiEngine |
|
37 #include <e32keys.h> //keys |
|
38 #include <avkon.rsg> |
|
39 |
|
40 const TInt KMaxPhraseCount = 50; |
|
41 |
|
42 TAknFepInputStateEntryQwertyBaseChinesePhrase::TAknFepInputStateEntryQwertyBaseChinesePhrase( |
|
43 MAknFepUIManagerStateInterface* aOwner, |
|
44 MAknFepUICtrlContainerChinese* aUIContainer) |
|
45 :TAknFepInputStateCandidateQwertyChinesePhrase(aOwner,aUIContainer) |
|
46 { |
|
47 iState = EEntry; |
|
48 |
|
49 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
50 MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane(); |
|
51 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
52 uiContainer->CandidatePane()->IsFirstPage()); |
|
53 TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length(); |
|
54 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
55 |
|
56 iOwner->PtiEngine()->SetCandidatePageLength(KMaxPhraseCount); |
|
57 uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
58 uiContainer->ShowVerticalScrollArrows(multiplePages); |
|
59 uiContainer->FocusCandidatePane(ETrue); |
|
60 candidatePane->SetHighlighted(ETrue); |
|
61 candidatePane->SelectFirstPhrase(); |
|
62 candidatePane->ShowCandidateOrdinals(ETrue); |
|
63 uiContainer->SetLayout(MAknFepUICtrlContainerChinese::ELayoutInput); |
|
64 UpdateIndicator(); |
|
65 } |
|
66 |
|
67 TBool TAknFepInputStateEntryQwertyBaseChinesePhrase::HandleKeyL(TInt aKey, TKeyPressLength aLength) |
|
68 { |
|
69 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
70 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
71 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
72 |
|
73 TBool ret = ETrue; |
|
74 |
|
75 if(aKey == EStdKeyBackspace) |
|
76 { |
|
77 if (iOwner->PtiEngine()->DeleteKeyPress().Length()) |
|
78 { |
|
79 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
80 uiContainer->CandidatePane()->IsFirstPage())); |
|
81 SetInputPaneToneMark(); |
|
82 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
83 RefreshUI(); |
|
84 } |
|
85 else |
|
86 { |
|
87 iOwner->FepMan()->TryCloseUiL(); |
|
88 } |
|
89 } |
|
90 else if(aLength == EShortKeyPress && iOwner->IsValidChineseInputKeyQwerty(aKey) ) |
|
91 { |
|
92 ptiengine->AppendKeyPress((TPtiKey)aKey); |
|
93 uiContainer->ShowVerticalScrollArrows(!(uiContainer->CandidatePane()->IsLastPage() && |
|
94 uiContainer->CandidatePane()->IsFirstPage())); |
|
95 SetInputPaneToneMark(); |
|
96 inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
97 RefreshUI(); |
|
98 } |
|
99 else |
|
100 { |
|
101 ret = TAknFepInputStateCandidateQwertyBaseChinesePhrase::HandleKeyL(aKey,aLength); |
|
102 } |
|
103 |
|
104 return ret; |
|
105 } |
|
106 |
|
107 void TAknFepInputStateEntryQwertyBaseChinesePhrase::RefreshUI() |
|
108 { |
|
109 CPtiEngine* ptiengine = iOwner->PtiEngine(); |
|
110 MAknFepUICtrlContainerChinese* uiContainer = UIContainer(); |
|
111 MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane(); |
|
112 |
|
113 // get cursor position |
|
114 TPoint baseLine = TPoint(0,0); |
|
115 TInt height = 0; |
|
116 TInt ascent = 0; |
|
117 TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent)); |
|
118 if (ret == KErrNone) |
|
119 { |
|
120 uiContainer->SetContainerPosition(baseLine, height); |
|
121 } |
|
122 |
|
123 // layout candidate and fill candidate buffer for first display page |
|
124 TInt candidateCount = 0; |
|
125 if(inputPane->IsFlagSet(MAknFepUICtrlInputPane::EPhoneticChanged)) |
|
126 { |
|
127 inputPane->ClearFlag(MAknFepUICtrlInputPane::EPhoneticChanged); |
|
128 TRAPD(ignore, |
|
129 candidateCount = ptiengine->GetChinesePhraseCandidatesL( |
|
130 *(uiContainer->CandidatePane()->CandidateArray()))); |
|
131 if(candidateCount == 0 || ignore != KErrNone) |
|
132 { |
|
133 return; |
|
134 } |
|
135 uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages(); |
|
136 } |
|
137 |
|
138 uiContainer->Enable(ETrue); |
|
139 uiContainer->CandidatePane()->SetCandidateBuffer(); |
|
140 |
|
141 TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() && |
|
142 uiContainer->CandidatePane()->IsFirstPage()); |
|
143 TInt bufLength = ptiengine->CandidatePage().Length(); |
|
144 TBool showHorizontalScrollArrows = multiplePages || bufLength>1; |
|
145 |
|
146 UIContainer()->ShowHorizontalScrollArrows(showHorizontalScrollArrows); |
|
147 UIContainer()->ShowVerticalScrollArrows(multiplePages); |
|
148 uiContainer->CandidatePane()->SelectFirstPhrase(); |
|
149 |
|
150 TPtrC ptr = ptiengine->GetPhoneticSpelling(1); |
|
151 inputPane->SetText(ptr); |
|
152 UpdateIndicator(); |
|
153 } |
|
154 |
|
155 void TAknFepInputStateEntryQwertyBaseChinesePhrase::SetInputPaneToneMark() |
|
156 { |
|
157 } |
|
158 |
|
159 void TAknFepInputStateEntryQwertyBaseChinesePhrase::InitializeStateL(void) |
|
160 { |
|
161 iOwner->FepMan()->UpdateCbaL(R_AVKON_SOFTKEYS_EMPTY); |
|
162 } |
|
163 |
|
164 // End of file |