|
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: CknFepHwrBxLayout |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <bautils.h> |
|
19 #include <peninputcmd.h> |
|
20 #include <peninputlayoutbutton.h> |
|
21 #include <peninputdropdownlist.h> |
|
22 #include <peninputhwrbxcn.rsg> |
|
23 #include <aknfeppeninputenums.h> |
|
24 #include <AknFepGlobalEnums.h> |
|
25 #include <peninputlayoutbutton.h> |
|
26 #include <AknUtils.h> |
|
27 #include <peninputdragbutton.h> |
|
28 #include <coemain.h> |
|
29 #include <peninputlayoutchoicelist.h> |
|
30 |
|
31 #include "peninputhwrbxlayout.h" |
|
32 #include "peninputhwrctrlid.h" |
|
33 #include "peninputhwrbxwnd.h" |
|
34 #include "peninputhwrbxstate.h" |
|
35 #include "peninputhwrevent.h" |
|
36 #include "peninputhwrbxdatastore.h" |
|
37 #include "aknlayoutscalable_avkon.cdl.h" |
|
38 |
|
39 _LIT(KResourceFile, "z:\\resource\\peninputhwrbxcn.rsc"); |
|
40 |
|
41 const TInt KUpperCaseIndex = 0; |
|
42 const TInt KLowerCaseIndex = 1; |
|
43 const TInt KTextCaseIndex = 2; |
|
44 const TInt KRepInitBrX = 0; |
|
45 const TInt KRepInitBrY = 0; |
|
46 |
|
47 |
|
48 // --------------------------------------------------------- |
|
49 // Constructor |
|
50 // --------------------------------------------------------- |
|
51 // |
|
52 CAknFepHwrBxLayoutImp* CAknFepHwrBxLayoutImp::NewL( TAny* /*aInitParams*/ ) |
|
53 { |
|
54 CAknFepHwrBxLayoutImp* self = new(ELeave) CAknFepHwrBxLayoutImp(); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop(self); |
|
58 |
|
59 return self; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------- |
|
63 // Destructor |
|
64 // --------------------------------------------------------- |
|
65 // |
|
66 CAknFepHwrBxLayoutImp::~CAknFepHwrBxLayoutImp() |
|
67 { |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // Constructor |
|
72 // --------------------------------------------------------- |
|
73 // |
|
74 CAknFepHwrBxLayoutImp::CAknFepHwrBxLayoutImp() |
|
75 { |
|
76 // See ConstructL() for initialisation completion. |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // Constructor |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 void CAknFepHwrBxLayoutImp::ConstructL() |
|
84 { |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // Implementation of CFepUiLayoutInterface |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 MPenUiLayoutBase* CAknFepHwrBxLayoutImp::CreateFepUiLayoutL(MLayoutOwner* aLayoutOwner, |
|
92 const TAny* aData) |
|
93 { |
|
94 CAknFepHwrBxLayout* uiLayout = CAknFepHwrBxLayout::NewL( aLayoutOwner, aData ); |
|
95 |
|
96 return uiLayout; |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------- |
|
100 // Constructor |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 CAknFepHwrBxLayout* CAknFepHwrBxLayout::NewL(MLayoutOwner* aLayoutOwner, const TAny* aInitData) |
|
104 { |
|
105 CAknFepHwrBxLayout* self = new (ELeave) CAknFepHwrBxLayout(aLayoutOwner); |
|
106 |
|
107 CleanupStack::PushL(self); |
|
108 self->ConstructL(aInitData); |
|
109 CleanupStack::Pop(self); |
|
110 |
|
111 return self; |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // Constructor |
|
116 // --------------------------------------------------------- |
|
117 // |
|
118 CAknFepHwrBxLayout::CAknFepHwrBxLayout(MLayoutOwner* aLayoutOwner) |
|
119 : CFepUiLayout(aLayoutOwner) |
|
120 { |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // Constructor |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 void CAknFepHwrBxLayout::ConstructL(const TAny* aInitData) |
|
128 { |
|
129 BaseConstructL(); |
|
130 |
|
131 //ignore aInitData, for later use |
|
132 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
133 TPixelsTwipsAndRotation ptSize; |
|
134 coeEnv->ScreenDevice()->GetDefaultScreenSizeAndRotation(ptSize); |
|
135 |
|
136 SetScreenSize(ptSize.iPixelSize); |
|
137 |
|
138 //iLafEnv->CreateLafEnvL(*ptSize); |
|
139 |
|
140 iResId = coeEnv->AddResourceFileL(KResourceFile); |
|
141 |
|
142 //create date store must before create UI because of property subscriber |
|
143 TPeninputLayoutData* layoutData = (TPeninputLayoutData*)aInitData; |
|
144 |
|
145 iDataStore = CAknFepHwrBxDataStore::NewL((*layoutData).iPtiEngine); |
|
146 |
|
147 TBool boxWndLandscape; |
|
148 |
|
149 //set proper screen style for box window |
|
150 if (ptSize.iPixelSize.iWidth < ptSize.iPixelSize.iHeight) |
|
151 { |
|
152 // protrait screen |
|
153 boxWndLandscape = EFalse; |
|
154 } |
|
155 else |
|
156 { |
|
157 // landscape screen |
|
158 boxWndLandscape = ETrue; |
|
159 } |
|
160 |
|
161 //create window UI |
|
162 iBxWindow = CAknFepHwrBxWnd::NewL(this, EHwrCtrlIdHwrWindow, boxWndLandscape); |
|
163 iBxWindow->SetResourceId(R_AKN_FEP_HWR_WINDOW); |
|
164 iBxWindow->ConstructFromResourceL(); |
|
165 |
|
166 iDataStore->SetScreenMode(ptSize); |
|
167 iDataStore->LoadAndPublishDefaultL(); |
|
168 |
|
169 //set propery size |
|
170 //iDataStore->SetSizeChanging(ETrue); |
|
171 iBxWindow->SizeChanged(boxWndLandscape); |
|
172 //iDataStore->SetSizeChanging(EFalse); |
|
173 |
|
174 AddControlL(iBxWindow); |
|
175 EnableLayoutMoving(static_cast<CDragBar*>(iBxWindow->MoveButton())); |
|
176 |
|
177 //set current state |
|
178 CAknFepHwrBxStateBase * state = CAknFepHwrBxStateInit::NewLC(this); |
|
179 SetCurrentStateL(state); |
|
180 CleanupStack::Pop(state); |
|
181 |
|
182 ResetLayoutRectL(); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------- |
|
186 // Destructor |
|
187 // --------------------------------------------------------- |
|
188 // |
|
189 CAknFepHwrBxLayout::~CAknFepHwrBxLayout() |
|
190 { |
|
191 delete iDataStore; |
|
192 CCoeEnv::Static()->DeleteResourceFile(iResId); |
|
193 delete iCurrentState; |
|
194 } |
|
195 |
|
196 // --------------------------------------------------------- |
|
197 // Set current state |
|
198 // --------------------------------------------------------- |
|
199 // |
|
200 void CAknFepHwrBxLayout::SetCurrentStateL(CAknFepHwrBxStateBase* aState) |
|
201 { |
|
202 if (iCurrentState) |
|
203 { |
|
204 iCurrentState->OnExit(); |
|
205 |
|
206 delete iCurrentState; |
|
207 iCurrentState = NULL; |
|
208 } |
|
209 |
|
210 if (aState) |
|
211 { |
|
212 aState->OnEntry(); |
|
213 } |
|
214 |
|
215 iCurrentState = aState; |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------- |
|
219 // Open option menu |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 void CAknFepHwrBxLayout::OpenOptionMenu() |
|
223 { |
|
224 SignalOwner(ESignalLaunchOptionMenu); |
|
225 } |
|
226 |
|
227 // --------------------------------------------------------- |
|
228 // Open lang switch menu |
|
229 // --------------------------------------------------------- |
|
230 // |
|
231 void CAknFepHwrBxLayout::OpenLangSwitchMenu() |
|
232 { |
|
233 SignalOwner(ESignalLaunchLanguageMenu); |
|
234 } |
|
235 |
|
236 // --------------------------------------------------------- |
|
237 // Handle command from both Fep & internal |
|
238 // --------------------------------------------------------- |
|
239 // |
|
240 TInt CAknFepHwrBxLayout::HandleCommand(TInt aCmd, TUint8* aData) |
|
241 { |
|
242 TInt ret = KErrNone; |
|
243 |
|
244 switch ( aCmd ) |
|
245 { |
|
246 case ECmdPenInputEditorNumericKeyMap: |
|
247 iDataStore->SetNumberMode(*(TAknEditorNumericKeymap*)aData); |
|
248 break; |
|
249 case ECmdPenInputPermittedRange: |
|
250 { |
|
251 const TInt* ranges = (TInt*)aData; |
|
252 iDataStore->SetPermittedRanges(*ranges); |
|
253 } |
|
254 break; |
|
255 case ECmdPenInputPermittedCase: |
|
256 { |
|
257 const TInt* ranges = (TInt*)aData; |
|
258 iDataStore->SetPermittedCases(*ranges); |
|
259 } |
|
260 break; |
|
261 case ECmdPenInputLanguage: |
|
262 { |
|
263 const TInt* language = (TInt*)aData; |
|
264 TRAP_IGNORE(iDataStore->SetLanguageL(*language)); |
|
265 } |
|
266 break; |
|
267 case ECmdPenInputRange: |
|
268 { |
|
269 TInt* range = (TInt*)aData; |
|
270 iDataStore->SetPremaryRange(*range); |
|
271 |
|
272 TBuf<4> buf; |
|
273 buf.Append(reinterpret_cast<TText*>(range), 4); |
|
274 SignalOwner(ESignalRange, buf); |
|
275 } |
|
276 break; |
|
277 case ECmdPenInputCase: |
|
278 { |
|
279 TInt cs = *((TInt*)aData); |
|
280 switch(cs) |
|
281 { |
|
282 case ECaseUpper: |
|
283 cs = KUpperCaseIndex; |
|
284 break; |
|
285 case ECaseLower: |
|
286 cs = KLowerCaseIndex; |
|
287 break; |
|
288 case ECaseText: |
|
289 cs = KTextCaseIndex; |
|
290 break; |
|
291 default: |
|
292 cs = KUpperCaseIndex; |
|
293 break; |
|
294 } |
|
295 iDataStore->SetCase(cs); |
|
296 } |
|
297 break; |
|
298 case ECmdPenInputSetWindowPos: |
|
299 { |
|
300 const TPoint* tl = (TPoint*)aData; |
|
301 const TRect rect = iBxWindow->Rect(); |
|
302 iBxWindow->SetRect(TRect(*tl,TSize(rect.Width(),rect.Height()))); |
|
303 } |
|
304 break; |
|
305 case ECmdPenInputEditorCustomNumericKeyMap: |
|
306 { |
|
307 TInt* len = (TInt*)(aData - 4); |
|
308 TPtrC16 keymapRes((const TUint16*)aData, *len/2); |
|
309 TRAP_IGNORE(iDataStore->SetNumberModeL(keymapRes)); |
|
310 } |
|
311 break; |
|
312 case ECmdPenInputEnableSettingBtn: |
|
313 { |
|
314 iBxWindow->SetEnableSettingBtn(*aData); |
|
315 } |
|
316 break; |
|
317 case ECmdPenInputWindowOpen: |
|
318 { |
|
319 //inform engine about input area size |
|
320 TRect hwrRect = iBxWindow->ClientPane()->Rect(); |
|
321 TSize boxSize(hwrRect.Width()/10*9/2, hwrRect.Height()); |
|
322 //jump to standby state |
|
323 TRAP_IGNORE( GoToStandbyStateL( *aData ) ); |
|
324 iDataStore->SetInputAreaSize(boxSize); |
|
325 TPixelsTwipsAndRotation size; |
|
326 CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(size); |
|
327 TSize wndSize(size.iPixelSize.iWidth,size.iPixelSize.iHeight); |
|
328 iDataStore->SetScreenSize(wndSize); |
|
329 |
|
330 } |
|
331 break; |
|
332 case ECmdPenInputSetTextAlignment: |
|
333 { |
|
334 TRAP_IGNORE(iBxWindow->SetTextAlignmentL( *aData )); |
|
335 } |
|
336 break; |
|
337 default: |
|
338 { |
|
339 ret = CFepUiLayout::HandleCommand( aCmd, aData ); |
|
340 } |
|
341 break; |
|
342 } |
|
343 |
|
344 TRAP_IGNORE(iCurrentState->HandleCommandL(aCmd,aData)); |
|
345 |
|
346 return ret; |
|
347 } |
|
348 |
|
349 // --------------------------------------------------------- |
|
350 // Handle size changed event |
|
351 // --------------------------------------------------------- |
|
352 // |
|
353 TInt CAknFepHwrBxLayout::SizeChanged(const TAny* /*pData*/) |
|
354 { |
|
355 TBool landscapeStyle; |
|
356 TPixelsTwipsAndRotation ptSize; |
|
357 |
|
358 CCoeEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(ptSize); |
|
359 |
|
360 if (ptSize.iPixelSize.iWidth < ptSize.iPixelSize.iHeight) |
|
361 { |
|
362 // protrait screen |
|
363 landscapeStyle = EFalse; |
|
364 } |
|
365 else |
|
366 { |
|
367 // landscape screen |
|
368 landscapeStyle = ETrue; |
|
369 } |
|
370 |
|
371 SetShadowRect(TRect()); |
|
372 iBxWindow->SetShadowRect(TRect()); |
|
373 |
|
374 iDataStore->SetSizeChanging(ETrue); |
|
375 iBxWindow->SizeChanged(landscapeStyle); |
|
376 iDataStore->SetSizeChanging(EFalse); |
|
377 |
|
378 iDataStore->SetScreenMode(ptSize); |
|
379 SetScreenSize(ptSize.iPixelSize); |
|
380 |
|
381 //config layout self |
|
382 TRAP_IGNORE(ResetLayoutRectL()); |
|
383 return KErrNone; |
|
384 } |
|
385 |
|
386 // --------------------------------------------------------- |
|
387 // Handle event from control |
|
388 // --------------------------------------------------------- |
|
389 // |
|
390 void CAknFepHwrBxLayout::HandleControlEvent(TInt aEventType, CFepUiBaseCtrl* aCtrl, |
|
391 const TDesC& aEventData) |
|
392 { |
|
393 TBool handled = EFalse; |
|
394 |
|
395 //translate the button up event into events usable for FSM |
|
396 if (aEventType == EEventButtonUp) |
|
397 { |
|
398 switch (aCtrl->ControlId()) |
|
399 { |
|
400 case EHwrCtrlIdSpace: |
|
401 aEventType = EHwrEventKeySpace; |
|
402 break; |
|
403 case EHwrCtrlIdVkb: |
|
404 aEventType = EHwrEventVkb; |
|
405 break; |
|
406 case EHwrCtrlIdTouchInputOption: |
|
407 aEventType = EHwrEventTouchInputOption; |
|
408 break; |
|
409 default: |
|
410 break; |
|
411 } |
|
412 } |
|
413 |
|
414 if (aEventType == EEventDraggingEnd && iDataStore) |
|
415 { |
|
416 iDataStore->SaveWindowPos(Position() + Rect().Size()); |
|
417 } |
|
418 |
|
419 //filter un-related events |
|
420 if ((aEventType != EEventSetAppCursorSelection) && |
|
421 (aEventType >= EHwrEventLast || aEventType < EHwrEventWindowClose)) |
|
422 { |
|
423 if (aEventType != EEventChoiceSelected) |
|
424 { |
|
425 return; |
|
426 } |
|
427 } |
|
428 |
|
429 if (iCurrentState != NULL && |
|
430 aEventType != EHwrEventVkb && |
|
431 aEventType != EHwrEventSetRange) |
|
432 { |
|
433 TRAP_IGNORE( (handled = iCurrentState->HandleEventL(aEventType, aEventData)) ); |
|
434 } |
|
435 |
|
436 if (!handled) |
|
437 { |
|
438 switch (aEventType) |
|
439 { |
|
440 case EHwrEventInputLangSwitch: |
|
441 OpenLangSwitchMenu(); |
|
442 break; |
|
443 case EHwrEventTouchInputOption: |
|
444 OpenOptionMenu(); |
|
445 break; |
|
446 case EHwrEventVkb: |
|
447 { |
|
448 iBxWindow->CancelWriting(); |
|
449 iBxWindow->PopUpPenInputModeSwitcher(); |
|
450 } |
|
451 break; |
|
452 case EHwrEventSetRange: |
|
453 { |
|
454 CAknFepHwrBxStateBase* state = NULL; |
|
455 TRAP_IGNORE( state = CAknFepHwrBxStateStandby::NewL( this )); |
|
456 TRAP_IGNORE( SetCurrentStateL(state)); |
|
457 |
|
458 TInt range = *(TInt*)aEventData.Ptr(); |
|
459 |
|
460 if ( range == ERangeSymbol ) |
|
461 { |
|
462 SignalOwner(ESignalLaunchSCT); |
|
463 } |
|
464 else |
|
465 { |
|
466 if (iDataStore) |
|
467 { |
|
468 iDataStore->SetPremaryRange(range); |
|
469 iDataStore->SaveRange(range); |
|
470 } |
|
471 TBuf<4> buf; |
|
472 buf.Append(reinterpret_cast<TText*>(&range), 4); |
|
473 SignalOwner(ESignalRange, buf); |
|
474 TRAP_IGNORE(SetLayoutPositionL()); |
|
475 } |
|
476 } |
|
477 break; |
|
478 case EHwrEventSetCase: |
|
479 { |
|
480 const TInt* cs = (TInt*)aEventData.Ptr(); |
|
481 if (iDataStore) |
|
482 { |
|
483 iDataStore->SetCase(*cs); |
|
484 } |
|
485 TInt curCase = ECaseUpper; |
|
486 switch(*cs) |
|
487 { |
|
488 case KUpperCaseIndex: |
|
489 curCase = ECaseUpper; |
|
490 break; |
|
491 case KLowerCaseIndex: |
|
492 curCase = ECaseLower; |
|
493 break; |
|
494 case KTextCaseIndex: |
|
495 curCase = ECaseText; |
|
496 break; |
|
497 default: |
|
498 break; |
|
499 } |
|
500 |
|
501 TBuf<4> buf; |
|
502 buf.Append(reinterpret_cast<TText*>(&curCase), 4); |
|
503 SignalOwner(ESignalCaseMode, buf); |
|
504 } |
|
505 break; |
|
506 case EHwrEventGetNextCandidatePage: |
|
507 { |
|
508 iDataStore->GetNextPredictivePage(); |
|
509 } |
|
510 break; |
|
511 case EHwrEventCandidateExisted: |
|
512 { |
|
513 (iBxWindow->DropdownList())->SetFlagCandidateExist( |
|
514 iDataStore->PredictiveCandidateExisted()); |
|
515 } |
|
516 break; |
|
517 case EHwrEventKeyBack: |
|
518 Delete(); |
|
519 break; |
|
520 case EHwrEventKeySpace: |
|
521 { |
|
522 if ( !( iDataStore->IsNumberOnly() ) ) |
|
523 { |
|
524 TBuf<1> buf; |
|
525 buf.Append( EKeySpace ); |
|
526 SignalOwner(ESignalKeyEvent, buf); |
|
527 } |
|
528 } |
|
529 break; |
|
530 case EHwrEventWindowClose: |
|
531 SignalOwner(ESignalLayoutClosed); |
|
532 break; |
|
533 case EEventChoiceSelected: |
|
534 { |
|
535 CFepLayoutChoiceList::SEvent* event = |
|
536 (CFepLayoutChoiceList::SEvent*)aEventData.Ptr(); |
|
537 if( event->iIndex != -1 ) |
|
538 { |
|
539 TBool switchByMode = ETrue; |
|
540 TInt mode = event->iCommand; |
|
541 |
|
542 TBuf<8> buf; |
|
543 buf.Append(reinterpret_cast<TText*>(&switchByMode), |
|
544 sizeof(TBool)/sizeof(TText)); |
|
545 buf.Append(reinterpret_cast<TText*>(&mode), sizeof(TInt)/sizeof(TText)); |
|
546 SignalOwner(ESignalLayoutUIChanged,buf); |
|
547 } |
|
548 } |
|
549 break; |
|
550 default: |
|
551 break; |
|
552 } |
|
553 } |
|
554 } |
|
555 // --------------------------------------------------------- |
|
556 // Handle key event |
|
557 // --------------------------------------------------------- |
|
558 // |
|
559 TBool CAknFepHwrBxLayout::HandleRawKeyEventL(const TRawEvent& aKeyEvent) |
|
560 { |
|
561 TBool handled = EFalse; |
|
562 |
|
563 if (iCurrentState) |
|
564 { |
|
565 handled = iCurrentState->HandleKeyEventL(aKeyEvent); |
|
566 } |
|
567 |
|
568 return handled; |
|
569 } |
|
570 |
|
571 // --------------------------------------------------------- |
|
572 // Validate move button destination |
|
573 // --------------------------------------------------------- |
|
574 // |
|
575 TBool CAknFepHwrBxLayout::IsValidDestination(const TRect& aRect, |
|
576 CDragBar* aDragBar, |
|
577 TBool& aVInfo,TBool& aHInfo, |
|
578 TBool aFlag) |
|
579 { |
|
580 TRect rect = aRect; |
|
581 |
|
582 if (aDragBar) |
|
583 { |
|
584 rect.SetSize(aDragBar->Rect().Size()); |
|
585 } |
|
586 |
|
587 if( aFlag ) |
|
588 { |
|
589 aHInfo = aVInfo = EFalse; |
|
590 if(rect.iTl.iX >= 0 && rect.iBr.iX < ScreenSize().iWidth) |
|
591 { |
|
592 aHInfo = ETrue; |
|
593 } |
|
594 |
|
595 if(rect.iTl.iY >= 0 && rect.iBr.iY < ScreenSize().iHeight) |
|
596 { |
|
597 aVInfo = ETrue; |
|
598 } |
|
599 |
|
600 return aHInfo && aVInfo; |
|
601 } |
|
602 else |
|
603 { |
|
604 TBool tlInvalid = !Rect().Contains(rect.iTl); |
|
605 TBool brInvalid = !Rect().Contains(rect.iBr); |
|
606 |
|
607 |
|
608 if (tlInvalid && !brInvalid) |
|
609 { |
|
610 if (rect.iTl.iX >= Rect().iTl.iX && rect.iTl.iX <= Rect().iBr.iX) |
|
611 { |
|
612 aHInfo = ETrue; |
|
613 } |
|
614 else if (rect.iTl.iY >= Rect().iTl.iY && rect.iTl.iY <= Rect().iBr.iY) |
|
615 { |
|
616 aVInfo = ETrue; |
|
617 } |
|
618 } |
|
619 else if (!tlInvalid && brInvalid) |
|
620 { |
|
621 if (rect.iBr.iX >= Rect().iTl.iX && rect.iBr.iX <= Rect().iBr.iX) |
|
622 { |
|
623 aHInfo = ETrue; |
|
624 } |
|
625 else if (rect.iBr.iY >= Rect().iTl.iY && rect.iBr.iY <= Rect().iBr.iY) |
|
626 |
|
627 { |
|
628 aVInfo = ETrue; |
|
629 } |
|
630 } |
|
631 |
|
632 return !(tlInvalid || brInvalid); |
|
633 } |
|
634 } |
|
635 |
|
636 // --------------------------------------------------------- |
|
637 // Handle edit text coming |
|
638 // --------------------------------------------------------- |
|
639 // |
|
640 TInt CAknFepHwrBxLayout::OnAppEditorTextComing(const TFepInputContextFieldData& aData) |
|
641 { |
|
642 if (iBxWindow) |
|
643 { |
|
644 TRAPD(err, iBxWindow->SetEditorTextL(aData)); |
|
645 return err; |
|
646 } |
|
647 |
|
648 return KErrNone; |
|
649 } |
|
650 |
|
651 // --------------------------------------------------------- |
|
652 // Translate the char code. |
|
653 // --------------------------------------------------------- |
|
654 // |
|
655 void CAknFepHwrBxLayout::TranslateCharCode( TDes& aCharCode ) |
|
656 { |
|
657 TPtrC16 ptr; |
|
658 ptr.Set(&KBackRep, sizeof(KBackRep)/2); |
|
659 |
|
660 if (aCharCode.CompareC(ptr) == 0) |
|
661 { |
|
662 aCharCode.Zero(); |
|
663 aCharCode.Append((TChar)EKeyBackspace); |
|
664 } |
|
665 else |
|
666 { |
|
667 ptr.Set(&KSpaceRep, sizeof(KSpaceRep)/2); |
|
668 if (aCharCode.CompareC(ptr) == 0) |
|
669 { |
|
670 aCharCode.Zero(); |
|
671 aCharCode.Append((TChar)EKeySpace); |
|
672 } |
|
673 else |
|
674 { |
|
675 ptr.Set(&KEnterRep, sizeof(KEnterRep)/2); |
|
676 if (aCharCode.CompareC(ptr) == 0) |
|
677 { |
|
678 aCharCode.Zero(); |
|
679 aCharCode.Append((TChar)EKeyEnter); |
|
680 } |
|
681 } |
|
682 } |
|
683 } |
|
684 |
|
685 // --------------------------------------------------------- |
|
686 // Submit the char code. |
|
687 // --------------------------------------------------------- |
|
688 // |
|
689 void CAknFepHwrBxLayout::SubmitL(const TDesC& aCharCode) |
|
690 { |
|
691 HBufC* buf = HBufC::NewLC(aCharCode.Length()); |
|
692 TPtr charcode(buf->Des()); |
|
693 charcode = aCharCode; |
|
694 TranslateCharCode( charcode ); |
|
695 SignalOwner(ESignalKeyEvent, charcode); |
|
696 |
|
697 CleanupStack::PopAndDestroy(buf); |
|
698 } |
|
699 |
|
700 // --------------------------------------------------------- |
|
701 // Delete the previous charcode and submit the new one |
|
702 // --------------------------------------------------------- |
|
703 // |
|
704 void CAknFepHwrBxLayout::ReplaceL(const TDesC& aOldCharCode, const TDesC& aNewCharCode) |
|
705 { |
|
706 // user tries to correct the previous selection |
|
707 // Delete the previous character and append the new one |
|
708 HBufC* p = HBufC::New(aNewCharCode.Length() + 2); |
|
709 if( p ) |
|
710 { |
|
711 TInt len = aOldCharCode.Length(); |
|
712 p->Des().Append((TUint16*)&len, 2); |
|
713 p->Des().Append(aNewCharCode); |
|
714 SignalOwner( ESignalReplaceText, *p ); |
|
715 delete p; |
|
716 } |
|
717 } |
|
718 |
|
719 // --------------------------------------------------------- |
|
720 // Delete the previous charcode |
|
721 // --------------------------------------------------------- |
|
722 // |
|
723 void CAknFepHwrBxLayout::Delete(TInt aChar) |
|
724 { |
|
725 //delete the last char |
|
726 const TInt len = sizeof(aChar); |
|
727 TBuf<len> aBufBck; |
|
728 aBufBck.Append((TChar)aChar); |
|
729 |
|
730 SignalOwner(ESignalKeyEvent, aBufBck); |
|
731 } |
|
732 |
|
733 // --------------------------------------------------------- |
|
734 // Reset layout rect |
|
735 // --------------------------------------------------------- |
|
736 // |
|
737 void CAknFepHwrBxLayout::SetLayoutPositionL() |
|
738 { |
|
739 ResetLayoutRectL(); |
|
740 } |
|
741 |
|
742 // --------------------------------------------------------- |
|
743 // Reset layout rect by LAF data |
|
744 // --------------------------------------------------------- |
|
745 // |
|
746 void CAknFepHwrBxLayout::ResetLayoutRectL() |
|
747 { |
|
748 TRect rtTmp(iBxWindow->Rect()); |
|
749 |
|
750 //get shadow size |
|
751 rtTmp.Resize(iBxWindow->ShadowTlSize() + iBxWindow->ShadowBrSize()); |
|
752 |
|
753 TPoint br = iDataStore->GetWindowPos(); |
|
754 if (br.iX == KRepInitBrX && br.iY ==KRepInitBrY) |
|
755 { |
|
756 SetRect(rtTmp); |
|
757 } |
|
758 else |
|
759 { |
|
760 TRect layouRect = TRect(TPoint(0, 0), ScreenSize()); |
|
761 TSize temp = rtTmp.Size(); |
|
762 if (br.iX > layouRect.iBr.iX) |
|
763 { |
|
764 br.iX = layouRect.iBr.iX; |
|
765 } |
|
766 |
|
767 if (br.iY > layouRect.iBr.iY) |
|
768 { |
|
769 br.iY = layouRect.iBr.iY; |
|
770 } |
|
771 |
|
772 TPoint tl = br - temp; |
|
773 |
|
774 if (tl.iX > layouRect.iBr.iX) |
|
775 { |
|
776 tl.iX = layouRect.iBr.iX; |
|
777 } |
|
778 else if (tl.iX < layouRect.iTl.iX) |
|
779 { |
|
780 tl.iX = layouRect.iTl.iX; |
|
781 } |
|
782 |
|
783 if (tl.iY > layouRect.iBr.iY) |
|
784 { |
|
785 tl.iY = layouRect.iBr.iY; |
|
786 } |
|
787 else if (tl.iY < layouRect.iTl.iY) |
|
788 { |
|
789 tl.iY = layouRect.iTl.iY; |
|
790 } |
|
791 |
|
792 SetRect( TRect(tl, temp) ); |
|
793 } |
|
794 } |
|
795 |
|
796 |
|
797 // --------------------------------------------------------------------------- |
|
798 // CAknFepHwrBxLayout::OnPointerEventOutsideLayout |
|
799 // Call back when the pointer down/up event happends outside of the layout |
|
800 // (other items were commented in a header). |
|
801 // --------------------------------------------------------------------------- |
|
802 // |
|
803 TBool CAknFepHwrBxLayout::OnPointerEventOutsideLayout(const TRawEvent& aEvent) |
|
804 { |
|
805 if (aEvent.Type() == TRawEvent::EButton1Down) |
|
806 { |
|
807 HandleControlEvent(EHwrEventPointerOutsideWnd, NULL, KNullDesC); |
|
808 } |
|
809 //forward the event |
|
810 return EFalse; |
|
811 } |
|
812 // --------------------------------------------------------------------------- |
|
813 // CAknFepHwrBxLayout::PenInputUiType |
|
814 // return current input UI type |
|
815 // (other items were commented in a header). |
|
816 // --------------------------------------------------------------------------- |
|
817 // |
|
818 TInt CAknFepHwrBxLayout::PenInputType() |
|
819 { |
|
820 return EPluginInputModeHwr; |
|
821 } |
|
822 |
|
823 void CAknFepHwrBxLayout::SetPositionFromOutside(const TPoint& aNewPos) |
|
824 { |
|
825 SetLayoutPos(aNewPos); |
|
826 iDataStore->SaveWindowPos(aNewPos); |
|
827 } |
|
828 |
|
829 // --------------------------------------------------------------------------- |
|
830 // CAknFepHwrBxLayout::GoToStandbyStateL |
|
831 // return current input UI type |
|
832 // (other items were commented in a header). |
|
833 // --------------------------------------------------------------------------- |
|
834 // |
|
835 void CAknFepHwrBxLayout::GoToStandbyStateL( TInt aOpenFlag ) |
|
836 { |
|
837 CAknFepHwrBxStateBase* state = NULL; |
|
838 if ( aOpenFlag == EPenInputOpenManually) |
|
839 { |
|
840 iBxWindow->SetPropertyL(MAknFepHwrPropertySubscriber::EAknFepHwrPropertySizeChanged, |
|
841 KNullDesC); |
|
842 } |
|
843 state = CAknFepHwrBxStateStandby::NewLC( this ); |
|
844 SetCurrentStateL(state); |
|
845 CleanupStack::Pop(state);//state |
|
846 } |
|
847 // End Of File |