44
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 the hwr layout
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// system includes
|
|
20 |
#include <peninputhiraganakanji.h> // hiraganakanji
|
|
21 |
#include <peninputuistatemgr.h> // use ui state mgr
|
|
22 |
#include <peninputdataconverter.h>
|
|
23 |
#include <aknfeppeninputenums.h> //command from fep or IME to plugin. for vkb/hwr, range defination
|
|
24 |
#include <peninputcommonlayoutglobalenum.h> // EPeninputLayoutEventEnter
|
|
25 |
#include <peninputeventjp.h>
|
|
26 |
#include <AknFepGlobalEnums.h> //define TWidthChar
|
|
27 |
#include <PtiEngine.h>
|
|
28 |
#include <peninputjapanesecandidatewnd.h>
|
|
29 |
#include <peninputjapanesepredictivewnd.h>
|
|
30 |
|
|
31 |
// user includes
|
|
32 |
#include "peninputhwrboxlayout.h"
|
|
33 |
#include "peninputhwrboxuistatetype.h" // UI state
|
|
34 |
#include "peninputhwrboxwindow.h" // use hwr window, which derived from base window
|
|
35 |
#include "peninputhwrboxdatamgr.h" // use data mgr
|
|
36 |
#include "peninputhwrboxuistatestandby.h"
|
|
37 |
#include "peninputhwrboxuistatestandbyjp.h"
|
|
38 |
#include "peninputhwrboxuistatewithtransitorychars.h"
|
|
39 |
#include "peninputhwrboxuistatepenstandby.h"
|
|
40 |
#include "peninputhwrboxuistatepenbeginwriting.h"
|
|
41 |
#include "peninputhwrboxuistatepenendwriting.h"
|
|
42 |
#include "peninputhwrboxuistatepencandidateselecting.h"
|
|
43 |
#include "peninputhwrevent.h"
|
|
44 |
#include "peninputhwrboxgroup.h"
|
|
45 |
|
|
46 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
47 |
#include <PeninputHwrStrokeLogConst.h>
|
|
48 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
49 |
|
|
50 |
// constant definition
|
|
51 |
const TInt KMaxCandidateLen = 128;
|
|
52 |
const TUint16 KBackRep = 0x2408;
|
|
53 |
const TUint16 KEnterRep = 0xF801;
|
|
54 |
const TUint16 KSpaceRep = 0xF800;
|
|
55 |
const TInt KDelay = 100000; //1/10 second
|
|
56 |
const TInt KPeninputBufLen = 16;
|
|
57 |
const TInt KPeninputBufLen8 = 8;
|
|
58 |
|
|
59 |
// ======== MEMBER FUNCTIONS ========
|
|
60 |
|
|
61 |
// ---------------------------------------------------------------------------
|
|
62 |
// CPeninputHwrBoxLayout::NewL
|
|
63 |
// (other items were commented in a header).
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CPeninputHwrBoxLayout* CPeninputHwrBoxLayout::NewL(MLayoutOwner* aLayoutOwner,
|
|
67 |
const TAny* aInitData)
|
|
68 |
{
|
|
69 |
CPeninputHwrBoxLayout* self = new (ELeave) CPeninputHwrBoxLayout(aLayoutOwner);
|
|
70 |
|
|
71 |
CleanupStack::PushL(self);
|
|
72 |
self->ConstructL(aInitData);
|
|
73 |
CleanupStack::Pop(self);
|
|
74 |
|
|
75 |
return self;
|
|
76 |
}
|
|
77 |
|
|
78 |
// ---------------------------------------------------------------------------
|
|
79 |
// CPeninputHwrBoxLayout::~CPeninputHwrBoxLayout
|
|
80 |
// (other items were commented in a header).
|
|
81 |
// ---------------------------------------------------------------------------
|
|
82 |
//
|
|
83 |
CPeninputHwrBoxLayout::~CPeninputHwrBoxLayout()
|
|
84 |
{
|
|
85 |
delete iHiraganaKanji;
|
|
86 |
delete iKeyEventAsync;
|
|
87 |
delete iKeyEventClearAsync;
|
|
88 |
delete iPointerEventAsync;
|
|
89 |
delete iUiStatePenMgr;
|
|
90 |
delete iSubmitText;
|
|
91 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
92 |
if (iLogger.LogValid())
|
|
93 |
{
|
|
94 |
iLogger.CloseLog();
|
|
95 |
}
|
|
96 |
iLogger.Close();
|
|
97 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
98 |
}
|
|
99 |
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
// CPeninputHwrBoxLayout::HandleEventL
|
|
102 |
// handle event from window server
|
|
103 |
// ---------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
TBool CPeninputHwrBoxLayout::HandleEventL(TEventType aType, const TAny* aData)
|
|
106 |
{
|
|
107 |
TRawEvent event=*((TRawEvent*)aData);
|
|
108 |
CFepUiBaseCtrl* ctrl = NULL;
|
|
109 |
if(ERawEvent == aType)
|
|
110 |
{
|
|
111 |
if (TRawEvent::EButton1Down == event.Type() && iHiraganaKanji)
|
|
112 |
{
|
|
113 |
iHiraganaKanji->CancelRepeat();
|
|
114 |
}
|
|
115 |
// DropDownList expanded and PointerDown on drawing area ---> cancel input and to StandBy
|
|
116 |
if (iExpanded
|
|
117 |
&& TRawEvent::EButton1Down == event.Type()
|
|
118 |
&& iUiStatePenMgr->CurrentUiState() == iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenCandidateSelecting)
|
|
119 |
&& iDropdownList
|
|
120 |
&& iHwrWindow->BoxGroup())
|
|
121 |
{
|
|
122 |
TPoint point = event.Pos() - Position ();
|
|
123 |
if (!iDropdownList->Rect().Contains(point)
|
|
124 |
&& iHwrWindow->BoxGroup()->Rect().Contains(point))
|
|
125 |
{
|
|
126 |
ClearInputToPenStandByL();
|
|
127 |
return ETrue;
|
|
128 |
}
|
|
129 |
}
|
|
130 |
if(TRawEvent::EButton1Up == event.Type())
|
|
131 |
{
|
|
132 |
ctrl = RootControl()->CtrlCapPointer();
|
|
133 |
}
|
|
134 |
}
|
|
135 |
TBool handled = CPeninputCommonLayout::HandleEventL(aType,aData);
|
|
136 |
// if dropdownlist expanded, capture off
|
|
137 |
// as the dropdownlist is the 1st control in the clientpane controlgroup, capture is not need.
|
|
138 |
if (TRawEvent::EButton1Up == event.Type() && !ctrl)
|
|
139 |
{
|
|
140 |
CFepUiBaseCtrl* capture = RootControl()->CtrlCapPointer();
|
|
141 |
if (capture && capture->ControlId() == EPeninutWindowCtrlIdDropDownList)
|
|
142 |
{ // dropdownlist expanded
|
|
143 |
iDropdownList = capture;
|
|
144 |
capture->CapturePointer(EFalse);
|
|
145 |
SetCapturePointerEventAgain(); // capture for transitory input on
|
|
146 |
HandleControlEvent(EPeninputLayoutHwrEventDropDownListExpanded, capture, KNullDesC);
|
|
147 |
}
|
|
148 |
}
|
|
149 |
// if a control do capture off, capture for transitory input on.
|
|
150 |
if (ctrl && !RootControl()->CtrlCapPointer())
|
|
151 |
{
|
|
152 |
SetCapturePointerEventAgain();
|
|
153 |
}
|
|
154 |
return handled;
|
|
155 |
}
|
|
156 |
|
|
157 |
// ---------------------------------------------------------------------------
|
|
158 |
// CPeninputHwrBoxLayout::HandleCommand
|
|
159 |
// (other items were commented in a header).
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
//
|
|
162 |
TInt CPeninputHwrBoxLayout::HandleCommand(TInt aCmd, TUint8* aData)
|
|
163 |
{
|
|
164 |
// Handle command from fep or IME to this layout
|
|
165 |
TUint* data = (TUint*) aData;
|
|
166 |
|
|
167 |
switch ( aCmd )
|
|
168 |
{
|
|
169 |
case ECmdPenInputPermittedRange: // different from common layout
|
|
170 |
// this command comes after ECmdPenInputJapaneseSetting
|
|
171 |
if (iDataMgr)
|
|
172 |
{
|
|
173 |
// in SetData, SetPermittedRanges() and SetCharacterRangePopupLare() called.
|
|
174 |
SetData(EPeninputDataTypePermittedRange, aData);
|
|
175 |
}
|
|
176 |
break;
|
|
177 |
case ECmdPenInputLanguage:
|
|
178 |
{
|
|
179 |
CPeninputCommonLayout::HandleCommand(aCmd, aData);
|
|
180 |
}
|
|
181 |
break;
|
|
182 |
case ECmdPenInputWindowOpen:
|
|
183 |
if (iHwrWindow)
|
|
184 |
{
|
|
185 |
iHwrWindow->Opened();
|
|
186 |
iLayoutWindow->Hide(EFalse); // before Hide Check or Change, parent controlgroup should be Hide Off.
|
|
187 |
TInt curRange = CPeninputDataConverter::AnyToInt(RequestData(EPeninputDataTypeCurrentRange));
|
|
188 |
TBool currHide = iHwrWindow->PredictiveWindow()->Hiden();
|
|
189 |
TBool newHide = ETrue;
|
|
190 |
if (static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->Predictive()
|
|
191 |
&& static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->Conversion()
|
|
192 |
&& ERangeHiraganaKanji == curRange)
|
|
193 |
{
|
|
194 |
newHide = EFalse;
|
|
195 |
}
|
|
196 |
if (newHide && !currHide || !newHide && currHide)
|
|
197 |
{
|
|
198 |
iHwrWindow->PredictiveWindow()->Hide(newHide);
|
|
199 |
iHwrWindow->SizeChanged(ETrue);
|
|
200 |
}
|
|
201 |
CPeninputCommonLayout::HandleCommand( aCmd, aData );
|
|
202 |
if (*data != EPenInputOpenManually && Position() == TPoint(0,0))
|
|
203 |
{ // position is not yet set.(English --> Japanese)
|
|
204 |
SendEventToWindow(EPeninputLayoutEventMovePosition, NULL, KNullDesC);
|
|
205 |
}
|
|
206 |
iHwrWindow->ICFEnableRegionUpdating(); // ICF::OnActivate()
|
|
207 |
}
|
|
208 |
ToPenStandBy();
|
|
209 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
210 |
if (iLogger.Handle())
|
|
211 |
{
|
|
212 |
if (iLogger.LogValid())
|
|
213 |
{
|
|
214 |
iLogger.CloseLog();
|
|
215 |
}
|
|
216 |
// Generate file name based on date.
|
|
217 |
TTime time;
|
|
218 |
time.HomeTime();
|
|
219 |
TDateTime datetime = time.DateTime();
|
|
220 |
TBuf<KHwrStrokeLogFileNameMaxLen> name;
|
|
221 |
name.Format(KHwrStrokeLogFileExt(),
|
|
222 |
datetime.Year(), TInt(datetime.Month()+1), datetime.Day()+1,
|
|
223 |
datetime.Hour(), datetime.Minute(), datetime.Second());
|
|
224 |
// Open(or create) log file
|
|
225 |
iLogger.CreateLog( KHwrStrokeLogDir(), name, EFileLoggingModeAppend);
|
|
226 |
// Disable date and time
|
|
227 |
iLogger.SetDateAndTime(EFalse, EFalse);
|
|
228 |
// Write log
|
|
229 |
iLogger.Write(KHwrStrokeLogOpen());
|
|
230 |
WriteHwrStrokeLogRange();
|
|
231 |
}
|
|
232 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
233 |
break;
|
|
234 |
case ECmdPenInputWindowClose:
|
|
235 |
SendEventToWindow(EPeninputLayoutEventCloseCharacterRange, NULL, KNullDesC);
|
|
236 |
HiraganaKanjiCompleteAll();
|
|
237 |
CPeninputCommonLayout::HandleCommand( aCmd, aData );
|
|
238 |
UiStateMgr()->SetCurrentUiState( EPeninputHwrUiStateNone );
|
|
239 |
Initialize();
|
|
240 |
SetCapturePointerEvent(EFalse);
|
|
241 |
iHwrWindow->Closed();
|
|
242 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
243 |
if (iLogger.LogValid())
|
|
244 |
{
|
|
245 |
iLogger.Write(KHwrStrokeLogClose());
|
|
246 |
iLogger.CloseLog();
|
|
247 |
}
|
|
248 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
249 |
break;
|
|
250 |
case ECmdPenInputRange: // different from common layout:control. ptiEngine.
|
|
251 |
{
|
|
252 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
253 |
iLogOff = 1;
|
|
254 |
#endif
|
|
255 |
// this command comes after ECmdPenInputJapaneseSetting, ECmdPenInputPermittedRange
|
|
256 |
if (iLayoutWindow)
|
|
257 |
{
|
|
258 |
iHwrWindow->ICFDisableRegionUpdating(); // ICF::OnDeActivate()
|
|
259 |
iLayoutWindow->Hide(EFalse); // before Hide Check or Change, parent controlgroup should be Hide Off.
|
|
260 |
}
|
|
261 |
if (iDataMgr)
|
|
262 |
{
|
|
263 |
TUint range = TranslateRangeHullHalf(*data);
|
|
264 |
TUint8* rangedata = reinterpret_cast<TUint8*>(&range);
|
|
265 |
// SetData(SetPremaryRange) and SizeChangedForBaseWindow and ChangeClientLayout
|
|
266 |
CPeninputCommonLayout::HandleCommand( aCmd, rangedata );
|
|
267 |
iRangeOrg = range;
|
|
268 |
TInt permittedRange = CPeninputDataConverter::AnyToInt(RequestData(EPeninputDataTypePermittedRange));
|
|
269 |
if (permittedRange & (ERangeHiraganaKanji | ERangeKatakana | ERangeFullWidthKatakana))
|
|
270 |
{
|
|
271 |
TInt index = 0;
|
|
272 |
if (range == ERangeEnglish || range == ERangeFullWidthEnglish)
|
|
273 |
{
|
|
274 |
index = 2; // see CPeninputHwrBoxDataMgr::SetCharacterRangePopupL()
|
|
275 |
}
|
|
276 |
if (range == ERangeNumber || range == ERangeFullWidthNumeric)
|
|
277 |
{
|
|
278 |
index = (permittedRange & (ERangeEnglish | ERangeFullWidthEnglish))? 3:2;
|
|
279 |
// see CPeninputHwrBoxDataMgr::SetCharacterRangePopupL()
|
|
280 |
}
|
|
281 |
if (index)
|
|
282 |
{
|
|
283 |
TPtrC dataPtr;
|
|
284 |
dataPtr.Set(reinterpret_cast<TUint16*>(&index),sizeof(TInt)/sizeof(TUint16));
|
|
285 |
HandleControlEvent(EPeninputLayoutEventRange,NULL,dataPtr); // call DoSetCurrentRange()
|
|
286 |
}
|
|
287 |
else
|
|
288 |
{
|
|
289 |
DoSetCurrentRange();
|
|
290 |
}
|
|
291 |
}
|
|
292 |
else
|
|
293 |
{
|
|
294 |
DoSetCurrentRange();
|
|
295 |
}
|
|
296 |
}
|
|
297 |
}
|
|
298 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
299 |
iLogOff = 0;
|
|
300 |
#endif
|
|
301 |
break;
|
|
302 |
case ECmdPenInputJapaneseSetting: // Japanese setting information
|
|
303 |
// this command comes before ECmdPenInputPermittedRange, ECmdPenInputRange
|
|
304 |
if (iDataMgr)
|
|
305 |
{
|
|
306 |
iDataMgr->Reset();
|
|
307 |
TUint val = *data;
|
|
308 |
TInt sctDimmFlag = (val & EPenInputJapaneseSettingLunchSCT)? 0: 1;
|
|
309 |
TPtr ptr((TUint16*)&sctDimmFlag, sizeof(TInt)/sizeof(TUint16));
|
|
310 |
SendEventToWindow(EEventSetDimmedSctBtn, NULL, ptr);
|
|
311 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetFullHalf(
|
|
312 |
(val & EPenInputJapaneseSettingCharacterWidth)? 1: 0);
|
|
313 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetPredictive(
|
|
314 |
(val & EPenInputJapaneseSettingPredictive)? ETrue: EFalse);
|
|
315 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetConversion(
|
|
316 |
(val & EPenInputJapaneseSettingConversion)? ETrue: EFalse);
|
|
317 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetClear(
|
|
318 |
(val & EPenInputJapaneseSettingDeletingDirection)? 1: 0);
|
|
319 |
}
|
|
320 |
break;
|
|
321 |
case ECmdPenInputEnableSettingBtn:
|
|
322 |
iHwrWindow->SetEnableSettingBtnJp(*data);
|
|
323 |
break;
|
|
324 |
case ECmdPenInputSendEditorTextAndCurPos:
|
|
325 |
CFepUiLayout::HandleCommand( aCmd, aData );
|
|
326 |
break;
|
|
327 |
default:
|
|
328 |
CPeninputCommonLayout::HandleCommand( aCmd, aData );
|
|
329 |
break;
|
|
330 |
}
|
|
331 |
return KErrNone;
|
|
332 |
}
|
|
333 |
|
|
334 |
// ---------------------------------------------------------------------------
|
|
335 |
// CPeninputHwrBoxLayout::HandleControlEvent
|
|
336 |
// (other items were commented in a header).
|
|
337 |
// ---------------------------------------------------------------------------
|
|
338 |
//
|
|
339 |
void CPeninputHwrBoxLayout::HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl, const TDesC& aEventData)
|
|
340 |
{
|
|
341 |
// Handle event from control
|
|
342 |
TInt* data = (TInt*)aEventData.Ptr();
|
|
343 |
TBool handled = EFalse;
|
|
344 |
|
|
345 |
if (EEventDraggingEnd == aEventType)
|
|
346 |
{
|
|
347 |
CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData);
|
|
348 |
}
|
|
349 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
350 |
if (EPeninputLayoutEventBack == aEventType)
|
|
351 |
{
|
|
352 |
WriteHwrStrokeLogClear();
|
|
353 |
}
|
|
354 |
if (EPeninputLayoutHwrEventCandidateSelected == aEventType && iLogger.LogValid())
|
|
355 |
{
|
|
356 |
if (aEventData.Length() > 1)
|
|
357 |
{
|
|
358 |
//get the candidate index
|
|
359 |
const TInt cellNo = aEventData[aEventData.Length()-1] + 1;
|
|
360 |
iLogger.WriteFormat(KHwrStrokeLogSelected(), cellNo);
|
|
361 |
}
|
|
362 |
}
|
|
363 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
364 |
|
|
365 |
if (iUiStatePenMgr != NULL)
|
|
366 |
{
|
|
367 |
handled = HandleControlEventPen(aEventType, aCtrl, aEventData);
|
|
368 |
}
|
|
369 |
if (handled)
|
|
370 |
{
|
|
371 |
return;
|
|
372 |
}
|
|
373 |
|
|
374 |
//deal with the event from all controls in layout
|
|
375 |
switch (aEventType)
|
|
376 |
{
|
|
377 |
case EPeninputLayoutEventClose:
|
|
378 |
case EPeninputLayoutEventOption:
|
|
379 |
case EPeninputLayoutEventToVkb:
|
|
380 |
HiraganaKanjiCompleteAll(); // call ToPenStandBy()
|
|
381 |
SetCapturePointerEvent(EFalse);
|
|
382 |
if (EPeninputLayoutEventClose == aEventType)
|
|
383 |
{
|
|
384 |
Initialize(); //jump to init state
|
|
385 |
}
|
|
386 |
if (EPeninputLayoutEventToVkb == aEventType)
|
|
387 |
{
|
|
388 |
TBuf<KPeninputBufLen8> buf;
|
|
389 |
TBool switchByMode = ETrue;
|
|
390 |
TInt mode = EPluginInputModeVkb;
|
|
391 |
CPeninputDataConverter::CombinationToDesc( switchByMode,
|
|
392 |
mode, buf );
|
|
393 |
SignalOwner( ESignalLayoutUIChanged, buf );
|
|
394 |
}
|
|
395 |
else
|
|
396 |
{
|
|
397 |
CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData);
|
|
398 |
}
|
|
399 |
break;
|
|
400 |
case EPeninputLayoutEventSct:
|
|
401 |
HiraganaKanjiCompleteAll();
|
|
402 |
SetCapturePointerEvent(EFalse);
|
|
403 |
SignalOwner(ESignalHwNotifySctPopup);
|
|
404 |
break;
|
|
405 |
case EPeninputLayoutEventSwitchLanguage: // nop
|
|
406 |
break;
|
|
407 |
|
|
408 |
case EPeninputLayoutEventRange: // from character range popup or when accept ECmdPenInputRange command
|
|
409 |
{
|
|
410 |
TInt permittedRange = CPeninputDataConverter::AnyToInt(RequestData(EPeninputDataTypePermittedRange));
|
|
411 |
TInt currentRange = CPeninputDataConverter::AnyToInt( RequestData( EPeninputDataTypeCurrentRange ) );
|
|
412 |
TInt range = currentRange;
|
|
413 |
TInt deActive = 0; // 0:none 1:ICF 2:display off
|
|
414 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetCurrentCharacterRangeIndex(*data);
|
|
415 |
switch(static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->CharacterRangeId())
|
|
416 |
{
|
|
417 |
case EPeninutCharacterRangeIdAll:
|
|
418 |
if (permittedRange & (ERangeHiraganaKanji | ERangeKatakana | ERangeFullWidthKatakana))
|
|
419 |
{
|
|
420 |
if (!(range & (ERangeHiraganaKanji | ERangeKatakana | ERangeFullWidthKatakana)))
|
|
421 |
{
|
|
422 |
range = (permittedRange & ERangeHiraganaKanji)? ERangeHiraganaKanji : ERangeKatakana;
|
|
423 |
}
|
|
424 |
}
|
|
425 |
break;
|
|
426 |
case EPeninutCharacterRangeIdKanaKanji:
|
|
427 |
permittedRange &= (ERangeHiraganaKanji | ERangeKatakana | ERangeFullWidthKatakana);
|
|
428 |
if (!(permittedRange & range))
|
|
429 |
{
|
|
430 |
range = (permittedRange & ERangeHiraganaKanji)? ERangeHiraganaKanji : ERangeKatakana;
|
|
431 |
}
|
|
432 |
break;
|
|
433 |
case EPeninutCharacterRangeIdLatin:
|
|
434 |
permittedRange &= (ERangeEnglish | ERangeFullWidthEnglish);
|
|
435 |
range = ERangeEnglish;
|
|
436 |
break;
|
|
437 |
case EPeninutCharacterRangeIdNumber:
|
|
438 |
permittedRange &= (ERangeNumber | ERangeFullWidthNumeric);
|
|
439 |
range = ERangeNumber;
|
|
440 |
break;
|
|
441 |
default:
|
|
442 |
break;
|
|
443 |
}
|
|
444 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetPermittedRanges(permittedRange);
|
|
445 |
range = TranslateRangeHullHalf(range);
|
|
446 |
if (!(range & permittedRange))
|
|
447 |
{
|
|
448 |
range = iRangeOrg;
|
|
449 |
}
|
|
450 |
if (aCtrl) // from character range popup
|
|
451 |
{
|
|
452 |
TBool currHide = iHwrWindow->PredictiveWindow()->Hiden();
|
|
453 |
TBool newHide = ETrue;
|
|
454 |
if (static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->Predictive()
|
|
455 |
&& static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->Conversion()
|
|
456 |
&& ERangeHiraganaKanji == range)
|
|
457 |
{
|
|
458 |
newHide = EFalse;
|
|
459 |
}
|
|
460 |
if (newHide && !currHide || !newHide && currHide)
|
|
461 |
{
|
|
462 |
LayoutOwner()->Hide(ETrue); // display off
|
|
463 |
deActive = 2;
|
|
464 |
iHwrWindow->PredictiveWindow()->Hide(newHide);
|
|
465 |
iHwrWindow->SizeChanged(ETrue);
|
|
466 |
}
|
|
467 |
else
|
|
468 |
{
|
|
469 |
iHwrWindow->ICFDisableRegionUpdating(); // ICF::OnDeActivate()
|
|
470 |
deActive = 1;
|
|
471 |
}
|
|
472 |
iHwrWindow->CharacterRangeWindow()->HidePopup();
|
|
473 |
}
|
|
474 |
if (aCtrl && range != currentRange) // from character range popup
|
|
475 |
{
|
|
476 |
// SetData(SetPremaryRange) and Sendkey( ESignalRange,...)
|
|
477 |
TPtrC rangeptr((TUint16*)(&range), sizeof(TInt)/sizeof(TUint16));
|
|
478 |
CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, rangeptr);
|
|
479 |
if (ERangeEnglish != range && ERangeNumber != range)
|
|
480 |
{
|
|
481 |
TInt native = ERangeNative;
|
|
482 |
TBuf<KPeninputBufLen> buf;
|
|
483 |
CPeninputDataConverter::CombinationToDesc( native, range, buf );
|
|
484 |
Sendkey( ESignalRange, buf );
|
|
485 |
}
|
|
486 |
}
|
|
487 |
else
|
|
488 |
{
|
|
489 |
SetData(EPeninputDataTypeCurrentRange, &range);
|
|
490 |
}
|
|
491 |
DoSetCurrentRange();
|
|
492 |
if (deActive == 2)
|
|
493 |
{
|
|
494 |
LayoutOwner()->Hide(EFalse); // display on
|
|
495 |
}
|
|
496 |
else if (deActive == 1)
|
|
497 |
{
|
|
498 |
iHwrWindow->ICFEnableRegionUpdating(); // ICF Cursor On
|
|
499 |
}
|
|
500 |
}
|
|
501 |
break;
|
|
502 |
|
|
503 |
// from HiraganaKanji
|
|
504 |
case EEventHiraganaKanjiWithTransitoryChars2Standbyjp:
|
|
505 |
if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
506 |
{
|
|
507 |
UiStateMgr()->SetCurrentUiState(EPeninputHwrUiStateStandbyjp);
|
|
508 |
SetCapturePointerEvent(EFalse);
|
|
509 |
ToPenStandBy();
|
|
510 |
}
|
|
511 |
break;
|
|
512 |
// from HiraganaKanji
|
|
513 |
case EEventHiraganaKanjiWithoutTransitoryChars:
|
|
514 |
if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
515 |
{
|
|
516 |
SetCapturePointerEvent(EFalse);
|
|
517 |
}
|
|
518 |
break;
|
|
519 |
|
|
520 |
case EEventVirtualKeyUp:
|
|
521 |
if ( UiStateMgr()->CurrentUiState()
|
|
522 |
&& !static_cast<CPeninputHwrBoxUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,aEventData) )
|
|
523 |
{
|
|
524 |
SetCapturePointerEvent(ETrue);
|
|
525 |
HiraganaHandleControlEventJp(aEventType, aEventData);
|
|
526 |
}
|
|
527 |
break;
|
|
528 |
case EPeninputLayoutEventBack:
|
|
529 |
{
|
|
530 |
TInt clear = EKeyBackspace;
|
|
531 |
TPtrC clearptr((TUint16*)(&clear), 1);
|
|
532 |
if ( UiStateMgr()->CurrentUiState()
|
|
533 |
&& !static_cast<CPeninputHwrBoxUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,clearptr) )
|
|
534 |
{
|
|
535 |
HiraganaHandleControlEventJp(aEventType, clearptr);
|
|
536 |
}
|
|
537 |
}
|
|
538 |
break;
|
|
539 |
case EPeninputLayoutEventEnter:
|
|
540 |
case EPeninputLayoutEventSelectItem: // select from prediction/convert candidates by pointer
|
|
541 |
case EPeninputLayoutEventTab:
|
|
542 |
if (EPeninputLayoutEventEnter == aEventType && IsPredictiveWithNoChar())
|
|
543 |
{ // without transitory chars and next word prediction candidates are offered
|
|
544 |
// Enter button should clear Prediction and enter a newline
|
|
545 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(EPeninputLayoutEventBack,KNullDesC));
|
|
546 |
}
|
|
547 |
if ( UiStateMgr()->CurrentUiState()
|
|
548 |
&& !static_cast<CPeninputHwrBoxUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,aEventData) )
|
|
549 |
{
|
|
550 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData));
|
|
551 |
}
|
|
552 |
break;
|
|
553 |
case EPeninputLayoutEventSpace: // convert
|
|
554 |
if ( UiStateMgr()->CurrentUiState()
|
|
555 |
&& !static_cast<CPeninputHwrBoxUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType, aEventData) )
|
|
556 |
{
|
|
557 |
HiraganaHandleControlEventJp(aEventType, aEventData);
|
|
558 |
}
|
|
559 |
break;
|
|
560 |
case EEventIcfPointerUp: // from ContextField
|
|
561 |
case EEventIcfCompleteAll: // from ContextField
|
|
562 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData));
|
|
563 |
break;
|
|
564 |
case EEventShowCandidateWnd: // CandidateWnd On
|
|
565 |
{
|
|
566 |
iHwrWindow->SetDimmed(ETrue);
|
|
567 |
}
|
|
568 |
break;
|
|
569 |
case EEventHideCandidateWnd: // CandidateWnd Off
|
|
570 |
{
|
|
571 |
iHwrWindow->SetDimmed(EFalse);
|
|
572 |
}
|
|
573 |
break;
|
|
574 |
case EEventWaitforEditorTextComing: // may use, someday.
|
|
575 |
{
|
|
576 |
iWaitforEditorTextComing = 1;
|
|
577 |
}
|
|
578 |
break;
|
|
579 |
case EEventDraggingEnd:
|
|
580 |
break;
|
|
581 |
case EPeninputLayoutEventSwitchCharacterRange:
|
|
582 |
if (static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->CharacterRangeArray()->Count() > 1)
|
|
583 |
{
|
|
584 |
HiraganaKanjiCompleteAll();
|
|
585 |
SendEventToWindow(aEventType, aCtrl, aEventData);
|
|
586 |
}
|
|
587 |
break;
|
|
588 |
case EEventICFSelectionChanged: // from ContextField (when whithout transitory input)
|
|
589 |
if (iHiraganaKanji)
|
|
590 |
{ // update saved data
|
|
591 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData));
|
|
592 |
}
|
|
593 |
break;
|
|
594 |
case EEventSetAppCursorSelection: // from ContextField
|
|
595 |
if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
596 |
{
|
|
597 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData));
|
|
598 |
}
|
|
599 |
break;
|
|
600 |
case EPeninputLayoutHwrEventDropDownListExpanded:
|
|
601 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
602 |
if (iLogger.LogValid())
|
|
603 |
{
|
|
604 |
iLogger.Write(KHwrStrokeLogExpand());
|
|
605 |
}
|
|
606 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
607 |
CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData);
|
|
608 |
iExpanded = ETrue;
|
|
609 |
break;
|
|
610 |
default:
|
|
611 |
CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData);
|
|
612 |
break;
|
|
613 |
}
|
|
614 |
}
|
|
615 |
|
|
616 |
// ---------------------------------------------------------------------------
|
|
617 |
// CPeninputHwrBoxLayout::HandleControlEventPen
|
|
618 |
// (other items were commented in a header).
|
|
619 |
// ---------------------------------------------------------------------------
|
|
620 |
//
|
|
621 |
TBool CPeninputHwrBoxLayout::HandleControlEventPen(TInt aEventType, CFepUiBaseCtrl* /*aCtrl*/, const TDesC& aEventData)
|
|
622 |
{
|
|
623 |
TBool handled = EFalse;
|
|
624 |
CPeninputHwrBoxUiState* current = static_cast<CPeninputHwrBoxUiState*>(iUiStatePenMgr->CurrentUiState());
|
|
625 |
TBuf<KMaxCandidateLen> charCode;
|
|
626 |
//filter un-related events
|
|
627 |
if (aEventType != EEventSetAppCursorSelection
|
|
628 |
&& aEventType != EPeninputLayoutEventClose
|
|
629 |
&& aEventType != EPeninputLayoutEventBack
|
|
630 |
&& aEventType != EPeninputLayoutEventEnter
|
|
631 |
&& (aEventType != EPeninputLayoutEventSpace || !iCapturePointerEvent)
|
|
632 |
&& aEventType != EPeninputLayoutEventRange
|
|
633 |
&& aEventType != EPeninputLayoutEventOption
|
|
634 |
&& aEventType != EPeninputLayoutEventSct
|
|
635 |
&& aEventType != EPeninputLayoutEventSwitchCharacterRange
|
|
636 |
&& aEventType != EEventDraggingEnd
|
|
637 |
&& (aEventType >= EPeninputLayoutHwrEventLast || aEventType < EPeninputLayoutHwrEventBeginWriting))
|
|
638 |
{
|
|
639 |
return handled;
|
|
640 |
}
|
|
641 |
TRAPD(err, current->HandleControlEventPenL(aEventType, aEventData, *this, charCode, handled));
|
|
642 |
if (KErrNone != err)
|
|
643 |
{ // close peninput
|
|
644 |
HiraganaKanjiCompleteAll(); // call ToPenStandBy()
|
|
645 |
SetCapturePointerEvent(EFalse);
|
|
646 |
Initialize(); //jump to init state
|
|
647 |
CPeninputCommonLayout::HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC);
|
|
648 |
handled = ETrue;
|
|
649 |
}
|
|
650 |
return handled;
|
|
651 |
}
|
|
652 |
|
|
653 |
// ---------------------------------------------------------------------------
|
|
654 |
// CPeninputHwrBoxLayout::OnAppEditorTextComing
|
|
655 |
// (other items were commented in a header).
|
|
656 |
// ---------------------------------------------------------------------------
|
|
657 |
//
|
|
658 |
TInt CPeninputHwrBoxLayout::OnAppEditorTextComing(const TFepInputContextFieldData& aData)
|
|
659 |
{
|
|
660 |
iWaitforEditorTextComing = 0;
|
|
661 |
// Handle edit text coming
|
|
662 |
if (iHiraganaKanji)
|
|
663 |
{
|
|
664 |
TRAPD(err, iHiraganaKanji->SetEditorTextL(aData));
|
|
665 |
if (KErrNone != err)
|
|
666 |
{
|
|
667 |
HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC);
|
|
668 |
}
|
|
669 |
return err;
|
|
670 |
}
|
|
671 |
return KErrNone;
|
|
672 |
}
|
|
673 |
|
|
674 |
// ---------------------------------------------------------
|
|
675 |
// Submit the char code.
|
|
676 |
// ---------------------------------------------------------
|
|
677 |
//
|
|
678 |
void CPeninputHwrBoxLayout::SubmitL(const TDesC& aCharCode)
|
|
679 |
{
|
|
680 |
TInt len = 0;
|
|
681 |
if (iSubmitText && !(*iSubmitText).CompareC(aCharCode)
|
|
682 |
|| !UiStateMgr()
|
|
683 |
|| !UiStateMgr()->CurrentUiState())
|
|
684 |
{
|
|
685 |
return;
|
|
686 |
}
|
|
687 |
if (iSubmitText)
|
|
688 |
{
|
|
689 |
len = iSubmitText->Length();
|
|
690 |
if (len > 1
|
|
691 |
&& UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
692 |
{
|
|
693 |
len = 1;
|
|
694 |
}
|
|
695 |
}
|
|
696 |
delete iSubmitText;
|
|
697 |
iSubmitText = NULL;
|
|
698 |
iSubmitText = aCharCode.AllocL();
|
|
699 |
|
|
700 |
TInt eventType = EEventVirtualKeyUp;
|
|
701 |
TPtr charcode(iSubmitText->Des());
|
|
702 |
|
|
703 |
//if charcode is enter or back or space, translate them back
|
|
704 |
TPtrC16 ptr;
|
|
705 |
ptr.Set(&KBackRep, sizeof(KBackRep)/sizeof(TUint16));
|
|
706 |
|
|
707 |
if (charcode.CompareC(ptr) == 0)
|
|
708 |
{
|
|
709 |
charcode.Zero();
|
|
710 |
charcode.Append((TChar)EKeyBackspace);
|
|
711 |
eventType = EPeninputLayoutEventBack;
|
|
712 |
}
|
|
713 |
else
|
|
714 |
{
|
|
715 |
ptr.Set(&KSpaceRep, sizeof(KSpaceRep)/sizeof(TUint16));
|
|
716 |
if (charcode.CompareC(ptr) == 0)
|
|
717 |
{
|
|
718 |
charcode.Zero();
|
|
719 |
charcode.Append((TChar)EKeySpace);
|
|
720 |
eventType = EPeninputLayoutEventSpace;
|
|
721 |
}
|
|
722 |
else
|
|
723 |
{
|
|
724 |
ptr.Set(&KEnterRep, sizeof(KEnterRep)/sizeof(TUint16));
|
|
725 |
if (charcode.CompareC(ptr) == 0)
|
|
726 |
{
|
|
727 |
charcode.Zero();
|
|
728 |
charcode.Append((TChar)EKeyEnter);
|
|
729 |
eventType = EPeninputLayoutEventEnter;
|
|
730 |
}
|
|
731 |
}
|
|
732 |
}
|
|
733 |
if (len > 0 &&
|
|
734 |
(EEventVirtualKeyUp != eventType
|
|
735 |
|| UiStateMgr()->CurrentUiState() != UiStateMgr()->GetUiState(EPeninputHwrUiStateStandby)))
|
|
736 |
{
|
|
737 |
for (TInt i = 0; i < len; i++)
|
|
738 |
{
|
|
739 |
DeleteL(EKeyDelete);
|
|
740 |
}
|
|
741 |
}
|
|
742 |
|
|
743 |
if (len > 0 &&
|
|
744 |
(EEventVirtualKeyUp == eventType
|
|
745 |
&& UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateStandby)))
|
|
746 |
{
|
|
747 |
// len == 1 or 2, charcode.Length() == 1 or 2.
|
|
748 |
TInt diff = charcode.Length() - len;
|
|
749 |
if (diff > 0)
|
|
750 |
{
|
|
751 |
HBufC* p = HBufC::NewL(charcode.Length() + 2);
|
|
752 |
p->Des().Append((TUint16*)&len, 2);
|
|
753 |
p->Des().Append(charcode.Left(len));
|
|
754 |
Sendkey( ESignalReplaceTextJp, *p );
|
|
755 |
delete p;
|
|
756 |
Sendkey( ESignalKeyEvent, charcode.Right(diff));
|
|
757 |
}
|
|
758 |
else
|
|
759 |
{
|
|
760 |
while (len > charcode.Length())
|
|
761 |
{
|
|
762 |
DeleteL(EKeyDelete);
|
|
763 |
--len;
|
|
764 |
}
|
|
765 |
HBufC* p = HBufC::NewL(charcode.Length() + 2);
|
|
766 |
p->Des().Append((TUint16*)&len, 2);
|
|
767 |
p->Des().Append(charcode);
|
|
768 |
Sendkey( ESignalReplaceTextJp, *p );
|
|
769 |
delete p;
|
|
770 |
}
|
|
771 |
}
|
|
772 |
else if ( !static_cast<CPeninputHwrBoxUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(eventType,charcode) )
|
|
773 |
{
|
|
774 |
SetCapturePointerEvent(ETrue);
|
|
775 |
iHiraganaKanji->HandleControlEventJpL(eventType, charcode);
|
|
776 |
}
|
|
777 |
if (EEventVirtualKeyUp != eventType)
|
|
778 |
{
|
|
779 |
delete iSubmitText;
|
|
780 |
iSubmitText = NULL;
|
|
781 |
}
|
|
782 |
}
|
|
783 |
|
|
784 |
// ---------------------------------------------------------
|
|
785 |
// Delete the previous charcode
|
|
786 |
// ---------------------------------------------------------
|
|
787 |
//
|
|
788 |
void CPeninputHwrBoxLayout::DeleteL(TInt aChar/* = EKeyBackspace*/)
|
|
789 |
{
|
|
790 |
//delete the last char
|
|
791 |
const TInt len = sizeof(aChar);
|
|
792 |
TBuf<len> aBufBck;
|
|
793 |
aBufBck.Append((TChar)aChar);
|
|
794 |
|
|
795 |
if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
796 |
{
|
|
797 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->PtiEngine()->HandleCommandL(EPtiCommandBackSpaceByForce);
|
|
798 |
}
|
|
799 |
else
|
|
800 |
{
|
|
801 |
SignalOwner(ESignalKeyEvent, aBufBck);
|
|
802 |
}
|
|
803 |
}
|
|
804 |
|
|
805 |
// ---------------------------------------------------------------------------
|
|
806 |
// CPeninputHwrBoxLayout::HandleRawKeyEventL
|
|
807 |
// (other items were commented in a header).
|
|
808 |
// ---------------------------------------------------------------------------
|
|
809 |
//
|
|
810 |
TBool CPeninputHwrBoxLayout::HandleRawKeyEventL(const TRawEvent& aKeyEvent)
|
|
811 |
{
|
|
812 |
TBool rs = EFalse;
|
|
813 |
if (iHiraganaKanji)
|
|
814 |
{
|
|
815 |
iHiraganaKanji->CancelRepeat();
|
|
816 |
}
|
|
817 |
if (iUiStatePenMgr)
|
|
818 |
{
|
|
819 |
CPeninputUiStateBase* current = iUiStatePenMgr->CurrentUiState();
|
|
820 |
if (iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenBeginWriting) == current)
|
|
821 |
{ // temporary
|
|
822 |
return ETrue;
|
|
823 |
}
|
|
824 |
if (iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenEndWriting) == current
|
|
825 |
|| iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenCandidateSelecting) == current)
|
|
826 |
{
|
|
827 |
TInt key = (aKeyEvent.ScanCode() & 0x000000FF);
|
|
828 |
switch(key)
|
|
829 |
{ // Handle clear key
|
|
830 |
case EKeyBackspace:
|
|
831 |
case EStdKeyBackspace: /* 0x01 */
|
|
832 |
case EStdKeyEscape: /* 0x04 */
|
|
833 |
{
|
|
834 |
// if TRawEvent::EKeyDown, return at once.
|
|
835 |
if (TRawEvent::EKeyDown == aKeyEvent.Type())
|
|
836 |
{
|
|
837 |
iKeyEventClearAsync->CallBack();
|
|
838 |
}
|
|
839 |
return ETrue;
|
|
840 |
}
|
|
841 |
default:
|
|
842 |
ToPenStandBy();
|
|
843 |
break;
|
|
844 |
}
|
|
845 |
}
|
|
846 |
}
|
|
847 |
if (UiStateMgr() && UiStateMgr()->CurrentUiState())
|
|
848 |
{
|
|
849 |
rs = UiStateMgr()->CurrentUiState()->HandleKeyEventL(aKeyEvent);
|
|
850 |
if (rs && iHiraganaKanji)
|
|
851 |
{
|
|
852 |
if (EStdKeyEnter == (aKeyEvent.ScanCode() & 0x000000FF) && IsPredictiveWithNoChar())
|
|
853 |
{ // without transitory chars and next word prediction candidates are offered
|
|
854 |
// Enter button should clear Prediction and enter a newline
|
|
855 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(EPeninputLayoutEventBack,KNullDesC));
|
|
856 |
return UiStateMgr()->GetUiState(EPeninputHwrUiStateStandby)->HandleKeyEventL(aKeyEvent);
|
|
857 |
}
|
|
858 |
rs = iHiraganaKanji->HandleKeyEvent(aKeyEvent);
|
|
859 |
}
|
|
860 |
}
|
|
861 |
if (!iWaitforEditorTextComing && TRawEvent::EKeyDown == aKeyEvent.Type() && TRawEvent::ENone == iKeyEvent.Type())
|
|
862 |
{
|
|
863 |
if (!rs)
|
|
864 |
{
|
|
865 |
SendEventToWindow(EPeninputLayoutEventCloseCharacterRange, NULL, KNullDesC);
|
|
866 |
HiraganaKanjiCompleteAll();
|
|
867 |
if (iWaitforEditorTextComing) // complete done.
|
|
868 |
{
|
|
869 |
rs = ETrue;
|
|
870 |
iKeyEvent = aKeyEvent;
|
|
871 |
iKeyEventAsync->CallBack(); // for key that hiraganakanji do not handle
|
|
872 |
}
|
|
873 |
}
|
|
874 |
else if (iHiraganaKanji)
|
|
875 |
{
|
|
876 |
iKeyEventAsync->CallBack(); // for pending event
|
|
877 |
}
|
|
878 |
}
|
|
879 |
return rs;
|
|
880 |
}
|
|
881 |
|
|
882 |
// ---------------------------------------------------------------------------
|
|
883 |
// CPeninputHwrBoxLayout::OnPointerEventOutsideLayout
|
|
884 |
// Call back when the pointer down/up event happends outside of the layout
|
|
885 |
// (other items were commented in a header).
|
|
886 |
// ---------------------------------------------------------------------------
|
|
887 |
//
|
|
888 |
TBool CPeninputHwrBoxLayout::OnPointerEventOutsideLayout(const TRawEvent& aEvent)
|
|
889 |
{
|
|
890 |
if (TRawEvent::EButton1Down == aEvent.Type()) // this if is not necessary. only EButton1Down.
|
|
891 |
{
|
|
892 |
HandleControlEventPen(EPeninputLayoutHwrEventPointerOutsideWnd, NULL, KNullDesC);
|
|
893 |
SendEventToWindow(EPeninputLayoutEventCloseCharacterRange, NULL, KNullDesC);
|
|
894 |
HiraganaKanjiCompleteAll();
|
|
895 |
if (iCapturePointerEvent)
|
|
896 |
{
|
|
897 |
iPointerEventDown = aEvent;
|
|
898 |
SetCapturePointerEvent(EFalse);
|
|
899 |
iPointerEventAsync->CallBack();
|
|
900 |
}
|
|
901 |
}
|
|
902 |
return EFalse;
|
|
903 |
}
|
|
904 |
|
|
905 |
// ---------------------------------------------------------------------------
|
|
906 |
// CPeninputHwrBoxLayout::DataMgr
|
|
907 |
// (other items were commented in a header)
|
|
908 |
// ---------------------------------------------------------------------------
|
|
909 |
//
|
|
910 |
CPeninputHwrBoxDataMgr* CPeninputHwrBoxLayout::DataMgr(TInt /*aDummy*/)
|
|
911 |
{
|
|
912 |
return static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr);
|
|
913 |
}
|
|
914 |
|
|
915 |
// ---------------------------------------------------------------------------
|
|
916 |
// CPeninputHwrBoxLayout::HwrBoxWindow
|
|
917 |
// (other items were commented in a header)
|
|
918 |
// ---------------------------------------------------------------------------
|
|
919 |
//
|
|
920 |
CPeninputHwrBoxWindow* CPeninputHwrBoxLayout::HwrBoxWindow()
|
|
921 |
{
|
|
922 |
return iHwrWindow;
|
|
923 |
}
|
|
924 |
|
|
925 |
void CPeninputHwrBoxLayout::ToPenStandBy(TBool aNotStandBy/* = EFalse*/)
|
|
926 |
{
|
|
927 |
if (iUiStatePenMgr)
|
|
928 |
{
|
|
929 |
CPeninputUiStateBase* current = iUiStatePenMgr->CurrentUiState();
|
|
930 |
if (iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenEndWriting) == current
|
|
931 |
|| iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenCandidateSelecting) == current)
|
|
932 |
{
|
|
933 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->ClearCandidates();
|
|
934 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
935 |
if (iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenEndWriting) == current && !aNotStandBy)
|
|
936 |
{
|
|
937 |
WriteHwrStrokeLogNew();
|
|
938 |
}
|
|
939 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
940 |
}
|
|
941 |
if (!aNotStandBy)
|
|
942 |
{
|
|
943 |
iUiStatePenMgr->SetCurrentUiState(EPeninputHwrUiStatePenStandBy);
|
|
944 |
|
|
945 |
if( iHwrWindow != NULL )
|
|
946 |
{
|
|
947 |
iHwrWindow->CancelWriting(); // Standby::OnEntry()
|
|
948 |
iHwrWindow->DimInputContextField(EFalse);
|
|
949 |
}
|
|
950 |
}
|
|
951 |
delete iSubmitText;
|
|
952 |
iSubmitText = NULL;
|
|
953 |
iExpanded = EFalse;
|
|
954 |
}
|
|
955 |
}
|
|
956 |
|
|
957 |
void CPeninputHwrBoxLayout::Initialize()
|
|
958 |
{
|
|
959 |
if (iUiStatePenMgr)
|
|
960 |
{
|
|
961 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
962 |
CPeninputUiStateBase* current = iUiStatePenMgr->CurrentUiState();
|
|
963 |
if (iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenEndWriting) == current
|
|
964 |
|| iUiStatePenMgr->GetUiState(EPeninputHwrUiStatePenBeginWriting) == current)
|
|
965 |
{
|
|
966 |
WriteHwrStrokeLogNew();
|
|
967 |
}
|
|
968 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
969 |
iUiStatePenMgr->SetCurrentUiState(EPeninputHwrUiStateNone);
|
|
970 |
}
|
|
971 |
if (iHwrWindow)
|
|
972 |
{
|
|
973 |
iHwrWindow->CancelWriting();
|
|
974 |
iHwrWindow->Hide(ETrue);
|
|
975 |
iExpanded = EFalse;
|
|
976 |
}
|
|
977 |
}
|
|
978 |
|
|
979 |
void CPeninputHwrBoxLayout::CompleteIfConvertingL()
|
|
980 |
{
|
|
981 |
if (iCapturePointerEvent // Transitory Input Exists
|
|
982 |
&& UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
983 |
{
|
|
984 |
iWaitforEditorTextComing = 0;
|
|
985 |
if (iHiraganaKanji)
|
|
986 |
{
|
|
987 |
iHiraganaKanji->HandleControlEventJpL(EEventCompleteIfConvertingHiraganaKanji, KNullDesC);
|
|
988 |
}
|
|
989 |
if (iWaitforEditorTextComing) // the status of hiraganakanji was converting ---> complete,but should not capture off
|
|
990 |
{
|
|
991 |
UiStateMgr()->SetCurrentUiState(EPeninputHwrUiStateStandbyjp);
|
|
992 |
iCapturePointerEvent = EFalse;
|
|
993 |
}
|
|
994 |
}
|
|
995 |
}
|
|
996 |
|
|
997 |
// ---------------------------------------------------------------------------
|
|
998 |
// CPeninputHwrBoxLayout::ClearInputToPenStandByL()
|
|
999 |
// clear last input char and goto PenStandBy
|
|
1000 |
// (other items were commented in a header)
|
|
1001 |
// ---------------------------------------------------------------------------
|
|
1002 |
//
|
|
1003 |
void CPeninputHwrBoxLayout::ClearInputToPenStandByL()
|
|
1004 |
{
|
|
1005 |
if (iSubmitText)
|
|
1006 |
{
|
|
1007 |
TInt len = iSubmitText->Length();
|
|
1008 |
if (len > 1 &&
|
|
1009 |
UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
1010 |
{
|
|
1011 |
len = 1;
|
|
1012 |
}
|
|
1013 |
for (TInt i = 0; i < len; i++)
|
|
1014 |
{
|
|
1015 |
DeleteL(EKeyDelete);
|
|
1016 |
}
|
|
1017 |
}
|
|
1018 |
ToPenStandBy();
|
|
1019 |
|
|
1020 |
if ( iHiraganaKanji != NULL && UiStateMgr() &&
|
|
1021 |
UiStateMgr()->CurrentUiState() ==
|
|
1022 |
UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
1023 |
{
|
|
1024 |
iHiraganaKanji->HandleControlEventJpL(EEventVirtualKeyUp,KNullDesC);
|
|
1025 |
}
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
1029 |
// ---------------------------------------------------------------------------
|
|
1030 |
// CPeninputHwrBoxLayout::WriteHwrStrokeLogNew
|
|
1031 |
// write log "New"
|
|
1032 |
// (other items were commented in a header)
|
|
1033 |
// ---------------------------------------------------------------------------
|
|
1034 |
//
|
|
1035 |
void CPeninputHwrBoxLayout::WriteHwrStrokeLogNew()
|
|
1036 |
{
|
|
1037 |
if (iLogger.LogValid())
|
|
1038 |
{
|
|
1039 |
iLogger.Write(KHwrStrokeLogNew());
|
|
1040 |
}
|
|
1041 |
}
|
|
1042 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
1043 |
|
|
1044 |
// ---------------------------------------------------------------------------
|
|
1045 |
// CPeninputHwrBoxLayout::CPeninputHwrBoxLayout
|
|
1046 |
// (other items were commented in a header).
|
|
1047 |
// ---------------------------------------------------------------------------
|
|
1048 |
//
|
|
1049 |
CPeninputHwrBoxLayout::CPeninputHwrBoxLayout(MLayoutOwner* aLayoutOwner)
|
|
1050 |
: CPeninputCommonLayout( aLayoutOwner ),
|
|
1051 |
iCapturePointerEvent(EFalse),
|
|
1052 |
iExpanded(EFalse)
|
|
1053 |
{
|
|
1054 |
}
|
|
1055 |
|
|
1056 |
// ---------------------------------------------------------------------------
|
|
1057 |
// CPeninputHwrBoxLayout::ConstructL
|
|
1058 |
// (other items were commented in a header).
|
|
1059 |
// ---------------------------------------------------------------------------
|
|
1060 |
//
|
|
1061 |
void CPeninputHwrBoxLayout::ConstructL(const TAny* aInitData)
|
|
1062 |
{
|
|
1063 |
CPeninputCommonLayout::ConstructL( aInitData );
|
|
1064 |
|
|
1065 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
1066 |
User::LeaveIfError( iLogger.Connect() );
|
|
1067 |
// Make directory
|
|
1068 |
RFs fs;
|
|
1069 |
if (fs.Connect() == KErrNone)
|
|
1070 |
{
|
|
1071 |
TInt ret = fs.MkDirAll(KHwrStrokeLogBaseDir());
|
|
1072 |
fs.Close();
|
|
1073 |
}
|
|
1074 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
1075 |
|
|
1076 |
iUiStatePenMgr = CPeninputUiStateMgr::NewL( this );
|
|
1077 |
|
|
1078 |
CPeninputUiStateBase* initialState =
|
|
1079 |
CPeninputUiStateBase::NewL( UiStateMgr(), this );
|
|
1080 |
UiStateMgr()->AddUiState( initialState, EPeninputHwrUiStateNone );
|
|
1081 |
|
|
1082 |
CPeninputHwrBoxUiStateStandby* standbyState =
|
|
1083 |
CPeninputHwrBoxUiStateStandby::NewL( UiStateMgr(), this );
|
|
1084 |
UiStateMgr()->AddUiState( standbyState, EPeninputHwrUiStateStandby );
|
|
1085 |
|
|
1086 |
CPeninputHwrBoxUiStateStandbyjp* standbyjpState =
|
|
1087 |
CPeninputHwrBoxUiStateStandbyjp::NewL( UiStateMgr(), this );
|
|
1088 |
UiStateMgr()->AddUiState( standbyjpState, EPeninputHwrUiStateStandbyjp );
|
|
1089 |
|
|
1090 |
CPeninputHwrBoxUiStateWithTransitoryChars* transitoryState =
|
|
1091 |
CPeninputHwrBoxUiStateWithTransitoryChars::NewL( UiStateMgr(), this );
|
|
1092 |
UiStateMgr()->AddUiState( transitoryState, EPeninputHwrUiStateWithTransitoryChars );
|
|
1093 |
|
|
1094 |
UiStateMgr()->SetCurrentUiState( initialState );
|
|
1095 |
|
|
1096 |
CPeninputUiStateBase* penInitialState =
|
|
1097 |
CPeninputHwrBoxUiState::NewL( iUiStatePenMgr, this );
|
|
1098 |
|
|
1099 |
iUiStatePenMgr->AddUiState( penInitialState, EPeninputHwrUiStateNone );
|
|
1100 |
CPeninputHwrBoxUiStatePenStandby* penStandbyState =
|
|
1101 |
CPeninputHwrBoxUiStatePenStandby::NewL( iUiStatePenMgr, this );
|
|
1102 |
iUiStatePenMgr->AddUiState( penStandbyState, EPeninputHwrUiStatePenStandBy );
|
|
1103 |
|
|
1104 |
CPeninputHwrBoxUiStatePenBeginWriting* penBeginState =
|
|
1105 |
CPeninputHwrBoxUiStatePenBeginWriting::NewL( iUiStatePenMgr, this );
|
|
1106 |
iUiStatePenMgr->AddUiState( penBeginState, EPeninputHwrUiStatePenBeginWriting );
|
|
1107 |
|
|
1108 |
CPeninputHwrBoxUiStatePenEndWriting* penEndState =
|
|
1109 |
CPeninputHwrBoxUiStatePenEndWriting::NewL( iUiStatePenMgr, this );
|
|
1110 |
iUiStatePenMgr->AddUiState( penEndState, EPeninputHwrUiStatePenEndWriting );
|
|
1111 |
|
|
1112 |
CPeninputHwrBoxUiStatePenCandidateSelecting* penCandidateSelectingState =
|
|
1113 |
CPeninputHwrBoxUiStatePenCandidateSelecting::NewL( iUiStatePenMgr, this );
|
|
1114 |
iUiStatePenMgr->AddUiState( penCandidateSelectingState, EPeninputHwrUiStatePenCandidateSelecting );
|
|
1115 |
|
|
1116 |
iUiStatePenMgr->SetCurrentUiState( penInitialState );
|
|
1117 |
|
|
1118 |
iHwrWindow = static_cast<CPeninputHwrBoxWindow*>(iLayoutWindow);
|
|
1119 |
Initialize();
|
|
1120 |
{
|
|
1121 |
TInt penSpeed = static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->WritingSpeed();
|
|
1122 |
TPtr ptr((TUint16*)&penSpeed,sizeof(TInt)/sizeof(TUint16));
|
|
1123 |
SendEventToWindow(EPeninputLayoutHwrEventWritingSpeedChange, NULL, ptr);
|
|
1124 |
}
|
|
1125 |
{
|
|
1126 |
TSize penSize = static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->PenSize();
|
|
1127 |
TPtr ptr((TUint16*)&penSize,sizeof(TSize)/sizeof(TUint16));
|
|
1128 |
SendEventToWindow(EPeninputLayoutHwrEventPenSizeChange, NULL, ptr);
|
|
1129 |
}
|
|
1130 |
{
|
|
1131 |
TRgb penColor = static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->PenColor();
|
|
1132 |
TPtr ptr((TUint16*)&penColor,sizeof(TRgb)/sizeof(TUint16));
|
|
1133 |
SendEventToWindow(EPeninputLayoutHwrEventPenColorChange, NULL, ptr);
|
|
1134 |
}
|
|
1135 |
//create hiraganakanji
|
|
1136 |
iHiraganaKanji = CPeninputHiraganaKanji::NewL(static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->PtiEngine()
|
|
1137 |
, this
|
|
1138 |
, iHwrWindow->InputContextField()
|
|
1139 |
, iHwrWindow->CandidateWindow()
|
|
1140 |
, iHwrWindow->PredictiveWindow());
|
|
1141 |
TCallBack cb(KeyEventCallback, this);
|
|
1142 |
TCallBack cbpointer(PointerEventCallback, this);
|
|
1143 |
iKeyEventAsync = new(ELeave) CAsyncCallBack(cb, CActive::EPriorityHigh);
|
|
1144 |
iPointerEventAsync = new(ELeave) CAsyncCallBack(cbpointer, CActive::EPriorityStandard);
|
|
1145 |
TCallBack cbClear(KeyEventClearCallback, this);
|
|
1146 |
iKeyEventClearAsync = new(ELeave) CAsyncCallBack(cbClear, CActive::EPriorityHigh);
|
|
1147 |
|
|
1148 |
iKeyEvent.Set(TRawEvent::ENone,0);
|
|
1149 |
iPointerEventDown.Set(TRawEvent::ENone,0);
|
|
1150 |
}
|
|
1151 |
|
|
1152 |
// ---------------------------------------------------------------------------
|
|
1153 |
// CPeninputHwrBoxLayout::DoSetCurrentRange
|
|
1154 |
// (other items were commented in a header).
|
|
1155 |
// ---------------------------------------------------------------------------
|
|
1156 |
//
|
|
1157 |
void CPeninputHwrBoxLayout::DoSetCurrentRange()
|
|
1158 |
{
|
|
1159 |
TInt currentRange = CPeninputDataConverter::AnyToInt( RequestData( EPeninputDataTypeCurrentRange ) );
|
|
1160 |
static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->SetEngineInputMode(currentRange); // PtiEngine:SetInputMode()
|
|
1161 |
|
|
1162 |
if ( currentRange == ERangeHiraganaKanji && static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->Conversion())
|
|
1163 |
{
|
|
1164 |
UiStateMgr()->SetCurrentUiState(EPeninputHwrUiStateStandbyjp);
|
|
1165 |
}
|
|
1166 |
else
|
|
1167 |
{
|
|
1168 |
UiStateMgr()->SetCurrentUiState(EPeninputHwrUiStateStandby);
|
|
1169 |
}
|
|
1170 |
SetCapturePointerEvent(EFalse);
|
|
1171 |
ToPenStandBy();
|
|
1172 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
1173 |
WriteHwrStrokeLogRange();
|
|
1174 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
1175 |
}
|
|
1176 |
|
|
1177 |
// ---------------------------------------------------------------------------
|
|
1178 |
// CPeninputHwrBoxLayout::CompleteAllHiraganaKanji
|
|
1179 |
// ---------------------------------------------------------------------------
|
|
1180 |
//
|
|
1181 |
void CPeninputHwrBoxLayout::HiraganaKanjiCompleteAll()
|
|
1182 |
{
|
|
1183 |
ToPenStandBy();
|
|
1184 |
if( UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
1185 |
{
|
|
1186 |
if (iHiraganaKanji)
|
|
1187 |
{ // CompleteALL
|
|
1188 |
TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(EEventCompleteAllHiraganaKanji, KNullDesC));
|
|
1189 |
}
|
|
1190 |
}
|
|
1191 |
}
|
|
1192 |
|
|
1193 |
// ---------------------------------------------------------------------------
|
|
1194 |
// CPeninputHwrBoxLayout::CreateLayoutWindowL
|
|
1195 |
// (other items were commented in a header)
|
|
1196 |
// ---------------------------------------------------------------------------
|
|
1197 |
//
|
|
1198 |
void CPeninputHwrBoxLayout::CreateLayoutWindowL()
|
|
1199 |
{
|
|
1200 |
iLayoutWindow = CPeninputHwrBoxWindow::NewL( this, this );
|
|
1201 |
}
|
|
1202 |
|
|
1203 |
// ---------------------------------------------------------------------------
|
|
1204 |
// CPeninputHwrBoxLayout::CreateDataMgrL
|
|
1205 |
// (other items were commented in a header)
|
|
1206 |
// ---------------------------------------------------------------------------
|
|
1207 |
//
|
|
1208 |
void CPeninputHwrBoxLayout::CreateDataMgrL( const TAny* /*aInitData*/ )
|
|
1209 |
{
|
|
1210 |
iDataMgr = CPeninputHwrBoxDataMgr::NewL( this );
|
|
1211 |
}
|
|
1212 |
|
|
1213 |
// ---------------------------------------------------------------------------
|
|
1214 |
// CPeninputHwrBoxLayout::LayoutType
|
|
1215 |
// (other items were commented in a header)
|
|
1216 |
// ---------------------------------------------------------------------------
|
|
1217 |
//
|
|
1218 |
TInt CPeninputHwrBoxLayout::LayoutType()
|
|
1219 |
{
|
|
1220 |
return EPluginInputModeHwr;
|
|
1221 |
}
|
|
1222 |
|
|
1223 |
// ---------------------------------------------------------------------------
|
|
1224 |
// CPeninputHwrBoxLayout::SemiTransparencyRequired
|
|
1225 |
// (other items were commented in a header)
|
|
1226 |
// ---------------------------------------------------------------------------
|
|
1227 |
//
|
|
1228 |
TBool CPeninputHwrBoxLayout::SemiTransparencyRequired()
|
|
1229 |
{
|
|
1230 |
return ETrue;
|
|
1231 |
}
|
|
1232 |
|
|
1233 |
// ---------------------------------------------------------------------------
|
|
1234 |
// CPeninputHwrBoxLayout::TranslateRangeHullHalf
|
|
1235 |
// (other items were commented in a header)
|
|
1236 |
// ---------------------------------------------------------------------------
|
|
1237 |
//
|
|
1238 |
TInt CPeninputHwrBoxLayout::TranslateRangeHullHalf(TInt aRange) const
|
|
1239 |
{
|
|
1240 |
TInt newRange = aRange;
|
|
1241 |
if (static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->FullHalf()) // Full
|
|
1242 |
{
|
|
1243 |
switch (aRange)
|
|
1244 |
{
|
|
1245 |
case ERangeEnglish:
|
|
1246 |
newRange = ERangeFullWidthEnglish;
|
|
1247 |
break;
|
|
1248 |
case ERangeNumber:
|
|
1249 |
newRange = ERangeFullWidthNumeric;
|
|
1250 |
break;
|
|
1251 |
case ERangeKatakana:
|
|
1252 |
newRange = ERangeFullWidthKatakana;
|
|
1253 |
break;
|
|
1254 |
default:
|
|
1255 |
break;
|
|
1256 |
}
|
|
1257 |
}
|
|
1258 |
else // half
|
|
1259 |
{
|
|
1260 |
switch (aRange)
|
|
1261 |
{
|
|
1262 |
case ERangeFullWidthEnglish:
|
|
1263 |
newRange = ERangeEnglish;
|
|
1264 |
break;
|
|
1265 |
case ERangeFullWidthNumeric:
|
|
1266 |
newRange = ERangeNumber;
|
|
1267 |
break;
|
|
1268 |
case ERangeFullWidthKatakana:
|
|
1269 |
newRange = ERangeKatakana;
|
|
1270 |
break;
|
|
1271 |
default:
|
|
1272 |
break;
|
|
1273 |
}
|
|
1274 |
}
|
|
1275 |
return newRange;
|
|
1276 |
}
|
|
1277 |
|
|
1278 |
TInt CPeninputHwrBoxLayout::KeyEventCallback(TAny* aThis)
|
|
1279 |
{
|
|
1280 |
if (aThis)
|
|
1281 |
{
|
|
1282 |
TRAPD(err,static_cast<CPeninputHwrBoxLayout*>(aThis)->DoKeyEventL());
|
|
1283 |
if (KErrNone != err)
|
|
1284 |
{
|
|
1285 |
static_cast<CPeninputHwrBoxLayout*>(aThis)->HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC);
|
|
1286 |
}
|
|
1287 |
return err;
|
|
1288 |
}
|
|
1289 |
return 0;
|
|
1290 |
}
|
|
1291 |
|
|
1292 |
TInt CPeninputHwrBoxLayout::PointerEventCallback(TAny* aThis)
|
|
1293 |
{
|
|
1294 |
if (aThis)
|
|
1295 |
{
|
|
1296 |
static_cast<CPeninputHwrBoxLayout*>(aThis)->DoPointerEvent();
|
|
1297 |
}
|
|
1298 |
return 0;
|
|
1299 |
}
|
|
1300 |
|
|
1301 |
void CPeninputHwrBoxLayout::DoKeyEventL()
|
|
1302 |
{
|
|
1303 |
TBool ret = iHiraganaKanji->HandlePendingEventL();
|
|
1304 |
if (!ret && TRawEvent::ENone != iKeyEvent.Type())
|
|
1305 |
{
|
|
1306 |
iKeyEvent.Set(TRawEvent::EKeyUp,iKeyEvent.ScanCode());
|
|
1307 |
CCoeEnv::Static()->WsSession().SimulateRawEvent(iKeyEvent);
|
|
1308 |
iKeyEvent.Set(TRawEvent::EKeyDown,iKeyEvent.ScanCode());
|
|
1309 |
CCoeEnv::Static()->WsSession().SimulateRawEvent(iKeyEvent);
|
|
1310 |
iKeyEvent.Set(TRawEvent::EKeyUp,iKeyEvent.ScanCode());
|
|
1311 |
CCoeEnv::Static()->WsSession().SimulateRawEvent(iKeyEvent);
|
|
1312 |
iKeyEvent.Set(TRawEvent::ENone,0);
|
|
1313 |
}
|
|
1314 |
}
|
|
1315 |
|
|
1316 |
void CPeninputHwrBoxLayout::DoPointerEvent()
|
|
1317 |
{
|
|
1318 |
if (TRawEvent::ENone != iPointerEventDown.Type())
|
|
1319 |
{
|
|
1320 |
User::After(KDelay);
|
|
1321 |
CCoeEnv::Static()->WsSession().SimulateRawEvent(iPointerEventDown);
|
|
1322 |
iPointerEventDown.Set(TRawEvent::EButton1Up,iPointerEventDown.Pos().iX,iPointerEventDown.Pos().iY);
|
|
1323 |
CCoeEnv::Static()->WsSession().SimulateRawEvent(iPointerEventDown);
|
|
1324 |
iPointerEventDown.Set(TRawEvent::ENone,0);
|
|
1325 |
}
|
|
1326 |
}
|
|
1327 |
|
|
1328 |
TInt CPeninputHwrBoxLayout::KeyEventClearCallback(TAny* aThis)
|
|
1329 |
{
|
|
1330 |
if (aThis)
|
|
1331 |
{
|
|
1332 |
TRAPD(err,static_cast<CPeninputHwrBoxLayout*>(aThis)->DoKeyClearEventL());
|
|
1333 |
if (KErrNone != err)
|
|
1334 |
{
|
|
1335 |
static_cast<CPeninputHwrBoxLayout*>(aThis)->HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC);
|
|
1336 |
}
|
|
1337 |
return err;
|
|
1338 |
}
|
|
1339 |
return 0;
|
|
1340 |
}
|
|
1341 |
|
|
1342 |
void CPeninputHwrBoxLayout::DoKeyClearEventL()
|
|
1343 |
{
|
|
1344 |
ClearInputToPenStandByL();
|
|
1345 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
1346 |
WriteHwrStrokeLogClear();
|
|
1347 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
1348 |
if (iHiraganaKanji)
|
|
1349 |
{
|
|
1350 |
iHiraganaKanji->RepeatClearKeyStart();
|
|
1351 |
}
|
|
1352 |
}
|
|
1353 |
|
|
1354 |
void CPeninputHwrBoxLayout::SetCapturePointerEvent(TBool aFlag)
|
|
1355 |
{
|
|
1356 |
if (iCapturePointerEvent && !aFlag || !iCapturePointerEvent && aFlag)
|
|
1357 |
{
|
|
1358 |
TBool dimmFlag = (aFlag)? EFalse : ETrue;
|
|
1359 |
TPtr ptr((TUint16*)&dimmFlag,sizeof(TBool)/sizeof(TUint16));
|
|
1360 |
SendEventToWindow(EPeninputLayoutEventSetConversion, NULL, ptr);
|
|
1361 |
//signal the owner that pointer needs not be captured
|
|
1362 |
TBool capture = aFlag;
|
|
1363 |
TPtrC captureData;
|
|
1364 |
captureData.Set((const TUint16*)&capture,sizeof(TBool)/sizeof(TUint16));
|
|
1365 |
SignalOwner(ESignalCapturePointer,captureData);
|
|
1366 |
iCapturePointerEvent = aFlag;
|
|
1367 |
}
|
|
1368 |
}
|
|
1369 |
|
|
1370 |
void CPeninputHwrBoxLayout::SetCapturePointerEventAgain()
|
|
1371 |
{
|
|
1372 |
if (iCapturePointerEvent)
|
|
1373 |
{
|
|
1374 |
//signal the owner that pointer needs not be captured
|
|
1375 |
TBool capture = ETrue;
|
|
1376 |
TPtrC captureData;
|
|
1377 |
captureData.Set((const TUint16*)&capture,sizeof(TBool)/sizeof(TUint16));
|
|
1378 |
SignalOwner(ESignalCapturePointer,captureData);
|
|
1379 |
}
|
|
1380 |
}
|
|
1381 |
|
|
1382 |
void CPeninputHwrBoxLayout::HiraganaHandleControlEventJp(TInt aEventType, const TDesC& aEventData)
|
|
1383 |
{
|
|
1384 |
if (iHiraganaKanji)
|
|
1385 |
{
|
|
1386 |
TRAPD(err, iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData));
|
|
1387 |
if (KErrNone != err)
|
|
1388 |
{ // close peninput
|
|
1389 |
HiraganaKanjiCompleteAll(); // call ToPenStandBy()
|
|
1390 |
SetCapturePointerEvent(EFalse);
|
|
1391 |
Initialize(); //jump to init state
|
|
1392 |
CPeninputCommonLayout::HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC);
|
|
1393 |
}
|
|
1394 |
}
|
|
1395 |
}
|
|
1396 |
|
|
1397 |
TBool CPeninputHwrBoxLayout::IsPredictiveWithNoChar() const
|
|
1398 |
{
|
|
1399 |
if (!iCapturePointerEvent // without transitory chars
|
|
1400 |
&& UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputHwrUiStateWithTransitoryChars))
|
|
1401 |
{
|
|
1402 |
return ETrue;
|
|
1403 |
}
|
|
1404 |
return EFalse;
|
|
1405 |
}
|
|
1406 |
|
|
1407 |
#ifdef __PENINPUT_HWR_STROKE_LOG_ON
|
|
1408 |
// ---------------------------------------------------------------------------
|
|
1409 |
// CPeninputHwrBoxLayout::WriteHwrStrokeLogClear
|
|
1410 |
// write log "Clear"
|
|
1411 |
// (other items were commented in a header)
|
|
1412 |
// ---------------------------------------------------------------------------
|
|
1413 |
//
|
|
1414 |
void CPeninputHwrBoxLayout::WriteHwrStrokeLogClear()
|
|
1415 |
{
|
|
1416 |
if (iLogger.LogValid())
|
|
1417 |
{
|
|
1418 |
iLogger.Write(KHwrStrokeLogClear());
|
|
1419 |
}
|
|
1420 |
}
|
|
1421 |
|
|
1422 |
// ---------------------------------------------------------------------------
|
|
1423 |
// CPeninputHwrBoxLayout::WriteHwrStrokeLogRange
|
|
1424 |
// write log characterrange
|
|
1425 |
// (other items were commented in a header)
|
|
1426 |
// ---------------------------------------------------------------------------
|
|
1427 |
//
|
|
1428 |
void CPeninputHwrBoxLayout::WriteHwrStrokeLogRange()
|
|
1429 |
{
|
|
1430 |
if (iLogger.LogValid() && !iLogOff)
|
|
1431 |
{
|
|
1432 |
TBuf<KHwrStrokeLogCharacterRangeLen> characterRange;
|
|
1433 |
switch(static_cast<CPeninputHwrBoxDataMgr*>(iDataMgr)->CharacterRangeId())
|
|
1434 |
{
|
|
1435 |
case EPeninutCharacterRangeIdKanaKanji:
|
|
1436 |
characterRange.Append(KHwrStrokeLogRangeKanaKanji());
|
|
1437 |
break;
|
|
1438 |
case EPeninutCharacterRangeIdLatin:
|
|
1439 |
characterRange.Append(KHwrStrokeLogRangeLatin());
|
|
1440 |
break;
|
|
1441 |
case EPeninutCharacterRangeIdNumber:
|
|
1442 |
characterRange.Append(KHwrStrokeLogRangeNumber());
|
|
1443 |
break;
|
|
1444 |
default:
|
|
1445 |
characterRange.Append(KHwrStrokeLogRangeAllTypes());
|
|
1446 |
break;
|
|
1447 |
}
|
|
1448 |
iLogger.WriteFormat(KHwrStrokeLogCharacterRange(), &characterRange);
|
|
1449 |
}
|
|
1450 |
}
|
|
1451 |
#endif // __PENINPUT_HWR_STROKE_LOG_ON
|
|
1452 |
// End Of File
|