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