44
|
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 TAknFepInputStateEntryZhuyinStrokeBasePhrase methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
#include "AknFepUiInputStateEntryZhuyinStrokeBasePhrase.h"
|
|
31 |
|
|
32 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
33 |
#include "AknFepUiCtrlContainerChinese.h"
|
|
34 |
#include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface
|
|
35 |
#include "AknFepUICtrlCandidatePane.h"
|
|
36 |
#include "AknFepUICtrlInputPane.h"
|
|
37 |
|
|
38 |
#include <PtiEngine.h> //CPtiEngine
|
|
39 |
#include <e32keys.h> //keys
|
|
40 |
#include <avkon.rsg>
|
|
41 |
#include <aknfep.rsg>
|
|
42 |
|
|
43 |
TAknFepInputStateEntryZhuyinStrokeBasePhrase::TAknFepInputStateEntryZhuyinStrokeBasePhrase(
|
|
44 |
MAknFepUIManagerStateInterface* aOwner,
|
|
45 |
MAknFepUICtrlContainerChinese* aUIContainer)
|
|
46 |
:TAknFepInputStateChineseBase(aOwner, aUIContainer)
|
|
47 |
{
|
|
48 |
iState = EEntry;
|
|
49 |
|
|
50 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
51 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
52 |
|
|
53 |
uiContainer->FocusCandidatePane(EFalse);
|
|
54 |
|
|
55 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
|
|
56 |
uiContainer->CandidatePane()->IsFirstPage());
|
|
57 |
TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
|
|
58 |
TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
|
|
59 |
|
|
60 |
uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
|
|
61 |
uiContainer->ShowVerticalScrollArrows(multiplePages);
|
|
62 |
uiContainer->FocusCandidatePane(ETrue);
|
|
63 |
candidatePane->SetHighlighted(ETrue);
|
|
64 |
candidatePane->ShowCandidateOrdinals(EFalse);
|
|
65 |
candidatePane->SelectFirstPhrase();
|
|
66 |
}
|
|
67 |
void TAknFepInputStateEntryZhuyinStrokeBasePhrase::HandleCommandL(TInt /*aCommandId*/)
|
|
68 |
{
|
|
69 |
RefreshUI();
|
|
70 |
}
|
|
71 |
|
|
72 |
TBool TAknFepInputStateEntryZhuyinStrokeBasePhrase::HandleKeyL(TInt aKey, TKeyPressLength aLength)
|
|
73 |
{
|
|
74 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
75 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
76 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
77 |
MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane();
|
|
78 |
|
|
79 |
if(aKey == EKeyBackspace)
|
|
80 |
{
|
|
81 |
if (iOwner->PtiEngine()->DeleteKeyPress().Length())
|
|
82 |
{
|
|
83 |
inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged);
|
|
84 |
RefreshUI();
|
|
85 |
SetInputPaneToneMark();
|
|
86 |
}
|
|
87 |
else
|
|
88 |
{
|
|
89 |
iOwner->FepMan()->TryCloseUiL();
|
|
90 |
if (aLength == ELongKeyPress)
|
|
91 |
{
|
|
92 |
iOwner->FepMan()->SetLongClearAfterCloseUI(ETrue);
|
|
93 |
}
|
|
94 |
}
|
|
95 |
}
|
|
96 |
else if((aLength == EShortKeyPress) && iOwner->IsValidChineseInputKey(aKey))
|
|
97 |
{
|
|
98 |
ptiengine->AppendKeyPress((TPtiKey)aKey);
|
|
99 |
SetInputPaneToneMark();
|
|
100 |
inputPane->SetFlag(MAknFepUICtrlInputPane::EPhoneticChanged);
|
|
101 |
RefreshUI();
|
|
102 |
}
|
|
103 |
else if(aKey == EKeyDownArrow)
|
|
104 |
{
|
|
105 |
if (!candidatePane->IsLastPage())
|
|
106 |
{
|
|
107 |
candidatePane->NextCandidatePage();
|
|
108 |
RefreshUI();
|
|
109 |
}
|
|
110 |
}
|
|
111 |
else if(aKey == EKeyUpArrow)
|
|
112 |
{
|
|
113 |
if(!candidatePane->IsFirstPage())
|
|
114 |
{
|
|
115 |
candidatePane->PreviousCandidatePage();
|
|
116 |
RefreshUI();
|
|
117 |
}
|
|
118 |
}
|
|
119 |
else if(aKey == EKeyOK || aKey == EKeyRightArrow || aKey == EKeyLeftArrow)
|
|
120 |
{
|
|
121 |
iOwner->ChangeState(ECandidate);
|
|
122 |
return EFalse;
|
|
123 |
}
|
|
124 |
return ETrue;
|
|
125 |
}
|
|
126 |
|
|
127 |
void TAknFepInputStateEntryZhuyinStrokeBasePhrase::RefreshUI()
|
|
128 |
{
|
|
129 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
130 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
131 |
MAknFepUICtrlInputPane* inputPane = uiContainer->InputPane();
|
|
132 |
|
|
133 |
// get cursor position
|
|
134 |
TPoint baseLine = TPoint(0,0);
|
|
135 |
TInt height = 0;
|
|
136 |
TInt ascent = 0;
|
|
137 |
TRAPD(ret,iOwner->FepMan()->GetScreenCoordinatesL(baseLine,height,ascent));
|
|
138 |
if (ret == KErrNone)
|
|
139 |
{
|
|
140 |
uiContainer->SetContainerPosition(baseLine, height);
|
|
141 |
}
|
|
142 |
|
|
143 |
// layout candidate and fill candidate buffer for first display page
|
|
144 |
TInt candidateCount = 0;
|
|
145 |
if(inputPane->IsFlagSet(MAknFepUICtrlInputPane::EPhoneticChanged))
|
|
146 |
{
|
|
147 |
inputPane->ClearFlag(MAknFepUICtrlInputPane::EPhoneticChanged);
|
|
148 |
TRAPD(ignore,candidateCount = ptiengine->GetChinesePhraseCandidatesL(
|
|
149 |
*(uiContainer->CandidatePane()->CandidateArray())));
|
|
150 |
if(candidateCount == 0 || ignore != KErrNone)
|
|
151 |
{
|
|
152 |
return;
|
|
153 |
}
|
|
154 |
uiContainer->CandidatePane()->SplitPhraseCandidatesIntoPages();
|
|
155 |
}
|
|
156 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
|
|
157 |
uiContainer->CandidatePane()->IsFirstPage());
|
|
158 |
TInt bufLength = ptiengine->CandidatePage().Length();
|
|
159 |
TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
|
|
160 |
|
|
161 |
uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
|
|
162 |
uiContainer->ShowVerticalScrollArrows(multiplePages);
|
|
163 |
|
|
164 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
165 |
uiContainer->Enable(ETrue);
|
|
166 |
TPtrC ptr = ptiengine->GetPhoneticSpelling(1);
|
|
167 |
inputPane->SetText(ptr);
|
|
168 |
UpdateIndicator();
|
|
169 |
}
|
|
170 |
|
|
171 |
void TAknFepInputStateEntryZhuyinStrokeBasePhrase::SetInputPaneToneMark()
|
|
172 |
{
|
|
173 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
174 |
MAknFepUICtrlInputPane* inputPane = UIContainer()->InputPane();
|
|
175 |
|
|
176 |
TText toneMark;
|
|
177 |
TBool toneMarkEntered = ptiengine->ToneMark(toneMark);
|
|
178 |
TBuf<1> buf;
|
|
179 |
if(toneMarkEntered)
|
|
180 |
{
|
|
181 |
buf.Append(toneMark);
|
|
182 |
}
|
|
183 |
inputPane->SetToneMark(buf);
|
|
184 |
}
|
|
185 |
|
|
186 |
void TAknFepInputStateEntryZhuyinStrokeBasePhrase::KeyTimerExpired()
|
|
187 |
{
|
|
188 |
}
|
|
189 |
|
|
190 |
void TAknFepInputStateEntryZhuyinStrokeBasePhrase::InitializeStateL(void)
|
|
191 |
{
|
|
192 |
iOwner->FepMan()->UpdateCbaL(R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT);
|
|
193 |
}
|
|
194 |
|
|
195 |
void TAknFepInputStateEntryZhuyinStrokeBasePhrase::UpdateIndicator()
|
|
196 |
{
|
|
197 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
198 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
199 |
TInt candidateCount = candidatePane->CandidateArray()->Count();
|
|
200 |
|
|
201 |
if ( candidatePane->IsFirstPage() || candidateCount== 0 )
|
|
202 |
{
|
|
203 |
uiContainer->CandidatePane()->ShowUpScrollArrows( EFalse );
|
|
204 |
}
|
|
205 |
else
|
|
206 |
{
|
|
207 |
uiContainer->CandidatePane()->ShowUpScrollArrows( ETrue );
|
|
208 |
}
|
|
209 |
|
|
210 |
if ( candidatePane->IsLastPage() || candidateCount== 0 )
|
|
211 |
{
|
|
212 |
uiContainer->CandidatePane()->ShowDownScrollArrows( EFalse );
|
|
213 |
}
|
|
214 |
else
|
|
215 |
{
|
|
216 |
uiContainer->CandidatePane()->ShowDownScrollArrows( ETrue );
|
|
217 |
}
|
|
218 |
}
|
|
219 |
|
|
220 |
// End of file
|