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: Implementation of hwr window class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// System includes
|
|
20 |
#include <peninputhwrwindow.rsg>
|
|
21 |
#include <peninputhwrwindowconfiginfo_01.rsg>
|
|
22 |
#include <aknfeppeninputenums.h>
|
|
23 |
#include <peninputinputcontextfield.h>
|
|
24 |
#include <peninputpluginutils.h>
|
|
25 |
#include <peninputcommonlayout.h>
|
|
26 |
#include <peninputeventbutton.h>
|
|
27 |
#include <peninputrepeatbutton.h>
|
|
28 |
#include <peninputlayouthwrwnd.h>
|
|
29 |
#include <peninputrangebar.h>
|
|
30 |
#include <peninputdataconverter.h>
|
|
31 |
#include <peninputdataprovider.h>
|
|
32 |
#include <peninputclientlayoutinfo.h>
|
|
33 |
#include <AknIconUtils.h>
|
|
34 |
#include <AknLayoutDef.h>
|
|
35 |
#include <AknUtils.h>
|
|
36 |
#include <aknlayoutscalable_avkon.cdl.h>
|
|
37 |
#include <AknsUtils.h>
|
|
38 |
#include <peninputlayoutchoicelist.h>
|
|
39 |
#include <AknFepGlobalEnums.h>
|
|
40 |
#include <peninputlayoutinputmodechoice.h>
|
|
41 |
#include <peninputlayoutmultilineicf.h>
|
|
42 |
|
|
43 |
// User includes
|
|
44 |
#include "peninputlayoutchoicelist.h"
|
|
45 |
#include "peninputgenerichwrwindow.h"
|
|
46 |
#include "peninputgenerichwrdatamgr.h"
|
|
47 |
#include "peninputgenerichwr.hrh"
|
|
48 |
#include "peninputgenericrecognizer.h"
|
|
49 |
#include "peninputgenerichwrlayout.h"
|
|
50 |
|
|
51 |
// Constants
|
|
52 |
_LIT( KHwrWindowResourceFile,
|
|
53 |
"z:\\resource\\plugins\\peninputhwrwindow.RSC" );
|
|
54 |
_LIT( KConfigurationResourceFile,
|
|
55 |
"z:\\resource\\plugins\\peninputhwrwindowconfiginfo_" );
|
|
56 |
_LIT( KResourceFileExtName, ".RSC" );
|
|
57 |
|
|
58 |
|
|
59 |
const TInt KWrittingFactor = 0;
|
|
60 |
const TInt KNormalFactor = 26;
|
|
61 |
|
|
62 |
const TInt KWriteBoxFrameBackColorMajor = EAknsMajorSkin;
|
|
63 |
const TInt KWriteBoxFrameBackColorGrp = EAknsMinorQsnOtherColors;
|
|
64 |
const TInt KWriteBoxFrameBackColorIdx = EAknsCIQsnOtherColorsCG9;
|
|
65 |
const TUint32 KDefaultWriteBoxFrameColor = 0x000000;
|
|
66 |
const TUint32 KDefaultWriteBoxBackColor = 0xffffff;
|
|
67 |
|
|
68 |
const TInt KPeninputHwrWndInvalidIndex = -1;
|
|
69 |
// ======== MEMBER FUNCTIONS ========
|
|
70 |
|
|
71 |
// --------------------------------------------------------------------------
|
|
72 |
// CPeninputGenericHwrWindow::CPeninputGenericHwrWindow
|
|
73 |
// (other items were commented in a header)
|
|
74 |
// --------------------------------------------------------------------------
|
|
75 |
//
|
|
76 |
CPeninputGenericHwrWindow::CPeninputGenericHwrWindow(
|
|
77 |
CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext )
|
|
78 |
: CPeninputLayoutWindow( aUiLayout, aLayoutContext ),
|
|
79 |
iNormalTransFactor(KNormalFactor),
|
|
80 |
iWriteTransFactor(KWrittingFactor),
|
|
81 |
iGuideLineSet(EFalse)
|
|
82 |
{
|
|
83 |
}
|
|
84 |
|
|
85 |
// --------------------------------------------------------------------------
|
|
86 |
// CPeninputGenericHwrWindow::NewL
|
|
87 |
// (other items were commented in a header)
|
|
88 |
// --------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
CPeninputGenericHwrWindow* CPeninputGenericHwrWindow::NewL(
|
|
91 |
CFepUiLayout* aUiLayout, MPeninputLayoutContext* aLayoutContext )
|
|
92 |
{
|
|
93 |
CPeninputGenericHwrWindow* self =
|
|
94 |
new ( ELeave ) CPeninputGenericHwrWindow( aUiLayout, aLayoutContext );
|
|
95 |
CleanupStack::PushL( self );
|
|
96 |
self->ConstructL();
|
|
97 |
CleanupStack::Pop( self );
|
|
98 |
|
|
99 |
return self;
|
|
100 |
}
|
|
101 |
|
|
102 |
// --------------------------------------------------------------------------
|
|
103 |
// CPeninputGenericHwrWindow::~CPeninputGenericHwrWindow
|
|
104 |
// (other items were commented in a header)
|
|
105 |
// --------------------------------------------------------------------------
|
|
106 |
//
|
|
107 |
CPeninputGenericHwrWindow::~CPeninputGenericHwrWindow()
|
|
108 |
{
|
|
109 |
for ( TInt i = 0; i < iRecogResult.Count(); i++ )
|
|
110 |
{
|
|
111 |
delete iRecogResult[i];
|
|
112 |
}
|
|
113 |
iRecogResult.Close();
|
|
114 |
iStrokeArray.Close();
|
|
115 |
delete iLastResult;
|
|
116 |
}
|
|
117 |
|
|
118 |
// --------------------------------------------------------------------------
|
|
119 |
// CPeninputGenericHwrWindow::ConstructL
|
|
120 |
// (other items were commented in a header)
|
|
121 |
// --------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CPeninputGenericHwrWindow::ConstructL()
|
|
124 |
{
|
|
125 |
CPeninputLayoutWindow::ConstructL();
|
|
126 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
127 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
128 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
129 |
|
|
130 |
if ( ( penData ) && ( iHwBox ) )
|
|
131 |
{
|
|
132 |
iHwBox->SetCharacterDelay( penData->iWritingSpeed );
|
|
133 |
iHwBox->SetFadingSpeed(penData->iFadingSpeed);
|
|
134 |
#ifdef _NOT_USING_DECUMA_MCR_
|
|
135 |
// similar as S90
|
|
136 |
|
|
137 |
iHwBox->SetStrokeDelay( 90000 );
|
|
138 |
|
|
139 |
#endif
|
|
140 |
|
|
141 |
iHwBox->SetPenSize( penData->iPenSize );
|
|
142 |
iHwBox->SetPenColor( penData->iPenColor );
|
|
143 |
iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
|
|
144 |
}
|
|
145 |
}
|
|
146 |
|
|
147 |
// --------------------------------------------------------------------------
|
|
148 |
// CPeninputGenericHwrWindow::HandleControlEvent
|
|
149 |
// (other items were commented in a header)
|
|
150 |
// --------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
void CPeninputGenericHwrWindow::HandleControlEvent( TInt aEventType,
|
|
153 |
CFepUiBaseCtrl* aCtrl,
|
|
154 |
const TDesC& aEventData )
|
|
155 |
{
|
|
156 |
// Call this function in base class
|
|
157 |
CPeninputLayoutWindow::HandleControlEvent( aEventType,
|
|
158 |
aCtrl,
|
|
159 |
aEventData );
|
|
160 |
|
|
161 |
TInt* data = ( TInt* ) aEventData.Ptr();
|
|
162 |
|
|
163 |
switch ( aEventType )
|
|
164 |
{
|
|
165 |
case EPeninputLayoutHwrEventPenColorChange:
|
|
166 |
case EPeninputLayoutHwrEventPenSizeChange:
|
|
167 |
case EPeninputLayoutHwrEventWritingSpeedChange:
|
|
168 |
{
|
|
169 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
170 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
171 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
172 |
|
|
173 |
iHwBox->SetCharacterDelay( penData->iWritingSpeed );
|
|
174 |
iHwBox->SetFadingSpeed(penData->iFadingSpeed);
|
|
175 |
|
|
176 |
#ifdef _NOT_USING_DECUMA_MCR_
|
|
177 |
|
|
178 |
// similar as S90
|
|
179 |
iHwBox->SetStrokeDelay( 90000 );
|
|
180 |
|
|
181 |
#endif
|
|
182 |
|
|
183 |
iHwBox->SetPenSize( penData->iPenSize );
|
|
184 |
iHwBox->SetPenColor( penData->iPenColor );
|
|
185 |
}
|
|
186 |
break;
|
|
187 |
case EPeninputLayoutHwrEventGuideLineChanged:
|
|
188 |
{
|
|
189 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
190 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
191 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
192 |
|
|
193 |
iHwBox->HideGuideLine( penData->iGuideLineOn == 0 ? EFalse : ETrue );
|
|
194 |
iHwBox->RefreshUI();
|
|
195 |
}
|
|
196 |
break;
|
|
197 |
case EEventHwrStrokeStarted:
|
|
198 |
{
|
|
199 |
OnStrokeStarted();
|
|
200 |
}
|
|
201 |
break;
|
|
202 |
case EEventHwrStrokeFinished:
|
|
203 |
{
|
|
204 |
OnStrokeFinished();
|
|
205 |
}
|
|
206 |
break;
|
|
207 |
case EEventHwrCharacterTimerOut:
|
|
208 |
{
|
|
209 |
OnStrokeCharacterTimerOut();
|
|
210 |
}
|
|
211 |
break;
|
|
212 |
case EEventHwrStrokeCanceled:
|
|
213 |
{
|
|
214 |
OnStrokeCanceled();
|
|
215 |
}
|
|
216 |
break;
|
|
217 |
case EPeninputLayoutEventCloseWindow:
|
|
218 |
{
|
|
219 |
iStrokeArray.Reset();
|
|
220 |
iHwBox->CapturePointer(EFalse);
|
|
221 |
iHwBox->CancelCharWriting();
|
|
222 |
}
|
|
223 |
break;
|
|
224 |
case EEventChoiceSelected:
|
|
225 |
{
|
|
226 |
CFepLayoutChoiceList::SEvent* event =
|
|
227 |
( CFepLayoutChoiceList::SEvent* ) aEventData.Ptr();
|
|
228 |
|
|
229 |
if ( event->iIndex != KPeninputHwrWndInvalidIndex )
|
|
230 |
{
|
|
231 |
if (aCtrl->ControlId() == EPeninutWindowCtrlIdSwitcherPopupWindow)
|
|
232 |
{
|
|
233 |
if (EPluginInputModeHwr != event->iCommand)
|
|
234 |
{
|
|
235 |
TBool switchByMode = ETrue;
|
|
236 |
TInt mode = event->iCommand;
|
|
237 |
|
|
238 |
TBuf<8> buf;
|
|
239 |
buf.Append(reinterpret_cast<TText*>(&switchByMode),
|
|
240 |
sizeof(TBool)/sizeof(TText));
|
|
241 |
buf.Append(reinterpret_cast<TText*>(&mode), sizeof(TInt)/sizeof(TText));
|
|
242 |
UiLayout()->SignalOwner(ESignalLayoutUIChanged,buf);
|
|
243 |
}
|
|
244 |
}
|
|
245 |
}
|
|
246 |
}
|
|
247 |
break;
|
|
248 |
case EPeninputLayoutEventToVkb:
|
|
249 |
{
|
|
250 |
iHwBox->CancelCharWriting();
|
|
251 |
PopupSwitchWindow();
|
|
252 |
}
|
|
253 |
break;
|
|
254 |
default:
|
|
255 |
break;
|
|
256 |
}
|
|
257 |
}
|
|
258 |
|
|
259 |
// --------------------------------------------------------------------------
|
|
260 |
// CPeninputGenericHwrWindow::GetWindowConfigResId
|
|
261 |
// (other items were commented in a header)
|
|
262 |
// --------------------------------------------------------------------------
|
|
263 |
//
|
|
264 |
TInt CPeninputGenericHwrWindow::GetWindowConfigResId()
|
|
265 |
{
|
|
266 |
return R_PENINPUT_LAYOUT_CONFIG_INFO;
|
|
267 |
}
|
|
268 |
|
|
269 |
// --------------------------------------------------------------------------
|
|
270 |
// CPeninputGenericHwrWindow::GetWindowResId
|
|
271 |
// (other items were commented in a header)
|
|
272 |
// --------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
TInt CPeninputGenericHwrWindow::GetWindowResId()
|
|
275 |
{
|
|
276 |
return R_PENINPUT_LAYOUT_HWR_WINDOW;
|
|
277 |
}
|
|
278 |
|
|
279 |
// --------------------------------------------------------------------------
|
|
280 |
// CPeninputGenericHwrWindow::GetWindowConfigResFileName
|
|
281 |
// (other items were commented in a header)
|
|
282 |
// --------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
const TDesC& CPeninputGenericHwrWindow::GetWindowConfigResFileName(
|
|
285 |
TInt aLangID )
|
|
286 |
{
|
|
287 |
if ( aLangID <= 0 )
|
|
288 |
{
|
|
289 |
return KNullDesC;
|
|
290 |
}
|
|
291 |
|
|
292 |
iResourceFilename.Zero();
|
|
293 |
iResourceFilename = KConfigurationResourceFile();
|
|
294 |
|
|
295 |
if ( aLangID < 10 )
|
|
296 |
{
|
|
297 |
iResourceFilename.AppendNum( 0 );
|
|
298 |
iResourceFilename.AppendNum( aLangID );
|
|
299 |
}
|
|
300 |
else
|
|
301 |
{
|
|
302 |
iResourceFilename.AppendNum( aLangID );
|
|
303 |
}
|
|
304 |
iResourceFilename.Append( KResourceFileExtName );
|
|
305 |
|
|
306 |
return iResourceFilename;
|
|
307 |
}
|
|
308 |
|
|
309 |
// --------------------------------------------------------------------------
|
|
310 |
// CPeninputGenericHwrWindow::GetWindowResFileName
|
|
311 |
// (other items were commented in a header)
|
|
312 |
// --------------------------------------------------------------------------
|
|
313 |
//
|
|
314 |
const TDesC& CPeninputGenericHwrWindow::GetWindowResFileName()
|
|
315 |
{
|
|
316 |
return KHwrWindowResourceFile();
|
|
317 |
}
|
|
318 |
|
|
319 |
// --------------------------------------------------------------------------
|
|
320 |
// CPeninputGenericHwrWindow::CreateAllControlsL
|
|
321 |
// (other items were commented in a header)
|
|
322 |
// --------------------------------------------------------------------------
|
|
323 |
//
|
|
324 |
void CPeninputGenericHwrWindow::CreateAllControlsL()
|
|
325 |
{
|
|
326 |
// Hwr box
|
|
327 |
AddHwBoxL();
|
|
328 |
|
|
329 |
// Range bar
|
|
330 |
AddRangeBarL();
|
|
331 |
|
|
332 |
// Language switch button
|
|
333 |
iLangSwitchBtn = AddButtonL( EPeninutWindowCtrlIdInputLangSwitcherBtn,
|
|
334 |
EPeninputLayoutEventSwitchLanguage,
|
|
335 |
R_PENINPUT_LAYOUT_HWR_SWITCH );
|
|
336 |
SetSwitchBtnFont(*iLangSwitchBtn);
|
|
337 |
SetSwitchBtnTextColor(*iLangSwitchBtn);
|
|
338 |
|
|
339 |
// Switch to vkb button
|
|
340 |
AddButtonL( EPeninutWindowCtrlIdSwitchToVkbBtn,
|
|
341 |
EPeninputLayoutEventToVkb,
|
|
342 |
R_PENINPUT_LAYOUT_HWR_VKB );
|
|
343 |
|
|
344 |
iModeSwitchChoice = CPeninputLayoutInputmodelChoice::NewL( UiLayout(),
|
|
345 |
EPeninutWindowCtrlIdSwitcherPopupWindow, EPluginInputModeHwr);
|
|
346 |
iModeSwitchChoice->SetListSkinID( KAknsIIDQsnFrList, KAknsIIDQsnFrPopupSub );
|
|
347 |
iModeSwitchChoice->AddEventObserver( UiLayout() );
|
|
348 |
AddControlL( iModeSwitchChoice );
|
|
349 |
|
|
350 |
if( iCtrlPool != NULL )
|
|
351 |
{
|
|
352 |
for ( TInt i = 0; i < iCtrlPool->ControlCount(); i++ )
|
|
353 |
{
|
|
354 |
iCtrlPool->ControlByIndex( i )->AddEventObserver( UiLayout() );
|
|
355 |
}
|
|
356 |
}
|
|
357 |
}
|
|
358 |
|
|
359 |
// --------------------------------------------------------------------------
|
|
360 |
// CPeninputGenericHwrWindow::ChangeUnitSize
|
|
361 |
// (other items were commented in a header)
|
|
362 |
// --------------------------------------------------------------------------
|
|
363 |
//
|
|
364 |
const TRect CPeninputGenericHwrWindow::ChangeUnitSize()
|
|
365 |
{
|
|
366 |
if (CPeninputDataConverter::AnyToInt(
|
|
367 |
iLayoutContext->RequestData(EAkninputDataTypeSizeChanging)) ||
|
|
368 |
!(CPeninputDataConverter::AnyToInt(
|
|
369 |
iLayoutContext->RequestData(EAkninputDataTypeUnitSizeSet))))
|
|
370 |
{
|
|
371 |
// if size changing, or unitwidth, unitheight has not been set yet
|
|
372 |
TAknWindowLineLayout appWnd;
|
|
373 |
TAknWindowLineLayout mainPane;
|
|
374 |
TAknWindowLineLayout wndLayout;
|
|
375 |
TAknWindowLineLayout unitLayout;
|
|
376 |
TAknLayoutRect mainPaneRect;
|
|
377 |
TAknLayoutRect wndRect;
|
|
378 |
TAknLayoutRect unitRect;
|
|
379 |
|
|
380 |
// Get hwr window layout
|
|
381 |
appWnd = AknLayoutScalable_Avkon::application_window( 0 ).LayoutLine();
|
|
382 |
|
|
383 |
if (appWnd.iW > appWnd.iH)
|
|
384 |
{
|
|
385 |
// landscape
|
|
386 |
mainPane = AknLayoutScalable_Avkon::main_pane(4).LayoutLine();
|
|
387 |
wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(2).LayoutLine();
|
|
388 |
}
|
|
389 |
else
|
|
390 |
{
|
|
391 |
// portrait
|
|
392 |
mainPane = AknLayoutScalable_Avkon::main_pane(1).LayoutLine();
|
|
393 |
wndLayout = AknLayoutScalable_Avkon::popup_fep_hwr_window(0).LayoutLine();
|
|
394 |
}
|
|
395 |
|
|
396 |
mainPaneRect.LayoutRect(appWnd.Rect(), mainPane);
|
|
397 |
wndRect.LayoutRect(mainPaneRect.Rect(), wndLayout);
|
|
398 |
|
|
399 |
unitLayout = AknLayoutScalable_Avkon::fep_hwr_aid_pane(1).LayoutLine();
|
|
400 |
unitRect.LayoutRect(wndRect.Rect(), unitLayout);
|
|
401 |
|
|
402 |
iHwrWndRect = TRect(0,
|
|
403 |
0,
|
|
404 |
wndRect.Rect().Width(),
|
|
405 |
wndRect.Rect().Height());
|
|
406 |
|
|
407 |
TInt unitWidth = unitRect.Rect().Width();
|
|
408 |
TInt unitHeight = unitRect.Rect().Height();
|
|
409 |
|
|
410 |
iLayoutContext->SetData(EPeninputDataTypeUnitWidth, &unitWidth);
|
|
411 |
iLayoutContext->SetData(EPeninputDataTypeUnitHeight, &unitHeight);
|
|
412 |
}
|
|
413 |
|
|
414 |
return iHwrWndRect;
|
|
415 |
}
|
|
416 |
|
|
417 |
// --------------------------------------------------------------------------
|
|
418 |
// CPeninputGenericHwrWindow::ChangeClientSize
|
|
419 |
// (other items were commented in a header)
|
|
420 |
// --------------------------------------------------------------------------
|
|
421 |
//
|
|
422 |
void CPeninputGenericHwrWindow::ChangeClientSize()
|
|
423 |
{
|
|
424 |
TInt unitWidth = CPeninputDataConverter::AnyToInt
|
|
425 |
( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
|
|
426 |
TInt unitHeight = CPeninputDataConverter::AnyToInt
|
|
427 |
( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
|
|
428 |
|
|
429 |
// Modify language switch button font
|
|
430 |
SetSwitchBtnFont(*iLangSwitchBtn);
|
|
431 |
|
|
432 |
TInt clientLayoutId = CPeninputDataConverter::AnyToInt
|
|
433 |
( iLayoutContext->RequestData( EPeninputDataTypeClientLayout ) );
|
|
434 |
CPeninputClientLayoutInfo* clientLayout =
|
|
435 |
ConfigInfo()->FindClientLayoutInfo( clientLayoutId );
|
|
436 |
|
|
437 |
if ( clientLayout )
|
|
438 |
{
|
|
439 |
// Change self rect
|
|
440 |
/*TInt width = clientLayout->Columns() * unitWidth;
|
|
441 |
TInt height = clientLayout->Rows() * unitHeight;
|
|
442 |
TRect rect = TRect( ClientPane()->Rect().iTl,
|
|
443 |
TSize( width, height ) );
|
|
444 |
|
|
445 |
ClientPane()->SetRect( rect );*/
|
|
446 |
// Change the postion and size of controls in current layout
|
|
447 |
ReorganizeControls( clientLayout->LayoutID() );
|
|
448 |
}
|
|
449 |
}
|
|
450 |
|
|
451 |
// --------------------------------------------------------------------------
|
|
452 |
// CPeninputGenericHwrWindow::ReorganizeControls
|
|
453 |
// (other items were commented in a header)
|
|
454 |
// --------------------------------------------------------------------------
|
|
455 |
//
|
|
456 |
void CPeninputGenericHwrWindow::ReorganizeControls( TInt aClientLayoutId, TBool /*aNeedReset*/ )
|
|
457 |
{
|
|
458 |
TInt unitWidth = CPeninputDataConverter::AnyToInt
|
|
459 |
( iLayoutContext->RequestData( EPeninputDataTypeUnitWidth ) );
|
|
460 |
TInt unitHeight = CPeninputDataConverter::AnyToInt
|
|
461 |
( iLayoutContext->RequestData( EPeninputDataTypeUnitHeight ) );
|
|
462 |
|
|
463 |
CPeninputClientLayoutInfo* clientLayout =
|
|
464 |
ConfigInfo()->FindClientLayoutInfo( aClientLayoutId );
|
|
465 |
|
|
466 |
// First remove all controls in the client pane, but don't delete them
|
|
467 |
( const_cast<RPointerArray<CFepUiBaseCtrl>&>
|
|
468 |
( ClientPane()->ControlList() ) ).Reset();
|
|
469 |
|
|
470 |
// Set case sensitive for the engine
|
|
471 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
472 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
473 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
474 |
|
|
475 |
penData->iRecognizer->SetCaseSensitive( ConfigInfo()->CaseSensitive() );
|
|
476 |
//Set guideline on or off
|
|
477 |
penData->iRecognizer->EnableGuideline( penData->iGuideLineOn == 1? ETrue : EFalse );
|
|
478 |
|
|
479 |
//reset window rect, titlebar rect, client rect
|
|
480 |
TSize szClient( clientLayout->Columns() * unitWidth,
|
|
481 |
clientLayout->Rows() * unitHeight );
|
|
482 |
|
|
483 |
TSize szWnd( clientLayout->Columns() * unitWidth,
|
|
484 |
clientLayout->Rows() * unitHeight + unitHeight );
|
|
485 |
|
|
486 |
TSize szTitle ( clientLayout->Columns() * unitWidth, unitHeight );
|
|
487 |
|
|
488 |
SetWindowRect( TRect(Rect().iTl, szWnd) );
|
|
489 |
|
|
490 |
//setwindowrect may change automactially for shadow or other things
|
|
491 |
TPoint ptTopLeft = Rect().iTl;
|
|
492 |
|
|
493 |
TitleBar()->SetRect( TRect(ptTopLeft, szTitle ) );
|
|
494 |
ClientPane()->SetRect( TRect(ptTopLeft + TPoint(0, unitHeight),
|
|
495 |
szClient) );
|
|
496 |
|
|
497 |
// Get control list from client layout
|
|
498 |
RPointerArray<CPeninputControlInfo>& controlList =
|
|
499 |
clientLayout->ControlInfoList();
|
|
500 |
const TInt count = controlList.Count();
|
|
501 |
TInt controlID = 0;
|
|
502 |
TInt cols = 0;
|
|
503 |
TInt rows = 0;
|
|
504 |
CFepUiBaseCtrl* ctrl = NULL;
|
|
505 |
|
|
506 |
//controls are based on client pane
|
|
507 |
TPoint point = ptTopLeft + TPoint(0, unitHeight);
|
|
508 |
|
|
509 |
for ( TInt i = 0; i < count; i++ )
|
|
510 |
{
|
|
511 |
controlID = controlList[i]->ControlID();
|
|
512 |
ctrl = iCtrlPool->Control( controlID );
|
|
513 |
|
|
514 |
if ( ctrl )
|
|
515 |
{
|
|
516 |
TRect rect;
|
|
517 |
rect.iTl = point
|
|
518 |
+ TPoint( controlList[i]->BeginColumn() * unitWidth,
|
|
519 |
controlList[i]->BeginRow() * unitHeight );
|
|
520 |
cols = controlList[i]->EndColumn()
|
|
521 |
- controlList[i]->BeginColumn();
|
|
522 |
rows = controlList[i]->EndRow()
|
|
523 |
- controlList[i]->BeginRow();
|
|
524 |
rect.SetSize( TSize( cols * unitWidth, rows * unitHeight ) );
|
|
525 |
AddNotOwnedControl( ctrl );
|
|
526 |
|
|
527 |
if ( ( ctrl->ControlType() | ECtrlButton ) == ECtrlButton )
|
|
528 |
{
|
|
529 |
TRect innerRect;
|
|
530 |
AknPenImageUtils::CalculateGraphicRect( rect, innerRect );
|
|
531 |
( static_cast<CAknFepCtrlCommonButton*> ( ctrl ) )->SizeChanged
|
|
532 |
( rect, innerRect, ETrue );
|
|
533 |
}
|
|
534 |
else if ( ctrl->ControlId() == EPeninutWindowCtrlIdRangeBar )
|
|
535 |
{
|
|
536 |
rect = TRect( rect.iTl, TSize( unitWidth, unitHeight ) );
|
|
537 |
( static_cast<CAknFepCtrlRangeBar*> ( ctrl ) )->SizeChanged( rect );
|
|
538 |
}
|
|
539 |
else if ( ctrl->ControlId() == EPeninutWindowCtrlIdHwrBox )
|
|
540 |
{
|
|
541 |
iHwBox->SetRect( rect );
|
|
542 |
DrawGuideLine();
|
|
543 |
}
|
|
544 |
}
|
|
545 |
}
|
|
546 |
}
|
|
547 |
|
|
548 |
// --------------------------------------------------------------------------
|
|
549 |
// CPeninputGenericHwrWindow::CalculateGuideLinePos
|
|
550 |
// (other items were commented in a header)
|
|
551 |
// --------------------------------------------------------------------------
|
|
552 |
//
|
|
553 |
void CPeninputGenericHwrWindow::CalculateGuideLinePos()
|
|
554 |
{
|
|
555 |
TRect rect = iHwBox->Rect();
|
|
556 |
TInt leftrightmargin = rect.Size().iWidth / 10;
|
|
557 |
|
|
558 |
TSize size;
|
|
559 |
size.iHeight = rect.iBr.iY - rect.iTl.iY;
|
|
560 |
size.iWidth = rect.iBr.iX - rect.iTl.iX;
|
|
561 |
iLayoutContext->SetData( EAkninputDataTypeInputArea, &size );
|
|
562 |
|
|
563 |
TInt bottommargin = *(TInt*)iLayoutContext->RequestData( EAkninputDataTypeGuideLineBottom );
|
|
564 |
TInt topmargin = *(TInt*)iLayoutContext->RequestData( EAkninputDataTypeGuideLineTop );
|
|
565 |
|
|
566 |
//TAknWindowLineLayout guideLineTop = AknLayoutScalable_Avkon::fep_hwr_write_pane_g5(0).LayoutLine();
|
|
567 |
//TAknWindowLineLayout guideLineBottom = AknLayoutScalable_Avkon::fep_hwr_write_pane_g6(0).LayoutLine();
|
|
568 |
|
|
569 |
iGuideLineTopTl.iX = rect.iTl.iX + leftrightmargin;
|
|
570 |
iGuideLineTopTl.iY = rect.iTl.iY + topmargin;
|
|
571 |
|
|
572 |
iGuideLineTopBr.iX = rect.iBr.iX - leftrightmargin;
|
|
573 |
iGuideLineTopBr.iY = rect.iTl.iY + topmargin;
|
|
574 |
|
|
575 |
iGuideLineBottomTl.iX = rect.iTl.iX + leftrightmargin;
|
|
576 |
iGuideLineBottomTl.iY = rect.iTl.iY + bottommargin;
|
|
577 |
|
|
578 |
iGuideLineBottomBr.iX = rect.iBr.iX - leftrightmargin;
|
|
579 |
iGuideLineBottomBr.iY = rect.iTl.iY + bottommargin;
|
|
580 |
|
|
581 |
iGuideLineSet = ETrue;
|
|
582 |
}
|
|
583 |
|
|
584 |
// --------------------------------------------------------------------------
|
|
585 |
// CPeninputGenericHwrWindow::DrawGuideLine
|
|
586 |
// (other items were commented in a header)
|
|
587 |
// --------------------------------------------------------------------------
|
|
588 |
//
|
|
589 |
void CPeninputGenericHwrWindow::DrawGuideLine()
|
|
590 |
{
|
|
591 |
// Set guide line
|
|
592 |
if ( ConfigInfo() )
|
|
593 |
{
|
|
594 |
TInt style = ConfigInfo()->GuideLine();
|
|
595 |
|
|
596 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
597 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
598 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
599 |
|
|
600 |
TInt language = penData->iRecognizer->GetLanguage();
|
|
601 |
|
|
602 |
TInt curRange = CPeninputDataConverter::AnyToInt
|
|
603 |
( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
|
|
604 |
|
|
605 |
if(language == ELangHindi && curRange == ERangeNative)
|
|
606 |
style = EPeninputGuideLineTop;
|
|
607 |
|
|
608 |
iHwBox->SetGuideLineStyle( style );
|
|
609 |
|
|
610 |
// if size changing, or guide line pos has not been set
|
|
611 |
CalculateGuideLinePos();
|
|
612 |
|
|
613 |
if ( style == EPeninputGuideLineTop)
|
|
614 |
{
|
|
615 |
iHwBox->SetTopGuideLinePosition(iGuideLineTopTl, iGuideLineTopBr);
|
|
616 |
}
|
|
617 |
else if ( style == EPeninputGuideLineBottom)
|
|
618 |
{
|
|
619 |
iHwBox->SetBottomGuideLinePosition(iGuideLineBottomTl, iGuideLineBottomBr);
|
|
620 |
}
|
|
621 |
else if ( style == EPeninputGuideLineBoth)
|
|
622 |
{
|
|
623 |
iHwBox->SetTopGuideLinePosition(iGuideLineTopTl, iGuideLineTopBr);
|
|
624 |
iHwBox->SetBottomGuideLinePosition(iGuideLineBottomTl, iGuideLineBottomBr);
|
|
625 |
}
|
|
626 |
|
|
627 |
iHwBox->RefreshUI();
|
|
628 |
}
|
|
629 |
}
|
|
630 |
// --------------------------------------------------------------------------
|
|
631 |
// CPeninputGenericHwrWindow::SetControlsFont
|
|
632 |
// (other items were commented in a header)
|
|
633 |
// --------------------------------------------------------------------------
|
|
634 |
//
|
|
635 |
void CPeninputGenericHwrWindow::SetControlsFont()
|
|
636 |
{
|
|
637 |
TAknTextLineLayout textPaneTextLayout;
|
|
638 |
TAknLayoutText txt;
|
|
639 |
textPaneTextLayout =
|
|
640 |
AknLayoutScalable_Avkon::fep_hwr_top_text_pane_t1().LayoutLine();
|
|
641 |
|
|
642 |
TInt leftMargin, rightMargin, topMargin, txtHeight;
|
|
643 |
|
|
644 |
CFepLayoutMultiLineIcf* icf = static_cast<CFepLayoutMultiLineIcf*>
|
|
645 |
(Control(EPeninputWindowCtrlIdMultiLineICF));
|
|
646 |
TRect rect = icf->Rect();
|
|
647 |
txt.LayoutText( rect, textPaneTextLayout );
|
|
648 |
TRect txtRect = txt.TextRect();
|
|
649 |
leftMargin = txtRect.iTl.iX - rect.iTl.iX;
|
|
650 |
rightMargin = rect.iBr.iX - txtRect.iBr.iX;
|
|
651 |
topMargin = txtRect.iTl.iY - rect.iTl.iY;
|
|
652 |
txtHeight = txtRect.Height();
|
|
653 |
|
|
654 |
icf->SetTextMargin( leftMargin, rightMargin, topMargin, 0);
|
|
655 |
icf->SetLineSpace( 1 );
|
|
656 |
const CFont* icfFont = AknLayoutUtils::FontFromId( textPaneTextLayout.iFont, NULL );
|
|
657 |
|
|
658 |
TRAP_IGNORE(icf->SizeChangedL(
|
|
659 |
static_cast<CFepLayoutMultiLineIcf*>(
|
|
660 |
Control(EPeninputWindowCtrlIdMultiLineICF))->Rect(),
|
|
661 |
txtHeight,
|
|
662 |
icfFont->FontMaxHeight(),
|
|
663 |
icfFont));
|
|
664 |
}
|
|
665 |
|
|
666 |
// --------------------------------------------------------------------------
|
|
667 |
// CPeninputGenericHwrWindow::AddRangeBarL
|
|
668 |
// (other items were commented in a header)
|
|
669 |
// --------------------------------------------------------------------------
|
|
670 |
//
|
|
671 |
void CPeninputGenericHwrWindow::AddRangeBarL()
|
|
672 |
{
|
|
673 |
// Range bar
|
|
674 |
iRangeBar = CAknFepCtrlRangeBar::NewL( UiLayout(),
|
|
675 |
EPeninutWindowCtrlIdRangeBar,
|
|
676 |
CAknFepCtrlRangeBar::EBtnGroupVertical );
|
|
677 |
|
|
678 |
// Set event id
|
|
679 |
iRangeBar->SetEventIdForRange( EPeninputLayoutEventRange );
|
|
680 |
iRangeBar->SetEventIdForCase( EPeninputLayoutEventRangeLoop );
|
|
681 |
iCtrlPool->AddControl( iRangeBar );
|
|
682 |
}
|
|
683 |
|
|
684 |
// --------------------------------------------------------------------------
|
|
685 |
// CPeninputGenericHwrWindow::AddButtonL
|
|
686 |
// (other items were commented in a header)
|
|
687 |
// --------------------------------------------------------------------------
|
|
688 |
//
|
|
689 |
CAknFepCtrlEventButton* CPeninputGenericHwrWindow::AddButtonL(
|
|
690 |
const TInt aControlId, const TInt aEventId, const TInt aResId,
|
|
691 |
const TInt aUnicode, const TBool aIsRepeat )
|
|
692 |
{
|
|
693 |
CAknFepCtrlEventButton* button = NULL;
|
|
694 |
|
|
695 |
if ( aIsRepeat )
|
|
696 |
{
|
|
697 |
button = CAknFepCtrlRepeatButton::NewL( UiLayout(), aControlId,
|
|
698 |
aEventId, aUnicode );
|
|
699 |
}
|
|
700 |
else
|
|
701 |
{
|
|
702 |
button = CAknFepCtrlEventButton::NewL( UiLayout(), aControlId,
|
|
703 |
aEventId, aUnicode,
|
|
704 |
KAknsIIDQsnFrFunctionButtonNormal,
|
|
705 |
KAknsIIDQsnFrFunctionButtonPressed,
|
|
706 |
KAknsIIDQsnFrFunctionButtonInactive );
|
|
707 |
}
|
|
708 |
|
|
709 |
CleanupStack::PushL( button );
|
|
710 |
if ( button )
|
|
711 |
{
|
|
712 |
// Read resource
|
|
713 |
TResourceReader reader;
|
|
714 |
|
|
715 |
CCoeEnv::Static()->CreateResourceReaderLC( reader, aResId );
|
|
716 |
button->SetResourceId( aResId );
|
|
717 |
button->ConstructFromResourceL();
|
|
718 |
// Pop and destroy reader
|
|
719 |
CleanupStack::PopAndDestroy( 1 );
|
|
720 |
|
|
721 |
// Add into the control pool
|
|
722 |
if ( iCtrlPool )
|
|
723 |
{
|
|
724 |
iCtrlPool->AddControl( button );
|
|
725 |
}
|
|
726 |
}
|
|
727 |
CleanupStack::Pop( button );
|
|
728 |
|
|
729 |
return button;
|
|
730 |
}
|
|
731 |
|
|
732 |
// --------------------------------------------------------------------------
|
|
733 |
// CPeninputGenericHwrWindow::AddHwBoxL
|
|
734 |
// (other items were commented in a header)
|
|
735 |
// --------------------------------------------------------------------------
|
|
736 |
//
|
|
737 |
void CPeninputGenericHwrWindow::AddHwBoxL()
|
|
738 |
{
|
|
739 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
740 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
741 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
742 |
|
|
743 |
iHwBox = CTransparentHwrWndExt::NewL( TRect(), UiLayout(),
|
|
744 |
EPeninutWindowCtrlIdHwrBox,
|
|
745 |
EFalse, penData->iGuideLineOn );
|
|
746 |
iHwBox->SetEnableFade( ETrue );
|
|
747 |
iHwBox->EnableTraceOutsideWindow( EFalse );
|
|
748 |
iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
|
|
749 |
|
|
750 |
if ( iCtrlPool )
|
|
751 |
{
|
|
752 |
iCtrlPool->AddControl( iHwBox );
|
|
753 |
}
|
|
754 |
|
|
755 |
SetHwBoxFrameBackColor();
|
|
756 |
}
|
|
757 |
|
|
758 |
// --------------------------------------------------------------------------
|
|
759 |
// CPeninputGenericHwrWindow::SetHwBoxFrameBackColor
|
|
760 |
// (other items were commented in a header)
|
|
761 |
// --------------------------------------------------------------------------
|
|
762 |
//
|
|
763 |
void CPeninputGenericHwrWindow::SetHwBoxFrameBackColor()
|
|
764 |
{
|
|
765 |
TRgb frameColor;
|
|
766 |
TRgb backColor;
|
|
767 |
TAknsItemID id;
|
|
768 |
|
|
769 |
id.Set(KWriteBoxFrameBackColorMajor, KWriteBoxFrameBackColorGrp);
|
|
770 |
|
|
771 |
TInt error = AknsUtils::GetCachedColor(UiLayout()->SkinInstance(),
|
|
772 |
frameColor,
|
|
773 |
id,
|
|
774 |
KWriteBoxFrameBackColorIdx);
|
|
775 |
|
|
776 |
if (error != KErrNone)
|
|
777 |
{
|
|
778 |
frameColor = TRgb(KDefaultWriteBoxFrameColor);
|
|
779 |
backColor = TRgb(KDefaultWriteBoxBackColor);
|
|
780 |
}
|
|
781 |
else
|
|
782 |
{
|
|
783 |
backColor = frameColor;
|
|
784 |
}
|
|
785 |
|
|
786 |
if (iHwBox)
|
|
787 |
{
|
|
788 |
iHwBox->SetFrameCol(frameColor);
|
|
789 |
iHwBox->SetBkColor(backColor);
|
|
790 |
}
|
|
791 |
}
|
|
792 |
|
|
793 |
// --------------------------------------------------------------------------
|
|
794 |
// CPeninputGenericHwrWindow::PopupChoiceList
|
|
795 |
// (other items were commented in a header)
|
|
796 |
// --------------------------------------------------------------------------
|
|
797 |
//
|
|
798 |
void CPeninputGenericHwrWindow::PopupChoiceList()
|
|
799 |
{
|
|
800 |
}
|
|
801 |
|
|
802 |
// --------------------------------------------------------------------------
|
|
803 |
// CPeninputGenericHwrWindow::DoCaseChange
|
|
804 |
// (other items were commented in a header)
|
|
805 |
// --------------------------------------------------------------------------
|
|
806 |
//
|
|
807 |
void CPeninputGenericHwrWindow::DoCaseChange( TInt aNewCase )
|
|
808 |
{
|
|
809 |
if( iDisableCaseChange )
|
|
810 |
{
|
|
811 |
iCachedCase = aNewCase;
|
|
812 |
return;
|
|
813 |
}
|
|
814 |
|
|
815 |
TInt curRange = CPeninputDataConverter::AnyToInt
|
|
816 |
( iLayoutContext->RequestData( EPeninputDataTypeCurrentRange ) );
|
|
817 |
TInt index = 0;
|
|
818 |
|
|
819 |
if ( ( curRange == ERangeEnglish )
|
|
820 |
|| ( ( curRange == ERangeNative ) && ( ConfigInfo()->CaseSensitive() ) ) )
|
|
821 |
{
|
|
822 |
switch ( aNewCase )
|
|
823 |
{
|
|
824 |
case ECaseUpper:
|
|
825 |
{
|
|
826 |
index = 2;
|
|
827 |
}
|
|
828 |
break;
|
|
829 |
case ECaseLower:
|
|
830 |
{
|
|
831 |
index = 1;
|
|
832 |
}
|
|
833 |
break;
|
|
834 |
case ECaseText:
|
|
835 |
{
|
|
836 |
index = 0;
|
|
837 |
}
|
|
838 |
break;
|
|
839 |
default:
|
|
840 |
break;
|
|
841 |
}
|
|
842 |
|
|
843 |
TRAP_IGNORE( iRangeBar->SetCaseL( curRange, index ) );
|
|
844 |
iLayoutContext->SetData( EPeninputDataTypeCase, &aNewCase );
|
|
845 |
}
|
|
846 |
//to modify guideline pos.
|
|
847 |
iHwBox->RefreshUI();
|
|
848 |
DrawGuideLine();
|
|
849 |
}
|
|
850 |
|
|
851 |
// --------------------------------------------------------------------------
|
|
852 |
// CPeninputGenericHwrWindow::OnStrokeStarted
|
|
853 |
// (other items were commented in a header)
|
|
854 |
// --------------------------------------------------------------------------
|
|
855 |
//
|
|
856 |
void CPeninputGenericHwrWindow::OnStrokeStarted()
|
|
857 |
{
|
|
858 |
iDisableCaseChange = ETrue;
|
|
859 |
iHwBox->SetWndTransparencyFactor(iWriteTransFactor);
|
|
860 |
|
|
861 |
if( !iCharacterStart )
|
|
862 |
{
|
|
863 |
iCharacterStart = ETrue;
|
|
864 |
|
|
865 |
TBuf<4> buf;
|
|
866 |
buf.Append(reinterpret_cast<TText*>(&iCharacterStart), sizeof(TBool)/sizeof(TText));
|
|
867 |
iLayoutContext->Sendkey( ESignalCharacterStart, buf );
|
|
868 |
|
|
869 |
}
|
|
870 |
}
|
|
871 |
|
|
872 |
// --------------------------------------------------------------------------
|
|
873 |
// CPeninputGenericHwrWindow::OnStrokeFinished
|
|
874 |
// (other items were commented in a header)
|
|
875 |
// --------------------------------------------------------------------------
|
|
876 |
//
|
|
877 |
void CPeninputGenericHwrWindow::OnStrokeFinished()
|
|
878 |
{
|
|
879 |
// No trace
|
|
880 |
if ( !iHwBox->HasNewTrace() )
|
|
881 |
{
|
|
882 |
return;
|
|
883 |
}
|
|
884 |
|
|
885 |
RArray<TPoint> strokes = iHwBox->StrokeList();
|
|
886 |
|
|
887 |
iStrokeArray.Reset();
|
|
888 |
|
|
889 |
const TInt count = strokes.Count();
|
|
890 |
|
|
891 |
#ifdef _NOT_USING_DECUMA_MCR_
|
|
892 |
// similar as S90
|
|
893 |
|
|
894 |
for ( TInt i = 0; i < count; i++ )
|
|
895 |
{
|
|
896 |
iStrokeArray.Append( strokes[i] );
|
|
897 |
}
|
|
898 |
|
|
899 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
900 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
901 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
902 |
|
|
903 |
TInt err = penData->iRecognizer->Recognize( iStrokeArray, iRecogResult );
|
|
904 |
|
|
905 |
if ( err == KErrNone && iRecogResult.Count() > 0 )
|
|
906 |
{
|
|
907 |
SubmitRecognitionResult( iRecogResult[0] );
|
|
908 |
}
|
|
909 |
#else
|
|
910 |
|
|
911 |
for ( TInt i = 0; i < count; i++ )
|
|
912 |
{
|
|
913 |
iStrokeArray.Append( strokes[i] );
|
|
914 |
}
|
|
915 |
|
|
916 |
#endif
|
|
917 |
|
|
918 |
}
|
|
919 |
|
|
920 |
// --------------------------------------------------------------------------
|
|
921 |
// CPeninputGenericHwrWindow::OnStrokeCharacterTimerOut
|
|
922 |
// (other items were commented in a header)
|
|
923 |
// --------------------------------------------------------------------------
|
|
924 |
//
|
|
925 |
void CPeninputGenericHwrWindow::OnStrokeCharacterTimerOut()
|
|
926 |
{
|
|
927 |
iDisableCaseChange = EFalse;
|
|
928 |
DoCaseChange(iCachedCase);
|
|
929 |
iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
|
|
930 |
#ifdef _NOT_USING_DECUMA_MCR_
|
|
931 |
// similar as S90
|
|
932 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
933 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
934 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
935 |
|
|
936 |
TInt language = penData->iRecognizer->GetLanguage();
|
|
937 |
if( language == ELangThai || language == ELangHindi || language == ELangVietnamese )
|
|
938 |
{
|
|
939 |
// This is a workarround to clear the recognizer.
|
|
940 |
RArray<TPoint> stroke_array;
|
|
941 |
stroke_array.Reset();
|
|
942 |
// Call recognize with a empty array of stroke is the condition
|
|
943 |
// to clear the context>
|
|
944 |
TInt err = penData->iRecognizer->Recognize( stroke_array, iRecogResult );
|
|
945 |
if( err == KErrNone && iRecogResult.Count() > 0 )
|
|
946 |
{
|
|
947 |
SubmitRecognitionResult( iRecogResult[0] );
|
|
948 |
}
|
|
949 |
}
|
|
950 |
|
|
951 |
delete iLastResult;
|
|
952 |
iLastResult = NULL;
|
|
953 |
|
|
954 |
#else
|
|
955 |
|
|
956 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
957 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
958 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
959 |
|
|
960 |
TInt err = penData->iRecognizer->Recognize( iStrokeArray, iRecogResult );
|
|
961 |
if ( err == KErrNone && iRecogResult.Count() > 0 )
|
|
962 |
{
|
|
963 |
const HBufC* res = iRecogResult[0];
|
|
964 |
iLayoutContext->Sendkey( ESignalKeyEvent, *res );
|
|
965 |
}
|
|
966 |
iStrokeArray.Reset();
|
|
967 |
|
|
968 |
#endif
|
|
969 |
|
|
970 |
|
|
971 |
iCharacterStart = EFalse;
|
|
972 |
}
|
|
973 |
|
|
974 |
// --------------------------------------------------------------------------
|
|
975 |
// CPeninputGenericHwrWindow::OnStrokeCanceled
|
|
976 |
// (other items were commented in a header)
|
|
977 |
// --------------------------------------------------------------------------
|
|
978 |
//
|
|
979 |
void CPeninputGenericHwrWindow::OnStrokeCanceled()
|
|
980 |
{
|
|
981 |
iDisableCaseChange = EFalse;
|
|
982 |
iHwBox->SetWndTransparencyFactor(iNormalTransFactor);
|
|
983 |
#ifdef _NOT_USING_DECUMA_MCR_
|
|
984 |
// similar as S90
|
|
985 |
CPeninputGenericHwrDataMgr::THandWritingPenData* penData =
|
|
986 |
( CPeninputGenericHwrDataMgr::THandWritingPenData* )
|
|
987 |
iLayoutContext->RequestData( EPeninputDataTypeReserve_1 );
|
|
988 |
|
|
989 |
TInt language = penData->iRecognizer->GetLanguage();
|
|
990 |
if( language == ELangThai || language == ELangHindi || language == ELangVietnamese )
|
|
991 |
{
|
|
992 |
// This is a workarround to clear the recognizer.
|
|
993 |
RArray<TPoint> stroke_array;
|
|
994 |
stroke_array.Reset();
|
|
995 |
// Call recognize with a empty array of stroke is the condition
|
|
996 |
// to clear the context>
|
|
997 |
TInt err = penData->iRecognizer->Recognize( stroke_array, iRecogResult );
|
|
998 |
// if( err == KErrNone && iRecogResult.Count() > 0 )
|
|
999 |
// {
|
|
1000 |
// SubmitRecognitionResult( iRecogResult[0] );
|
|
1001 |
// }
|
|
1002 |
}
|
|
1003 |
|
|
1004 |
delete iLastResult;
|
|
1005 |
iLastResult = NULL;
|
|
1006 |
|
|
1007 |
|
|
1008 |
|
|
1009 |
#endif
|
|
1010 |
|
|
1011 |
iCharacterStart = EFalse;
|
|
1012 |
}
|
|
1013 |
|
|
1014 |
// -----------------------------------------------------------------------------
|
|
1015 |
// CPeninputGenericHwrWindow::ConstructFromResourceL
|
|
1016 |
// (other items were commented in a header).
|
|
1017 |
// -----------------------------------------------------------------------------
|
|
1018 |
//
|
|
1019 |
void CPeninputGenericHwrWindow::ConstructFromResourceL()
|
|
1020 |
{
|
|
1021 |
CPeninputLayoutWindow::ConstructFromResourceL();
|
|
1022 |
|
|
1023 |
if (iLangSwitchBtn)
|
|
1024 |
{
|
|
1025 |
SetSwitchBtnTextColor(*iLangSwitchBtn);
|
|
1026 |
}
|
|
1027 |
|
|
1028 |
SetHwBoxFrameBackColor();
|
|
1029 |
|
|
1030 |
TRgb* iPenColor =
|
|
1031 |
( TRgb* ) iLayoutContext->RequestData(EPeninputDataTypePenTailColor);
|
|
1032 |
if (iHwBox)
|
|
1033 |
{
|
|
1034 |
iHwBox->SetPenColor( *iPenColor);
|
|
1035 |
}
|
|
1036 |
|
|
1037 |
}
|
|
1038 |
|
|
1039 |
// ---------------------------------------------------------------------------
|
|
1040 |
// CPeninputGenericHwrWindow::PopupSwitchWindow
|
|
1041 |
// (other items were commented in a header).
|
|
1042 |
// ---------------------------------------------------------------------------
|
|
1043 |
//
|
|
1044 |
void CPeninputGenericHwrWindow::PopupSwitchWindow()
|
|
1045 |
{
|
|
1046 |
CFepUiBaseCtrl* modeSwitchBtn = Control(EPeninutWindowCtrlIdSwitchToVkbBtn);
|
|
1047 |
|
|
1048 |
if ( modeSwitchBtn )
|
|
1049 |
{
|
|
1050 |
TRect rect = modeSwitchBtn->Rect();
|
|
1051 |
TRAP_IGNORE(iModeSwitchChoice->PopUpSwitchListL(rect));
|
|
1052 |
}
|
|
1053 |
}
|
|
1054 |
// ---------------------------------------------------------------------------
|
|
1055 |
// CPeninputGenericHwrWindow::OnDeActivate
|
|
1056 |
// (other items were commented in a header).
|
|
1057 |
// ---------------------------------------------------------------------------
|
|
1058 |
//
|
|
1059 |
void CPeninputGenericHwrWindow::OnDeActivate()
|
|
1060 |
{
|
|
1061 |
//reset range
|
|
1062 |
TInt range = -1;
|
|
1063 |
iLayoutContext->SetData( EPeninputDataTypeCurrentRange, &range );
|
|
1064 |
CPeninputLayoutWindow::OnDeActivate();
|
|
1065 |
}
|
|
1066 |
|
|
1067 |
|
|
1068 |
TBool CPeninputGenericHwrWindow::IsMultiLineIcf()
|
|
1069 |
{
|
|
1070 |
return ETrue;
|
|
1071 |
}
|
|
1072 |
|
|
1073 |
TBool CPeninputGenericHwrWindow::IsCanChangeRange(TInt aRange)
|
|
1074 |
{
|
|
1075 |
if (aRange == ERangeSymbol)
|
|
1076 |
{
|
|
1077 |
UiLayout()->SignalOwner(ESignalLaunchSCT);
|
|
1078 |
|
|
1079 |
return EFalse;
|
|
1080 |
}
|
|
1081 |
|
|
1082 |
return ETrue;
|
|
1083 |
}
|
|
1084 |
|
|
1085 |
void CPeninputGenericHwrWindow::ChangeToPreviousRange(TInt aRange)
|
|
1086 |
{
|
|
1087 |
if(iRangeBar)
|
|
1088 |
{
|
|
1089 |
iRangeBar->ActiveRange(aRange);
|
|
1090 |
}
|
|
1091 |
}
|
|
1092 |
|
|
1093 |
inline TBool IsLanguageBidi( TInt aLanguage )
|
|
1094 |
{
|
|
1095 |
return aLanguage == ELangArabic || aLanguage == ELangFarsi ||
|
|
1096 |
aLanguage == ELangHebrew ;
|
|
1097 |
}
|
|
1098 |
void CPeninputGenericHwrWindow::OnLanguageChange()
|
|
1099 |
{
|
|
1100 |
TBool bidi = IsLanguageBidi( ConfigInfo()->Language() );
|
|
1101 |
iHwBox->SetEnableFade( !bidi );
|
|
1102 |
}
|
|
1103 |
|
|
1104 |
void CPeninputGenericHwrWindow::SubmitRecognitionResult(HBufC* aRes )
|
|
1105 |
{
|
|
1106 |
if( !iLastResult )
|
|
1107 |
{
|
|
1108 |
iLayoutContext->Sendkey( ESignalKeyEvent, *aRes );
|
|
1109 |
}
|
|
1110 |
else
|
|
1111 |
{
|
|
1112 |
if( iLastResult->Compare( *aRes ) != 0 )
|
|
1113 |
{
|
|
1114 |
//replace
|
|
1115 |
if ( ( *aRes ).Locate( EKeyBackspace ) != KErrNotFound )
|
|
1116 |
{
|
|
1117 |
TBuf<1> buf;
|
|
1118 |
buf.Append( EKeyBackspace );
|
|
1119 |
iLayoutContext->Sendkey( ESignalKeyEvent, buf );
|
|
1120 |
}
|
|
1121 |
else
|
|
1122 |
{
|
|
1123 |
HBufC* p = HBufC::New(aRes->Length() + 2);
|
|
1124 |
if( p )
|
|
1125 |
{
|
|
1126 |
TInt len = iLastResult->Length();
|
|
1127 |
p->Des().Append((TUint16*)&len, 2);
|
|
1128 |
p->Des().Append(*aRes);
|
|
1129 |
iLayoutContext->Sendkey( ESignalReplaceText, *p );
|
|
1130 |
delete p;
|
|
1131 |
}
|
|
1132 |
}
|
|
1133 |
}
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
delete iLastResult;
|
|
1137 |
iLastResult = NULL;
|
|
1138 |
|
|
1139 |
if ( (*aRes).Locate( EKeyBackspace ) != KErrNotFound ||
|
|
1140 |
aRes->Length() >= 50 )
|
|
1141 |
{
|
|
1142 |
iHwBox->CancelCharWriting();
|
|
1143 |
}
|
|
1144 |
else
|
|
1145 |
{
|
|
1146 |
iLastResult = aRes->Alloc();
|
|
1147 |
}
|
|
1148 |
}
|
|
1149 |
void CPeninputGenericHwrWindow::Move(const TPoint& aOffset)
|
|
1150 |
{
|
|
1151 |
CPeninputLayoutWindow::Move(aOffset);
|
|
1152 |
DrawGuideLine();
|
|
1153 |
}
|