diff -r ebd48d2de13c -r ecbabf52600f textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp --- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp Tue Aug 31 15:31:50 2010 +0300 +++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp Wed Sep 01 12:23:33 2010 +0100 @@ -22,13 +22,16 @@ #include #include #include +#include #include "peninputlayoutvirtualkeyctrl.h" #include "peninputlayoutvkb.h" #include "peninputlayout.h" #include "peninputpluginutils.h" +#include "peninputcmd.h" _LIT( KKeyShiftCharacter, "\x2191"); +_LIT( KKeyStarCharacter, "\x002a"); const TInt KDefaultKeyMargin = 10; @@ -101,6 +104,12 @@ void CVirtualKeyCtrl::ConstructL() { BaseConstructL(); + + //tap accuracy enhancement + if( FeatureManager::FeatureSupported( KFeatureIdFfCapacitiveDisplay )) + { + EnableExtResponseArea( ETrue, TRect(TPoint(10,10),TSize(10,10)) ); + } } // --------------------------------------------------------------------------- @@ -109,7 +118,7 @@ // (other items were commented in a header). // --------------------------------------------------------------------------- // -void CVirtualKeyCtrl::DrawKeyText() +void CVirtualKeyCtrl::DrawKeyText(CFbsBitGc* aGc) { TBool textlineset = EFalse; @@ -123,12 +132,12 @@ if (iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) != KNullDesC) { TAknLayoutText textLayout; - textLayout.LayoutText(Rect(), + textLayout.LayoutText(GetRect(), iKeyboard->TextLineLayout(TVirtualKeyTextPos(i))); TRgb color( KRgbBlack ); // sane default for nonskinned case if ( AknsUtils::AvkonSkinEnabled() ) { - AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), + AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), color, KAknsIIDQsnTextColors, iKeyboard->KeyTextColorGroup() ); @@ -138,14 +147,22 @@ if( iKeyboard->ShiftIcon() && iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter ) { - CFbsBitGc* gc = static_cast(BitGc()); + //CFbsBitGc* gc = GetGc();//static_cast(BitGc()); AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(), - *gc, + *aGc, textLayout.TextRect() ); } + else if(iKeyboard->StarIcon() && + iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyStarCharacter ) + { + //CFbsBitGc* gc = static_cast(BitGc()); + AknPenInputDrawUtils::DrawColorIcon( iKeyboard->StarIcon(), + *aGc, + textLayout.TextRect() ); + } else { - textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)), + textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)), EFalse, color); } } @@ -155,9 +172,9 @@ if (!textlineset) { TAknLayoutText textLayout; - textLayout.LayoutText(Rect(), iKeyboard->iVKBTextLineLayout); + textLayout.LayoutText(GetRect(), iKeyboard->iVKBTextLineLayout); - CFbsBitGc* gc = static_cast(BitGc()); + //CFbsBitGc* gc = static_cast(BitGc()); //charRect.Move(keyboardRect.iTl); //if(iKeyInfo->Dimmed()) @@ -169,7 +186,7 @@ if ( AknsUtils::AvkonSkinEnabled() || iKeyboard->KeyTextColorGroup() != INVALID_COLOR_GROUP ) { - AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), + AknsUtils::GetCachedColor( UiLayout()->SkinInstance(), color, KAknsIIDQsnTextColors, iKeyboard->KeyTextColorGroup() ); @@ -185,11 +202,11 @@ } if( iKeyInfo->DisplayUnicode() && iKeyInfo->DisplayUnicode()->Length() != 0) { - textLayout.DrawText(*BitGc(), *iKeyInfo->DisplayUnicode(), EFalse, color); + textLayout.DrawText(*aGc, *iKeyInfo->DisplayUnicode(), EFalse, color); } else { - textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(), EFalse, color); + textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(), EFalse, color); } //if(iKeyInfo->Dimmed()) @@ -219,7 +236,7 @@ TRect innerRect = Rect(); innerRect.Shrink( 4, 0 ); - AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(), + AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(), *gc, Rect(), innerRect, @@ -236,7 +253,7 @@ TRect innerrect = rect; innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); - AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), + AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), *gc, rect, innerrect, @@ -283,7 +300,7 @@ gc->SetPenColor(KRgbBlack); gc->SetBrushStyle( CGraphicsContext::ENullBrush ); //Draw text again. - DrawKeyText(); + DrawKeyText(gc); } // --------------------------------------------------------------------------- @@ -297,15 +314,28 @@ TBool aInvertFlag) { CFbsBitGc* gc = static_cast(BitGc()); + DrawBmp(gc,aDestRect,aSourceRect,aBmp,aMask,aInvertFlag); + } + +// --------------------------------------------------------------------------- +// CVirtualKeyCtrl::DrawBmp +// Draw bitmap +// (other items were commented in a header). +// --------------------------------------------------------------------------- +// +void CVirtualKeyCtrl::DrawBmp(CFbsBitGc* aGc, const TRect& aDestRect,const TRect& aSourceRect, + const CFbsBitmap* aBmp,CFbsBitmap* aMask, + TBool aInvertFlag) + { if(aMask) { //TRect bmpRect(TPoint(0,0),aMask->SizeInPixels()); - gc->DrawBitmapMasked(aDestRect,aBmp,aSourceRect,aMask,aInvertFlag); + aGc->DrawBitmapMasked(aDestRect,aBmp,aSourceRect,aMask,aInvertFlag); } else { - gc->DrawBitmap(aDestRect,aBmp,aSourceRect); - } + aGc->DrawBitmap(aDestRect,aBmp,aSourceRect); + } } // --------------------------------------------------------------------------- @@ -328,7 +358,7 @@ TRect innerRect = Rect(); innerRect.Shrink( 4, 0 ); - AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(), + AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(), *gc, Rect(), innerRect, @@ -344,13 +374,31 @@ { TRect innerrect = rect; innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); - - AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), - *gc, - rect, - innerrect, - iKeyboard->KeySkinId(EKeyBmpNormal), - KAknsIIDDefault); + TBool bHasDrawn = EFalse; + if(UiLayout()->NotDrawToLayoutDevice()) + { + /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->NormalKeyBmp(), + iKeyboard->NormalKeyDev(), + rect,innerrect, + iKeyboard->KeySkinId(EKeyBmpNormal), + KAknsIIDDefault,Rect());*/ + TBool ret = iKeyboard->PrepareNormalKeyBmp(rect,innerrect,Rect()); + if(ret) + { + gc->BitBlt(rect.iTl,iKeyboard->NormalKeyBmp()); + bHasDrawn = ETrue; + } + } + + if(!bHasDrawn) + { + AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), + *gc, + rect, + innerrect, + iKeyboard->KeySkinId(EKeyBmpNormal), + KAknsIIDDefault); + } } else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpNormal ) ) { @@ -387,9 +435,28 @@ gc->SetPenColor( KRgbBlack ); gc->SetBrushStyle( CGraphicsContext::ENullBrush ); gc->SetFaded(EFalse); - DrawKeyText(); + DrawKeyText(gc); } - + +CFbsBitGc* CVirtualKeyCtrl::GetGc() + { + if(UiLayout()->NotDrawToLayoutDevice()) + { + //draw to highligh bitmap + if(Keyboard()->Bitmap()->SizeInPixels() != Rect().Size()) + { + Keyboard()->Bitmap()->Resize(Rect().Size()); + Keyboard()->HighlightDev()->Resize( Rect().Size()); + //gc must be adjusted + Keyboard()->HighlightGc()->Activate(Keyboard()->HighlightDev()); + Keyboard()->HighlightGc()->Resized(); + } + return Keyboard()->HighlightGc(); + } + else + return static_cast(BitGc()); + } + // --------------------------------------------------------------------------- // CVirtualKeyCtrl::DrawHighlightKey // Draw key in highlight state @@ -398,8 +465,11 @@ // void CVirtualKeyCtrl::DrawHighlightKey() { - CFbsBitGc* gc = static_cast(BitGc()); - TRect rect = Rect(); + CFbsBitGc* gc = GetGc(); + if(UiLayout()->NotDrawToLayoutDevice()) + gc->Activate( Keyboard()->HighlightDev() ); + TRect rect = GetRect(); + TPoint bmpPos = rect.iTl; TRect bmpRect(TPoint(0,0),rect.Size()); @@ -407,12 +477,12 @@ iVirtualKeyDrawInfo.iVKPressedMiddleImgID.iMajor && iVirtualKeyDrawInfo.iVKPressedRightImgID.iMajor) { - TRect innerRect = Rect(); + TRect innerRect = GetRect(); innerRect.Shrink( 4, 0 ); - AknPenInputDrawUtils::Draw3PiecesFrame(AknsUtils::SkinInstance(), + AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(), *gc, - Rect(), + GetRect(), innerRect, iVirtualKeyDrawInfo.iVKPressedLeftImgID, iVirtualKeyDrawInfo.iVKPressedMiddleImgID, @@ -428,20 +498,39 @@ else if (iKeyboard->KeySkinId(EKeyBmpHighlight) != KAknsIIDNone) { TRect innerrect = rect; + innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin ); - - AknsDrawUtils::DrawFrame(AknsUtils::SkinInstance(), - *gc, - rect, - innerrect, - iKeyboard->KeySkinId(EKeyBmpHighlight), - KAknsIIDDefault); + TBool bHasDrawn = EFalse; + if(UiLayout()->NotDrawToLayoutDevice()) + { + /*TBool ret = iKeyboard->PrepareKeyBmp(iKeyboard->HighightKeyBmp(), + iKeyboard->HighlightKeyDev(), + rect,innerrect, + iKeyboard->KeySkinId(EKeyBmpHighlight), + KAknsIIDDefault,Rect());*/ + TBool ret = iKeyboard->PrepareHighlightKeyBmp(rect,innerrect,Rect()); + if(ret) + { + gc->BitBlt(rect.iTl,iKeyboard->HighightKeyBmp()); + bHasDrawn = ETrue; + } + } + + if(!bHasDrawn) + { + AknsDrawUtils::DrawFrame(UiLayout()->SkinInstance(), + *gc, + rect, + innerrect, + iKeyboard->KeySkinId(EKeyBmpHighlight), + KAknsIIDDefault); + } } else if( iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ) ) { TRect srcRect(TPoint(0,0), iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight )->SizeInPixels()); - DrawBmp(rect, + DrawBmp(gc, rect, srcRect, iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlight ), iKeyboard->NonIrregularKeyBitmap( EKeyBmpHighlightMask ), @@ -474,7 +563,15 @@ gc->SetBrushStyle( CGraphicsContext::ENullBrush ); gc->SetFaded(EFalse); - DrawKeyText(); + if(UiLayout()->NotDrawToLayoutDevice()) + { + DrawKeyText(Keyboard()->HighlightGc()); + UpdateChangedArea(ETrue); + } + else + { + DrawKeyText(gc); + } } @@ -538,7 +635,22 @@ //draw key new state iKeyboard->DrawBubble(iKeyInfo); - ReDraw(); + if(UiLayout()->NotDrawToLayoutDevice()) + { + if( !(iKeyInfo->Dimmed()) && (iKeyInfo->Latched() || (PointerDown()&&!iKeyInfo->IsLatchKey())) ) + { + DrawHighlightKey(); + } + else + { + ReDraw(); + } + } + else + { + ReDraw(); + UpdateArea( Rect() ); + } UpdateArea( Rect() ); if(iKeyInfo->IsLatchKey()) @@ -577,8 +689,17 @@ // When key down, latch key won't generate event. eventType = iKeyInfo->Latched() ? EEventVirtualKeyLatched : EEventVirtualKeyUnLatched; } - ReDraw(); - UpdateAreaImmed( Rect() ); + if(UiLayout()->NotDrawToLayoutDevice()) + { + //no need to draw again, just remove the highlight bitmap + UpdateChangedArea(EFalse); + Draw(); + } + else + { + ReDraw(); + UpdateAreaImmed( Rect() ); + } ReportKeyEvent(eventType); @@ -586,7 +707,7 @@ #ifdef RD_TACTILE_FEEDBACK if (UiLayout()->SupportTactileFeedback()) { - UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse); + UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse); } #endif // RD_TACTILE_FEEDBACK return this; @@ -612,7 +733,12 @@ iKeyboard->DrawBubble(iKeyInfo); ReDraw(); - UpdateArea( Rect() ); + if(UiLayout()->NotDrawToLayoutDevice()) + { + UpdateChangedArea(ETrue); + } + else + UpdateArea( Rect() ); } @@ -635,8 +761,15 @@ } iKeyboard->ClearBubble(ETrue); - ReDraw(); - UpdateArea( Rect() ); + if(UiLayout()->NotDrawToLayoutDevice()) + { + UpdateChangedArea(EFalse); + } + else + { + ReDraw(); + UpdateArea( Rect() ); + } #ifdef RD_TACTILE_FEEDBACK if ( iKeyboard->GowithPointerDown() ) @@ -646,7 +779,7 @@ { if (!Hiden()) { - UiLayout()->DoTactileFeedback(ETouchFeedbackBasicKeypad, ETrue, EFalse); + UiLayout()->DoTactileFeedback(ETouchFeedbackCharacterInputButton, ETrue, EFalse); } } } @@ -657,8 +790,15 @@ { CFepUiBaseCtrl::CancelPointerDownL(); iKeyboard->ClearBubble(ETrue); - ReDraw(); - UpdateArea( Rect() ); + if(UiLayout()->NotDrawToLayoutDevice()) + { + UpdateChangedArea(EFalse); + } + else + { + ReDraw(); + UpdateArea( Rect() ); + } } // --------------------------------------------------------------------------- // CVirtualKeyCtrl::ReDraw @@ -668,8 +808,24 @@ // void CVirtualKeyCtrl::ReDraw() { - Draw(); - UpdateArea(Rect(), EFalse); + if(UiLayout()->NotDrawToLayoutDevice()) + { + if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey())) + { + DrawHighlightKey(); + UpdateChangedArea(ETrue); + } + else + { + Draw(); + UpdateArea(Rect(), EFalse); + } + } + else + { + Draw(); + UpdateArea(Rect(), EFalse); + } } // --------------------------------------------------------------------------- @@ -887,6 +1043,10 @@ // void CVirtualRawKeyCtrl::HandlePointerLeave(const TPoint& aPoint) { + if(UiLayout()->NotDrawToLayoutDevice()) + { + UpdateChangedArea(EFalse); + } TRawEvent event; event.Set(TRawEvent::EButton1Up,aPoint.iX,aPoint.iY); @@ -898,9 +1058,42 @@ { if (!VirtualKey()->Dimmed() && !Hiden()) { - UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveKeypad, ETrue, EFalse); + UiLayout()->DoTactileFeedback(ETouchFeedbackSensitiveInput, ETrue, EFalse); } } #endif //RD_TACTILE_FEEDBACK } + +TRect CVirtualKeyCtrl::GetRect() + { + TRect r(Rect()); + if(UiLayout()->NotDrawToLayoutDevice()) + { + if(iKeyInfo->Latched()||(PointerDown()&&!iKeyInfo->IsLatchKey())) + { + r.Move(-r.iTl.iX, -r.iTl.iY); + } + } + return r; + } + +void CVirtualKeyCtrl::UpdateChangedArea(TBool aFlag) + { + struct SData + { + TUint32 ctrl; + TBool flag; + CFbsBitmap* bmp; + TRect pos; + } data; + + data.ctrl = (TUint32)this; + data.flag = aFlag; + data.bmp = Keyboard()->Bitmap();//aFlag ? Keyboard()->iBitmap : 0; + data.pos = Rect(); + TPtrC ptr; + ptr.Set(reinterpret_cast(&data),sizeof(data)/sizeof(TUint16)); + + UiLayout()->SignalOwner(ESignalUpdateChangedArea,ptr); + } //end of file