21
|
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 <peninputlayoutmultilineicf.h>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <peninputcommonbutton.h>
|
|
24 |
#include <peninputlayout.h>
|
|
25 |
#include <peninputcmd.h>
|
|
26 |
#include <peninputlabel.h>
|
|
27 |
|
|
28 |
#include <peninputrawkeybutton.h>
|
|
29 |
|
|
30 |
#include "peninputitutwesternuistatespelling.h"
|
|
31 |
#include "peninputgenericitutuimgrbase.h"
|
|
32 |
#include "peninputgenericitutdatamgr.h"
|
|
33 |
#include "peninputgenericitutlayoutcontext.h"
|
|
34 |
#include "peninputgenericitutconverter.h"
|
|
35 |
#include "peninputitutcustomizationresourcemgr.h"
|
|
36 |
#include "peninputgenericitutlayout.h"
|
|
37 |
#include "peninputcommonbgctrl.h"
|
|
38 |
#include "peninputgenericitutwindowmanager.h"
|
|
39 |
#include "peninputgenericitutwindow.h"
|
|
40 |
#include <peninputlayoutbubblectrl.h>
|
|
41 |
|
|
42 |
CWesternItutUiStateSpelling* CWesternItutUiStateSpelling::NewL(CGenericItutUiMgrBase* aOwner)
|
|
43 |
{
|
|
44 |
CWesternItutUiStateSpelling* self = new (ELeave) CWesternItutUiStateSpelling(aOwner);
|
|
45 |
CleanupStack::PushL(self);
|
|
46 |
self->ConstructL();
|
|
47 |
CleanupStack::Pop(self);
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
CWesternItutUiStateSpelling::~CWesternItutUiStateSpelling()
|
|
52 |
{
|
|
53 |
delete iRscMgr;
|
|
54 |
}
|
|
55 |
|
|
56 |
CWesternItutUiStateSpelling::CWesternItutUiStateSpelling(CGenericItutUiMgrBase* aOwner)
|
|
57 |
:CGenericItutUiStateBase(aOwner)
|
|
58 |
{
|
|
59 |
iICF = static_cast<CFepLayoutMultiLineIcf*>(iOwner->LayoutContext()->Control(ECtrlIdICF));
|
|
60 |
}
|
|
61 |
|
|
62 |
void CWesternItutUiStateSpelling::ConstructL()
|
|
63 |
{
|
|
64 |
CGenericItutUiStateBase::ConstructL();
|
|
65 |
iRscMgr = CItutCustomizedRscMgr::NewL(iOwner->LayoutContext()->UiLayout(),
|
|
66 |
iOwner->LayoutContext());
|
|
67 |
}
|
|
68 |
|
|
69 |
void CWesternItutUiStateSpelling::CreateTextBtnIfNeededL(CAknFepCtrlCommonButton*& aBtn,
|
|
70 |
TInt aCtrlId,
|
|
71 |
TInt aCtrlPos,
|
|
72 |
TInt aTextResId,
|
|
73 |
TAknTextLineLayout aTextFormat)
|
|
74 |
{
|
|
75 |
if (!aBtn)
|
|
76 |
{
|
|
77 |
aBtn = CAknFepCtrlCommonButton::NewL(iOwner->LayoutContext()->UiLayout(),
|
|
78 |
aCtrlId,
|
|
79 |
KAknsIIDQsnFrFunctionButtonNormal,
|
|
80 |
KAknsIIDQsnFrFunctionButtonPressed,
|
|
81 |
KAknsIIDQsnFrFunctionButtonInactive);
|
|
82 |
aBtn->SetRect(TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(aCtrlPos)));
|
|
83 |
HBufC* btntext = StringLoader::LoadLC(aTextResId);
|
|
84 |
aBtn->SetTextFormat(aTextFormat);
|
|
85 |
aBtn->SetTextL(*btntext);
|
|
86 |
aBtn->SetTextColorIndex( EAknsCIQsnTextColorsCG65 );
|
|
87 |
CleanupStack::PopAndDestroy(btntext);
|
|
88 |
iOwner->LayoutContext()->UiLayout()->AddControlL(aBtn);
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
void CWesternItutUiStateSpelling::OnEntryL()
|
|
93 |
{
|
|
94 |
TInt keypadResId = KInvalidResId;
|
|
95 |
switch (iOwner->DataMgr()->InputMode())
|
|
96 |
{
|
|
97 |
case ENumber:
|
|
98 |
keypadResId = R_FINGER_INPUT_KEYPAD_NUMBER;
|
|
99 |
break;
|
|
100 |
case ELatin:
|
|
101 |
keypadResId = iOwner->DataMgr()->KeypadResourceId();
|
|
102 |
break;
|
|
103 |
default:
|
|
104 |
break;
|
|
105 |
}
|
|
106 |
//hide bubble in the first place.
|
|
107 |
iICF->HideBubble();
|
|
108 |
|
|
109 |
// update resource id of keypad
|
|
110 |
iOwner->DataMgr()->NotifyChangeControlLayout(
|
|
111 |
MItutPropertySubscriber::EItutPropertyKeypadResourceId, keypadResId);
|
|
112 |
|
|
113 |
// hide not needed controls
|
|
114 |
CFepUiBaseCtrl* baseCtrl = iOwner->LayoutContext()->Control(ECtrlIdSwitch);
|
|
115 |
if ( baseCtrl )
|
|
116 |
{
|
|
117 |
baseCtrl->Hide(ETrue);
|
|
118 |
}
|
|
119 |
iOwner->LayoutContext()->Control(ECtrlIdOptions)->Hide(ETrue);
|
|
120 |
iOwner->LayoutContext()->Control(ECtrlIdClose)->Hide(ETrue);
|
|
121 |
baseCtrl = iOwner->LayoutContext()->Control(ECtrlIdIndicator);
|
|
122 |
if ( baseCtrl )
|
|
123 |
{
|
|
124 |
baseCtrl->Hide(ETrue);
|
|
125 |
}
|
|
126 |
// Hide Chinese Arrow Up button and Arrow Down button
|
|
127 |
CAknFepCtrlRawKeyButton* upbtn =
|
|
128 |
static_cast<CAknFepCtrlRawKeyButton *>(iOwner->LayoutContext()->Control(ECtrlIdArrowUp));
|
|
129 |
CAknFepCtrlRawKeyButton* downbtn =
|
|
130 |
static_cast<CAknFepCtrlRawKeyButton *>(iOwner->LayoutContext()->Control(ECtrlIdArrowDown));
|
|
131 |
|
|
132 |
if( upbtn )
|
|
133 |
{
|
|
134 |
upbtn->Hide(ETrue);
|
|
135 |
}
|
|
136 |
|
|
137 |
if( downbtn )
|
|
138 |
{
|
|
139 |
downbtn->Hide(ETrue);
|
|
140 |
}
|
|
141 |
//
|
|
142 |
|
|
143 |
if ( iOwner->DataMgr()->IsChineseSpellMode())
|
|
144 |
{
|
|
145 |
CAknFepCtrlRawKeyButton* leftbtn =
|
|
146 |
static_cast<CAknFepCtrlRawKeyButton *>( iOwner->LayoutContext()->Control( ECtrlIdArrowLeft ));
|
|
147 |
if( leftbtn )
|
|
148 |
{
|
|
149 |
leftbtn->Hide( ETrue );
|
|
150 |
}
|
|
151 |
|
|
152 |
CAknFepCtrlRawKeyButton* rightbtn =
|
|
153 |
static_cast<CAknFepCtrlRawKeyButton *>( iOwner->LayoutContext()->Control( ECtrlIdArrowRight ));
|
|
154 |
if( rightbtn )
|
|
155 |
{
|
|
156 |
rightbtn->Hide( ETrue );
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
TAknTextLineLayout btntextformat = TItutDataConverter::AnyToTextLine(
|
|
161 |
iOwner->DataMgr()->RequestData(EBtnTextLine));
|
|
162 |
TAknTextLineLayout btntextCancel = TItutDataConverter::AnyToTextLine(
|
|
163 |
iOwner->DataMgr()->RequestData(ESpellTextCancle));
|
|
164 |
CreateTextBtnIfNeededL(iOk, ECtrlIdOkBtn, EItutPosOk, R_PENINPUT_FINGER_OK, btntextformat);
|
|
165 |
iOk->SetReady(ETrue);
|
|
166 |
iOk->Hide(EFalse);
|
|
167 |
iICF->IsEmpty() ? iOk->SetDimmed(ETrue) : iOk->SetDimmed(EFalse);
|
|
168 |
|
|
169 |
CreateTextBtnIfNeededL(iCancel, ECtrlIdCancelBtn, EItutPosCancel,
|
|
170 |
R_PENINPUT_FINGER_CANCEL, btntextformat);
|
|
171 |
iCancel->SetReady(ETrue);
|
|
172 |
iCancel->Hide(EFalse);
|
|
173 |
|
|
174 |
iOwner->DataMgr()->SetSpellMode(ETrue);
|
|
175 |
iICF->SetLineSeparatorAfterPrompt(ETrue);
|
|
176 |
|
|
177 |
ReCalcLayoutL();
|
|
178 |
// Show ICF, Backspace after position changed to avoid flicker
|
|
179 |
iOwner->LayoutContext()->Control(ECtrlIdBackspace)->Hide( EFalse );
|
|
180 |
iOwner->LayoutContext()->Control(ECtrlIdICF)->Hide( EFalse );
|
|
181 |
CAknFepCtrlLabel* indilabel = static_cast<CAknFepCtrlLabel*>
|
|
182 |
(iOwner->LayoutContext()->Control(ECtrlIdSpellIndicator));
|
|
183 |
if ( indilabel && iOwner->DataMgr()->IsChineseSpellMode())
|
|
184 |
{
|
|
185 |
indilabel->Hide( EFalse );
|
|
186 |
}
|
|
187 |
iOwner->DataMgr()->SetUpdate(ETrue);
|
|
188 |
}
|
|
189 |
|
|
190 |
void CWesternItutUiStateSpelling::OnExit()
|
|
191 |
{
|
|
192 |
CAknFepCtrlLabel* indilabel = static_cast<CAknFepCtrlLabel*>
|
|
193 |
(iOwner->LayoutContext()->Control(ECtrlIdSpellIndicator));
|
|
194 |
if ( indilabel )
|
|
195 |
{
|
|
196 |
indilabel->Hide( ETrue );
|
|
197 |
}
|
|
198 |
// Hide ICF, Backspace, Arrow contrls when exit to avoid flicker
|
|
199 |
iOwner->LayoutContext()->ShowArrowBtn(0);
|
|
200 |
iOwner->LayoutContext()->Control(ECtrlIdBackspace)->Hide( ETrue );
|
|
201 |
iOwner->LayoutContext()->Control(ECtrlIdICF)->Hide( ETrue );
|
|
202 |
TRAP_IGNORE(iICF->SetPromptTextL( KNullDesC ));
|
|
203 |
iOk->Hide(ETrue);
|
|
204 |
iCancel->Hide(ETrue);
|
|
205 |
iOwner->DataMgr()->SetSpellMode(EFalse);
|
|
206 |
iICF->SetLineSeparatorAfterPrompt(EFalse);
|
|
207 |
|
|
208 |
iOwner->DataMgr()->SetChineseSpellFlag( EFalse );
|
|
209 |
}
|
|
210 |
|
|
211 |
CGenericItutUiMgrBase::TUiState CWesternItutUiStateSpelling::StateType()
|
|
212 |
{
|
|
213 |
return CGenericItutUiMgrBase::EStateSpelling;
|
|
214 |
}
|
|
215 |
|
|
216 |
TInt CWesternItutUiStateSpelling::HandleCommandL(TInt aCmd, TUint8* /*aData*/)
|
|
217 |
{
|
|
218 |
switch (aCmd)
|
|
219 |
{
|
|
220 |
case EItutExtCmdSizeChanged:
|
|
221 |
{
|
|
222 |
ReCalcLayoutL();
|
|
223 |
return KErrNone;
|
|
224 |
}
|
|
225 |
case EItutCmdCheckIcfEmpty:
|
|
226 |
{
|
|
227 |
iICF->IsEmpty() ? iOk->SetDimmed(ETrue) : iOk->SetDimmed(EFalse);
|
|
228 |
return KErrNone;
|
|
229 |
}
|
|
230 |
default:
|
|
231 |
break;
|
|
232 |
}
|
|
233 |
|
|
234 |
return KErrNotSupported;
|
|
235 |
}
|
|
236 |
|
|
237 |
TBool CWesternItutUiStateSpelling::HandleCtrlEventL(TInt aEventType,
|
|
238 |
CFepUiBaseCtrl* aCtrl,
|
|
239 |
const TDesC& /*aEventData*/)
|
|
240 |
{
|
|
241 |
switch (aEventType)
|
|
242 |
{
|
|
243 |
case EEventButtonUp:
|
|
244 |
{
|
|
245 |
TInt ctrlid = aCtrl->ControlId();
|
|
246 |
|
|
247 |
if (ctrlid != ECtrlIdOkBtn && ctrlid != ECtrlIdCancelBtn)
|
|
248 |
{
|
|
249 |
return EFalse;
|
|
250 |
}
|
|
251 |
|
|
252 |
TBuf<4> buf;
|
|
253 |
TBool exitbyok = (ctrlid == ECtrlIdOkBtn);
|
|
254 |
buf.Append(reinterpret_cast<TText*>(&exitbyok), sizeof(TBool)/sizeof(TText));
|
|
255 |
|
|
256 |
iOwner->LayoutContext()->UiLayout()->SignalOwner(ESignalExitSpellMode, buf);
|
|
257 |
return ETrue;
|
|
258 |
}
|
|
259 |
default:
|
|
260 |
break;
|
|
261 |
}
|
|
262 |
|
|
263 |
return EFalse;
|
|
264 |
}
|
|
265 |
|
|
266 |
void CWesternItutUiStateSpelling::ReCalcLayoutL()
|
|
267 |
{
|
|
268 |
TAknTextLineLayout btntextformat = TItutDataConverter::AnyToTextLine(
|
|
269 |
iOwner->DataMgr()->RequestData(EBtnTextLine));
|
|
270 |
TAknTextLineLayout btntextCancel = TItutDataConverter::AnyToTextLine(
|
|
271 |
iOwner->DataMgr()->RequestData(ESpellTextCancle));
|
|
272 |
TRect btnrect = TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(EItutPosOk));
|
|
273 |
iOk->SetTextFormat(btntextformat);
|
|
274 |
iOk->SizeChanged(btnrect, btnrect, ETrue);
|
|
275 |
|
|
276 |
btnrect = TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(EItutPosCancel));
|
|
277 |
iCancel->SetTextFormat(btntextCancel);
|
|
278 |
iCancel->SizeChanged(btnrect, btnrect, ETrue);
|
|
279 |
//iICF->SetRect( TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(ESpellICFRect)) );
|
|
280 |
CFont* icffont;
|
|
281 |
if ( iOwner->DataMgr()->IsPortraitWest() &&
|
|
282 |
(!iOwner->DataMgr()->IsChineseSpellMode()))
|
|
283 |
{
|
|
284 |
icffont = TItutDataConverter::AnyToFont(iOwner->DataMgr()->RequestData(ESpellFont));
|
|
285 |
}
|
|
286 |
else
|
|
287 |
{
|
|
288 |
icffont = TItutDataConverter::AnyToFont(iOwner->DataMgr()->RequestData(EIcfFont));
|
|
289 |
}
|
|
290 |
TRect rect = TItutDataConverter::AnyToRect(iOwner->DataMgr()->RequestData(ESpellICFRect) );
|
|
291 |
|
|
292 |
|
|
293 |
iICF->SetTextMargin (
|
|
294 |
iOwner->DataMgr()->iSpellIcfTextLeftMarginForPrtWest,
|
|
295 |
iOwner->DataMgr()->iSpellIcfTextRightMarginForPrtWest,
|
|
296 |
iOwner->DataMgr()->iSpellIcfTextTopMarginForPrtWest,
|
|
297 |
iOwner->DataMgr()->iSpellIcfTextBottomMarginForPrtWest );
|
|
298 |
|
|
299 |
iICF->SetLineSpace( iOwner->DataMgr()->iSpellIcfTextLineSpaceMarginForPrtWest );
|
|
300 |
|
|
301 |
|
|
302 |
if ( iOwner->DataMgr()->IsPortraitWest() &&
|
|
303 |
(!iOwner->DataMgr()->IsChineseSpellMode()))
|
|
304 |
{
|
|
305 |
iICF->SizeChangedL(rect,
|
|
306 |
iOwner->DataMgr()->iSpellIcfTextHeightForPrtWest,
|
|
307 |
icffont->FontMaxHeight(),
|
|
308 |
icffont);
|
|
309 |
}
|
|
310 |
else
|
|
311 |
{
|
|
312 |
iICF->SizeChangedL(rect,
|
|
313 |
iOwner->DataMgr()->iIcfTextHeight,
|
|
314 |
icffont->FontMaxHeight(),
|
|
315 |
icffont);
|
|
316 |
}
|
|
317 |
|
|
318 |
CAknFepCtrlCommonButton* clrBtn = static_cast<CAknFepCtrlCommonButton*>(
|
|
319 |
iOwner->LayoutContext()->Control(ECtrlIdBackspace) );
|
|
320 |
|
|
321 |
// When size changed in r-to-l language, it should be mirrored
|
|
322 |
TRect rt = TItutDataConverter::AnyToRect( iOwner->DataMgr()->RequestData(ESpellClrRect) );
|
|
323 |
TRect innerRect = TItutDataConverter::AnyToRect(
|
|
324 |
iOwner->DataMgr()->RequestData(ESpellClrInnerRect) );
|
|
325 |
TBool bSizedChanged = (rt.Size() != clrBtn->Rect().Size()) &&
|
|
326 |
(innerRect.Size() != clrBtn->ForgroundBmpRect().Size());
|
|
327 |
clrBtn->SizeChanged( rt, innerRect, ETrue );
|
|
328 |
|
|
329 |
if( bSizedChanged && iOwner->DataMgr()->IsRtoLLanguage() )
|
|
330 |
{
|
|
331 |
iOwner->UiManager()->Window()->HandleButtonResOnLangDirChange( ECtrlIdBackspace );
|
|
332 |
}
|
|
333 |
if ( iOwner->DataMgr()->IsPortraitWest() &&
|
|
334 |
(!iOwner->DataMgr()->IsChineseSpellMode()))
|
|
335 |
{
|
|
336 |
iOwner->LayoutContext()->Control(ECtrlIdArrowLeft)->Hide( EFalse );
|
|
337 |
iOwner->LayoutContext()->Control(ECtrlIdArrowRight)->Hide( EFalse );
|
|
338 |
|
|
339 |
// left button
|
|
340 |
CAknFepCtrlCommonButton* middleBtn = static_cast<CAknFepCtrlCommonButton*>(
|
|
341 |
iOwner->LayoutContext()->Control(ECtrlIdArrowLeft));
|
|
342 |
TRect middleRect = TItutDataConverter::AnyToRect(
|
|
343 |
iOwner->DataMgr()->RequestData(ESpellArrowLeft));
|
|
344 |
TRect middleInnerRect = TItutDataConverter::AnyToRect(
|
|
345 |
iOwner->DataMgr()->RequestData(ESpellArrowLeftInner));
|
|
346 |
middleBtn->SizeChanged( middleRect, middleInnerRect, ETrue );
|
|
347 |
|
|
348 |
// right button
|
|
349 |
middleBtn = static_cast<CAknFepCtrlCommonButton*>(
|
|
350 |
iOwner->LayoutContext()->Control(ECtrlIdArrowRight));
|
|
351 |
middleRect = TItutDataConverter::AnyToRect(
|
|
352 |
iOwner->DataMgr()->RequestData(ESpellArrowRight));
|
|
353 |
middleInnerRect = TItutDataConverter::AnyToRect(
|
|
354 |
iOwner->DataMgr()->RequestData(ESpellArrowRightInner));
|
|
355 |
middleBtn->SizeChanged( middleRect, middleInnerRect, ETrue );
|
|
356 |
|
|
357 |
// Indicator bubble
|
|
358 |
TRect bubbleRect = TItutDataConverter::AnyToRect(
|
|
359 |
iOwner->DataMgr()->RequestData( ESpellIndiPaneWithoutTextRect ));
|
|
360 |
TRect iconRect = TItutDataConverter::AnyToRect(
|
|
361 |
iOwner->DataMgr()->RequestData( ESpellIndiIconWithoutTextRect ));
|
|
362 |
TSize offset;
|
|
363 |
offset.iHeight = iconRect.iTl.iY - bubbleRect.iTl.iY;
|
|
364 |
offset.iWidth = iconRect.iTl.iX - bubbleRect.iTl.iX;
|
|
365 |
TSize size( iconRect.Width(), iconRect.Height());
|
|
366 |
|
|
367 |
iICF->MsgBubbleCtrl()->SetRect( bubbleRect );
|
|
368 |
iICF->MsgBubbleCtrl()->SetIconOffsetAndSize( offset, size );
|
|
369 |
|
|
370 |
TBuf<100> text;
|
|
371 |
iICF->MsgBubbleCtrl()->GetText( text );
|
|
372 |
iICF->ShowBubble( text, iICF->MsgBubbleCtrl()->Rect());
|
|
373 |
}
|
|
374 |
}
|
|
375 |
|
|
376 |
// End Of File
|