|
1 /* |
|
2 * Copyright (c) 2002-2005 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: drop-down list control |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknFepGlobalEnums.h> |
|
20 #include <peninputgeneralitutnew.rsg> |
|
21 #include <peninputscrollablelist.h> |
|
22 #include <peninputlayout.h> |
|
23 #include <e32keys.h> |
|
24 #include <s32mem.h> |
|
25 #include <peninputlayoutmultilineicf.h> |
|
26 #include <StringLoader.h> |
|
27 |
|
28 #include "peninputitutwesternuistatematchselection.h" |
|
29 #include "peninputgenericitutuimgrbase.h" |
|
30 #include "peninputgenericitutdatamgr.h" |
|
31 #include "peninputgenericitutlayoutcontext.h" |
|
32 #include "peninputgenericitutconverter.h" |
|
33 |
|
34 CWesternItutUiStateMatchSelection* CWesternItutUiStateMatchSelection::NewL( |
|
35 CGenericItutUiMgrBase* aOwner) |
|
36 { |
|
37 CWesternItutUiStateMatchSelection* self = |
|
38 new (ELeave) CWesternItutUiStateMatchSelection(aOwner); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(self); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CWesternItutUiStateMatchSelection::~CWesternItutUiStateMatchSelection() |
|
46 { |
|
47 iCandlist.ResetAndDestroy(); |
|
48 iCandlist.Close(); |
|
49 delete iSpellText; |
|
50 } |
|
51 |
|
52 CWesternItutUiStateMatchSelection::CWesternItutUiStateMatchSelection( |
|
53 CGenericItutUiMgrBase* aOwner):CGenericItutUiStateBase(aOwner) |
|
54 { |
|
55 iSelList = static_cast<CFepLayoutScrollableList*>( |
|
56 iOwner->LayoutContext()->Control(ECtrlIdMatchSelection)); |
|
57 |
|
58 iIcf = static_cast<CFepLayoutMultiLineIcf*>( |
|
59 iOwner->LayoutContext()->Control(ECtrlIdICF)); |
|
60 } |
|
61 |
|
62 void CWesternItutUiStateMatchSelection::ConstructL() |
|
63 { |
|
64 CGenericItutUiStateBase::ConstructL(); |
|
65 iSpellText = StringLoader::LoadL(R_PENINPUT_FINGER_SPELL); |
|
66 } |
|
67 |
|
68 void CWesternItutUiStateMatchSelection::OnEntryL() |
|
69 { |
|
70 TInt keypadResId = KInvalidResId; |
|
71 switch (iOwner->DataMgr()->InputMode()) |
|
72 { |
|
73 case ENumber: |
|
74 keypadResId = R_FINGER_INPUT_KEYPAD_NUMBER; |
|
75 break; |
|
76 case ELatin: |
|
77 keypadResId = iOwner->DataMgr()->KeypadResourceId(); |
|
78 break; |
|
79 default: |
|
80 break; |
|
81 } |
|
82 |
|
83 // update resource id of keypad, candidate drop list |
|
84 iOwner->DataMgr()->NotifyChangeControlLayout( |
|
85 MItutPropertySubscriber::EItutPropertyKeypadResourceId, |
|
86 keypadResId); |
|
87 |
|
88 if (iOwner->DataMgr()->IsChinese()) |
|
89 { |
|
90 iOwner->LayoutContext()->ShowArrowBtn(EBtnArrowLeft | EBtnArrowRight |
|
91 | EBtnArrowUp| EBtnArrowDown); |
|
92 } |
|
93 else |
|
94 { |
|
95 iOwner->LayoutContext()->ShowArrowBtn(EBtnArrowLeft | EBtnArrowRight); |
|
96 } |
|
97 } |
|
98 |
|
99 void CWesternItutUiStateMatchSelection::OnExit() |
|
100 { |
|
101 iOwner->LayoutContext()->ShowArrowBtn(0); |
|
102 iSelList->CloseWindow(); |
|
103 iIcf->SetOverLapState(EFalse); |
|
104 } |
|
105 |
|
106 CGenericItutUiMgrBase::TUiState CWesternItutUiStateMatchSelection::StateType() |
|
107 { |
|
108 return CGenericItutUiMgrBase::EStateMatchSelection; |
|
109 } |
|
110 |
|
111 void CWesternItutUiStateMatchSelection::ReportItemSelected(TInt aCmdId, TInt aIdx, TBool aCommit) |
|
112 { |
|
113 TBuf<8> buf; |
|
114 buf.Append(reinterpret_cast<TText*>(&aIdx), sizeof(TInt)/sizeof(TText)); |
|
115 buf.Append(reinterpret_cast<TText*>(&aCommit), sizeof(TBool)/sizeof(TText)); |
|
116 |
|
117 iOwner->LayoutContext()->UiLayout()->SignalOwner(aCmdId, buf); |
|
118 } |
|
119 |
|
120 void CWesternItutUiStateMatchSelection::ReportItemSelected(TInt aCmdId, TInt aIdx) |
|
121 { |
|
122 TBuf<4> buf; |
|
123 buf.Append(reinterpret_cast<TText*>(&aIdx), sizeof(TInt)/sizeof(TText)); |
|
124 |
|
125 iOwner->LayoutContext()->UiLayout()->SignalOwner(aCmdId, buf); |
|
126 } |
|
127 |
|
128 TBool CWesternItutUiStateMatchSelection::HandleCtrlEventL( |
|
129 TInt aEventType, CFepUiBaseCtrl* aCtrl, const TDesC& aEventData) |
|
130 { |
|
131 switch (aEventType) |
|
132 { |
|
133 case EItutCmdPredictItemSelected: |
|
134 { |
|
135 TInt itemidx = *(TInt*)aEventData.Ptr(); |
|
136 |
|
137 // if press spell, then enter spell mode, otherwise select an item |
|
138 // note that spell do not belong to iCandlist |
|
139 itemidx == iCandlist.Count() ? |
|
140 iOwner->LayoutContext()->UiLayout()->SignalOwner(ESignalEnterSpellMode) : |
|
141 // according to updated ui spec, if select an item, do not commit it |
|
142 //ReportItemSelected(ESignalSelectMatchSelectionText, itemidx, ETrue); |
|
143 ReportItemSelected(ESignalSelectMatchSelectionText, itemidx, ETrue); |
|
144 return ETrue; |
|
145 } |
|
146 case EEventChoiceSelected: |
|
147 { |
|
148 CFepLayoutChoiceList::SEvent* event = |
|
149 (CFepLayoutChoiceList::SEvent*)aEventData.Ptr(); |
|
150 |
|
151 if ( aCtrl->ControlId() == ECtrlIdMatchSelection && event->iIndex == -1) |
|
152 { |
|
153 iOwner->LayoutContext()->EnterMatchSelectionState(EFalse); |
|
154 return ETrue; |
|
155 } |
|
156 } |
|
157 break; |
|
158 default: |
|
159 break; |
|
160 } |
|
161 |
|
162 return EFalse; |
|
163 } |
|
164 |
|
165 TInt CWesternItutUiStateMatchSelection::HandleCommandL(TInt aCmd, TUint8* aData) |
|
166 { |
|
167 switch (aCmd) |
|
168 { |
|
169 case ECmdPenInputFingerMatchList: |
|
170 { |
|
171 RDesReadStream readStream; |
|
172 TPtr8 countPtr(aData, 2*sizeof(TInt), 2*sizeof(TInt)); |
|
173 readStream.Open(countPtr); |
|
174 CleanupClosePushL(readStream); |
|
175 |
|
176 TInt candcount = readStream.ReadInt32L(); |
|
177 TInt totalsize = readStream.ReadInt32L(); |
|
178 CleanupStack::PopAndDestroy(&readStream); |
|
179 |
|
180 TPtr8 ptr(aData + 2*sizeof(TInt), totalsize - 2*sizeof(TInt), |
|
181 totalsize - 2*sizeof(TInt)); |
|
182 readStream.Open(ptr); |
|
183 CleanupClosePushL(readStream); |
|
184 |
|
185 iCandlist.ResetAndDestroy(); |
|
186 |
|
187 iSelList->ClearItemsL(); |
|
188 CFepLayoutChoiceList::SItem item; |
|
189 |
|
190 for (TInt i = 0; i < candcount; i++) |
|
191 { |
|
192 TInt candSize = readStream.ReadInt32L(); |
|
193 |
|
194 HBufC* candBuf = HBufC::NewLC(candSize/2); |
|
195 TPtr candBufPtr = candBuf->Des(); |
|
196 |
|
197 readStream.ReadL(candBufPtr, candSize/2); |
|
198 iCandlist.AppendL(candBuf); |
|
199 CleanupStack::Pop(candBuf); |
|
200 |
|
201 item.iCommand = EItutCmdPredictItemSelected; |
|
202 item.iText.Copy(candBufPtr); |
|
203 iSelList->AddItemL(item); |
|
204 |
|
205 } |
|
206 |
|
207 if (iCandlist.Count() != 0) |
|
208 { |
|
209 item.iCommand = EItutCmdEnterSpellMode; |
|
210 item.iText.Copy(*iSpellText); |
|
211 iSelList->AddItemL(item); |
|
212 SetMatchSelListLTPosAndDisplay(); |
|
213 } |
|
214 |
|
215 CleanupStack::PopAndDestroy(&readStream); |
|
216 return KErrNone; |
|
217 } |
|
218 default: |
|
219 break; |
|
220 } |
|
221 |
|
222 return KErrNotSupported; |
|
223 } |
|
224 |
|
225 void CWesternItutUiStateMatchSelection::SetMatchSelListLTPosAndDisplay() |
|
226 { |
|
227 TPoint posbelow, posright; |
|
228 posbelow = posright = iIcf->Rect().iTl; |
|
229 iIcf->InlineTextPos(posbelow, posright); |
|
230 TPoint tlPos = iOwner->DataMgr()->IsLandScape() ? posright : posbelow; |
|
231 iSelList->SetCurrentFocusedIndex(-1); |
|
232 iSelList->Display( TRect(tlPos, tlPos), CFepLayoutPopupWnd::EDispBottomRight); |
|
233 } |
|
234 |
|
235 // End Of File |