20 #include <w32std.h> |
20 #include <w32std.h> |
21 #include <AknsDrawUtils.h> |
21 #include <AknsDrawUtils.h> |
22 #include <eikenv.h> |
22 #include <eikenv.h> |
23 #include <AknsConstants.h> |
23 #include <AknsConstants.h> |
24 #include <AknUtils.h> |
24 #include <AknUtils.h> |
|
25 #include <featmgr.h> |
25 |
26 |
26 #include "peninputlayoutvirtualkeyctrl.h" |
27 #include "peninputlayoutvirtualkeyctrl.h" |
27 #include "peninputlayoutvkb.h" |
28 #include "peninputlayoutvkb.h" |
28 #include "peninputlayout.h" |
29 #include "peninputlayout.h" |
29 #include "peninputpluginutils.h" |
30 #include "peninputpluginutils.h" |
|
31 #include "peninputcmd.h" |
30 |
32 |
31 _LIT( KKeyShiftCharacter, "\x2191"); |
33 _LIT( KKeyShiftCharacter, "\x2191"); |
|
34 _LIT( KKeyStarCharacter, "\x002a"); |
32 |
35 |
33 const TInt KDefaultKeyMargin = 10; |
36 const TInt KDefaultKeyMargin = 10; |
34 |
37 |
35 // --------------------------------------------------------------------------- |
38 // --------------------------------------------------------------------------- |
36 // CVirtualKeyCtrl::NewL |
39 // CVirtualKeyCtrl::NewL |
99 // --------------------------------------------------------------------------- |
102 // --------------------------------------------------------------------------- |
100 // |
103 // |
101 void CVirtualKeyCtrl::ConstructL() |
104 void CVirtualKeyCtrl::ConstructL() |
102 { |
105 { |
103 BaseConstructL(); |
106 BaseConstructL(); |
|
107 |
|
108 //tap accuracy enhancement |
|
109 if( FeatureManager::FeatureSupported( KFeatureIdFfCapacitiveDisplay )) |
|
110 { |
|
111 EnableExtResponseArea( ETrue, TRect(TPoint(10,10),TSize(10,10)) ); |
|
112 } |
104 } |
113 } |
105 |
114 |
106 // --------------------------------------------------------------------------- |
115 // --------------------------------------------------------------------------- |
107 // CVirtualKeyCtrl::DrawKeyText |
116 // CVirtualKeyCtrl::DrawKeyText |
108 // Draw key text |
117 // Draw key text |
109 // (other items were commented in a header). |
118 // (other items were commented in a header). |
110 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
111 // |
120 // |
112 void CVirtualKeyCtrl::DrawKeyText() |
121 void CVirtualKeyCtrl::DrawKeyText(CFbsBitGc* aGc) |
113 { |
122 { |
114 TBool textlineset = EFalse; |
123 TBool textlineset = EFalse; |
115 |
124 |
116 // if text line set |
125 // if text line set |
117 for (TInt i = 0; i <= EPosLast; i++) |
126 for (TInt i = 0; i <= EPosLast; i++) |
121 textlineset = ETrue; |
130 textlineset = ETrue; |
122 |
131 |
123 if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC) |
132 if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC) |
124 { |
133 { |
125 TAknLayoutText textLayout; |
134 TAknLayoutText textLayout; |
126 textLayout.LayoutText(Rect(), |
135 textLayout.LayoutText(GetRect(), |
127 iKeyboard->TextLineLayout(TVirtualKeyTextPos(i))); |
136 iKeyboard->TextLineLayout(TVirtualKeyTextPos(i))); |
128 TRgb color( KRgbBlack ); // sane default for nonskinned case |
137 TRgb color( KRgbBlack ); // sane default for nonskinned case |
129 if ( AknsUtils::AvkonSkinEnabled() ) |
138 if ( AknsUtils::AvkonSkinEnabled() ) |
130 { |
139 { |
131 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
140 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
132 color, |
141 color, |
133 KAknsIIDQsnTextColors, |
142 KAknsIIDQsnTextColors, |
134 iKeyboard->KeyTextColorGroup() ); |
143 iKeyboard->KeyTextColorGroup() ); |
135 } |
144 } |
136 |
145 |
137 // replace the shift text to shift icon |
146 // replace the shift text to shift icon |
138 if( iKeyboard->ShiftIcon() && |
147 if( iKeyboard->ShiftIcon() && |
139 iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter ) |
148 iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter ) |
140 { |
149 { |
141 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
150 //CFbsBitGc* gc = GetGc();//static_cast<CFbsBitGc*>(BitGc()); |
142 AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(), |
151 AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(), |
143 *gc, |
152 *aGc, |
144 textLayout.TextRect() ); |
153 textLayout.TextRect() ); |
|
154 } |
|
155 else if(iKeyboard->StarIcon() && |
|
156 iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyStarCharacter ) |
|
157 { |
|
158 //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
159 AknPenInputDrawUtils::DrawColorIcon( iKeyboard->StarIcon(), |
|
160 *aGc, |
|
161 textLayout.TextRect() ); |
145 } |
162 } |
146 else |
163 else |
147 { |
164 { |
148 textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)), |
165 textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)), |
149 EFalse, color); |
166 EFalse, color); |
150 } |
167 } |
151 } |
168 } |
152 } |
169 } |
153 } |
170 } |
154 |
171 |
155 if (!textlineset) |
172 if (!textlineset) |
156 { |
173 { |
157 TAknLayoutText textLayout; |
174 TAknLayoutText textLayout; |
158 textLayout.LayoutText(Rect(), iKeyboard->iVKBTextLineLayout); |
175 textLayout.LayoutText(GetRect(), iKeyboard->iVKBTextLineLayout); |
159 |
176 |
160 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
177 //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
161 |
178 |
162 //charRect.Move(keyboardRect.iTl); |
179 //charRect.Move(keyboardRect.iTl); |
163 //if(iKeyInfo->Dimmed()) |
180 //if(iKeyInfo->Dimmed()) |
164 // { |
181 // { |
165 // gc->SetFadingParameters(iKeyboard->iFadingParamBlack, iKeyboard->iFadingParamWhite); |
182 // gc->SetFadingParameters(iKeyboard->iFadingParamBlack, iKeyboard->iFadingParamWhite); |
167 // } |
184 // } |
168 TRgb color( KRgbBlack ); // sane default for nonskinned case |
185 TRgb color( KRgbBlack ); // sane default for nonskinned case |
169 if ( AknsUtils::AvkonSkinEnabled() || |
186 if ( AknsUtils::AvkonSkinEnabled() || |
170 iKeyboard->KeyTextColorGroup() != INVALID_COLOR_GROUP ) |
187 iKeyboard->KeyTextColorGroup() != INVALID_COLOR_GROUP ) |
171 { |
188 { |
172 AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
189 AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), |
173 color, |
190 color, |
174 KAknsIIDQsnTextColors, |
191 KAknsIIDQsnTextColors, |
175 iKeyboard->KeyTextColorGroup() ); |
192 iKeyboard->KeyTextColorGroup() ); |
176 } |
193 } |
177 else |
194 else |
183 { |
200 { |
184 color = KRgbGray; |
201 color = KRgbGray; |
185 } |
202 } |
186 if( iKeyInfo->DisplayUnicode() && iKeyInfo->DisplayUnicode()->Length() != 0) |
203 if( iKeyInfo->DisplayUnicode() && iKeyInfo->DisplayUnicode()->Length() != 0) |
187 { |
204 { |
188 textLayout.DrawText(*BitGc(), *iKeyInfo->DisplayUnicode(), EFalse, color); |
205 textLayout.DrawText(*aGc, *iKeyInfo->DisplayUnicode(), EFalse, color); |
189 } |
206 } |
190 else |
207 else |
191 { |
208 { |
192 textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(), EFalse, color); |
209 textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(), EFalse, color); |
193 } |
210 } |
194 |
211 |
195 //if(iKeyInfo->Dimmed()) |
212 //if(iKeyInfo->Dimmed()) |
196 // gc->SetFaded(EFalse); |
213 // gc->SetFaded(EFalse); |
197 |
214 |
217 iVirtualKeyDrawInfo.iVKDimRightImgID.iMajor) |
234 iVirtualKeyDrawInfo.iVKDimRightImgID.iMajor) |
218 { |
235 { |
219 TRect innerRect = Rect(); |
236 TRect innerRect = Rect(); |
220 innerRect.Shrink( 4, 0 ); |
237 innerRect.Shrink( 4, 0 ); |
221 |
238 |
222 AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(), |
239 AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(), |
223 *gc, |
240 *gc, |
224 Rect(), |
241 Rect(), |
225 innerRect, |
242 innerRect, |
226 iVirtualKeyDrawInfo.iVKDimLeftImgID, |
243 iVirtualKeyDrawInfo.iVKDimLeftImgID, |
227 iVirtualKeyDrawInfo.iVKDimMiddleImgID, |
244 iVirtualKeyDrawInfo.iVKDimMiddleImgID, |
234 else if (iKeyboard->KeySkinId(EKeyBmpDim) != KAknsIIDNone) |
251 else if (iKeyboard->KeySkinId(EKeyBmpDim) != KAknsIIDNone) |
235 { |
252 { |
236 TRect innerrect = rect; |
253 TRect innerrect = rect; |
237 innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); |
254 innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); |
238 |
255 |
239 AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), |
256 AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), |
240 *gc, |
257 *gc, |
241 rect, |
258 rect, |
242 innerrect, |
259 innerrect, |
243 iKeyboard->KeySkinId(EKeyBmpDim), |
260 iKeyboard->KeySkinId(EKeyBmpDim), |
244 KAknsIIDDefault); |
261 KAknsIIDDefault); |
295 void CVirtualKeyCtrl::DrawBmp(const TRect& aDestRect,const TRect& aSourceRect, |
312 void CVirtualKeyCtrl::DrawBmp(const TRect& aDestRect,const TRect& aSourceRect, |
296 const CFbsBitmap* aBmp,CFbsBitmap* aMask, |
313 const CFbsBitmap* aBmp,CFbsBitmap* aMask, |
297 TBool aInvertFlag) |
314 TBool aInvertFlag) |
298 { |
315 { |
299 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
316 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
|
317 DrawBmp(gc,aDestRect,aSourceRect,aBmp,aMask,aInvertFlag); |
|
318 } |
|
319 |
|
320 // --------------------------------------------------------------------------- |
|
321 // CVirtualKeyCtrl::DrawBmp |
|
322 // Draw bitmap |
|
323 // (other items were commented in a header). |
|
324 // --------------------------------------------------------------------------- |
|
325 // |
|
326 void CVirtualKeyCtrl::DrawBmp(CFbsBitGc* aGc, const TRect& aDestRect,const TRect& aSourceRect, |
|
327 const CFbsBitmap* aBmp,CFbsBitmap* aMask, |
|
328 TBool aInvertFlag) |
|
329 { |
300 if(aMask) |
330 if(aMask) |
301 { |
331 { |
302 //TRect bmpRect(TPoint(0,0),aMask->SizeInPixels()); |
332 //TRect bmpRect(TPoint(0,0),aMask->SizeInPixels()); |
303 gc->DrawBitmapMasked(aDestRect,aBmp,aSourceRect,aMask,aInvertFlag); |
333 aGc->DrawBitmapMasked(aDestRect,aBmp,aSourceRect,aMask,aInvertFlag); |
304 } |
334 } |
305 else |
335 else |
306 { |
336 { |
307 gc->DrawBitmap(aDestRect,aBmp,aSourceRect); |
337 aGc->DrawBitmap(aDestRect,aBmp,aSourceRect); |
308 } |
338 } |
309 } |
339 } |
310 |
340 |
311 // --------------------------------------------------------------------------- |
341 // --------------------------------------------------------------------------- |
312 // CVirtualKeyCtrl::DrawNormalStateKey |
342 // CVirtualKeyCtrl::DrawNormalStateKey |
313 // Draw key in normal state |
343 // Draw key in normal state |
326 iVirtualKeyDrawInfo.iVKRightImgID.iMajor) |
356 iVirtualKeyDrawInfo.iVKRightImgID.iMajor) |
327 { |
357 { |
328 TRect innerRect = Rect(); |
358 TRect innerRect = Rect(); |
329 innerRect.Shrink( 4, 0 ); |
359 innerRect.Shrink( 4, 0 ); |
330 |
360 |
331 AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(), |
361 AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(), |
332 *gc, |
362 *gc, |
333 Rect(), |
363 Rect(), |
334 innerRect, |
364 innerRect, |
335 iVirtualKeyDrawInfo.iVKLeftImgID, |
365 iVirtualKeyDrawInfo.iVKLeftImgID, |
336 iVirtualKeyDrawInfo.iVKMiddleImgID, |
366 iVirtualKeyDrawInfo.iVKMiddleImgID, |
342 } |
372 } |
343 else if (iKeyboard->KeySkinId(EKeyBmpNormal) != KAknsIIDNone) |
373 else if (iKeyboard->KeySkinId(EKeyBmpNormal) != KAknsIIDNone) |
344 { |
374 { |
345 TRect innerrect = rect; |
375 TRect innerrect = rect; |
346 innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); |
376 innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); |
347 |
377 TBool bHasDrawn = EFalse; |
348 AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), |
378 if(UiLayout()->NotDrawToLayoutDevice()) |
349 *gc, |
379 { |
350 rect, |
380 /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->NormalKeyBmp(), |
351 innerrect, |
381 iKeyboard->NormalKeyDev(), |
352 iKeyboard->KeySkinId(EKeyBmpNormal), |
382 rect,innerrect, |
353 KAknsIIDDefault); |
383 iKeyboard->KeySkinId(EKeyBmpNormal), |
|
384 KAknsIIDDefault,Rect());*/ |
|
385 TBool ret = iKeyboard->PrepareNormalKeyBmp(rect,innerrect,Rect()); |
|
386 if(ret) |
|
387 { |
|
388 gc->BitBlt(rect.iTl,iKeyboard->NormalKeyBmp()); |
|
389 bHasDrawn = ETrue; |
|
390 } |
|
391 } |
|
392 |
|
393 if(!bHasDrawn) |
|
394 { |
|
395 AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), |
|
396 *gc, |
|
397 rect, |
|
398 innerrect, |
|
399 iKeyboard->KeySkinId(EKeyBmpNormal), |
|
400 KAknsIIDDefault); |
|
401 } |
354 } |
402 } |
355 else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal ) ) |
403 else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal ) ) |
356 { |
404 { |
357 TRect srcRect(TPoint(0,0), |
405 TRect srcRect(TPoint(0,0), |
358 iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal )->SizeInPixels()); |
406 iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal )->SizeInPixels()); |
385 } |
433 } |
386 |
434 |
387 gc->SetPenColor( KRgbBlack ); |
435 gc->SetPenColor( KRgbBlack ); |
388 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
436 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
389 gc->SetFaded(EFalse); |
437 gc->SetFaded(EFalse); |
390 DrawKeyText(); |
438 DrawKeyText(gc); |
391 } |
439 } |
392 |
440 |
|
441 CFbsBitGc* CVirtualKeyCtrl::GetGc() |
|
442 { |
|
443 if(UiLayout()->NotDrawToLayoutDevice()) |
|
444 { |
|
445 //draw to highligh bitmap |
|
446 if(Keyboard()->Bitmap()->SizeInPixels() != Rect().Size()) |
|
447 { |
|
448 Keyboard()->Bitmap()->Resize(Rect().Size()); |
|
449 Keyboard()->HighlightDev()->Resize( Rect().Size()); |
|
450 //gc must be adjusted |
|
451 Keyboard()->HighlightGc()->Activate(Keyboard()->HighlightDev()); |
|
452 Keyboard()->HighlightGc()->Resized(); |
|
453 } |
|
454 return Keyboard()->HighlightGc(); |
|
455 } |
|
456 else |
|
457 return static_cast<CFbsBitGc*>(BitGc()); |
|
458 } |
|
459 |
393 // --------------------------------------------------------------------------- |
460 // --------------------------------------------------------------------------- |
394 // CVirtualKeyCtrl::DrawHighlightKey |
461 // CVirtualKeyCtrl::DrawHighlightKey |
395 // Draw key in highlight state |
462 // Draw key in highlight state |
396 // (other items were commented in a header). |
463 // (other items were commented in a header). |
397 // --------------------------------------------------------------------------- |
464 // --------------------------------------------------------------------------- |
398 // |
465 // |
399 void CVirtualKeyCtrl::DrawHighlightKey() |
466 void CVirtualKeyCtrl::DrawHighlightKey() |
400 { |
467 { |
401 CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc()); |
468 CFbsBitGc* gc = GetGc(); |
402 TRect rect = Rect(); |
469 if(UiLayout()->NotDrawToLayoutDevice()) |
|
470 gc->Activate( Keyboard()->HighlightDev() ); |
|
471 TRect rect = GetRect(); |
|
472 |
403 TPoint bmpPos = rect.iTl; |
473 TPoint bmpPos = rect.iTl; |
404 TRect bmpRect(TPoint(0,0),rect.Size()); |
474 TRect bmpRect(TPoint(0,0),rect.Size()); |
405 |
475 |
406 if(iVirtualKeyDrawInfo.iVKPressedLeftImgID.iMajor && |
476 if(iVirtualKeyDrawInfo.iVKPressedLeftImgID.iMajor && |
407 iVirtualKeyDrawInfo.iVKPressedMiddleImgID.iMajor && |
477 iVirtualKeyDrawInfo.iVKPressedMiddleImgID.iMajor && |
408 iVirtualKeyDrawInfo.iVKPressedRightImgID.iMajor) |
478 iVirtualKeyDrawInfo.iVKPressedRightImgID.iMajor) |
409 { |
479 { |
410 TRect innerRect = Rect(); |
480 TRect innerRect = GetRect(); |
411 innerRect.Shrink( 4, 0 ); |
481 innerRect.Shrink( 4, 0 ); |
412 |
482 |
413 AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(), |
483 AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(), |
414 *gc, |
484 *gc, |
415 Rect(), |
485 GetRect(), |
416 innerRect, |
486 innerRect, |
417 iVirtualKeyDrawInfo.iVKPressedLeftImgID, |
487 iVirtualKeyDrawInfo.iVKPressedLeftImgID, |
418 iVirtualKeyDrawInfo.iVKPressedMiddleImgID, |
488 iVirtualKeyDrawInfo.iVKPressedMiddleImgID, |
419 iVirtualKeyDrawInfo.iVKPressedRightImgID); |
489 iVirtualKeyDrawInfo.iVKPressedRightImgID); |
420 |
490 |
426 |
496 |
427 //do we have highlight background bmp for this key? |
497 //do we have highlight background bmp for this key? |
428 else if (iKeyboard->KeySkinId(EKeyBmpHighlight) != KAknsIIDNone) |
498 else if (iKeyboard->KeySkinId(EKeyBmpHighlight) != KAknsIIDNone) |
429 { |
499 { |
430 TRect innerrect = rect; |
500 TRect innerrect = rect; |
|
501 |
431 innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); |
502 innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); |
432 |
503 TBool bHasDrawn = EFalse; |
433 AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), |
504 if(UiLayout()->NotDrawToLayoutDevice()) |
434 *gc, |
505 { |
435 rect, |
506 /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->HighightKeyBmp(), |
436 innerrect, |
507 iKeyboard->HighlightKeyDev(), |
437 iKeyboard->KeySkinId(EKeyBmpHighlight), |
508 rect,innerrect, |
438 KAknsIIDDefault); |
509 iKeyboard->KeySkinId(EKeyBmpHighlight), |
|
510 KAknsIIDDefault,Rect());*/ |
|
511 TBool ret = iKeyboard->PrepareHighlightKeyBmp(rect,innerrect,Rect()); |
|
512 if(ret) |
|
513 { |
|
514 gc->BitBlt(rect.iTl,iKeyboard->HighightKeyBmp()); |
|
515 bHasDrawn = ETrue; |
|
516 } |
|
517 } |
|
518 |
|
519 if(!bHasDrawn) |
|
520 { |
|
521 AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), |
|
522 *gc, |
|
523 rect, |
|
524 innerrect, |
|
525 iKeyboard->KeySkinId(EKeyBmpHighlight), |
|
526 KAknsIIDDefault); |
|
527 } |
439 } |
528 } |
440 else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ) ) |
529 else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ) ) |
441 { |
530 { |
442 TRect srcRect(TPoint(0,0), |
531 TRect srcRect(TPoint(0,0), |
443 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight )->SizeInPixels()); |
532 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight )->SizeInPixels()); |
444 DrawBmp(rect, |
533 DrawBmp(gc, rect, |
445 srcRect, |
534 srcRect, |
446 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ), |
535 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ), |
447 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlightMask ), |
536 iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlightMask ), |
448 ETrue); |
537 ETrue); |
449 } |
538 } |
472 |
561 |
473 gc->SetPenColor( KRgbBlack ); |
562 gc->SetPenColor( KRgbBlack ); |
474 |
563 |
475 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
564 gc->SetBrushStyle( CGraphicsContext::ENullBrush ); |
476 gc->SetFaded(EFalse); |
565 gc->SetFaded(EFalse); |
477 DrawKeyText(); |
566 if(UiLayout()->NotDrawToLayoutDevice()) |
|
567 { |
|
568 DrawKeyText(Keyboard()->HighlightGc()); |
|
569 UpdateChangedArea(ETrue); |
|
570 } |
|
571 else |
|
572 { |
|
573 DrawKeyText(gc); |
|
574 } |
478 |
575 |
479 } |
576 } |
480 |
577 |
481 // --------------------------------------------------------------------------- |
578 // --------------------------------------------------------------------------- |
482 // CVirtualKeyCtrl::Draw |
579 // CVirtualKeyCtrl::Draw |
536 |
633 |
537 CFepUiBaseCtrl::HandlePointerDownEventL(aPoint); |
634 CFepUiBaseCtrl::HandlePointerDownEventL(aPoint); |
538 |
635 |
539 //draw key new state |
636 //draw key new state |
540 iKeyboard->DrawBubble(iKeyInfo); |
637 iKeyboard->DrawBubble(iKeyInfo); |
541 ReDraw(); |
638 if(UiLayout()->NotDrawToLayoutDevice()) |
|
639 { |
|
640 if( !(iKeyInfo->Dimmed()) && (iKeyInfo->Latched() || (PointerDown()&&!iKeyInfo->IsLatchKey())) ) |
|
641 { |
|
642 DrawHighlightKey(); |
|
643 } |
|
644 else |
|
645 { |
|
646 ReDraw(); |
|
647 } |
|
648 } |
|
649 else |
|
650 { |
|
651 ReDraw(); |
|
652 UpdateArea( Rect() ); |
|
653 } |
542 UpdateArea( Rect() ); |
654 UpdateArea( Rect() ); |
543 |
655 |
544 if(iKeyInfo->IsLatchKey()) |
656 if(iKeyInfo->IsLatchKey()) |
545 { |
657 { |
546 // Only set latch status, not generate event for latch key |
658 // Only set latch status, not generate event for latch key |
575 { |
687 { |
576 // When key up, latch key will generate event. |
688 // When key up, latch key will generate event. |
577 // When key down, latch key won't generate event. |
689 // When key down, latch key won't generate event. |
578 eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched; |
690 eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched; |
579 } |
691 } |
580 ReDraw(); |
692 if(UiLayout()->NotDrawToLayoutDevice()) |
581 UpdateAreaImmed( Rect() ); |
693 { |
|
694 //no need to draw again, just remove the highlight bitmap |
|
695 UpdateChangedArea(EFalse); |
|
696 Draw(); |
|
697 } |
|
698 else |
|
699 { |
|
700 ReDraw(); |
|
701 UpdateAreaImmed( Rect() ); |
|
702 } |
582 ReportKeyEvent(eventType); |
703 ReportKeyEvent(eventType); |
583 |
704 |
584 |
705 |
585 //Advanced tactile feedback REQ 417-47932 |
706 //Advanced tactile feedback REQ 417-47932 |
586 #ifdef RD_TACTILE_FEEDBACK |
707 #ifdef RD_TACTILE_FEEDBACK |
587 if (UiLayout()->SupportTactileFeedback()) |
708 if (UiLayout()->SupportTactileFeedback()) |
588 { |
709 { |
589 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse); |
710 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse); |
590 } |
711 } |
591 #endif // RD_TACTILE_FEEDBACK |
712 #endif // RD_TACTILE_FEEDBACK |
592 return this; |
713 return this; |
593 } |
714 } |
594 |
715 |
633 { |
759 { |
634 iKeyInfo->SetLatched(!iKeyInfo->Latched()); |
760 iKeyInfo->SetLatched(!iKeyInfo->Latched()); |
635 } |
761 } |
636 |
762 |
637 iKeyboard->ClearBubble(ETrue); |
763 iKeyboard->ClearBubble(ETrue); |
638 ReDraw(); |
764 if(UiLayout()->NotDrawToLayoutDevice()) |
639 UpdateArea( Rect() ); |
765 { |
|
766 UpdateChangedArea(EFalse); |
|
767 } |
|
768 else |
|
769 { |
|
770 ReDraw(); |
|
771 UpdateArea( Rect() ); |
|
772 } |
640 |
773 |
641 #ifdef RD_TACTILE_FEEDBACK |
774 #ifdef RD_TACTILE_FEEDBACK |
642 if ( iKeyboard->GowithPointerDown() ) |
775 if ( iKeyboard->GowithPointerDown() ) |
643 { |
776 { |
644 |
777 |
645 if (UiLayout()->SupportTactileFeedback()) |
778 if (UiLayout()->SupportTactileFeedback()) |
646 { |
779 { |
647 if (!Hiden()) |
780 if (!Hiden()) |
648 { |
781 { |
649 UiLayout()->DoTactileFeedback(ETouchFeedbackBasicKeypad, ETrue, EFalse); |
782 UiLayout()->DoTactileFeedback(ETouchFeedbackCharacterInputButton, ETrue, EFalse); |
650 } |
783 } |
651 } |
784 } |
652 } |
785 } |
653 #endif //RD_TACTILE_FEEDBACK |
786 #endif //RD_TACTILE_FEEDBACK |
654 } |
787 } |
655 |
788 |
656 void CVirtualKeyCtrl::CancelPointerDownL() |
789 void CVirtualKeyCtrl::CancelPointerDownL() |
657 { |
790 { |
658 CFepUiBaseCtrl::CancelPointerDownL(); |
791 CFepUiBaseCtrl::CancelPointerDownL(); |
659 iKeyboard->ClearBubble(ETrue); |
792 iKeyboard->ClearBubble(ETrue); |
660 ReDraw(); |
793 if(UiLayout()->NotDrawToLayoutDevice()) |
661 UpdateArea( Rect() ); |
794 { |
|
795 UpdateChangedArea(EFalse); |
|
796 } |
|
797 else |
|
798 { |
|
799 ReDraw(); |
|
800 UpdateArea( Rect() ); |
|
801 } |
662 } |
802 } |
663 // --------------------------------------------------------------------------- |
803 // --------------------------------------------------------------------------- |
664 // CVirtualKeyCtrl::ReDraw |
804 // CVirtualKeyCtrl::ReDraw |
665 // Redraw and updates the key |
805 // Redraw and updates the key |
666 // (other items were commented in a header). |
806 // (other items were commented in a header). |
667 // --------------------------------------------------------------------------- |
807 // --------------------------------------------------------------------------- |
668 // |
808 // |
669 void CVirtualKeyCtrl::ReDraw() |
809 void CVirtualKeyCtrl::ReDraw() |
670 { |
810 { |
671 Draw(); |
811 if(UiLayout()->NotDrawToLayoutDevice()) |
672 UpdateArea(Rect(), EFalse); |
812 { |
|
813 if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey())) |
|
814 { |
|
815 DrawHighlightKey(); |
|
816 UpdateChangedArea(ETrue); |
|
817 } |
|
818 else |
|
819 { |
|
820 Draw(); |
|
821 UpdateArea(Rect(), EFalse); |
|
822 } |
|
823 } |
|
824 else |
|
825 { |
|
826 Draw(); |
|
827 UpdateArea(Rect(), EFalse); |
|
828 } |
673 } |
829 } |
674 |
830 |
675 // --------------------------------------------------------------------------- |
831 // --------------------------------------------------------------------------- |
676 // CVirtualKeyCtrl::ReportKeyEvent |
832 // CVirtualKeyCtrl::ReportKeyEvent |
677 // Report current key event |
833 // Report current key event |
885 // (other items were commented in a header). |
1041 // (other items were commented in a header). |
886 // --------------------------------------------------------------------------- |
1042 // --------------------------------------------------------------------------- |
887 // |
1043 // |
888 void CVirtualRawKeyCtrl::HandlePointerLeave(const TPoint& aPoint) |
1044 void CVirtualRawKeyCtrl::HandlePointerLeave(const TPoint& aPoint) |
889 { |
1045 { |
|
1046 if(UiLayout()->NotDrawToLayoutDevice()) |
|
1047 { |
|
1048 UpdateChangedArea(EFalse); |
|
1049 } |
890 TRawEvent event; |
1050 TRawEvent event; |
891 event.Set(TRawEvent::EButton1Up,aPoint.iX,aPoint.iY); |
1051 event.Set(TRawEvent::EButton1Up,aPoint.iX,aPoint.iY); |
892 |
1052 |
893 SimulateRawEvent(event); |
1053 SimulateRawEvent(event); |
894 |
1054 |
896 #ifdef RD_TACTILE_FEEDBACK |
1056 #ifdef RD_TACTILE_FEEDBACK |
897 if (UiLayout()->SupportTactileFeedback()) |
1057 if (UiLayout()->SupportTactileFeedback()) |
898 { |
1058 { |
899 if (!VirtualKey()->Dimmed() && !Hiden()) |
1059 if (!VirtualKey()->Dimmed() && !Hiden()) |
900 { |
1060 { |
901 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse); |
1061 UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse); |
902 } |
1062 } |
903 } |
1063 } |
904 #endif //RD_TACTILE_FEEDBACK |
1064 #endif //RD_TACTILE_FEEDBACK |
905 } |
1065 } |
|
1066 |
|
1067 TRect CVirtualKeyCtrl::GetRect() |
|
1068 { |
|
1069 TRect r(Rect()); |
|
1070 if(UiLayout()->NotDrawToLayoutDevice()) |
|
1071 { |
|
1072 if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey())) |
|
1073 { |
|
1074 r.Move(-r.iTl.iX, -r.iTl.iY); |
|
1075 } |
|
1076 } |
|
1077 return r; |
|
1078 } |
|
1079 |
|
1080 void CVirtualKeyCtrl::UpdateChangedArea(TBool aFlag) |
|
1081 { |
|
1082 struct SData |
|
1083 { |
|
1084 TUint32 ctrl; |
|
1085 TBool flag; |
|
1086 CFbsBitmap* bmp; |
|
1087 TRect pos; |
|
1088 } data; |
|
1089 |
|
1090 data.ctrl = (TUint32)this; |
|
1091 data.flag = aFlag; |
|
1092 data.bmp = Keyboard()->Bitmap();//aFlag ? Keyboard()->iBitmap : 0; |
|
1093 data.pos = Rect(); |
|
1094 TPtrC ptr; |
|
1095 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
1096 |
|
1097 UiLayout()->SignalOwner(ESignalUpdateChangedArea,ptr); |
|
1098 } |
906 //end of file |
1099 //end of file |