|
1 /* |
|
2 * Copyright (c) 2002-2007 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 ui state machine (Pen Wndwriting State) |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // System includes |
|
20 #include <peninputuistatemgr.h> |
|
21 #include <peninputcommonlayoutglobalenum.h> |
|
22 #include <peninputdataconverter.h> |
|
23 #include <aknfeppeninputenums.h> // ERangeNumber |
|
24 // user includes |
|
25 //#include "peninputhwrevent.h" |
|
26 #include "peninputhwrarabic.hrh" |
|
27 #include "peninputhwrarabiclayout.h" |
|
28 #include "peninputhwrarabicdatamgr.h" // use data mgr |
|
29 #include "peninputhwrarabicwindow.h" // use hwr window, which derived from base window |
|
30 #include "peninputhwrarabicstateendwriting.h" |
|
31 |
|
32 // constant definition |
|
33 //const TUint16 KBackRep = 0x2408; |
|
34 // convert displayable backspace |
|
35 const TUint16 KBackRep = 0x2190; |
|
36 const TUint16 KEnterRep = 0xF801; |
|
37 const TInt KMaxCandidateLen = 128; |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // Implementation of Class CPeninputHwrBxAbStateEndWriting |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CPeninputHwrBxAbStateEndWriting::NewL |
|
45 // (other items were commented in a header). |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 CPeninputHwrBxAbStateEndWriting* CPeninputHwrBxAbStateEndWriting::NewL(MPeninputUiStateMgr* aUiStateMgr, |
|
49 MPeninputLayoutContext* aContext) |
|
50 { |
|
51 CPeninputHwrBxAbStateEndWriting* self = new ( ELeave ) CPeninputHwrBxAbStateEndWriting(aUiStateMgr,aContext); |
|
52 CleanupStack::PushL(self); |
|
53 self->Construct(); |
|
54 CleanupStack::Pop(self); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CPeninputHwrBxAbStateEndWriting::~CPeninputHwrBxAbStateEndWriting |
|
60 // (other items were commented in a header). |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CPeninputHwrBxAbStateEndWriting::~CPeninputHwrBxAbStateEndWriting() |
|
64 { |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CPeninputHwrBxAbStateEndWriting::HandleControlEventPenL |
|
69 // (other items were commented in a header). |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 void CPeninputHwrBxAbStateEndWriting::HandleControlEventPenL( TInt aEventType, |
|
73 const TDesC& aEventData, CPeninputHwrBxAbLayout& aUiLayout, TDes& aCharCode, TBool& aHandled ) |
|
74 { |
|
75 aHandled = EFalse; |
|
76 switch (aEventType) |
|
77 { |
|
78 case EEventHwrStrokeStarted: |
|
79 { |
|
80 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateBeginWriting); |
|
81 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->OnStrokeStarted(); |
|
82 aHandled = ETrue; |
|
83 } |
|
84 break; |
|
85 case EEventHwrStrokeFinished: |
|
86 { |
|
87 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->GetCandidate(0, aCharCode); |
|
88 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->OnStrokeFinished(); |
|
89 |
|
90 //aUiLayout.SubmitL(aCharCode); |
|
91 |
|
92 TPtrC16 ptrBack; |
|
93 TPtrC16 ptrEnter; |
|
94 ptrBack.Set(&KBackRep, sizeof(KBackRep)/2); |
|
95 ptrEnter.Set(&KEnterRep, sizeof(KEnterRep)/2); |
|
96 |
|
97 //if char code is backspace or enter |
|
98 if (aCharCode.CompareC(ptrBack) == 0 |
|
99 || aCharCode.CompareC(ptrEnter) == 0) |
|
100 { |
|
101 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
102 } |
|
103 else |
|
104 { |
|
105 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateCandidateSelecting); |
|
106 } |
|
107 aHandled = ETrue; |
|
108 } |
|
109 break; |
|
110 case EEventHwrCharacterTimerOut: |
|
111 { |
|
112 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateCandidateSelecting); |
|
113 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->OnStrokeCharacterTimerOut(); |
|
114 aHandled = ETrue; |
|
115 } |
|
116 break; |
|
117 case EPeninputLayoutHwrEventCandidateSelected: |
|
118 { |
|
119 //cancel writing timer |
|
120 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->CancelWriting(); |
|
121 //There must be a charcode and length at least |
|
122 if (aEventData.Length() > 1) |
|
123 { |
|
124 //get the candidate index |
|
125 const TInt cellNo = aEventData[aEventData.Length()-1]; |
|
126 |
|
127 //get and submit the candidate to fep |
|
128 TBuf<KMaxCandidateLen> charCode; |
|
129 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->GetCandidate(cellNo, charCode); |
|
130 aUiLayout.SubmitL(charCode); |
|
131 |
|
132 TInt dataType = CPeninputDataConverter::AnyToInt(aUiLayout.RequestData( EPeninputDataTypeCurrentRange )); |
|
133 if (dataType == ERangeNative) |
|
134 { |
|
135 static_cast<CPeninputHwrBxAbWnd *>(aUiLayout.LayoutWindow())->ResetAndShowDropdownList(); |
|
136 } |
|
137 aHandled = ETrue; |
|
138 } |
|
139 } |
|
140 break; |
|
141 case EEventHwrStrokeCanceled: |
|
142 { |
|
143 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
144 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->OnStrokeCanceled(); |
|
145 aHandled = ETrue; |
|
146 } |
|
147 break; |
|
148 case EPeninputLayoutEventBack: |
|
149 { |
|
150 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
151 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->HandleBackspaceKeyEvent(); |
|
152 aHandled = ETrue; |
|
153 } |
|
154 break; |
|
155 default: |
|
156 aHandled = EFalse; |
|
157 break; |
|
158 } |
|
159 |
|
160 } |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CPeninputHwrBxAbStateEndWriting::CPeninputHwrBxAbStateEndWriting |
|
164 // (other items were commented in a header). |
|
165 // ----------------------------------------------------------------------------- |
|
166 // |
|
167 CPeninputHwrBxAbStateEndWriting::CPeninputHwrBxAbStateEndWriting(MPeninputUiStateMgr* aUiStateMgr, |
|
168 MPeninputLayoutContext* aContext) |
|
169 :CPeninputHwrBxAbStateBase(aUiStateMgr,aContext) |
|
170 { |
|
171 } |
|
172 |
|
173 void CPeninputHwrBxAbStateEndWriting::ToCandidateSelecting(CPeninputHwrBxAbLayout& /*aUiLayout*/) |
|
174 { |
|
175 } |
|
176 |
|
177 // End Of File |