|
1 /* |
|
2 * Copyright (c) 2005-2007 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 for PeninputLayoutControl |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <AknIconUtils.h> |
|
20 #include <AknsUtils.h> |
|
21 #include <AknUtils.h> |
|
22 #include <AknsDrawUtils.h> |
|
23 #include "peninputlayout.h" |
|
24 |
|
25 #include "peninputlayoutbubblectrl.h" |
|
26 #include "peninputlayoutvirtualkeyctrl.h" |
|
27 #include "peninputlayoutvkb.h" |
|
28 #include "peninputpluginutils.h" |
|
29 |
|
30 const TInt KFadingParamBlack = 128; |
|
31 const TInt KFadingParamWhite = 192; |
|
32 const TInt KDefaultBubbleSize = 50; |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // Implementation of Class CVirtualKeyboard |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // CVirtualKeyboard::NewL |
|
40 // Factory function |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CVirtualKeyboard* CVirtualKeyboard::NewL(const TRect& aRect, |
|
44 CFepUiLayout* aUiLayout,TInt aControlId, |
|
45 const TFontSpec& aFontSpec, |
|
46 TBool aIrregular) |
|
47 { |
|
48 CVirtualKeyboard* vkb = new(ELeave) CVirtualKeyboard(aRect,aUiLayout, |
|
49 aControlId,aFontSpec, |
|
50 aIrregular); |
|
51 CleanupStack::PushL(vkb); |
|
52 vkb->ConstructL(); |
|
53 vkb->SetRect(aRect); |
|
54 CleanupStack::Pop(); |
|
55 return vkb; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CVirtualKeyboard::NewL |
|
60 // Factory function |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C CVirtualKeyboard* CVirtualKeyboard::NewL(const TRect& aRect, |
|
64 CFepUiLayout* aUiLayout,TInt aControlId, |
|
65 CFont* aFont, |
|
66 TBool aIrregular) |
|
67 { |
|
68 TFontSpec fontSpec; |
|
69 fontSpec.iHeight = 0; |
|
70 CVirtualKeyboard* vkb = new(ELeave) CVirtualKeyboard(aRect,aUiLayout, |
|
71 aControlId,fontSpec, |
|
72 aIrregular); |
|
73 vkb->SetFont(aFont); |
|
74 CleanupStack::PushL(vkb); |
|
75 vkb->ConstructL(); |
|
76 vkb->SetRect(aRect); |
|
77 CleanupStack::Pop(); |
|
78 return vkb; |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CVirtualKeyboard::CVirtualKeyboard |
|
84 // Default constructor |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 EXPORT_C CVirtualKeyboard::CVirtualKeyboard(const TRect& /*aRect*/, |
|
88 CFepUiLayout* aUiLayout, TInt aControlId, |
|
89 const TFontSpec& aFontSpec, |
|
90 TBool aIrregular): |
|
91 CControlGroup(aUiLayout,aControlId), |
|
92 iFadingParamBlack(KFadingParamBlack), |
|
93 iFadingParamWhite(KFadingParamWhite), |
|
94 iKeyNormalSkinId(KAknsIIDNone), |
|
95 iKeyHighlightSkinId(KAknsIIDNone), |
|
96 iKeyDimSkinId(KAknsIIDNone), |
|
97 iNeedDrawBackground(ETrue), |
|
98 iIrregularKey(aIrregular), |
|
99 iBubbleCtrl(NULL), |
|
100 iBubbleVerticalMargin(0), |
|
101 iKeyTextColorGroup(INVALID_COLOR_GROUP) |
|
102 { |
|
103 iFontSpec = aFontSpec; |
|
104 SetControlType(ECtrlVirtualKeyboard); |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CVirtualKeyboard::~CVirtualKeyboard |
|
109 // Destructor |
|
110 // --------------------------------------------------------------------------- |
|
111 // |
|
112 EXPORT_C CVirtualKeyboard::~CVirtualKeyboard() |
|
113 { |
|
114 if ( iBubbleCtrl ) |
|
115 delete iBubbleCtrl; |
|
116 |
|
117 //free keys |
|
118 iKeyArray.ResetAndDestroy(); |
|
119 iKeyArray.Close(); |
|
120 |
|
121 //key highlight bitmap |
|
122 iKeyHighLightBmpList.ResetAndDestroy(); |
|
123 iKeyHighLightBmpList.Close(); |
|
124 |
|
125 iKeyHighLightMaskBmpList.ResetAndDestroy(); |
|
126 iKeyHighLightMaskBmpList.Close(); |
|
127 |
|
128 delete iDimKeyBmp; |
|
129 |
|
130 delete iDimKeyMaskBmp; |
|
131 |
|
132 //font |
|
133 if(iFontOwnership && iFont) |
|
134 { |
|
135 BitmapDevice()->ReleaseFont(iFont); |
|
136 iFont = NULL; |
|
137 } |
|
138 iUnUsedRawKeyCtrlPool.ResetAndDestroy(); |
|
139 iUnUsedRawKeyCtrlPool.Close(); |
|
140 |
|
141 iUnUsedKeyCtrlPool.ResetAndDestroy(); |
|
142 iUnUsedKeyCtrlPool.Close(); |
|
143 |
|
144 iTextLineLayout.Close(); |
|
145 iTextLineSet.Close(); |
|
146 |
|
147 iNonIrregularKeyBmpList.ResetAndDestroy(); |
|
148 iNonIrregularKeyBmpList.Close(); |
|
149 |
|
150 DestroyIrregularBmps(); |
|
151 |
|
152 delete iShiftIcon; |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CVirtualKeyboard::ConstructL |
|
157 // 2nd phase constructor |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C void CVirtualKeyboard::ConstructL () |
|
161 { |
|
162 CControlGroup::ConstructL(); |
|
163 if(BitmapDevice() && iFontSpec.iHeight) |
|
164 { |
|
165 if (KErrNone != BitmapDevice()->GetNearestFontInPixels(iFont,iFontSpec)) |
|
166 { |
|
167 iFont = NULL; |
|
168 } |
|
169 else |
|
170 { |
|
171 iFontOwnership = ETrue; |
|
172 } |
|
173 } |
|
174 |
|
175 for (TInt i = 0; i <= EPosLast; i++) |
|
176 { |
|
177 iTextLineLayout.AppendL(TAknTextLineLayout()); |
|
178 iTextLineSet.AppendL(EFalse); |
|
179 } |
|
180 |
|
181 if (iIrregularKey) |
|
182 { |
|
183 ConstructIrregularBmps(); |
|
184 } |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CVirtualKeyboard::AddKeyL |
|
189 // Add a key to key board |
|
190 // --------------------------------------------------------------------------- |
|
191 // |
|
192 EXPORT_C void CVirtualKeyboard::AddKeyL(CVirtualKey* aKey) |
|
193 { |
|
194 if(aKey) |
|
195 { |
|
196 iKeyArray.AppendL(aKey); |
|
197 |
|
198 //create key control |
|
199 CVirtualKeyCtrl* ctrl = CreateKeyCtrlL(aKey,EFalse);//CVirtualKeyCtrl::NewL(this,aKey); |
|
200 #ifdef RD_TACTILE_FEEDBACK |
|
201 //Advanced Tactile feedback REQ417-47932 |
|
202 ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveInput); |
|
203 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveInput); |
|
204 #endif |
|
205 CleanupStack::PushL(ctrl); |
|
206 AddKeyControlL(ctrl); |
|
207 CleanupStack::Pop(); |
|
208 if (aKey->ScanCode() == -1) |
|
209 { |
|
210 DimKey(aKey, ETrue); |
|
211 } |
|
212 } |
|
213 } |
|
214 |
|
215 // --------------------------------------------------------------------------- |
|
216 // CVirtualKeyboard::AddRawKeyL |
|
217 // Add a raw key to key board |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 EXPORT_C void CVirtualKeyboard::AddRawKeyL(CVirtualKey* aKey) |
|
221 { |
|
222 if(aKey) |
|
223 { |
|
224 iKeyArray.AppendL(aKey); |
|
225 |
|
226 //create key control |
|
227 //CVirtualRawKeyCtrl* ctrl = CVirtualRawKeyCtrl::NewL(this,aKey); |
|
228 CVirtualRawKeyCtrl* ctrl = static_cast<CVirtualRawKeyCtrl*>(CreateKeyCtrlL(aKey,ETrue)); |
|
229 #ifdef RD_TACTILE_FEEDBACK |
|
230 //Advanced Tactile feedback REQ417-47932 |
|
231 ctrl->SetTactileFeedbackType(ETouchFeedbackSensitiveInput); |
|
232 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect(),ETouchFeedbackSensitiveInput); |
|
233 |
|
234 #endif |
|
235 CleanupStack::PushL(ctrl); |
|
236 AddKeyControlL(ctrl); |
|
237 CleanupStack::Pop(); |
|
238 if (aKey->ScanCode() == -1) |
|
239 { |
|
240 DimKey(aKey, ETrue); |
|
241 } |
|
242 } |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // CVirtualKeyboard::RemoveKey |
|
247 // Remove a key from keyboard |
|
248 // --------------------------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C void CVirtualKeyboard::RemoveKey(CVirtualKey* aKey) |
|
251 { |
|
252 if(!aKey) |
|
253 return; |
|
254 TInt idx = iKeyArray.Find(aKey); |
|
255 if(KErrNotFound != idx) |
|
256 { |
|
257 iKeyArray.Remove(idx); |
|
258 CVirtualKeyCtrl* ctrl = FindCtrlForKey(aKey); |
|
259 |
|
260 #ifdef RD_TACTILE_FEEDBACK |
|
261 UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(ctrl),ctrl->Rect()); |
|
262 #endif |
|
263 if(iActiveCtrl == ctrl) |
|
264 iActiveCtrl = 0; |
|
265 |
|
266 RemoveKeyControl(ctrl); |
|
267 aKey->iKeyCtrl = 0; |
|
268 } |
|
269 |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // CVirtualKeyboard::FindCtrlForKey |
|
274 // Find the key control which has the virtual key information. |
|
275 // --------------------------------------------------------------------------- |
|
276 // |
|
277 CVirtualKeyCtrl* CVirtualKeyboard::FindCtrlForKey(const CVirtualKey* aKey) |
|
278 { |
|
279 for(TInt i = 0; i < ControlList().Count(); ++i) |
|
280 { |
|
281 CVirtualKeyCtrl* keyCtrl = static_cast<CVirtualKeyCtrl*>(ControlList()[i]); |
|
282 if(keyCtrl->iKeyInfo == aKey) |
|
283 return keyCtrl; |
|
284 } |
|
285 return 0; |
|
286 |
|
287 } |
|
288 // --------------------------------------------------------------------------- |
|
289 // CVirtualKeyboard::CreateKeyL |
|
290 // Add a key to keyboard |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 EXPORT_C void CVirtualKeyboard::CreateKeyL(TUint aCode, TUint aScanCode, |
|
294 const TRect& aRect, const TRect& aDrawRect, TInt aBaseline, |
|
295 TInt aHighlightBmpIdx,TInt aHighlightMaskBmpId) |
|
296 { |
|
297 CVirtualKey* key = CVirtualKey::NewL(aCode,aScanCode,aRect,aDrawRect, |
|
298 aBaseline,aHighlightBmpIdx,aHighlightMaskBmpId); |
|
299 CleanupStack::PushL(key); |
|
300 AddKeyL(key); |
|
301 CleanupStack::Pop(key); |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CVirtualKeyboard::CreateKeyL |
|
306 // Add a key to keyboard |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 EXPORT_C void CVirtualKeyboard::CreateKeyL(const TDesC& aCode, TUint aScanCode, |
|
310 const TRect& aRect, const TRect& aDrawRect, TInt aBaseline, |
|
311 TInt aHighlightBmpIdx,TInt aHighlightMaskBmpId) |
|
312 { |
|
313 CVirtualKey* key = CVirtualKey::NewL(aCode,aScanCode,aRect,aDrawRect, |
|
314 aBaseline,aHighlightBmpIdx,aHighlightMaskBmpId); |
|
315 CleanupStack::PushL(key); |
|
316 AddKeyL(key); |
|
317 //key->SetKeyboard(this); |
|
318 //key->iKeyboard = this; |
|
319 CleanupStack::Pop(key); |
|
320 } |
|
321 |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // CVirtualKeyboard::CreateRawKeyL |
|
325 // Add a key to keyboard |
|
326 // --------------------------------------------------------------------------- |
|
327 // |
|
328 EXPORT_C void CVirtualKeyboard::CreateRawKeyL(TUint aCode, TUint aScanCode, |
|
329 const TRect& aRect, const TRect& aDrawRect, TInt aBaseline, |
|
330 TInt aHighlightBmpIdx,TInt aHighlightMaskBmpId) |
|
331 { |
|
332 CVirtualKey* key = CVirtualKey::NewL(aCode,aScanCode,aRect,aDrawRect, |
|
333 aBaseline,aHighlightBmpIdx,aHighlightMaskBmpId); |
|
334 CleanupStack::PushL(key); |
|
335 AddRawKeyL(key); |
|
336 CleanupStack::Pop(key); |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // CVirtualKeyboard::CreateRawKeyL |
|
341 // Add a key to keyboard |
|
342 // --------------------------------------------------------------------------- |
|
343 // |
|
344 EXPORT_C void CVirtualKeyboard::CreateRawKeyL(const TDesC& aCode, TUint aScanCode, |
|
345 const TRect& aRect, const TRect& aDrawRect, TInt aBaseline, |
|
346 TInt aHighlightBmpIdx,TInt aHighlightMaskBmpId) |
|
347 { |
|
348 CVirtualKey* key = CVirtualKey::NewL(aCode,aScanCode,aRect,aDrawRect, |
|
349 aBaseline,aHighlightBmpIdx,aHighlightMaskBmpId); |
|
350 CleanupStack::PushL(key); |
|
351 AddRawKeyL(key); |
|
352 CleanupStack::Pop(key); |
|
353 } |
|
354 |
|
355 // --------------------------------------------------------------------------- |
|
356 // CVirtualKeyboard::CreateRawKeyL |
|
357 // Add a key to keyboard |
|
358 // --------------------------------------------------------------------------- |
|
359 // |
|
360 EXPORT_C void CVirtualKeyboard::CreateRawKeyL(RPointerArray<HBufC>& aUnicodesList, |
|
361 TInt aScanCode, |
|
362 const TRect& aRect) |
|
363 { |
|
364 CVirtualKey* key = CVirtualKey::NewL(aUnicodesList, |
|
365 aScanCode, |
|
366 aRect); |
|
367 CleanupStack::PushL(key); |
|
368 AddRawKeyL(key); |
|
369 CleanupStack::Pop(key); |
|
370 } |
|
371 |
|
372 // CVirtualKeyboard::Draw |
|
373 // Draw virtual keyboard |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 EXPORT_C void CVirtualKeyboard::Draw() |
|
377 { |
|
378 if(!AbleToDraw()) |
|
379 return; |
|
380 const TRect& keyboardRect = Rect(); |
|
381 |
|
382 if (iNeedDrawBackground) |
|
383 { |
|
384 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
385 |
|
386 //mask bitmaps |
|
387 if (!iIrregularKey) |
|
388 { |
|
389 DrawOpaqueMaskBackground(); |
|
390 } |
|
391 |
|
392 // ----- draw bitmaps ----- |
|
393 gc->Activate( BitmapDevice() ); |
|
394 |
|
395 if(!BackgroundBmp()) |
|
396 { |
|
397 // ----- draw bitmaps ----- |
|
398 |
|
399 gc->SetBrushColor( BkColor()); |
|
400 gc->SetPenColor( KRgbBlack ); |
|
401 gc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
402 if (!iIrregularKey) |
|
403 { |
|
404 gc->DrawRect(keyboardRect); |
|
405 } |
|
406 } |
|
407 else |
|
408 { |
|
409 // ----- draw bitmaps ----- |
|
410 if(BkMaskBmp()) |
|
411 { |
|
412 TRect bmpRect(TPoint(0,0),BkMaskBmp()->SizeInPixels()); |
|
413 if (!iIrregularKey) |
|
414 { |
|
415 gc->DrawBitmapMasked(keyboardRect,BackgroundBmp(),bmpRect,BkMaskBmp(),EFalse); |
|
416 } |
|
417 } |
|
418 else |
|
419 { |
|
420 if (!iIrregularKey) |
|
421 { |
|
422 gc->DrawBitmap(keyboardRect,BackgroundBmp()); |
|
423 } |
|
424 } |
|
425 } |
|
426 |
|
427 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
428 } |
|
429 |
|
430 //draw each key control |
|
431 for(TInt i = 0; i < ControlList().Count(); ++i) |
|
432 { |
|
433 CVirtualKeyCtrl* ctrl = static_cast<CVirtualKeyCtrl*>(ControlList()[i]); |
|
434 ctrl->Draw(); |
|
435 } |
|
436 } |
|
437 |
|
438 void CVirtualKeyboard::ClearBubble(TBool /*aSetZeroSize*/) |
|
439 { |
|
440 if ( iBubbleCtrl ) |
|
441 { |
|
442 iBubbleCtrl->Close(); |
|
443 } |
|
444 } |
|
445 |
|
446 void CVirtualKeyboard::DrawBubble(CVirtualKey* aKey) |
|
447 { |
|
448 |
|
449 if ( aKey && !aKey->Dimmed() && iBubbleCtrl && iIsShowBubble) |
|
450 { |
|
451 TRect rect = iBubbleCtrl->Rect(); |
|
452 TRect parentWndRect = Rect(); |
|
453 TInt x1 = aKey->Rect().iTl.iX - ( iBubbleSize.iWidth - aKey->Rect().Width() ) / 2; |
|
454 TInt x2 = aKey->Rect().iBr.iX + ( iBubbleSize.iWidth - aKey->Rect().Width() ) / 2; |
|
455 if ( x1 < 0 ) |
|
456 { |
|
457 rect.iTl.iX = parentWndRect.iTl.iX; |
|
458 rect.iBr.iX = iBubbleSize.iWidth; |
|
459 } |
|
460 else if ( x2 > parentWndRect.iBr.iX ) |
|
461 { |
|
462 rect.iTl.iX = parentWndRect.iBr.iX - iBubbleSize.iWidth; |
|
463 rect.iBr.iX = parentWndRect.iBr.iX; |
|
464 } |
|
465 else |
|
466 { |
|
467 rect.iTl.iX = x1; |
|
468 rect.iBr.iX = x2; |
|
469 } |
|
470 |
|
471 rect.iTl.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY - |
|
472 iBubbleSize.iHeight + Rect().iTl.iY; |
|
473 rect.iBr.iY = iBubbleVerticalMargin + aKey->Rect().iTl.iY + Rect().iTl.iY; |
|
474 |
|
475 if( aKey->DisplayUnicode() && aKey->DisplayUnicode()->Length() != 0 ) |
|
476 { |
|
477 TRAP_IGNORE(iBubbleCtrl->SetTextL(*aKey->DisplayUnicode())); |
|
478 } |
|
479 else |
|
480 { |
|
481 TRAP_IGNORE(iBubbleCtrl->SetTextL(aKey->KeyUnicodes())); |
|
482 } |
|
483 iBubbleCtrl->Popup(rect); |
|
484 } |
|
485 } |
|
486 |
|
487 EXPORT_C void CVirtualKeyboard::ShowBubble(TBool aFlag) |
|
488 { |
|
489 TBool flag = iBubbleCtrl ? ETrue : EFalse; |
|
490 iIsShowBubble = aFlag; |
|
491 if ( flag != aFlag ) |
|
492 { |
|
493 if(!flag) |
|
494 { |
|
495 TRAP_IGNORE(iBubbleCtrl = CBubbleCtrl::NewL(TRect(0,0,0,0),UiLayout(),-0xFFFF)); |
|
496 iBubbleSize = TSize(KDefaultBubbleSize,KDefaultBubbleSize); |
|
497 } |
|
498 } |
|
499 } |
|
500 |
|
501 EXPORT_C TBool CVirtualKeyboard::GowithPointerDown() |
|
502 { |
|
503 return iGowithPointerDown; |
|
504 } |
|
505 |
|
506 EXPORT_C void CVirtualKeyboard::SetGowithPointerDown(TBool aFlag) |
|
507 { |
|
508 iGowithPointerDown = aFlag; |
|
509 } |
|
510 |
|
511 EXPORT_C void CVirtualKeyboard::SetBubbleBitmapParam(CFbsBitmap* aBmpId, |
|
512 CFbsBitmap* aMaskBmpId , |
|
513 TAknsItemID aBgSkinId ) |
|
514 { |
|
515 if ( iBubbleCtrl ) |
|
516 { |
|
517 iBubbleCtrl->SetBitmapParam(aBmpId,aMaskBmpId,aBgSkinId); |
|
518 } |
|
519 } |
|
520 |
|
521 EXPORT_C void CVirtualKeyboard::SetBubbleSize(const TSize& aSize) |
|
522 { |
|
523 iBubbleSize = aSize; |
|
524 } |
|
525 |
|
526 EXPORT_C void CVirtualKeyboard::SetBubbleVerticalMargin(TInt aMargin) |
|
527 { |
|
528 iBubbleVerticalMargin = aMargin; |
|
529 } |
|
530 |
|
531 EXPORT_C void CVirtualKeyboard::SetTextFormat(TAknTextLineLayout aTextFormat) |
|
532 { |
|
533 if ( iBubbleCtrl ) |
|
534 { |
|
535 iBubbleCtrl->SetTextFormat(aTextFormat); |
|
536 } |
|
537 } |
|
538 |
|
539 EXPORT_C void CVirtualKeyboard::SetFrameDiff(TInt aLeftDiff, TInt aTopDiff, |
|
540 TInt aRightDiff,TInt aBottomDiff) |
|
541 { |
|
542 if ( iBubbleCtrl ) |
|
543 { |
|
544 iBubbleCtrl->SetFrameDiff(aLeftDiff,aTopDiff,aRightDiff,aBottomDiff); |
|
545 } |
|
546 } |
|
547 |
|
548 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPt) |
|
549 { |
|
550 if(iWndControl) |
|
551 { |
|
552 return CFepUiBaseCtrl::HandlePointerMoveEventL(aPt); |
|
553 } |
|
554 |
|
555 if( !iGowithPointerDown ) |
|
556 { |
|
557 return CControlGroup::HandlePointerMoveEventL( aPt ); |
|
558 } |
|
559 |
|
560 CFepUiBaseCtrl* ctrl = ControlForPoints(aPt); |
|
561 |
|
562 if( !iRect.Contains(aPt) ) // not belong our group |
|
563 return NULL; // Check: This will not happen! |
|
564 |
|
565 if( !PointerDown() ) |
|
566 { |
|
567 return NULL; |
|
568 } |
|
569 if(ctrl != iCtrlWithPointerDown) |
|
570 { |
|
571 if ( iBubbleCtrl && iIsShowBubble ) |
|
572 { |
|
573 //iBubbleCtrl->Freeze(); |
|
574 } |
|
575 if( iCtrlWithPointerDown ) |
|
576 { |
|
577 iCtrlWithPointerDown->HandlePointerLeave(aPt); |
|
578 } |
|
579 |
|
580 iCtrlWithPointerDown = ctrl; |
|
581 |
|
582 if( ctrl ) |
|
583 { |
|
584 iCtrlWithPointerDown->HandlePointerEnter(aPt); |
|
585 } |
|
586 |
|
587 if ( iBubbleCtrl && iIsShowBubble ) |
|
588 { |
|
589 //iBubbleCtrl->UnFreeze(); |
|
590 } |
|
591 } |
|
592 else |
|
593 { |
|
594 if(ctrl) |
|
595 ctrl->HandlePointerMoveEventL(aPt); |
|
596 } |
|
597 |
|
598 return this; |
|
599 } |
|
600 |
|
601 // --------------------------------------------------------------------------- |
|
602 // CVirtualKeyboard::DrawKey |
|
603 // Draw a key |
|
604 // --------------------------------------------------------------------------- |
|
605 // |
|
606 void CVirtualKeyboard::DrawKey(const CVirtualKey* aKey) |
|
607 { |
|
608 if (Hiden()) |
|
609 { |
|
610 return; |
|
611 } |
|
612 |
|
613 CVirtualKeyCtrl* keyCtrl = FindCtrlForKey(aKey); |
|
614 if(keyCtrl) |
|
615 { |
|
616 keyCtrl->Draw(); |
|
617 } |
|
618 |
|
619 TRect rect(Rect().iTl+aKey->Rect().iTl,aKey->Rect().Size()); |
|
620 |
|
621 UpdateArea(rect, EFalse); |
|
622 } |
|
623 |
|
624 // --------------------------------------------------------------------------- |
|
625 // CVirtualKeyboard::SetFont |
|
626 // Set vkb font |
|
627 // (other items were commented in a header). |
|
628 // --------------------------------------------------------------------------- |
|
629 // |
|
630 EXPORT_C void CVirtualKeyboard::SetFont(const TFontSpec& aFontSpec) |
|
631 { |
|
632 iFontSpec = aFontSpec; |
|
633 //release old font |
|
634 if(iFontOwnership && iFont) |
|
635 { |
|
636 BitmapDevice()->ReleaseFont(iFont); |
|
637 iFont = NULL; |
|
638 } |
|
639 iFontOwnership = ETrue; |
|
640 if(BitmapDevice()) |
|
641 { |
|
642 if (KErrNone != BitmapDevice()->GetNearestFontInPixels(iFont,iFontSpec)) |
|
643 iFont = NULL; |
|
644 } |
|
645 } |
|
646 |
|
647 // --------------------------------------------------------------------------- |
|
648 // CVirtualKeyboard::SetFont |
|
649 // Set VKB font |
|
650 // (other items were commented in a header). |
|
651 // --------------------------------------------------------------------------- |
|
652 // |
|
653 EXPORT_C void CVirtualKeyboard::SetFont(const CFont* aFont) |
|
654 { |
|
655 if(iFontOwnership && iFont) |
|
656 { |
|
657 BitmapDevice()->ReleaseFont(iFont); |
|
658 } |
|
659 iFontOwnership = EFalse; |
|
660 iFont = const_cast<CFont*>(aFont); |
|
661 if(iFont) |
|
662 iFontSpec = iFont->FontSpecInTwips(); |
|
663 } |
|
664 |
|
665 |
|
666 // --------------------------------------------------------------------------- |
|
667 // CVirtualKeyboard::SetFontColor |
|
668 // Set VKB key font color |
|
669 // (other items were commented in a header). |
|
670 // --------------------------------------------------------------------------- |
|
671 // |
|
672 EXPORT_C void CVirtualKeyboard::SetFontColor( const TRgb aFontColor ) |
|
673 { |
|
674 iFontColor = aFontColor; |
|
675 } |
|
676 |
|
677 // --------------------------------------------------------------------------- |
|
678 // CVirtualKeyboard::AddKeyHighLightBitmapL |
|
679 // Add a key highlight bmp |
|
680 // (other items were commented in a header). |
|
681 // --------------------------------------------------------------------------- |
|
682 // |
|
683 EXPORT_C void CVirtualKeyboard::AddKeyHighLightBitmapL(CFbsBitmap* aBmp) |
|
684 { |
|
685 iKeyHighLightBmpList.AppendL(aBmp); |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------------------------- |
|
689 // CVirtualKeyboard::AddKeyHighLightMaskBitmapL |
|
690 // Add a key highlight mask bmp |
|
691 // (other items were commented in a header). |
|
692 // --------------------------------------------------------------------------- |
|
693 // |
|
694 EXPORT_C void CVirtualKeyboard::AddKeyHighLightMaskBitmapL(CFbsBitmap* aBmp) |
|
695 { |
|
696 iKeyHighLightMaskBmpList.AppendL(aBmp); |
|
697 } |
|
698 |
|
699 // --------------------------------------------------------------------------- |
|
700 // CVirtualKeyboard::RemoveKeyHighLightBitmap |
|
701 // Remove a key highlight bmp |
|
702 // (other items were commented in a header). |
|
703 // --------------------------------------------------------------------------- |
|
704 // |
|
705 EXPORT_C void CVirtualKeyboard::RemoveKeyHighLightBitmap(TInt aIndex) |
|
706 { |
|
707 __ASSERT_DEBUG(aIndex >= 0 && aIndex < iKeyHighLightBmpList.Count(), |
|
708 User::Panic(_L("peninputserver"), EUiGeneralIndexError)); |
|
709 iKeyHighLightBmpList.Remove(aIndex); |
|
710 } |
|
711 |
|
712 // --------------------------------------------------------------------------- |
|
713 // CVirtualKeyboard::RemoveKeyHighLightMaskBitmap |
|
714 // Remove a key highlight mask bmp |
|
715 // (other items were commented in a header). |
|
716 // --------------------------------------------------------------------------- |
|
717 // |
|
718 EXPORT_C void CVirtualKeyboard::RemoveKeyHighLightMaskBitmap(TInt aIndex) |
|
719 { |
|
720 __ASSERT_DEBUG(aIndex >= 0 && aIndex < iKeyHighLightMaskBmpList.Count(), |
|
721 User::Panic(_L("peninputserver"), EUiGeneralIndexError)); |
|
722 iKeyHighLightMaskBmpList.Remove(aIndex); |
|
723 } |
|
724 |
|
725 |
|
726 // --------------------------------------------------------------------------- |
|
727 // CVirtualKeyboard::DimKey |
|
728 // Dim a key |
|
729 // (other items were commented in a header). |
|
730 // --------------------------------------------------------------------------- |
|
731 // |
|
732 EXPORT_C void CVirtualKeyboard::DimKey(CVirtualKey* aKey, TBool aFlag) |
|
733 { |
|
734 if(!aKey) |
|
735 return; |
|
736 if(aFlag == aKey->Dimmed() ) |
|
737 return; |
|
738 |
|
739 if (!aFlag && aKey->ScanCode() == -1) |
|
740 { |
|
741 return; |
|
742 } |
|
743 aKey->SetDimmed(aFlag); |
|
744 DrawKey(aKey); |
|
745 |
|
746 #ifdef RD_TACTILE_FEEDBACK |
|
747 CVirtualKeyCtrl* keyCtrl = FindCtrlForKey(aKey); |
|
748 |
|
749 if(keyCtrl->IsKindOfControl(ECtrlTactileFeedback)) |
|
750 { |
|
751 if(aFlag) |
|
752 UiLayout()->DeRegisterFeedbackArea(reinterpret_cast<TInt>(keyCtrl),keyCtrl->Rect()); |
|
753 else |
|
754 UiLayout()->RegisterFeedbackArea(reinterpret_cast<TInt>(keyCtrl),keyCtrl->Rect(),keyCtrl->TactileFeedbackType()); |
|
755 } |
|
756 #endif |
|
757 } |
|
758 |
|
759 EXPORT_C void CVirtualKeyboard::EnableKeyFeedback( CVirtualKey* aKey, TBool aEnable ) |
|
760 { |
|
761 #ifdef RD_TACTILE_FEEDBACK |
|
762 CVirtualKeyCtrl* keyCtrl = FindCtrlForKey(aKey); |
|
763 |
|
764 if ( keyCtrl && keyCtrl->IsKindOfControl(ECtrlTactileFeedback) ) |
|
765 { |
|
766 TInt id = reinterpret_cast<TInt>(keyCtrl); |
|
767 UiLayout()->DeRegisterFeedbackArea(id,keyCtrl->Rect()); |
|
768 if( aEnable ) |
|
769 { |
|
770 UiLayout()->RegisterFeedbackArea(id,keyCtrl->Rect(),keyCtrl->TactileFeedbackType()); |
|
771 } |
|
772 } |
|
773 #endif |
|
774 } |
|
775 |
|
776 void CVirtualKeyboard::AddKeyControlL(CVirtualKeyCtrl* aKeyCtrl) |
|
777 { |
|
778 //do nothing if we already has the control. |
|
779 if(!aKeyCtrl || KErrNotFound != iCtrlList.Find(aKeyCtrl)) |
|
780 return; |
|
781 |
|
782 iOwnedCtrlList.AppendL(aKeyCtrl); |
|
783 |
|
784 iCtrlList.AppendL(aKeyCtrl); |
|
785 aKeyCtrl->iKeyboard = this; |
|
786 //aKeyCtrl->Move(iRect.iTl); |
|
787 } |
|
788 |
|
789 |
|
790 void CVirtualKeyboard::RemoveKeyControl(CVirtualKeyCtrl* aKeyCtrl) |
|
791 { |
|
792 if(!aKeyCtrl) |
|
793 return; |
|
794 TInt idx = iOwnedCtrlList.Find(aKeyCtrl); |
|
795 if(KErrNotFound != idx) |
|
796 { |
|
797 iOwnedCtrlList.Remove(idx); |
|
798 } |
|
799 idx = iCtrlList.Find(aKeyCtrl); |
|
800 if(KErrNotFound != idx) |
|
801 { |
|
802 iCtrlList.Remove(idx); |
|
803 } |
|
804 //aKeyCtrl can't be deleted. This is for VKB fix: VKB will dynamically |
|
805 //remove current keys during layout handling pointer event. Thus |
|
806 //CControlGroup::SetActiveCtrl will panic. |
|
807 //delete aKeyCtrl; |
|
808 TInt err; |
|
809 aKeyCtrl->SetReady(EFalse); //disable the control |
|
810 if(aKeyCtrl->IsKindOfControl(ECtrlVirtualItutKey)) |
|
811 { |
|
812 err = iUnUsedRawKeyCtrlPool.Append(aKeyCtrl); |
|
813 } |
|
814 else |
|
815 { |
|
816 err = iUnUsedKeyCtrlPool.Append(aKeyCtrl); |
|
817 } |
|
818 if(KErrNone != err) |
|
819 delete aKeyCtrl; |
|
820 } |
|
821 // --------------------------------------------------------------------------- |
|
822 // CVirtualKeyboard::SetRect |
|
823 // Set the control rect |
|
824 // (other items were commented in a header). |
|
825 // --------------------------------------------------------------------------- |
|
826 // |
|
827 EXPORT_C void CVirtualKeyboard::SetRect(const TRect& aRect) |
|
828 { |
|
829 if(aRect == Rect()) |
|
830 return; |
|
831 TPoint offset = aRect.iTl - iRect.iTl; |
|
832 CControlGroup::SetRect(aRect); |
|
833 //move all virtual keys |
|
834 for(TInt i = 0; i < ControlList().Count(); ++i) |
|
835 { |
|
836 ControlList()[i]->Move(offset); |
|
837 } |
|
838 } |
|
839 |
|
840 |
|
841 // --------------------------------------------------------------------------- |
|
842 // CVirtualKeyboard::CreateKeyCtrlL |
|
843 // Create a control |
|
844 // (other items were commented in a header). |
|
845 // --------------------------------------------------------------------------- |
|
846 // |
|
847 CVirtualKeyCtrl* CVirtualKeyboard::CreateKeyCtrlL(CVirtualKey* aKeyInfo, |
|
848 TBool aRawKeyFlag) |
|
849 { |
|
850 RPointerArray<CVirtualKeyCtrl> &unUsedCtrlPool = aRawKeyFlag ? |
|
851 iUnUsedRawKeyCtrlPool : iUnUsedKeyCtrlPool; |
|
852 for(TInt i = 0 ; i < unUsedCtrlPool .Count(); ++i) |
|
853 { |
|
854 if(unUsedCtrlPool [i]->iKeyInfo->ScanCode() == aKeyInfo->ScanCode()) |
|
855 { |
|
856 CVirtualKeyCtrl* ctrl = unUsedCtrlPool [i]; |
|
857 unUsedCtrlPool.Remove(i); |
|
858 ctrl->iKeyInfo = aKeyInfo; |
|
859 TRect rect = aKeyInfo->Rect(); |
|
860 rect.Move(Rect().iTl); |
|
861 ctrl->SetRect(rect); |
|
862 aKeyInfo->iKeyCtrl = ctrl; |
|
863 ctrl->SetReady(ETrue); //enable the control |
|
864 return ctrl; |
|
865 } |
|
866 } |
|
867 if(aRawKeyFlag) |
|
868 return CVirtualRawKeyCtrl::NewL(this,aKeyInfo); |
|
869 else |
|
870 return CVirtualKeyCtrl::NewL(this,aKeyInfo); |
|
871 } |
|
872 |
|
873 void CVirtualKeyboard::ConstructIrregularBmps() |
|
874 { |
|
875 ConstructOneIrregularBmp(iKeyLeftDownBmpList); |
|
876 |
|
877 ConstructOneIrregularBmp(iKeyMiddleUpBmpList); |
|
878 |
|
879 ConstructOneIrregularBmp(iKeyMiddleDownBmpList); |
|
880 |
|
881 ConstructOneIrregularBmp(iKeyRightDownBmpList); |
|
882 |
|
883 ConstructOneIrregularBmp(iKeyRightUpBmpList); |
|
884 } |
|
885 |
|
886 void CVirtualKeyboard::ConstructOneIrregularBmp(RPointerArray<CFbsBitmap>& iBmpList) |
|
887 { |
|
888 if (iBmpList.Count() != 0) |
|
889 { |
|
890 return; |
|
891 } |
|
892 |
|
893 |
|
894 for(TInt index = 0; index <= EKeyStateDimmedMask ; index ++) |
|
895 { |
|
896 iBmpList.Append(NULL); |
|
897 } |
|
898 } |
|
899 |
|
900 void CVirtualKeyboard::DestroyIrregularBmps() |
|
901 { |
|
902 iKeyLeftDownBmpList.ResetAndDestroy(); |
|
903 iKeyLeftDownBmpList.Close(); |
|
904 |
|
905 iKeyMiddleUpBmpList.ResetAndDestroy(); |
|
906 iKeyMiddleUpBmpList.Close(); |
|
907 |
|
908 iKeyMiddleDownBmpList.ResetAndDestroy(); |
|
909 iKeyMiddleDownBmpList.Close(); |
|
910 |
|
911 iKeyRightDownBmpList.ResetAndDestroy(); |
|
912 iKeyRightDownBmpList.Close(); |
|
913 |
|
914 iKeyRightUpBmpList.ResetAndDestroy(); |
|
915 iKeyRightUpBmpList.Close(); |
|
916 } |
|
917 |
|
918 EXPORT_C void CVirtualKeyboard:: AddIrregularKeyBitmapL(TVirtualKeyIrregularKeyType aKeyType, |
|
919 TVirtualKeyIrregularKeyState aKeyState, |
|
920 CFbsBitmap* aBmp) |
|
921 { |
|
922 switch(aKeyType) |
|
923 { |
|
924 case EKeyLeftDown: |
|
925 { |
|
926 delete iKeyLeftDownBmpList[aKeyState]; |
|
927 iKeyLeftDownBmpList[aKeyState] = aBmp; |
|
928 } |
|
929 break; |
|
930 case EKeyMiddleUp: |
|
931 { |
|
932 delete iKeyMiddleUpBmpList[aKeyState]; |
|
933 iKeyMiddleUpBmpList[aKeyState] = aBmp; |
|
934 } |
|
935 break; |
|
936 case EKeyMiddleDown: |
|
937 { |
|
938 delete iKeyMiddleDownBmpList[aKeyState]; |
|
939 iKeyMiddleDownBmpList[aKeyState] = aBmp; |
|
940 } |
|
941 break; |
|
942 case EKeyRightDown: |
|
943 { |
|
944 delete iKeyRightDownBmpList[aKeyState]; |
|
945 iKeyRightDownBmpList[aKeyState] = aBmp; |
|
946 } |
|
947 break; |
|
948 case EKeyRightUp: |
|
949 { |
|
950 delete iKeyRightUpBmpList[aKeyState]; |
|
951 iKeyRightUpBmpList[aKeyState] = aBmp; |
|
952 } |
|
953 break; |
|
954 default: |
|
955 { |
|
956 User::Leave(KErrNotFound); |
|
957 } |
|
958 } |
|
959 } |
|
960 |
|
961 EXPORT_C void CVirtualKeyboard::RemoveIrregularKeyBitmapL(TVirtualKeyIrregularKeyType aKeyType, |
|
962 TVirtualKeyIrregularKeyState aKeyState) |
|
963 { |
|
964 switch(aKeyType) |
|
965 { |
|
966 case EKeyLeftDown: |
|
967 { |
|
968 delete iKeyLeftDownBmpList[aKeyState]; |
|
969 iKeyLeftDownBmpList[aKeyState] = NULL; |
|
970 } |
|
971 break; |
|
972 case EKeyMiddleUp: |
|
973 { |
|
974 delete iKeyMiddleUpBmpList[aKeyState]; |
|
975 iKeyMiddleUpBmpList[aKeyState] = NULL; |
|
976 } |
|
977 break; |
|
978 case EKeyMiddleDown: |
|
979 { |
|
980 delete iKeyMiddleDownBmpList[aKeyState]; |
|
981 iKeyMiddleDownBmpList[aKeyState] = NULL; |
|
982 } |
|
983 break; |
|
984 case EKeyRightDown: |
|
985 { |
|
986 delete iKeyRightDownBmpList[aKeyState]; |
|
987 iKeyRightDownBmpList[aKeyState] = NULL; |
|
988 } |
|
989 break; |
|
990 case EKeyRightUp: |
|
991 { |
|
992 delete iKeyRightUpBmpList[aKeyState]; |
|
993 iKeyRightUpBmpList[aKeyState] = NULL; |
|
994 } |
|
995 break; |
|
996 default: |
|
997 { |
|
998 User::Leave(KErrNotFound); |
|
999 } |
|
1000 } |
|
1001 } |
|
1002 |
|
1003 EXPORT_C CFbsBitmap* CVirtualKeyboard::IrregularKeyBitmap(TVirtualKeyIrregularKeyType aKeyType, |
|
1004 TVirtualKeyIrregularKeyState aKeyState) |
|
1005 { |
|
1006 CFbsBitmap* ret; |
|
1007 switch(aKeyType) |
|
1008 { |
|
1009 case EKeyLeftDown: |
|
1010 { |
|
1011 ret = iKeyLeftDownBmpList[aKeyState]; |
|
1012 } |
|
1013 break; |
|
1014 case EKeyMiddleUp: |
|
1015 { |
|
1016 ret = iKeyMiddleUpBmpList[aKeyState]; |
|
1017 } |
|
1018 break; |
|
1019 case EKeyMiddleDown: |
|
1020 { |
|
1021 ret = iKeyMiddleDownBmpList[aKeyState]; |
|
1022 } |
|
1023 break; |
|
1024 case EKeyRightDown: |
|
1025 { |
|
1026 ret = iKeyRightDownBmpList[aKeyState]; |
|
1027 } |
|
1028 break; |
|
1029 case EKeyRightUp: |
|
1030 { |
|
1031 ret = iKeyRightUpBmpList[aKeyState]; |
|
1032 } |
|
1033 break; |
|
1034 default: |
|
1035 { |
|
1036 ret = NULL; |
|
1037 } |
|
1038 } |
|
1039 |
|
1040 return ret; |
|
1041 } |
|
1042 |
|
1043 EXPORT_C TBool CVirtualKeyboard::IsIrregularKeyBoard() |
|
1044 { |
|
1045 return iIrregularKey; |
|
1046 } |
|
1047 |
|
1048 EXPORT_C void CVirtualKeyboard::SetIrregularKeyBoard(TBool aIrregular) |
|
1049 { |
|
1050 iIrregularKey = aIrregular; |
|
1051 |
|
1052 if (iIrregularKey) |
|
1053 { |
|
1054 ConstructIrregularBmps(); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 EXPORT_C void CVirtualKeyboard::SetNonIrregularKeyBitmapL(TVirtualKeyBmpType aBmpType, |
|
1059 CFbsBitmap* aBmp) |
|
1060 { |
|
1061 TInt i = iNonIrregularKeyBmpList.Count(); |
|
1062 for( ; i < EKeyBmpLastType + 1; i++) |
|
1063 { |
|
1064 iNonIrregularKeyBmpList.Append(NULL); |
|
1065 } |
|
1066 delete iNonIrregularKeyBmpList[aBmpType]; |
|
1067 iNonIrregularKeyBmpList[aBmpType] = aBmp; |
|
1068 } |
|
1069 |
|
1070 EXPORT_C CFbsBitmap* CVirtualKeyboard::NonIrregularKeyBitmap(TVirtualKeyBmpType aBmpType) |
|
1071 { |
|
1072 if( iNonIrregularKeyBmpList.Count() > aBmpType ) |
|
1073 { |
|
1074 return iNonIrregularKeyBmpList[aBmpType]; |
|
1075 } |
|
1076 return NULL; |
|
1077 } |
|
1078 |
|
1079 EXPORT_C void CVirtualKeyboard::SetVirtualKeyImgID(TVirtualKeyDrawInfo aVirtualKeyDrawInfo) |
|
1080 { |
|
1081 for(TInt i = 0; i < ControlList().Count(); ++i) |
|
1082 { |
|
1083 CVirtualKeyCtrl* ctrl = static_cast<CVirtualKeyCtrl*>(ControlList()[i]); |
|
1084 ctrl->SetVirtualKeyImgID(aVirtualKeyDrawInfo); |
|
1085 } |
|
1086 } |
|
1087 |
|
1088 EXPORT_C void CVirtualKeyboard::SetShiftIcon( CPenInputColorIcon* aIcon ) |
|
1089 { |
|
1090 delete iShiftIcon; |
|
1091 iShiftIcon = aIcon; |
|
1092 } |
|
1093 /* |
|
1094 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerDownEventL(const TPoint& aPoint) |
|
1095 { |
|
1096 return CControlGroup::HandlePointerDownEventL(aPoint); |
|
1097 } |
|
1098 |
|
1099 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerUpEventL(const TPoint& aPoint) |
|
1100 { |
|
1101 return CControlGroup::HandlePointerUpEventL(aPoint); |
|
1102 } |
|
1103 |
|
1104 EXPORT_C CFepUiBaseCtrl* CVirtualKeyboard::HandlePointerMoveEventL(const TPoint& aPoint) |
|
1105 { |
|
1106 return CControlGroup::HandlePointerMoveEventL(aPoint); |
|
1107 } |
|
1108 */ |
|
1109 //end of implementation of class CVirtualKeyboard |
|
1110 |
|
1111 // Implementation of Class CVirtualKey |
|
1112 |
|
1113 // --------------------------------------------------------------------------- |
|
1114 // CVirtualKey::CVirtualKey |
|
1115 // default constructor |
|
1116 // --------------------------------------------------------------------------- |
|
1117 // |
|
1118 CVirtualKey::CVirtualKey(TUint aCode, TInt aScanCode, |
|
1119 const TRect& aRect, TInt aHighlightBmpIdx, TInt aHighlightMaskBmpId) |
|
1120 : |
|
1121 iRect(aRect), |
|
1122 iHighlightBmpIndex(aHighlightBmpIdx), |
|
1123 iHighlightMaskBmpIndex(aHighlightMaskBmpId), |
|
1124 iIsLatchKey(EFalse),iLatched(EFalse) |
|
1125 { |
|
1126 iCode = aCode; |
|
1127 iScanCode = aScanCode; |
|
1128 } |
|
1129 |
|
1130 // --------------------------------------------------------------------------- |
|
1131 // CVirtualKey::CVirtualKey |
|
1132 // default constructor |
|
1133 // --------------------------------------------------------------------------- |
|
1134 // |
|
1135 CVirtualKey::CVirtualKey(TInt aScanCode, |
|
1136 const TRect& aRect) |
|
1137 : iRect(aRect), |
|
1138 iHighlightBmpIndex(-1), |
|
1139 iHighlightMaskBmpIndex(-1), |
|
1140 iIsLatchKey(EFalse),iLatched(EFalse) |
|
1141 { |
|
1142 iScanCode = aScanCode; |
|
1143 } |
|
1144 |
|
1145 // --------------------------------------------------------------------------- |
|
1146 // CVirtualKey::NewL |
|
1147 // factory function |
|
1148 // --------------------------------------------------------------------------- |
|
1149 // |
|
1150 EXPORT_C CVirtualKey* CVirtualKey::NewL(TUint aCode, TInt aScanCode, |
|
1151 const TRect& aRect, const TRect& aCharRect, |
|
1152 TInt aBaseLine, TInt aHighlightBmpIdx, |
|
1153 TInt aHighlightMaskBmpId) |
|
1154 { |
|
1155 TBuf<1> buf; |
|
1156 buf.Append(aCode); |
|
1157 return CVirtualKey::NewL(buf,aScanCode,aRect,aCharRect,aBaseLine, |
|
1158 aHighlightBmpIdx,aHighlightMaskBmpId); |
|
1159 } |
|
1160 |
|
1161 // --------------------------------------------------------------------------- |
|
1162 // CVirtualKey::NewL |
|
1163 // factory fuction |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // |
|
1166 EXPORT_C CVirtualKey* CVirtualKey::NewL(const TDesC& aCodeData, TInt aScanCode, |
|
1167 const TRect& aRect, const TRect& /*aCharRect*/, |
|
1168 TInt /*aBaseLine*/, TInt aHighlightBmpIdx, |
|
1169 TInt aHighlightMaskBmpId) |
|
1170 { |
|
1171 TUint code = 0; |
|
1172 |
|
1173 if(aCodeData.Length()) |
|
1174 code = aCodeData[0]; |
|
1175 |
|
1176 CVirtualKey* key = new(ELeave) CVirtualKey(code,aScanCode,aRect, |
|
1177 aHighlightBmpIdx, |
|
1178 aHighlightMaskBmpId); |
|
1179 CleanupStack::PushL(key); |
|
1180 |
|
1181 if (code == 0xffffffff|| |
|
1182 code == 0xffff) |
|
1183 { |
|
1184 key->ConstructL(KNullDesC()); |
|
1185 } |
|
1186 else |
|
1187 { |
|
1188 key->ConstructL(aCodeData); |
|
1189 } |
|
1190 |
|
1191 CleanupStack::Pop(key); |
|
1192 return key; |
|
1193 } |
|
1194 |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // CVirtualKey::NewL |
|
1197 // factory fuction |
|
1198 // --------------------------------------------------------------------------- |
|
1199 // |
|
1200 EXPORT_C CVirtualKey* CVirtualKey::NewL(RPointerArray<HBufC>& aUnicodesList, |
|
1201 TInt aScanCode, |
|
1202 const TRect& aRect) |
|
1203 { |
|
1204 CVirtualKey* key = new (ELeave) CVirtualKey(aScanCode, |
|
1205 aRect); |
|
1206 CleanupStack::PushL(key); |
|
1207 key->ConstructL(aUnicodesList); |
|
1208 CleanupStack::Pop(key); |
|
1209 return key; |
|
1210 } |
|
1211 |
|
1212 // --------------------------------------------------------------------------- |
|
1213 // CVirtualKey::ConstructL() |
|
1214 // 2nd constructor |
|
1215 // --------------------------------------------------------------------------- |
|
1216 // |
|
1217 void CVirtualKey::ConstructL(const TDesC& aCodeData) |
|
1218 { |
|
1219 iCodeData = aCodeData.AllocL(); |
|
1220 } |
|
1221 |
|
1222 // --------------------------------------------------------------------------- |
|
1223 // CVirtualKey::ConstructL() |
|
1224 // 2nd constructor |
|
1225 // --------------------------------------------------------------------------- |
|
1226 // |
|
1227 void CVirtualKey::ConstructL(const RPointerArray<HBufC>& aUnicodesList) |
|
1228 { |
|
1229 iCodeData = KNullDesC().AllocL(); |
|
1230 |
|
1231 for (TInt i = 0; i <= EPosLast; i++) |
|
1232 { |
|
1233 if (i <= aUnicodesList.Count() - 1) |
|
1234 { |
|
1235 iUnicodesList.AppendL(aUnicodesList[i]); |
|
1236 } |
|
1237 else |
|
1238 { |
|
1239 iUnicodesList.AppendL(NULL); |
|
1240 } |
|
1241 } |
|
1242 } |
|
1243 |
|
1244 // CVirtualKey::~CVirtualKey |
|
1245 // default destructor |
|
1246 // --------------------------------------------------------------------------- |
|
1247 // |
|
1248 EXPORT_C CVirtualKey::~CVirtualKey() |
|
1249 { |
|
1250 delete iCodeData; |
|
1251 delete iDisplayCodeData; |
|
1252 iUnicodesList.ResetAndDestroy(); |
|
1253 iUnicodesList.Close(); |
|
1254 } |
|
1255 |
|
1256 |
|
1257 // --------------------------------------------------------------------------- |
|
1258 // set latch state |
|
1259 // --------------------------------------------------------------------------- |
|
1260 // |
|
1261 EXPORT_C void CVirtualKey::SetLatched(TBool aFlag) |
|
1262 { |
|
1263 if(!iIsLatchKey || iLatched == aFlag) |
|
1264 return; |
|
1265 |
|
1266 iLatched = aFlag; |
|
1267 if(iKeyCtrl) |
|
1268 { |
|
1269 //find key |
|
1270 //iKeyboard->DrawKey(this); |
|
1271 iKeyCtrl->Draw(); |
|
1272 } |
|
1273 } |
|
1274 |
|
1275 // --------------------------------------------------------------------------- |
|
1276 //set key rect |
|
1277 // --------------------------------------------------------------------------- |
|
1278 // |
|
1279 EXPORT_C void CVirtualKey::SetRect(const TRect& aRect) |
|
1280 { |
|
1281 if(iRect == aRect) |
|
1282 return; |
|
1283 //if(iKeyboard) |
|
1284 // iKeyboard->ChangeFeedbackArea(reinterpret_cast<TInt>(this),aRect,iRect); |
|
1285 iRect = aRect; |
|
1286 |
|
1287 // CVirtualKey's rect is not absoluate position, but relative to keyboard, |
|
1288 // so need to move CVirtualKeyCtrl |
|
1289 if(iKeyCtrl) |
|
1290 { |
|
1291 iKeyCtrl->SetRect(iRect); |
|
1292 iKeyCtrl->Move(iKeyCtrl->Keyboard()->Rect().iTl); |
|
1293 } |
|
1294 } |
|
1295 |
|
1296 EXPORT_C void CVirtualKey::SetUnicodesL(RPointerArray<HBufC>& aUnicodesList) |
|
1297 { |
|
1298 iUnicodesList.ResetAndDestroy(); |
|
1299 |
|
1300 for (TInt i = 0; i <= EPosLast; i++) |
|
1301 { |
|
1302 if (i <= aUnicodesList.Count() - 1) |
|
1303 { |
|
1304 iUnicodesList.AppendL(aUnicodesList[i]); |
|
1305 } |
|
1306 else |
|
1307 { |
|
1308 iUnicodesList.AppendL(NULL); |
|
1309 } |
|
1310 } |
|
1311 } |
|
1312 |
|
1313 EXPORT_C TVirtualKeyIrregularKeyType CVirtualKey::IrregualrKeyType() |
|
1314 { |
|
1315 return iIrregularKeyType; |
|
1316 } |
|
1317 |
|
1318 EXPORT_C void CVirtualKey::SetIrregualrKeyType(TVirtualKeyIrregularKeyType aKeyType) |
|
1319 { |
|
1320 iIrregularKeyType = aKeyType; |
|
1321 } |
|
1322 |
|
1323 // --------------------------------------------------------------------------- |
|
1324 // CVirtualKey::KeyUnicodes |
|
1325 //Return key unicodes in a specific position -- support for multi language |
|
1326 // --------------------------------------------------------------------------- |
|
1327 const TDesC& CVirtualKey::KeyUnicodes(TVirtualKeyTextPos aPos) const |
|
1328 { |
|
1329 if (aPos >= 0 && aPos <= EPosLast && iUnicodesList[aPos]) |
|
1330 { |
|
1331 return *(iUnicodesList[aPos]); |
|
1332 } |
|
1333 |
|
1334 return KNullDesC; |
|
1335 } |
|
1336 |
|
1337 TBool CVirtualKey::UnicodesListEmpty(TInt& aIdx) |
|
1338 { |
|
1339 if (iUnicodesList.Count() == 0) |
|
1340 { |
|
1341 return ETrue; |
|
1342 } |
|
1343 |
|
1344 TBool empty = ETrue; |
|
1345 |
|
1346 for (TInt i = 0; i <= EPosLast; i++) |
|
1347 { |
|
1348 if (iUnicodesList[i]) |
|
1349 { |
|
1350 empty = EFalse; |
|
1351 aIdx = i; |
|
1352 break; |
|
1353 } |
|
1354 } |
|
1355 |
|
1356 return empty; |
|
1357 } |
|
1358 |
|
1359 EXPORT_C void CVirtualKey::SetDisplayUnicodeL( const TDesC& aDspUnicode ) |
|
1360 { |
|
1361 delete iDisplayCodeData; |
|
1362 iDisplayCodeData = NULL; |
|
1363 iDisplayCodeData = aDspUnicode.AllocL(); |
|
1364 } |
|
1365 |
|
1366 EXPORT_C void CVirtualKey::HideKeyCtrl( TBool aHide ) |
|
1367 { |
|
1368 if ( iKeyCtrl ) |
|
1369 { |
|
1370 iKeyCtrl->Hide( aHide ); |
|
1371 } |
|
1372 } |
|
1373 //end of implementation of Class CVirtualKey |