44
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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 TAknFepInputStateEntryZhuyinPhraseCreation methods.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
|
29 |
|
|
30 |
#include <PtiEngine.h> //CPtiEngine
|
|
31 |
#include <avkon.rsg>
|
|
32 |
#include <aknfep.rsg>
|
|
33 |
|
|
34 |
#include "aknfepuiinputstatezhuyinphrasecreationbase.h"
|
|
35 |
#include "AknFepUIManagerStateInterface.h" //MAknFepUIManagerStateInterface
|
|
36 |
#include "AknFepManagerUIInterface.h" //MAknFepManagerUIInterface
|
|
37 |
#include "AknFepUiCtrlContainerChinese.h"
|
|
38 |
#include "AknFepUICtrlPinyinPopup.h" //Pinyin phrase
|
|
39 |
#include "aknfepuictrleditpane.h"
|
|
40 |
#include "AknFepUICtrlCandidatePane.h"
|
|
41 |
#include "AknFepUICtrlInputPane.h"
|
|
42 |
#include "aknfepzhuyinkeyhandlerinterface.h" //MZhuyinKeyHandler
|
|
43 |
#include "AknFepZhuyinAnalyser.h"
|
|
44 |
#include "aknfepzhuyinconvertion.h" //TZhuyinSymbolsMethods
|
|
45 |
|
|
46 |
_LIT( KStrokeManualSeparator, "\x002E");
|
|
47 |
_LIT( KToneMark1, "\x0020" );
|
|
48 |
_LIT( KToneMark2, "\x02CA" );
|
|
49 |
_LIT( KToneMark3, "\x02C7" );
|
|
50 |
_LIT( KToneMark4, "\x02CB" );
|
|
51 |
_LIT( KToneMark5, "\x02D9" );
|
|
52 |
|
|
53 |
const TInt KMaxBufLen = 100;
|
|
54 |
const TInt KMaxKeystrokeCount = 100;
|
|
55 |
const TInt KMaxInputLength = 31;
|
|
56 |
const TInt KMaxPhraseCreationCount = 7;
|
|
57 |
|
|
58 |
// ---------------------------------------------------------
|
|
59 |
// C++ constructor
|
|
60 |
// ---------------------------------------------------------
|
|
61 |
//
|
|
62 |
TAknFepInputStateZhuyinPhraseCreationBase::TAknFepInputStateZhuyinPhraseCreationBase(
|
|
63 |
MAknFepUIManagerStateInterface* aOwner,
|
|
64 |
MAknFepUICtrlContainerChinese* aUIContainer ) :
|
|
65 |
TAknFepInputStateCandidateBase( aOwner, aUIContainer )
|
|
66 |
{
|
|
67 |
iState = EEntry;
|
|
68 |
|
|
69 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
70 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
71 |
|
|
72 |
uiContainer->FocusCandidatePane(EFalse);
|
|
73 |
|
|
74 |
TBool multiplePages = !(uiContainer->CandidatePane()->IsLastPage() &&
|
|
75 |
uiContainer->CandidatePane()->IsFirstPage());
|
|
76 |
TInt bufLength = iOwner->PtiEngine()->CandidatePage().Length();
|
|
77 |
TBool showHorizontalScrollArrows = multiplePages || bufLength>1;
|
|
78 |
|
|
79 |
uiContainer->ShowHorizontalScrollArrows(showHorizontalScrollArrows);
|
|
80 |
uiContainer->ShowVerticalScrollArrows(multiplePages);
|
|
81 |
uiContainer->FocusCandidatePane(ETrue);
|
|
82 |
candidatePane->SetHighlighted(ETrue);
|
|
83 |
candidatePane->ShowCandidateOrdinals(EFalse);
|
|
84 |
candidatePane->SelectFirstPhrase();
|
|
85 |
}
|
|
86 |
|
|
87 |
TBool TAknFepInputStateZhuyinPhraseCreationBase::AddKeystrokeL( TInt aKey )
|
|
88 |
{
|
|
89 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
90 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
91 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
92 |
CDesCArrayFlat* zhuyinSymbol = popup->ZhuyinSymbols();
|
|
93 |
TInt chineseCount = popup->ChineseCharsDisped()->Count();
|
|
94 |
TInt currentIndex = editPane->GetCursorIndexOfKeystroke();
|
|
95 |
TBuf<1> buf;
|
|
96 |
TBuf<KMaxBufLen> showbuf;
|
|
97 |
showbuf = uiContainer->PinyinPopupWindow()->GetEEPContent();
|
|
98 |
|
|
99 |
TInt ret = iOwner->ZhuyinKeyHandler()->GetZhuyinSymbol( (TPtiKey)aKey, buf );
|
|
100 |
TInt showbufLen = showbuf.Length();
|
|
101 |
|
|
102 |
if ( showbufLen >= KMaxInputLength )
|
|
103 |
{
|
|
104 |
if ( ( 0 == currentIndex ) || ( 1 == ret ) )
|
|
105 |
{
|
|
106 |
iOwner->ZhuyinKeyHandler()->Reset();
|
|
107 |
return EFalse;
|
|
108 |
}
|
|
109 |
return ReplaceKeystrokeL( currentIndex,
|
|
110 |
chineseCount,
|
|
111 |
buf,
|
|
112 |
zhuyinSymbol
|
|
113 |
);
|
|
114 |
}
|
|
115 |
|
|
116 |
if ( showbufLen == KMaxInputLength - 1 )
|
|
117 |
{
|
|
118 |
if ( 0 == currentIndex )
|
|
119 |
{
|
|
120 |
iOwner->ZhuyinKeyHandler()->Reset();
|
|
121 |
return EFalse;
|
|
122 |
}
|
|
123 |
else if ( 1 == ret )
|
|
124 |
{
|
|
125 |
zhuyinSymbol->InsertL( currentIndex, buf );
|
|
126 |
if ( CheckKeystrokeCountL( chineseCount, zhuyinSymbol ) )
|
|
127 |
{
|
|
128 |
editPane->SetCursorIndexOfKeystroke( currentIndex + 1 );
|
|
129 |
return ETrue;
|
|
130 |
}
|
|
131 |
else
|
|
132 |
{
|
|
133 |
iOwner->ZhuyinKeyHandler()->Reset();
|
|
134 |
zhuyinSymbol->Delete( currentIndex );
|
|
135 |
return EFalse;
|
|
136 |
}
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
return ReplaceKeystrokeL( currentIndex,
|
|
141 |
chineseCount,
|
|
142 |
buf,
|
|
143 |
zhuyinSymbol
|
|
144 |
);
|
|
145 |
}
|
|
146 |
}
|
|
147 |
|
|
148 |
|
|
149 |
else if ( ( 0 != currentIndex ) &&
|
|
150 |
( KMaxInputLength <= showbufLen ) )
|
|
151 |
{
|
|
152 |
if ( 0 == ret )
|
|
153 |
{
|
|
154 |
zhuyinSymbol->Delete( currentIndex - 1 );
|
|
155 |
zhuyinSymbol->InsertL( currentIndex - 1, buf );
|
|
156 |
return ETrue;
|
|
157 |
}
|
|
158 |
else
|
|
159 |
{
|
|
160 |
iOwner->ZhuyinKeyHandler()->Reset();
|
|
161 |
return EFalse;
|
|
162 |
}
|
|
163 |
}
|
|
164 |
else if ( ( 0 == currentIndex ) &&
|
|
165 |
( KMaxInputLength > showbufLen ) )
|
|
166 |
{
|
|
167 |
zhuyinSymbol->InsertL( currentIndex, buf );
|
|
168 |
editPane->SetCursorIndexOfKeystroke( currentIndex + 1 );
|
|
169 |
return ETrue;
|
|
170 |
}
|
|
171 |
else if ( ( 0 != currentIndex ) &&
|
|
172 |
( KMaxInputLength > showbufLen ) )
|
|
173 |
{
|
|
174 |
if ( 0 == ret )
|
|
175 |
{
|
|
176 |
zhuyinSymbol->Delete( currentIndex - 1 );
|
|
177 |
zhuyinSymbol->InsertL( currentIndex - 1, buf );
|
|
178 |
return ETrue;
|
|
179 |
}
|
|
180 |
else if ( 1 == ret )
|
|
181 |
{
|
|
182 |
zhuyinSymbol->InsertL( currentIndex, buf );
|
|
183 |
editPane->SetCursorIndexOfKeystroke( currentIndex + 1 );
|
|
184 |
return ETrue;
|
|
185 |
}
|
|
186 |
}
|
|
187 |
return ETrue;
|
|
188 |
}
|
|
189 |
|
|
190 |
TBool TAknFepInputStateZhuyinPhraseCreationBase::AddToneMarkL()
|
|
191 |
{
|
|
192 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
193 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
194 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
195 |
MZhuyinKeyHandler* zhuyinKeyHandler = iOwner->ZhuyinKeyHandler();
|
|
196 |
CDesCArrayFlat* zhuyinSymbols = uiContainer->PinyinPopupWindow()->ZhuyinSymbols();
|
|
197 |
|
|
198 |
TBuf<1> baseBuf;
|
|
199 |
TBuf<1> buf;
|
|
200 |
baseBuf.Zero();
|
|
201 |
TInt strokePos = editPane->GetCursorIndexOfKeystroke();
|
|
202 |
|
|
203 |
TBuf<KMaxBufLen> showbuf;
|
|
204 |
showbuf = popup->GetEEPContent();
|
|
205 |
|
|
206 |
if ( strokePos > 0 )
|
|
207 |
{
|
|
208 |
baseBuf.Append( zhuyinSymbols->MdcaPoint( strokePos - 1 ) );
|
|
209 |
}
|
|
210 |
TInt insert = zhuyinKeyHandler->GetToneMark( baseBuf, buf );
|
|
211 |
if ( insert == 0 )
|
|
212 |
{
|
|
213 |
zhuyinSymbols->Delete ( strokePos - 1, 1 );
|
|
214 |
zhuyinSymbols->InsertL(strokePos - 1, buf);
|
|
215 |
}
|
|
216 |
// for insert
|
|
217 |
else if ( insert == 1)
|
|
218 |
{
|
|
219 |
if ( showbuf.Length() >= KMaxInputLength )
|
|
220 |
{
|
|
221 |
return EFalse;
|
|
222 |
}
|
|
223 |
zhuyinSymbols->InsertL(strokePos, buf);
|
|
224 |
editPane->SetCursorIndexOfKeystroke(strokePos + 1);
|
|
225 |
}
|
|
226 |
return ETrue;
|
|
227 |
}
|
|
228 |
|
|
229 |
TBool TAknFepInputStateZhuyinPhraseCreationBase::DeleteZhuyinSymbolOrChinese()
|
|
230 |
{
|
|
231 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
232 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
233 |
MAknFepUICtrlPinyinPopup* popup = uiContainer->PinyinPopupWindow();
|
|
234 |
CDesCArrayFlat* zhuyinSymbols = popup->ZhuyinSymbols();
|
|
235 |
CDesCArrayFlat* chineseDisped = popup->ChineseCharsDisped();
|
|
236 |
CDesCArrayFlat* zhuyinSymbolsForChinese = popup->ZhuyinSymbolsForChineseCharsDisped();
|
|
237 |
TInt keyStrokePos = editPane->GetCursorIndexOfKeystroke();
|
|
238 |
|
|
239 |
if ( 1 == keyStrokePos )
|
|
240 |
{
|
|
241 |
editPane->Reset();
|
|
242 |
}
|
|
243 |
|
|
244 |
if ( keyStrokePos != 0 )
|
|
245 |
{
|
|
246 |
TZhuyinSymbolsMethods::DeleteZhuyinSymbol(
|
|
247 |
zhuyinSymbols,
|
|
248 |
keyStrokePos);
|
|
249 |
editPane->SetCursorIndexOfKeystroke(keyStrokePos-1);
|
|
250 |
}
|
|
251 |
else if ( chineseDisped->Count() )
|
|
252 |
{
|
|
253 |
TInt oldLen = zhuyinSymbols->Count();
|
|
254 |
TZhuyinSymbolsMethods::DeleteChineseChar(
|
|
255 |
zhuyinSymbols,
|
|
256 |
chineseDisped,
|
|
257 |
zhuyinSymbolsForChinese
|
|
258 |
);
|
|
259 |
TInt newLen = zhuyinSymbols->Count();
|
|
260 |
editPane->SetCursorIndexOfKeystroke(newLen - oldLen);
|
|
261 |
}
|
|
262 |
return ETrue;
|
|
263 |
}
|
|
264 |
|
|
265 |
TBool TAknFepInputStateZhuyinPhraseCreationBase::UpdateEEPContent()
|
|
266 |
{
|
|
267 |
CPtiEngine* ptiengine = iOwner->PtiEngine();
|
|
268 |
CDesCArrayFlat* zhuyinSymbols = UIContainer()->PinyinPopupWindow()->ZhuyinSymbols();
|
|
269 |
CDesCArrayFlat* chineseDisped = UIContainer()->PinyinPopupWindow()->ChineseCharsDisped();
|
|
270 |
CAknFepZhuyinAnalyser* analyser = iOwner->ZhuyinAnalyser();
|
|
271 |
CDesCArrayFlat* candidateList = UIContainer()->CandidatePane()->CandidateArray();
|
|
272 |
TBuf<KMaxBufLen> buf;
|
|
273 |
TBool isPhraseCreation = EFalse;
|
|
274 |
TInt extLen = chineseDisped->Count() + zhuyinSymbols->Count() - KMaxInputLength;
|
|
275 |
|
|
276 |
if ( extLen > 0 )
|
|
277 |
{
|
|
278 |
TInt keyStrokePos = UIContainer()->EditPaneWindow()->GetCursorIndexOfKeystroke();
|
|
279 |
zhuyinSymbols->Delete ( zhuyinSymbols->Count() - extLen, extLen );
|
|
280 |
if ( keyStrokePos > zhuyinSymbols->Count() )
|
|
281 |
{
|
|
282 |
UIContainer()->EditPaneWindow()->SetCursorIndexOfKeystroke( zhuyinSymbols->Count() );
|
|
283 |
}
|
|
284 |
}
|
|
285 |
|
|
286 |
TBool valid = TZhuyinSymbolsMethods::UpdateEEPContent(
|
|
287 |
ptiengine,
|
|
288 |
analyser,
|
|
289 |
zhuyinSymbols,
|
|
290 |
chineseDisped,
|
|
291 |
candidateList,
|
|
292 |
buf,
|
|
293 |
isPhraseCreation
|
|
294 |
);
|
|
295 |
|
|
296 |
if ( ( chineseDisped->Count() != 0 || zhuyinSymbols->Count() > 1 ) &&
|
|
297 |
( candidateList->Count() != 0 ) )
|
|
298 |
{
|
|
299 |
for ( TInt i = 0; i < candidateList->Count(); ++i )
|
|
300 |
{
|
|
301 |
if ( TZhuyinSymbolsMethods::IsZhuyinSymbol( candidateList->MdcaPoint( i ) ) )
|
|
302 |
{
|
|
303 |
candidateList->Delete( i, 1 );
|
|
304 |
break;
|
|
305 |
}
|
|
306 |
}
|
|
307 |
}
|
|
308 |
UIContainer()->PinyinPopupWindow()->SetEEPContentValid(valid);
|
|
309 |
UIContainer()->CandidatePane()->SplitPhraseCandidatesIntoPages();
|
|
310 |
if ( !valid || candidateList->Count() == 0 )
|
|
311 |
{
|
|
312 |
DeleteSeparatorWhenInvaild( buf );
|
|
313 |
valid = EFalse;
|
|
314 |
}
|
|
315 |
CheckShowInfo( buf, zhuyinSymbols );
|
|
316 |
UIContainer()->PinyinPopupWindow()->SetEEPContent(buf);
|
|
317 |
return valid;
|
|
318 |
}
|
|
319 |
|
|
320 |
void TAknFepInputStateZhuyinPhraseCreationBase::UpdateIndicator()
|
|
321 |
{
|
|
322 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
323 |
MAknFepUICtrlCandidatePane* candidatePane = uiContainer->CandidatePane();
|
|
324 |
TInt candidateCount = candidatePane->CandidateArray()->Count();
|
|
325 |
|
|
326 |
if ( candidatePane->IsFirstPage() || candidateCount== 0 )
|
|
327 |
{
|
|
328 |
uiContainer->CandidatePane()->ShowUpScrollArrows( EFalse );
|
|
329 |
}
|
|
330 |
else
|
|
331 |
{
|
|
332 |
uiContainer->CandidatePane()->ShowUpScrollArrows( ETrue );
|
|
333 |
}
|
|
334 |
|
|
335 |
if ( candidatePane->IsLastPage() || candidateCount== 0 )
|
|
336 |
{
|
|
337 |
uiContainer->CandidatePane()->ShowDownScrollArrows( EFalse );
|
|
338 |
}
|
|
339 |
else
|
|
340 |
{
|
|
341 |
uiContainer->CandidatePane()->ShowDownScrollArrows( ETrue );
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|
|
345 |
// ---------------------------------------------------------
|
|
346 |
// Get high light begine position.
|
|
347 |
// ---------------------------------------------------------
|
|
348 |
//
|
|
349 |
TInt TAknFepInputStateZhuyinPhraseCreationBase::BegPosOfMoreThanSeven()
|
|
350 |
{
|
|
351 |
TInt i = 0;
|
|
352 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
353 |
TBuf<KMaxBufLen> buf;
|
|
354 |
buf = uiContainer->PinyinPopupWindow()->GetEEPContent();
|
|
355 |
TInt characterCount = uiContainer->PinyinPopupWindow()->ChineseCharsDisped()->Count();
|
|
356 |
TInt allTextCount = characterCount;
|
|
357 |
|
|
358 |
// calculate the total number of character according to stroke
|
|
359 |
for (i = 0; i < buf.Length() && allTextCount < KMaxPhraseCreationCount; i++ )
|
|
360 |
{
|
|
361 |
if ( ( buf.Mid( i, 1 ) == KStrokeManualSeparator )||
|
|
362 |
( buf.Mid( i, 1 ) == KToneMark1 ) ||
|
|
363 |
( buf.Mid( i, 1 ) == KToneMark2 ) ||
|
|
364 |
( buf.Mid( i, 1 ) == KToneMark3 ) ||
|
|
365 |
( buf.Mid( i, 1 ) == KToneMark4 ) ||
|
|
366 |
( buf.Mid( i, 1 ) == KToneMark5 ) )
|
|
367 |
{
|
|
368 |
allTextCount++;
|
|
369 |
}
|
|
370 |
}
|
|
371 |
|
|
372 |
allTextCount++;
|
|
373 |
|
|
374 |
if ( allTextCount > KMaxPhraseCreationCount )
|
|
375 |
{
|
|
376 |
return i;
|
|
377 |
}
|
|
378 |
else
|
|
379 |
{
|
|
380 |
return 0;
|
|
381 |
}
|
|
382 |
}
|
|
383 |
|
|
384 |
// ---------------------------------------------------------
|
|
385 |
// Set high light.
|
|
386 |
// ---------------------------------------------------------
|
|
387 |
//
|
|
388 |
void TAknFepInputStateZhuyinPhraseCreationBase::HighlightMoreThanSeven( TInt aBegPos )
|
|
389 |
{
|
|
390 |
MAknFepUICtrlEditPane* editPane = UIContainer()->EditPaneWindow();
|
|
391 |
TBuf<KMaxBufLen> buf;
|
|
392 |
buf = UIContainer()->PinyinPopupWindow()->GetEEPContent();
|
|
393 |
TInt EndPos = buf.Length();
|
|
394 |
editPane->SetHighlight( aBegPos, EndPos );
|
|
395 |
}
|
|
396 |
|
|
397 |
// ---------------------------------------------------------
|
|
398 |
// replace the keystroke.
|
|
399 |
// ---------------------------------------------------------
|
|
400 |
//
|
|
401 |
TBool TAknFepInputStateZhuyinPhraseCreationBase::ReplaceKeystrokeL(
|
|
402 |
TInt aIndex,
|
|
403 |
TInt aChineseCount,
|
|
404 |
const TDesC& aSymbol,
|
|
405 |
CDesCArrayFlat* aZhuyinSymbol )
|
|
406 |
{
|
|
407 |
TBuf<1> bufTmp;
|
|
408 |
bufTmp.Append( aZhuyinSymbol->MdcaPoint( aIndex - 1 ) );
|
|
409 |
aZhuyinSymbol->Delete( aIndex - 1 );
|
|
410 |
aZhuyinSymbol->InsertL( aIndex - 1, aSymbol );
|
|
411 |
if ( CheckKeystrokeCountL( aChineseCount, aZhuyinSymbol ) )
|
|
412 |
{
|
|
413 |
return ETrue;
|
|
414 |
}
|
|
415 |
else
|
|
416 |
{
|
|
417 |
aZhuyinSymbol->Delete( aIndex - 1 );
|
|
418 |
aZhuyinSymbol->InsertL( aIndex - 1, bufTmp );
|
|
419 |
return EFalse;
|
|
420 |
}
|
|
421 |
}
|
|
422 |
|
|
423 |
void TAknFepInputStateZhuyinPhraseCreationBase::RefreshUI()
|
|
424 |
{
|
|
425 |
MAknFepUICtrlContainerChinese* uiContainer = UIContainer();
|
|
426 |
MAknFepUICtrlEditPane* editPane = uiContainer->EditPaneWindow();
|
|
427 |
CDesCArrayFlat* zhuyinSymbols = uiContainer->PinyinPopupWindow()->ZhuyinSymbols();
|
|
428 |
CDesCArrayFlat* chineseDisped = uiContainer->PinyinPopupWindow()->ChineseCharsDisped();
|
|
429 |
|
|
430 |
CDesCArrayFlat* candidateList = uiContainer->CandidatePane()->CandidateArray();
|
|
431 |
|
|
432 |
// get cursor position
|
|
433 |
TPoint baseLine;
|
|
434 |
TInt height(0);
|
|
435 |
TInt ascent(0);
|
|
436 |
TRAPD(ret,iOwner->FepMan()->
|
|
437 |
GetScreenCoordinatesL(baseLine,height,ascent));
|
|
438 |
if ( ret == KErrNone )
|
|
439 |
{
|
|
440 |
uiContainer->SetContainerPosition( baseLine, height );
|
|
441 |
}
|
|
442 |
TBuf<KMaxBufLen> seed;
|
|
443 |
TBool valid = ETrue;
|
|
444 |
TBuf<KMaxBufLen> buf;
|
|
445 |
buf = uiContainer->PinyinPopupWindow()->GetEEPContent();
|
|
446 |
valid = uiContainer->PinyinPopupWindow()->GetEEPContentValid();
|
|
447 |
|
|
448 |
TBool isHighlight = EFalse;
|
|
449 |
TInt zhuyinBegPos = chineseDisped->Count();
|
|
450 |
|
|
451 |
TRAP_IGNORE( isHighlight = !iOwner->ZhuyinAnalyser()->AnalyzeL( buf.Mid( zhuyinBegPos ) ) );
|
|
452 |
CheckShowInfo( buf, zhuyinSymbols );
|
|
453 |
|
|
454 |
TInt keyStrokePos = editPane->GetCursorIndexOfKeystroke();
|
|
455 |
if ( keyStrokePos > zhuyinSymbols->Count() + 1 )
|
|
456 |
{
|
|
457 |
keyStrokePos = zhuyinSymbols->Count();
|
|
458 |
editPane->SetCursorIndexOfKeystroke( keyStrokePos );
|
|
459 |
}
|
|
460 |
TInt newCursorPos = TZhuyinSymbolsMethods::RefreshCursorPos(
|
|
461 |
chineseDisped->Count(),buf,keyStrokePos);
|
|
462 |
|
|
463 |
TZhuyinSymbolsMethods::Convert2Des(zhuyinSymbols,seed);
|
|
464 |
editPane->SetTextForZhuyin(buf,newCursorPos,chineseDisped->Count(),seed,keyStrokePos,!valid);
|
|
465 |
if ( !valid || isHighlight
|
|
466 |
|| candidateList->Count()== 0 || zhuyinSymbols->Count() == 0 )
|
|
467 |
{
|
|
468 |
uiContainer->CandidatePane()->SetInVisiable();
|
|
469 |
editPane->SetHighlight(chineseDisped->Count(),buf.Length()-1);
|
|
470 |
uiContainer->SetControlInVisible( EFalse );
|
|
471 |
uiContainer->Enable( ETrue );
|
|
472 |
uiContainer->ShowHorizontalScrollArrows( EFalse );
|
|
473 |
uiContainer->ShowVerticalScrollArrows( EFalse );
|
|
474 |
}
|
|
475 |
else
|
|
476 |
{
|
|
477 |
uiContainer->SetControlInVisible( ETrue );
|
|
478 |
uiContainer->CandidatePane()->SetCandidateBuffer();
|
|
479 |
uiContainer->CandidatePane()->SelectFirstPhrase();
|
|
480 |
uiContainer->Enable( ETrue );
|
|
481 |
uiContainer->ShowVerticalScrollArrows( ETrue );
|
|
482 |
}
|
|
483 |
TInt begPos = BegPosOfMoreThanSeven();
|
|
484 |
|
|
485 |
if ( begPos )
|
|
486 |
{
|
|
487 |
HighlightMoreThanSeven( begPos );
|
|
488 |
}
|
|
489 |
|
|
490 |
UpdateIndicator();
|
|
491 |
}
|
|
492 |
|
|
493 |
// ---------------------------------------------------------
|
|
494 |
// Check the keystroke count.
|
|
495 |
// ---------------------------------------------------------
|
|
496 |
//
|
|
497 |
TBool TAknFepInputStateZhuyinPhraseCreationBase::CheckKeystrokeCountL(
|
|
498 |
TInt aChineseCount,
|
|
499 |
CDesCArrayFlat* aZhuyinSymbol )
|
|
500 |
{
|
|
501 |
TBuf<KMaxKeystrokeCount> inputBuf;
|
|
502 |
|
|
503 |
for (TInt i = 0; i < aZhuyinSymbol->Count(); ++i )
|
|
504 |
{
|
|
505 |
inputBuf.Append( aZhuyinSymbol->MdcaPoint( i ) );
|
|
506 |
}
|
|
507 |
|
|
508 |
if ( !iOwner->ZhuyinAnalyser()->AnalyzeL( inputBuf ) )
|
|
509 |
{
|
|
510 |
return ETrue;
|
|
511 |
}
|
|
512 |
else
|
|
513 |
{
|
|
514 |
HBufC* showBuf = iOwner->ZhuyinAnalyser()->LastAnalysisResult();
|
|
515 |
if ( showBuf->Length() > KMaxInputLength - aChineseCount )
|
|
516 |
{
|
|
517 |
return EFalse;
|
|
518 |
}
|
|
519 |
}
|
|
520 |
return ETrue;
|
|
521 |
}
|
|
522 |
|
|
523 |
void TAknFepInputStateZhuyinPhraseCreationBase::HandleCommandL(TInt /*aCommandId*/)
|
|
524 |
{
|
|
525 |
RefreshUI();
|
|
526 |
}
|
|
527 |
|
|
528 |
void TAknFepInputStateZhuyinPhraseCreationBase::CheckShowInfo( TDes& aOutDes,
|
|
529 |
CDesCArrayFlat* aZhuyinSymbol )
|
|
530 |
{
|
|
531 |
if( aOutDes.Length() <= KMaxInputLength )
|
|
532 |
{
|
|
533 |
return;
|
|
534 |
}
|
|
535 |
TInt extLen = aOutDes.Length() - KMaxInputLength;
|
|
536 |
TInt delCount = 0;
|
|
537 |
TBuf<KMaxInputLength> delBuf;
|
|
538 |
delBuf.Copy( aOutDes.Mid( KMaxInputLength ) );
|
|
539 |
aOutDes.Delete( KMaxInputLength, extLen );
|
|
540 |
if ( aOutDes.Mid( KMaxInputLength - 1, 1 ).
|
|
541 |
Compare( KStrokeManualSeparator ) == 0 )
|
|
542 |
{
|
|
543 |
aOutDes.Delete( KMaxInputLength - 1, 1 );
|
|
544 |
}
|
|
545 |
|
|
546 |
for ( TInt i = 0; i < delBuf.Length(); i++ )
|
|
547 |
{
|
|
548 |
if ( delBuf.Mid( i, 1 ).Compare( KStrokeManualSeparator ) != 0 )
|
|
549 |
{
|
|
550 |
delCount++;
|
|
551 |
}
|
|
552 |
}
|
|
553 |
|
|
554 |
for ( TInt i = 0; i < delCount; i++ )
|
|
555 |
{
|
|
556 |
aZhuyinSymbol->Delete( aZhuyinSymbol->Count() - 1 );
|
|
557 |
}
|
|
558 |
}
|
|
559 |
|
|
560 |
// ---------------------------------------------------------
|
|
561 |
// Change CBA
|
|
562 |
// ---------------------------------------------------------
|
|
563 |
//
|
|
564 |
void TAknFepInputStateZhuyinPhraseCreationBase::ChangeCbaL()
|
|
565 |
{
|
|
566 |
MAknFepUICtrlPinyinPopup* popup = UIContainer()->PinyinPopupWindow();
|
|
567 |
CDesCArrayFlat* zhuyinSymbol = popup->ZhuyinSymbols();
|
|
568 |
CDesCArrayFlat* chineseArray = popup->ChineseCharsDisped( );
|
|
569 |
CDesCArrayFlat* candidateArray = UIContainer()->CandidatePane()->CandidateArray( );
|
|
570 |
TBool vaild = popup->GetEEPContentValid( );
|
|
571 |
TInt lastRes = popup->GetLastResouce();
|
|
572 |
|
|
573 |
if ( chineseArray->Count( ) == KMaxPhraseCreationCount )
|
|
574 |
{
|
|
575 |
if ( lastRes == R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE )
|
|
576 |
{
|
|
577 |
return;
|
|
578 |
}
|
|
579 |
//User cba done-done-cancel
|
|
580 |
iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE );
|
|
581 |
popup->SetLastResouce( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE );
|
|
582 |
}
|
|
583 |
else if ( ( 0 != zhuyinSymbol->Count( ) ) && (candidateArray->Count( )
|
|
584 |
!= 0 ) && vaild )
|
|
585 |
{
|
|
586 |
if ( lastRes == R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT )
|
|
587 |
{
|
|
588 |
return;
|
|
589 |
}
|
|
590 |
//User cba select-select-cancel
|
|
591 |
iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT );
|
|
592 |
popup->SetLastResouce( R_AKNFEP_SOFTKEYS_PHRASE_CREATION_SELECT_CANCEL_SELECT );
|
|
593 |
}
|
|
594 |
else if ( (chineseArray->Count( ) > 1 )
|
|
595 |
&& ( 0 == zhuyinSymbol->Count( ) ) )
|
|
596 |
{
|
|
597 |
if ( lastRes == R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE )
|
|
598 |
{
|
|
599 |
return;
|
|
600 |
}
|
|
601 |
//User cba Done-Done-Cancel
|
|
602 |
iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE );
|
|
603 |
popup->SetLastResouce( R_AKNFEP_SOFTKEYS_DONE_CANCEL_DONE );
|
|
604 |
}
|
|
605 |
else
|
|
606 |
{
|
|
607 |
if ( lastRes == R_AKNFEP_SOFTKEYS__PHRASE_CREATION_EMPTY_CANCEL_EMPTY )
|
|
608 |
{
|
|
609 |
return;
|
|
610 |
}
|
|
611 |
iOwner->FepMan()->UpdateCbaL( R_AKNFEP_SOFTKEYS__PHRASE_CREATION_EMPTY_CANCEL_EMPTY );
|
|
612 |
popup->SetLastResouce( R_AKNFEP_SOFTKEYS__PHRASE_CREATION_EMPTY_CANCEL_EMPTY );
|
|
613 |
}
|
|
614 |
}
|
|
615 |
|
|
616 |
void TAknFepInputStateZhuyinPhraseCreationBase::DeleteSeparatorWhenInvaild( TDes& aDes )
|
|
617 |
{
|
|
618 |
TInt count = aDes.Length();
|
|
619 |
for ( TInt i = count - 1; i > 0; i-- )
|
|
620 |
{
|
|
621 |
if ( aDes.Mid( i, 1 ).Compare( KStrokeManualSeparator ) == 0 )
|
|
622 |
{
|
|
623 |
aDes.Delete( i, 1 );
|
|
624 |
}
|
|
625 |
}
|
|
626 |
}
|
|
627 |
|
|
628 |
// End of file
|