|
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 CandidateSelecting 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 "peninputhwrboxarabicstatecandidateselecting.h" |
|
31 #include "peninputlayouthwrwnd.h" |
|
32 |
|
33 // constant definition |
|
34 const TInt KMaxCandidateLen = 128; |
|
35 |
|
36 // ======== MEMBER FUNCTIONS ======== |
|
37 |
|
38 // Implementation of Class CPeninputHwrBxAbStateCandidateSelecting |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CPeninputHwrBxAbStateCandidateSelecting::NewL |
|
42 // (other items were commented in a header). |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CPeninputHwrBxAbStateCandidateSelecting* CPeninputHwrBxAbStateCandidateSelecting::NewL(MPeninputUiStateMgr* aUiStateMgr, |
|
46 MPeninputLayoutContext* aContext) |
|
47 { |
|
48 CPeninputHwrBxAbStateCandidateSelecting* self = new ( ELeave ) CPeninputHwrBxAbStateCandidateSelecting(aUiStateMgr,aContext); |
|
49 CleanupStack::PushL(self); |
|
50 self->Construct(); |
|
51 CleanupStack::Pop(self); |
|
52 return self; |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CPeninputHwrBxAbStateCandidateSelecting::~CPeninputHwrBxAbStateCandidateSelecting |
|
57 // (other items were commented in a header). |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CPeninputHwrBxAbStateCandidateSelecting::~CPeninputHwrBxAbStateCandidateSelecting() |
|
61 { |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CPeninputHwrBoxUiStatePenBeginWriting::HandleControlEventPenL |
|
66 // (other items were commented in a header). |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 void CPeninputHwrBxAbStateCandidateSelecting::HandleControlEventPenL( TInt aEventType, |
|
70 const TDesC& aEventData, CPeninputHwrBxAbLayout& aUiLayout, TDes& /*aCharCode*/, TBool& aHandled ) |
|
71 { |
|
72 aHandled = EFalse; |
|
73 switch (aEventType) |
|
74 { |
|
75 case EEventHwrStrokeStarted: |
|
76 { |
|
77 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateBeginWriting); |
|
78 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->OnStrokeStarted(); |
|
79 aHandled = ETrue; |
|
80 } |
|
81 break; |
|
82 |
|
83 case EPeninputLayoutHwrEventCandidateSelected: |
|
84 { |
|
85 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
86 |
|
87 //cancel writing timer |
|
88 CTransparentHwrWndExt * transparentHwrWndExt = |
|
89 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->getCTransparentHwrWndExt(); |
|
90 //transparentHwrWndExt->SetWndTransparencyFactor(iInactiveTrans); |
|
91 transparentHwrWndExt->CancelCharWriting(); |
|
92 //submit text. |
|
93 if (aEventData.Length() > 1) |
|
94 { |
|
95 //get the candidate index |
|
96 const TInt cellNo = aEventData[aEventData.Length()-1]; |
|
97 |
|
98 //not the first candidate, replace previouse char |
|
99 if (cellNo > 0) |
|
100 { |
|
101 //get the first candidate |
|
102 TBuf<KMaxCandidateLen> oldCharCode; |
|
103 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->GetCandidate(0, oldCharCode); |
|
104 |
|
105 //get the new candidate |
|
106 TBuf<KMaxCandidateLen> newCharCode; |
|
107 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->GetCandidate(cellNo, newCharCode); |
|
108 |
|
109 aUiLayout.TranslateCharCode(newCharCode); |
|
110 |
|
111 //delete the first candidate submitted and submit new |
|
112 aUiLayout.ReplaceL(oldCharCode, newCharCode); |
|
113 } |
|
114 } |
|
115 |
|
116 TInt dataType = CPeninputDataConverter::AnyToInt(aUiLayout.RequestData( EPeninputDataTypeCurrentRange )); |
|
117 if (dataType == ERangeNative) |
|
118 { |
|
119 static_cast<CPeninputHwrBxAbWnd *>(aUiLayout.LayoutWindow())->ResetAndShowDropdownList(); |
|
120 } |
|
121 aHandled = ETrue; |
|
122 } |
|
123 break; |
|
124 case EEventHwrStrokeCanceled: |
|
125 { |
|
126 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
127 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->OnStrokeCanceled(); |
|
128 aHandled = ETrue; |
|
129 } |
|
130 break; |
|
131 case EPeninputLayoutEventRange: |
|
132 { |
|
133 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
134 // aHandled = ETrue; |
|
135 } |
|
136 break; |
|
137 case EEventIcfPointerUpEvent: |
|
138 { |
|
139 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
140 TInt dataType = CPeninputDataConverter::AnyToInt(aUiLayout.RequestData( EPeninputDataTypeCurrentRange )); |
|
141 if (dataType == ERangeNative) |
|
142 { |
|
143 static_cast<CPeninputHwrBxAbWnd *>(aUiLayout.LayoutWindow())->ResetAndShowDropdownList(); |
|
144 aHandled = ETrue; |
|
145 } |
|
146 } |
|
147 break; |
|
148 case EPeninputLayoutEventBack: |
|
149 { |
|
150 aUiLayout.UiStateMgr()->SetCurrentUiState(EPeninputHwrBxAbStateStandby); |
|
151 TInt dataType = CPeninputDataConverter::AnyToInt(aUiLayout.RequestData( EPeninputDataTypeCurrentRange )); |
|
152 if (dataType == ERangeNative) |
|
153 { |
|
154 static_cast<CPeninputHwrBxAbWnd *>(aUiLayout.LayoutWindow())->ResetAndShowDropdownList(); |
|
155 } |
|
156 static_cast<CPeninputHwrBxAbWnd*>(aUiLayout.LayoutWindow())->HandleBackspaceKeyEvent(); |
|
157 aHandled = ETrue; |
|
158 } |
|
159 break; |
|
160 default: |
|
161 break; |
|
162 } |
|
163 } |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CPeninputHwrBxAbStateCandidateSelecting::CPeninputHwrBxAbStateCandidateSelecting |
|
167 // (other items were commented in a header). |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 CPeninputHwrBxAbStateCandidateSelecting::CPeninputHwrBxAbStateCandidateSelecting(MPeninputUiStateMgr* aUiStateMgr, |
|
171 MPeninputLayoutContext* aContext) |
|
172 :CPeninputHwrBxAbStateBase(aUiStateMgr,aContext) |
|
173 { |
|
174 } |
|
175 |
|
176 // End Of File |