|
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 vkb layout |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // system includes |
|
20 #include <AknFepGlobalEnums.h> // by w45wang for the temp |
|
21 #include <peninputjapanesepredictivewnd.h> |
|
22 #include <peninputhiraganakanji.h> // hiraganakanji |
|
23 #include <peninputuistatemgr.h> // use ui state mgr |
|
24 #include <peninputdataconverter.h> |
|
25 #include <aknfeppeninputenums.h> //command from fep or IME to plugin. for vkb/hwr |
|
26 #include <peninputcommonlayoutglobalenum.h> // EPeninputLayoutEventEnter |
|
27 #include <txtetext.h> // CEditableText::EParagraphDelimiter |
|
28 |
|
29 // user includes |
|
30 #include "peninputvkblayout.h" |
|
31 #include "peninputvkbuistatetype.h" // UI state |
|
32 #include "peninputvkb.hrh" // control ID and range defination |
|
33 #include "peninputvkbwindow.h" // use vkb window, which derived from base window |
|
34 #include "peninputvkbdatamgr.h" // use data mgr |
|
35 #include "peninputvkbuistatestandby.h" |
|
36 #include "peninputvkbuistatestandbyjp.h" |
|
37 #include "peninputvkbuistatewithtransitorychars.h" |
|
38 #include "peninputcontextfieldjp.h" |
|
39 |
|
40 // constant definition |
|
41 const TInt KPeninputVkbFullSpaceCode = 0x3000; |
|
42 const TInt KDelay = 100000; //1/10 second |
|
43 const TInt KPeninputBufLen = 16; |
|
44 const TUint KHalfDakuten = 0xff9e; |
|
45 const TUint KHalfHanDakuten = 0xff9f; |
|
46 const TUint KFullDakuten = 0x309b; |
|
47 const TUint KFullHanDakuten = 0x309c; |
|
48 const TUint KLittle = 0x5c0f; |
|
49 |
|
50 const TInt KModeSwitchBufLen = 8; // by w45wang for the temp |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CPeninputVkbLayout::NewL |
|
56 // (other items were commented in a header). |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CPeninputVkbLayout* CPeninputVkbLayout::NewL(MLayoutOwner* aLayoutOwner, |
|
60 const TAny* aInitData) |
|
61 { |
|
62 CPeninputVkbLayout* self = new (ELeave) CPeninputVkbLayout(aLayoutOwner); |
|
63 |
|
64 CleanupStack::PushL(self); |
|
65 self->ConstructL(aInitData); |
|
66 CleanupStack::Pop(self); |
|
67 |
|
68 return self; |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CPeninputVkbLayout::~CPeninputVkbLayout |
|
73 // (other items were commented in a header). |
|
74 // --------------------------------------------------------------------------- |
|
75 // |
|
76 CPeninputVkbLayout::~CPeninputVkbLayout() |
|
77 { |
|
78 delete iHiraganaKanji; |
|
79 delete iKeyEventAsync; |
|
80 delete iPointerEventAsync; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CPeninputHwrBoxLayout::HandleEventL |
|
85 // handle event from window server |
|
86 // --------------------------------------------------------------------------- |
|
87 // |
|
88 TBool CPeninputVkbLayout::HandleEventL(TEventType aType, const TAny* aData) |
|
89 { |
|
90 TRawEvent event=*((TRawEvent*)aData); |
|
91 if(ERawEvent == aType) |
|
92 { |
|
93 if (TRawEvent::EButton1Down == event.Type() && iHiraganaKanji) |
|
94 { |
|
95 iHiraganaKanji->CancelRepeat(); |
|
96 } |
|
97 } |
|
98 return CPeninputCommonLayout::HandleEventL(aType,aData); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CPeninputVkbLayout::HandleCommand |
|
103 // (other items were commented in a header). |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 TInt CPeninputVkbLayout::HandleCommand(TInt aCmd, TUint8* aData) |
|
107 { |
|
108 // Handle command from fep or IME to this layout |
|
109 TUint* data = (TUint*) aData; |
|
110 |
|
111 switch ( aCmd ) |
|
112 { |
|
113 case ECmdPenInputPermittedRange: // different from common layout |
|
114 // this command comes after ECmdPenInputJapaneseSetting |
|
115 if (iDataMgr) |
|
116 { |
|
117 static_cast<CPeninputVkbDataMgr*>(iDataMgr)->SetPermittedRange(*data); |
|
118 } |
|
119 break; |
|
120 case ECmdPenInputLanguage: |
|
121 { |
|
122 CPeninputCommonLayout::HandleCommand(aCmd, aData); |
|
123 } |
|
124 break; |
|
125 case ECmdPenInputWindowOpen: |
|
126 if (iVkbWindow) |
|
127 { |
|
128 iVkbWindow->Opened(); |
|
129 TInt curRange = CPeninputDataConverter::AnyToInt(RequestData(EPeninputDataTypeCurrentRange)); |
|
130 TBool currHide = iVkbWindow->PredictiveWindow()->Hiden(); |
|
131 TBool newHide = ETrue; |
|
132 if (static_cast<CPeninputVkbDataMgr*>(iDataMgr)->Predictive() |
|
133 && ERangeHiraganaKanji == curRange) |
|
134 { |
|
135 newHide = EFalse; |
|
136 } |
|
137 if (newHide && !currHide || !newHide && currHide) |
|
138 { |
|
139 iVkbWindow->PredictiveWindow()->Hide(newHide); |
|
140 } |
|
141 CPeninputCommonLayout::HandleCommand( aCmd, aData ); |
|
142 if (*data != EPenInputOpenManually && Position() == TPoint(0,0)) |
|
143 { // position is not yet set.(English --> Japanese) |
|
144 SendEventToWindow(EPeninputLayoutEventMovePosition, NULL, KNullDesC); |
|
145 } |
|
146 iWaitforEditorTextComing = 0; |
|
147 iVkbWindow->ICFEnableRegionUpdating(); // ICF::OnActivate() |
|
148 } |
|
149 break; |
|
150 case ECmdPenInputWindowClose: |
|
151 { |
|
152 HiraganaKanjiCompleteAll(); |
|
153 CPeninputCommonLayout::HandleCommand( aCmd, aData ); |
|
154 UiStateMgr()->SetCurrentUiState( EPeninputVkbUiStateNone ); |
|
155 SetCapturePointerEvent(EFalse); |
|
156 iVkbWindow->Closed(); |
|
157 iWaitforEditorTextComing = 0; |
|
158 } |
|
159 break; |
|
160 case ECmdPenInputRange: // different from common layout:control ptiEngine |
|
161 // this command comes after ECmdPenInputJapaneseSetting, ECmdPenInputPermittedRange |
|
162 { |
|
163 iRangeOrg = TranslateRangeHullHalf(*data); |
|
164 if (iLayoutWindow) |
|
165 { |
|
166 iVkbWindow->ICFDisableRegionUpdating(); // ICF::OnDeActivate() |
|
167 iVkbWindow->SetSizeToRangeButtons(); // To Call CAknFepCtrlButton::ResizeBitmaps() |
|
168 TBool currHide = iVkbWindow->PredictiveWindow()->Hiden(); |
|
169 TBool newHide = ETrue; |
|
170 if (static_cast<CPeninputVkbDataMgr*>(iDataMgr)->Predictive() |
|
171 && ERangeHiraganaKanji == iRangeOrg) |
|
172 { |
|
173 newHide = EFalse; |
|
174 } |
|
175 if (newHide && !currHide || !newHide && currHide) |
|
176 { |
|
177 LayoutOwner()->Hide( ETrue ); |
|
178 } |
|
179 } |
|
180 TUint range = iRangeOrg; |
|
181 TUint8* rangedata = reinterpret_cast<TUint8*>(&range); |
|
182 CPeninputCommonLayout::HandleCommand( aCmd, rangedata ); |
|
183 DoSetCurrentRange(); |
|
184 } |
|
185 break; |
|
186 case ECmdPenInputJapaneseSetting: // Japanese setting information |
|
187 // this command comes before ECmdPenInputPermittedRange, ECmdPenInputRange |
|
188 { |
|
189 TUint val = *data; |
|
190 TInt sctDimmFlag = (val & EPenInputJapaneseSettingLunchSCT)? 0: 1; |
|
191 TPtr ptr((TUint16*)&sctDimmFlag, sizeof(TInt)/sizeof(TUint16)); |
|
192 SendEventToWindow(EEventSetDimmedSctBtn, NULL, ptr); |
|
193 static_cast<CPeninputVkbDataMgr*>(iDataMgr)->SetFullHalf( |
|
194 (val & EPenInputJapaneseSettingCharacterWidth)? 1: 0); |
|
195 static_cast<CPeninputVkbDataMgr*>(iDataMgr)->SetPredictive( |
|
196 (val & EPenInputJapaneseSettingPredictive)? ETrue: EFalse); |
|
197 static_cast<CPeninputVkbDataMgr*>(iDataMgr)->SetClear( |
|
198 (val & EPenInputJapaneseSettingDeletingDirection)? 1: 0); |
|
199 static_cast<CPeninputVkbDataMgr*>(iDataMgr)->SetJapaneseFlags(val); |
|
200 } |
|
201 break; |
|
202 case ECmdPenInputEnableSettingBtn: |
|
203 iVkbWindow->SetEnableSettingBtnJp(*data); |
|
204 break; |
|
205 case ECmdPenInputSendEditorTextAndCurPos: |
|
206 CFepUiLayout::HandleCommand( aCmd, aData ); |
|
207 break; |
|
208 |
|
209 default: |
|
210 CPeninputCommonLayout::HandleCommand( aCmd, aData ); |
|
211 break; |
|
212 } |
|
213 return KErrNone; |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // CPeninputVkbLayout::HandleControlEvent |
|
218 // (other items were commented in a header). |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CPeninputVkbLayout::HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl, const TDesC& aEventData) |
|
222 { |
|
223 // Handle event from control |
|
224 TInt* data = (TInt*)aEventData.Ptr(); |
|
225 |
|
226 //deal with the event from all controls in layout |
|
227 switch (aEventType) |
|
228 { |
|
229 case EPeninputLayoutEventClose: |
|
230 case EPeninputLayoutEventOption: |
|
231 case EPeninputLayoutEventToHwr: |
|
232 { |
|
233 HiraganaKanjiCompleteAll(); |
|
234 SetCapturePointerEvent(EFalse); |
|
235 if (EPeninputLayoutEventToHwr == aEventType) |
|
236 { |
|
237 // by w45wang for the temp |
|
238 TBool switchByMode = ETrue; |
|
239 TInt mode = EPluginInputModeHwr; |
|
240 TBuf<KModeSwitchBufLen> buf; |
|
241 CPeninputDataConverter::CombinationToDesc( switchByMode, mode, buf ); |
|
242 SignalOwner( ESignalLayoutUIChanged, buf ); |
|
243 // end |
|
244 } |
|
245 else |
|
246 { |
|
247 CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData); |
|
248 } |
|
249 iWaitforEditorTextComing = 0; |
|
250 } |
|
251 break; |
|
252 case EPeninputLayoutEventSct: |
|
253 HiraganaKanjiCompleteAll(); |
|
254 SetCapturePointerEvent(EFalse); |
|
255 SignalOwner(ESignalHwNotifySctPopup); |
|
256 break; |
|
257 case EPeninputLayoutEventSwitchLanguage: // nop |
|
258 break; |
|
259 |
|
260 case EPeninputLayoutEventRange: // different from common layout:control ptiEngine |
|
261 { |
|
262 HiraganaKanjiCompleteAll(); |
|
263 TInt permittedRange = CPeninputDataConverter::AnyToInt(RequestData(EPeninputDataTypePermittedRange)); |
|
264 TInt range = TranslateRangeHullHalf(*data); |
|
265 if (!(range & permittedRange)) |
|
266 { |
|
267 range = iRangeOrg; |
|
268 } |
|
269 TPtrC rangeptr((TUint16*)(&range), sizeof(TInt)/sizeof(TUint16)); |
|
270 TBool currHide = iVkbWindow->PredictiveWindow()->Hiden(); |
|
271 TBool newHide = ETrue; |
|
272 if (static_cast<CPeninputVkbDataMgr*>(iDataMgr)->Predictive() |
|
273 && ERangeHiraganaKanji == *data) |
|
274 { |
|
275 newHide = EFalse; |
|
276 } |
|
277 if (newHide && !currHide || !newHide && currHide) |
|
278 { |
|
279 LayoutOwner()->Hide(ETrue); // display off |
|
280 iVkbWindow->PredictiveWindow()->Hide(newHide); |
|
281 } |
|
282 else |
|
283 { |
|
284 iVkbWindow->ICFDisableRegionUpdating(); // ICF::OnDeActivate() |
|
285 } |
|
286 CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, rangeptr); |
|
287 if (ERangeEnglish != range && ERangeNumber != range) |
|
288 { |
|
289 TInt native = ERangeNative; |
|
290 TBuf<KPeninputBufLen> buf; |
|
291 CPeninputDataConverter::CombinationToDesc( native, range, buf ); |
|
292 Sendkey( ESignalRange, buf ); |
|
293 } |
|
294 DoSetCurrentRange(); |
|
295 if (newHide && !currHide || !newHide && currHide) |
|
296 { |
|
297 LayoutOwner()->Hide(EFalse); // display on |
|
298 } |
|
299 else |
|
300 { |
|
301 iVkbWindow->ICFEnableRegionUpdating(); // ICF Cursor On |
|
302 } |
|
303 } |
|
304 break; |
|
305 |
|
306 // from HiraganaKanji |
|
307 case EEventHiraganaKanjiWithTransitoryChars2Standbyjp: |
|
308 if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputVkbUiStateWithTransitoryChars)) |
|
309 { |
|
310 UiStateMgr()->SetCurrentUiState(EPeninputVkbUiStateStandbyjp); |
|
311 SetCapturePointerEvent(EFalse); |
|
312 } |
|
313 break; |
|
314 // from HiraganaKanji |
|
315 case EEventHiraganaKanjiWithoutTransitoryChars: |
|
316 if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputVkbUiStateWithTransitoryChars)) |
|
317 { |
|
318 SetCapturePointerEvent(EFalse); |
|
319 } |
|
320 break; |
|
321 |
|
322 case EEventVirtualKeyUp: |
|
323 { |
|
324 // convert kutenn/touten code |
|
325 TUint newChar = *((TUint16*)data); // case : aEventData length == 1 |
|
326 TInt len = aEventData.Length(); |
|
327 if (1 != len) |
|
328 { |
|
329 TVirtualKeyEventData* dataPtr = (TVirtualKeyEventData* ) aEventData.Ptr(); |
|
330 newChar = dataPtr->iKeyEvent.iCode; |
|
331 } |
|
332 TPtrC eventData(reinterpret_cast<TUint16*>(&newChar), sizeof(TUint16)/sizeof(TUint16)); |
|
333 TBool ret = static_cast<CPeninputVkbDataMgr*>(iDataMgr)->ConvertCommaFullStop(newChar); |
|
334 |
|
335 // Kana : dakuten,handakuten,little |
|
336 if (!ret && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputVkbUiStateStandby) ) |
|
337 { |
|
338 TChar preChar = iVkbWindow->InputContextField()->CharacterOnCursor(); |
|
339 if (preChar == TChar(CEditableText::EParagraphDelimiter)) |
|
340 { |
|
341 preChar = TChar( KNoChar ); |
|
342 } |
|
343 if (preChar != TChar( KNoChar )) |
|
344 { |
|
345 if (iWaitforEditorTextComing > 0) |
|
346 { |
|
347 -- iWaitforEditorTextComing; |
|
348 break; |
|
349 } |
|
350 TBool status = EFalse; |
|
351 TInt currentRange = CPeninputDataConverter::AnyToInt( RequestData( EPeninputDataTypeCurrentRange ) ); |
|
352 if (ERangeKatakana == currentRange && (KHalfDakuten == newChar || KHalfHanDakuten == newChar || KLittle == newChar)) |
|
353 { |
|
354 TChar prePreChar = iVkbWindow->InputContextField()->CharacterAroundCursor(-1); |
|
355 if (prePreChar == TChar(CEditableText::EParagraphDelimiter)) |
|
356 { |
|
357 prePreChar = TChar( KNoChar ); |
|
358 } |
|
359 TRAP_IGNORE(static_cast<CPeninputVkbDataMgr*>(iDataMgr)->HandleFunctionalVkbEventWithPrePreCharL(eventData, TUint(preChar), TUint(prePreChar) |
|
360 , status, iWaitforEditorTextComing)) |
|
361 } |
|
362 else if (KFullDakuten == newChar || KFullHanDakuten == newChar || KLittle == newChar) |
|
363 { |
|
364 TRAP_IGNORE(static_cast<CPeninputVkbDataMgr*>(iDataMgr)->HandleFunctionalVkbEventL(eventData, TUint(preChar) |
|
365 , status, iWaitforEditorTextComing)) |
|
366 } |
|
367 if (iWaitforEditorTextComing) |
|
368 { |
|
369 iWaitforEditorTextComing = 5; |
|
370 } |
|
371 if (status) |
|
372 { |
|
373 break; |
|
374 } |
|
375 } |
|
376 else // if the editor stirng is empty, ignore little |
|
377 { |
|
378 TUint16* text = (TUint16*)eventData.Ptr(); // always aEventData length == 1 |
|
379 if (TUint16(0x5c0f) == *text) |
|
380 { |
|
381 iWaitforEditorTextComing = 0; |
|
382 break; |
|
383 } |
|
384 } |
|
385 } |
|
386 iWaitforEditorTextComing = 0; |
|
387 if ( UiStateMgr()->CurrentUiState() |
|
388 && !static_cast<CPeninputVkbUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,eventData) ) |
|
389 { |
|
390 SetCapturePointerEvent(ETrue); |
|
391 HiraganaHandleControlEventJp(aEventType, eventData); |
|
392 } |
|
393 } |
|
394 break; |
|
395 case EPeninputLayoutEventBack: |
|
396 { |
|
397 // update clear code : backspace/delete |
|
398 // 1:delete 0:backspace |
|
399 TInt clear = EKeyBackspace; |
|
400 TPtrC clearptr((TUint16*)(&clear), 1); |
|
401 if ( UiStateMgr()->CurrentUiState() |
|
402 && !static_cast<CPeninputVkbUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,clearptr) ) |
|
403 { |
|
404 HiraganaHandleControlEventJp(aEventType, clearptr); |
|
405 } |
|
406 } |
|
407 break; |
|
408 case EPeninputLayoutEventEnter: |
|
409 case EPeninputLayoutEventSelectItem: // select from prediction/convert candidates by pointer |
|
410 case EPeninputLayoutEventTab: |
|
411 if (EPeninputLayoutEventEnter == aEventType && IsPredictiveWithNoChar()) |
|
412 { // without transitory chars and next word prediction candidates are offered |
|
413 // Enter button should clear Prediction and enter a newline |
|
414 TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(EPeninputLayoutEventBack,KNullDesC)); |
|
415 } |
|
416 if ( UiStateMgr()->CurrentUiState() |
|
417 && !static_cast<CPeninputVkbUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,aEventData) ) |
|
418 { |
|
419 TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData)); |
|
420 } |
|
421 break; |
|
422 case EPeninputLayoutEventSpace: |
|
423 { |
|
424 // update space code : full/half |
|
425 TInt space = *data; |
|
426 TPtrC spaceptr((TUint16*)(&space), 1); |
|
427 if (static_cast<CPeninputVkbDataMgr*>(iDataMgr)->JapaneseFlags() & EPenInputJapaneseSettingQwertyWidthOfSpace) |
|
428 { |
|
429 TInt currentRange = CPeninputDataConverter::AnyToInt |
|
430 ( RequestData( EPeninputDataTypeCurrentRange ) ); |
|
431 TInt fullWidth = (ERangeHiraganaKanji |
|
432 | ERangeFullWidthKatakana |
|
433 | ERangeFullWidthEnglish |
|
434 | ERangeFullWidthNumeric |
|
435 | ERangeHiraganaOnly ); |
|
436 if ( currentRange & fullWidth) |
|
437 { |
|
438 space = KPeninputVkbFullSpaceCode; |
|
439 } |
|
440 } |
|
441 if ( UiStateMgr()->CurrentUiState() |
|
442 && !static_cast<CPeninputVkbUiState*>(UiStateMgr()->CurrentUiState())->HandleControlEvent(aEventType,spaceptr) ) |
|
443 { |
|
444 HiraganaHandleControlEventJp(aEventType, spaceptr); |
|
445 } |
|
446 } |
|
447 break; |
|
448 case EEventIcfPointerUp: // from ContextField |
|
449 case EEventIcfCompleteAll: // from ContextField |
|
450 { |
|
451 TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData)); |
|
452 SetCapturePointerEventAgain(); |
|
453 } |
|
454 break; |
|
455 case EEventSizeChanged: // PredictiveWnd On/Off resize and redraw |
|
456 if (iVkbWindow && static_cast<CFepUiBaseCtrl*>(iVkbWindow->PredictiveWindow()) == aCtrl) |
|
457 { |
|
458 iVkbWindow->SizeChanged(ETrue); |
|
459 } |
|
460 else |
|
461 { |
|
462 CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData); |
|
463 } |
|
464 break; |
|
465 case EEventShowCandidateWnd: // CandidateWnd On |
|
466 { |
|
467 iVkbWindow->SetDimmed(ETrue); |
|
468 } |
|
469 break; |
|
470 case EEventHideCandidateWnd: // CandidateWnd Off |
|
471 { |
|
472 iVkbWindow->SetDimmed(EFalse); |
|
473 } |
|
474 break; |
|
475 case EEventWaitforEditorTextComing: // may use, someday. |
|
476 { |
|
477 iWaitforEditorTextComing = 1; |
|
478 } |
|
479 break; |
|
480 case EEventDraggingEnd: |
|
481 { |
|
482 CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData); |
|
483 SetCapturePointerEventAgain(); |
|
484 } |
|
485 break; |
|
486 case EEventICFSelectionChanged: // from ContextField (when whithout transitory input) |
|
487 if (iHiraganaKanji) |
|
488 { // update saved data |
|
489 TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData)); |
|
490 } |
|
491 break; |
|
492 case EEventSetAppCursorSelection: // from ContextField |
|
493 if (UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputVkbUiStateWithTransitoryChars)) |
|
494 { |
|
495 TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData)); |
|
496 } |
|
497 break; |
|
498 default: |
|
499 CPeninputCommonLayout::HandleControlEvent(aEventType, aCtrl, aEventData); |
|
500 break; |
|
501 } |
|
502 } |
|
503 |
|
504 // --------------------------------------------------------------------------- |
|
505 // CPeninputVkbLayout::OnAppEditorTextComing |
|
506 // (other items were commented in a header). |
|
507 // --------------------------------------------------------------------------- |
|
508 // |
|
509 TInt CPeninputVkbLayout::OnAppEditorTextComing(const TFepInputContextFieldData& aData) |
|
510 { |
|
511 iWaitforEditorTextComing = 0; |
|
512 // Handle edit text coming |
|
513 if (iHiraganaKanji) |
|
514 { |
|
515 TRAPD(err, iHiraganaKanji->SetEditorTextL(aData)); |
|
516 if (KErrNone != err) |
|
517 { |
|
518 HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC); |
|
519 } |
|
520 return err; |
|
521 } |
|
522 return KErrNone; |
|
523 } |
|
524 |
|
525 // --------------------------------------------------------------------------- |
|
526 // CPeninputVkbLayout::HandleRawKeyEventL |
|
527 // (other items were commented in a header). |
|
528 // --------------------------------------------------------------------------- |
|
529 // |
|
530 TBool CPeninputVkbLayout::HandleRawKeyEventL(const TRawEvent& aKeyEvent) |
|
531 { |
|
532 TBool rs = EFalse; |
|
533 if (iHiraganaKanji) |
|
534 { |
|
535 iHiraganaKanji->CancelRepeat(); |
|
536 } |
|
537 if (UiStateMgr() && UiStateMgr()->CurrentUiState()) |
|
538 { |
|
539 rs = UiStateMgr()->CurrentUiState()->HandleKeyEventL(aKeyEvent); |
|
540 if (rs && iHiraganaKanji) |
|
541 { |
|
542 if (EStdKeyEnter == (aKeyEvent.ScanCode() & 0x000000FF) && 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 return UiStateMgr()->GetUiState(EPeninputVkbUiStateStandby)->HandleKeyEventL(aKeyEvent); |
|
547 } |
|
548 rs = iHiraganaKanji->HandleKeyEvent(aKeyEvent); |
|
549 } |
|
550 } |
|
551 if (!iWaitforEditorTextComing && TRawEvent::EKeyDown == aKeyEvent.Type() && TRawEvent::ENone == iKeyEvent.Type()) |
|
552 { |
|
553 if (!rs) // state == standby or state == standbyjp or key that hiraganakanji do not handle. |
|
554 { |
|
555 HiraganaKanjiCompleteAll(); |
|
556 if (iWaitforEditorTextComing) // complete done. |
|
557 { |
|
558 rs = ETrue; |
|
559 iKeyEvent = aKeyEvent; |
|
560 iKeyEventAsync->CallBack(); // for key that hiraganakanji do not handle |
|
561 } |
|
562 } |
|
563 else if (iHiraganaKanji) |
|
564 { |
|
565 iKeyEventAsync->CallBack(); // for pending event |
|
566 } |
|
567 } |
|
568 return rs; |
|
569 } |
|
570 |
|
571 // --------------------------------------------------------------------------- |
|
572 // CPeninputVkbLayout::OnPointerEventOutsideLayout |
|
573 // Call back when the pointer down/up event happends outside of the layout |
|
574 // (other items were commented in a header). |
|
575 // --------------------------------------------------------------------------- |
|
576 // |
|
577 TBool CPeninputVkbLayout::OnPointerEventOutsideLayout(const TRawEvent& aEvent) |
|
578 { |
|
579 if (TRawEvent::EButton1Down == aEvent.Type()) // this if is not necessary. only EButton1Down. |
|
580 { |
|
581 HiraganaKanjiCompleteAll(); |
|
582 if (iCapturePointerEvent) |
|
583 { |
|
584 iPointerEventDown = aEvent; |
|
585 SetCapturePointerEvent(EFalse); |
|
586 iPointerEventAsync->CallBack(); |
|
587 } |
|
588 } |
|
589 return EFalse; |
|
590 } |
|
591 |
|
592 // --------------------------------------------------------------------------- |
|
593 // CPeninputVkbLayout::DoSetCurrentRange |
|
594 // (other items were commented in a header). |
|
595 // --------------------------------------------------------------------------- |
|
596 // |
|
597 void CPeninputVkbLayout::DoSetCurrentRange() |
|
598 { |
|
599 TInt currentRange = CPeninputDataConverter::AnyToInt( RequestData( EPeninputDataTypeCurrentRange ) ); |
|
600 |
|
601 static_cast<CPeninputVkbDataMgr*>(iDataMgr)->SetEngineInputMode(currentRange); // PtiEngine:SetInputMode() |
|
602 |
|
603 if (iVkbWindow) |
|
604 { |
|
605 iVkbWindow->DoRangeChange(); // RangeBar |
|
606 } |
|
607 |
|
608 if ( currentRange == ERangeHiraganaKanji ) |
|
609 { |
|
610 UiStateMgr()->SetCurrentUiState(EPeninputVkbUiStateStandbyjp); |
|
611 } |
|
612 else |
|
613 { |
|
614 UiStateMgr()->SetCurrentUiState(EPeninputVkbUiStateStandby); |
|
615 } |
|
616 SetCapturePointerEvent(EFalse); |
|
617 } |
|
618 |
|
619 // --------------------------------------------------------------------------- |
|
620 // CPeninputVkbLayout::CPeninputVkbLayout |
|
621 // (other items were commented in a header). |
|
622 // --------------------------------------------------------------------------- |
|
623 // |
|
624 CPeninputVkbLayout::CPeninputVkbLayout(MLayoutOwner* aLayoutOwner) |
|
625 : CPeninputCommonLayout( aLayoutOwner ),iCapturePointerEvent(EFalse) |
|
626 { |
|
627 } |
|
628 |
|
629 // --------------------------------------------------------------------------- |
|
630 // CPeninputVkbLayout::ConstructL |
|
631 // (other items were commented in a header). |
|
632 // --------------------------------------------------------------------------- |
|
633 // |
|
634 void CPeninputVkbLayout::ConstructL(const TAny* aInitData) |
|
635 { |
|
636 CPeninputCommonLayout::ConstructL( aInitData ); |
|
637 CPeninputUiStateBase* initialState = |
|
638 CPeninputUiStateBase::NewL( UiStateMgr(), this ); |
|
639 UiStateMgr()->AddUiState( initialState, EPeninputVkbUiStateNone ); |
|
640 |
|
641 CPeninputVkbUiStateStandby* standbyState = |
|
642 CPeninputVkbUiStateStandby::NewL( UiStateMgr(), this ); |
|
643 UiStateMgr()->AddUiState( standbyState, EPeninputVkbUiStateStandby ); |
|
644 |
|
645 CPeninputVkbUiStateStandbyjp* standbyjpState = |
|
646 CPeninputVkbUiStateStandbyjp::NewL( UiStateMgr(), this ); |
|
647 UiStateMgr()->AddUiState( standbyjpState, EPeninputVkbUiStateStandbyjp ); |
|
648 |
|
649 CPeninputVkbUiStateWithTransitoryChars* transitoryState = |
|
650 CPeninputVkbUiStateWithTransitoryChars::NewL( UiStateMgr(), this ); |
|
651 UiStateMgr()->AddUiState( transitoryState, EPeninputVkbUiStateWithTransitoryChars ); |
|
652 |
|
653 UiStateMgr()->SetCurrentUiState( initialState ); |
|
654 iVkbWindow = static_cast<CPeninputVkbWindow*>(iLayoutWindow); |
|
655 //create hiraganakanji |
|
656 iHiraganaKanji = CPeninputHiraganaKanji::NewL(static_cast<CPeninputVkbDataMgr*>(iDataMgr)->PtiEngine() |
|
657 , this |
|
658 , iVkbWindow->InputContextField() |
|
659 , iVkbWindow->CandidateWindow() |
|
660 , iVkbWindow->PredictiveWindow()); |
|
661 TCallBack cb(KeyEventCallback, this); |
|
662 TCallBack cbpointer(PointerEventCallback, this); |
|
663 iKeyEventAsync = new(ELeave) CAsyncCallBack(cb, CActive::EPriorityStandard); |
|
664 iPointerEventAsync = new(ELeave) CAsyncCallBack(cbpointer, CActive::EPriorityStandard); |
|
665 iKeyEvent.Set(TRawEvent::ENone,0); |
|
666 iPointerEventDown.Set(TRawEvent::ENone,0); |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // CPeninputVkbLayout::CompleteAllHiraganaKanji |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 void CPeninputVkbLayout::HiraganaKanjiCompleteAll() |
|
674 { |
|
675 if( UiStateMgr() && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputVkbUiStateWithTransitoryChars)) |
|
676 { |
|
677 if (iHiraganaKanji) |
|
678 { // CompleteALL |
|
679 TRAP_IGNORE(iHiraganaKanji->HandleControlEventJpL(EEventCompleteAllHiraganaKanji, KNullDesC)); |
|
680 } |
|
681 } |
|
682 } |
|
683 |
|
684 // --------------------------------------------------------------------------- |
|
685 // CPeninputGenericVkbLayout::CreateLayoutWindowL |
|
686 // (other items were commented in a header) |
|
687 // --------------------------------------------------------------------------- |
|
688 // |
|
689 void CPeninputVkbLayout::CreateLayoutWindowL() |
|
690 { |
|
691 iLayoutWindow = CPeninputVkbWindow::NewL( this, this ); |
|
692 } |
|
693 |
|
694 // --------------------------------------------------------------------------- |
|
695 // CPeninputGenericVkbLayout::CreateDataMgrL |
|
696 // (other items were commented in a header) |
|
697 // --------------------------------------------------------------------------- |
|
698 // |
|
699 void CPeninputVkbLayout::CreateDataMgrL( const TAny* /*aInitData*/ ) |
|
700 { |
|
701 iDataMgr = CPeninputVkbDataMgr::NewL( this ); |
|
702 } |
|
703 |
|
704 // --------------------------------------------------------------------------- |
|
705 // CPeninputVkbLayout::LayoutType |
|
706 // (other items were commented in a header) |
|
707 // --------------------------------------------------------------------------- |
|
708 // |
|
709 TInt CPeninputVkbLayout::LayoutType() |
|
710 { |
|
711 return EPluginInputModeVkb; |
|
712 } |
|
713 |
|
714 |
|
715 // --------------------------------------------------------------------------- |
|
716 // CPeninputVkbLayout::TranslateRangeHullHalf |
|
717 // (other items were commented in a header) |
|
718 // --------------------------------------------------------------------------- |
|
719 // |
|
720 TInt CPeninputVkbLayout::TranslateRangeHullHalf(TInt aRange) const |
|
721 { |
|
722 TInt newRange = aRange; |
|
723 if (static_cast<CPeninputVkbDataMgr*>(iDataMgr)->FullHalf()) // Full |
|
724 { |
|
725 switch (aRange) |
|
726 { |
|
727 case ERangeEnglish: |
|
728 newRange = ERangeFullWidthEnglish; |
|
729 break; |
|
730 case ERangeNumber: |
|
731 newRange = ERangeFullWidthNumeric; |
|
732 break; |
|
733 case ERangeKatakana: |
|
734 newRange = ERangeFullWidthKatakana; |
|
735 break; |
|
736 default: |
|
737 break; |
|
738 } |
|
739 } |
|
740 else // half |
|
741 { |
|
742 switch (aRange) |
|
743 { |
|
744 case ERangeFullWidthEnglish: |
|
745 newRange = ERangeEnglish; |
|
746 break; |
|
747 case ERangeFullWidthNumeric: |
|
748 newRange = ERangeNumber; |
|
749 break; |
|
750 case ERangeFullWidthKatakana: |
|
751 newRange = ERangeKatakana; |
|
752 break; |
|
753 default: |
|
754 break; |
|
755 } |
|
756 } |
|
757 return newRange; |
|
758 } |
|
759 |
|
760 TInt CPeninputVkbLayout::KeyEventCallback(TAny* aThis) |
|
761 { |
|
762 if (aThis) |
|
763 { |
|
764 TRAPD(err,static_cast<CPeninputVkbLayout*>(aThis)->DoKeyEventL()); |
|
765 if (KErrNone != err) |
|
766 { |
|
767 static_cast<CPeninputVkbLayout*>(aThis)->HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC); |
|
768 } |
|
769 return err; |
|
770 } |
|
771 return 0; |
|
772 } |
|
773 |
|
774 TInt CPeninputVkbLayout::PointerEventCallback(TAny* aThis) |
|
775 { |
|
776 if (aThis) |
|
777 { |
|
778 static_cast<CPeninputVkbLayout*>(aThis)->DoPointerEvent(); |
|
779 } |
|
780 return 0; |
|
781 } |
|
782 |
|
783 void CPeninputVkbLayout::DoKeyEventL() |
|
784 { |
|
785 TBool ret = iHiraganaKanji->HandlePendingEventL(); |
|
786 if (!ret && TRawEvent::ENone != iKeyEvent.Type()) |
|
787 { |
|
788 iKeyEvent.Set(TRawEvent::EKeyUp,iKeyEvent.ScanCode()); |
|
789 CCoeEnv::Static()->WsSession().SimulateRawEvent(iKeyEvent); |
|
790 iKeyEvent.Set(TRawEvent::EKeyDown,iKeyEvent.ScanCode()); |
|
791 CCoeEnv::Static()->WsSession().SimulateRawEvent(iKeyEvent); |
|
792 iKeyEvent.Set(TRawEvent::EKeyUp,iKeyEvent.ScanCode()); |
|
793 CCoeEnv::Static()->WsSession().SimulateRawEvent(iKeyEvent); |
|
794 iKeyEvent.Set(TRawEvent::ENone,0); |
|
795 } |
|
796 } |
|
797 |
|
798 void CPeninputVkbLayout::DoPointerEvent() |
|
799 { |
|
800 if (TRawEvent::ENone != iPointerEventDown.Type()) |
|
801 { |
|
802 User::After(KDelay); |
|
803 CCoeEnv::Static()->WsSession().SimulateRawEvent(iPointerEventDown); |
|
804 iPointerEventDown.Set(TRawEvent::EButton1Up,iPointerEventDown.Pos().iX,iPointerEventDown.Pos().iY); |
|
805 CCoeEnv::Static()->WsSession().SimulateRawEvent(iPointerEventDown); |
|
806 iPointerEventDown.Set(TRawEvent::ENone,0); |
|
807 } |
|
808 } |
|
809 |
|
810 void CPeninputVkbLayout::SetCapturePointerEvent(TBool aFlag) |
|
811 { |
|
812 if (iCapturePointerEvent && !aFlag || !iCapturePointerEvent && aFlag) |
|
813 { |
|
814 //signal the owner that pointer needs not be captured |
|
815 TBool capture = aFlag; |
|
816 TPtrC captureData; |
|
817 captureData.Set((const TUint16*)&capture,sizeof(TBool)/sizeof(TUint16)); |
|
818 SignalOwner(ESignalCapturePointer,captureData); |
|
819 iCapturePointerEvent = aFlag; |
|
820 } |
|
821 } |
|
822 |
|
823 void CPeninputVkbLayout::SetCapturePointerEventAgain() |
|
824 { |
|
825 if (iCapturePointerEvent) |
|
826 { |
|
827 //signal the owner that pointer needs not be captured |
|
828 TBool capture = ETrue; |
|
829 TPtrC captureData; |
|
830 captureData.Set((const TUint16*)&capture,sizeof(TBool)/sizeof(TUint16)); |
|
831 SignalOwner(ESignalCapturePointer,captureData); |
|
832 } |
|
833 } |
|
834 |
|
835 void CPeninputVkbLayout::HiraganaHandleControlEventJp(TInt aEventType, const TDesC& aEventData) |
|
836 { |
|
837 if (iHiraganaKanji) |
|
838 { // close peninput |
|
839 TRAPD(err, iHiraganaKanji->HandleControlEventJpL(aEventType,aEventData)); |
|
840 if (KErrNone != err) |
|
841 { |
|
842 HiraganaKanjiCompleteAll(); |
|
843 SetCapturePointerEvent(EFalse); |
|
844 CPeninputCommonLayout::HandleControlEvent(EPeninputLayoutEventClose, NULL, KNullDesC); |
|
845 } |
|
846 } |
|
847 } |
|
848 |
|
849 TBool CPeninputVkbLayout::IsPredictiveWithNoChar() const |
|
850 { |
|
851 if (!iCapturePointerEvent // without transitory chars |
|
852 && UiStateMgr()->CurrentUiState() == UiStateMgr()->GetUiState(EPeninputVkbUiStateWithTransitoryChars)) |
|
853 { |
|
854 return ETrue; |
|
855 } |
|
856 return EFalse; |
|
857 } |
|
858 // End Of File |