--- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp Tue May 11 16:31:42 2010 +0300
+++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutvkbkeyctrl.cpp Tue May 25 13:03:44 2010 +0300
@@ -28,6 +28,7 @@
#include "peninputlayoutvkb.h"
#include "peninputlayout.h"
#include "peninputpluginutils.h"
+#include "peninputcmd.h"
_LIT( KKeyShiftCharacter, "\x2191");
_LIT( KKeyStarCharacter, "\x002a");
@@ -117,7 +118,7 @@
// (other items were commented in a header).
// ---------------------------------------------------------------------------
//
-void CVirtualKeyCtrl::DrawKeyText()
+void CVirtualKeyCtrl::DrawKeyText(CFbsBitGc* aGc)
{
TBool textlineset = EFalse;
@@ -131,7 +132,7 @@
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() )
@@ -146,22 +147,22 @@
if( iKeyboard->ShiftIcon() &&
iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyShiftCharacter )
{
- CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
+ //CFbsBitGc* gc = GetGc();//static_cast<CFbsBitGc*>(BitGc());
AknPenInputDrawUtils::DrawColorIcon( iKeyboard->ShiftIcon(),
- *gc,
+ *aGc,
textLayout.TextRect() );
}
else if(iKeyboard->StarIcon() &&
iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)) == KKeyStarCharacter )
{
- CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
+ //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
AknPenInputDrawUtils::DrawColorIcon( iKeyboard->StarIcon(),
- *gc,
+ *aGc,
textLayout.TextRect() );
}
else
{
- textLayout.DrawText(*BitGc(), iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)),
+ textLayout.DrawText(*aGc, iKeyInfo->KeyUnicodes(TVirtualKeyTextPos(i)),
EFalse, color);
}
}
@@ -171,9 +172,9 @@
if (!textlineset)
{
TAknLayoutText textLayout;
- textLayout.LayoutText(Rect(), iKeyboard->iVKBTextLineLayout);
+ textLayout.LayoutText(GetRect(), iKeyboard->iVKBTextLineLayout);
- CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
+ //CFbsBitGc* gc = static_cast<CFbsBitGc*>(BitGc());
//charRect.Move(keyboardRect.iTl);
//if(iKeyInfo->Dimmed())
@@ -201,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())
@@ -299,7 +300,7 @@
gc->SetPenColor(KRgbBlack);
gc->SetBrushStyle( CGraphicsContext::ENullBrush );
//Draw text again.
- DrawKeyText();
+ DrawKeyText(gc);
}
// ---------------------------------------------------------------------------
@@ -313,15 +314,28 @@
TBool aInvertFlag)
{
CFbsBitGc* gc = static_cast<CFbsBitGc*>(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);
+ }
}
// ---------------------------------------------------------------------------
@@ -360,13 +374,30 @@
{
TRect innerrect = rect;
innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
-
- AknsDrawUtils::DrawFrame(UiLayout()->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());
+ 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 ) )
{
@@ -403,9 +434,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<CFbsBitGc*>(BitGc());
+ }
+
// ---------------------------------------------------------------------------
// CVirtualKeyCtrl::DrawHighlightKey
// Draw key in highlight state
@@ -414,8 +464,11 @@
//
void CVirtualKeyCtrl::DrawHighlightKey()
{
- CFbsBitGc* gc = static_cast<CFbsBitGc*>(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());
@@ -423,12 +476,12 @@
iVirtualKeyDrawInfo.iVKPressedMiddleImgID.iMajor &&
iVirtualKeyDrawInfo.iVKPressedRightImgID.iMajor)
{
- TRect innerRect = Rect();
+ TRect innerRect = GetRect();
innerRect.Shrink( 4, 0 );
AknPenInputDrawUtils::Draw3PiecesFrame(UiLayout()->SkinInstance(),
*gc,
- Rect(),
+ GetRect(),
innerRect,
iVirtualKeyDrawInfo.iVKPressedLeftImgID,
iVirtualKeyDrawInfo.iVKPressedMiddleImgID,
@@ -444,20 +497,38 @@
else if (iKeyboard->KeySkinId(EKeyBmpHighlight) != KAknsIIDNone)
{
TRect innerrect = rect;
+
innerrect.Shrink( KDefaultKeyMargin, KDefaultKeyMargin );
-
- AknsDrawUtils::DrawFrame(UiLayout()->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());
+ 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 ),
@@ -490,7 +561,15 @@
gc->SetBrushStyle( CGraphicsContext::ENullBrush );
gc->SetFaded(EFalse);
- DrawKeyText();
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ DrawKeyText(Keyboard()->HighlightGc());
+ UpdateChangedArea(ETrue);
+ }
+ else
+ {
+ DrawKeyText(gc);
+ }
}
@@ -554,7 +633,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())
@@ -593,8 +687,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);
@@ -628,7 +731,12 @@
iKeyboard->DrawBubble(iKeyInfo);
ReDraw();
- UpdateArea( Rect() );
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ UpdateChangedArea(ETrue);
+ }
+ else
+ UpdateArea( Rect() );
}
@@ -651,8 +759,15 @@
}
iKeyboard->ClearBubble(ETrue);
- ReDraw();
- UpdateArea( Rect() );
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ UpdateChangedArea(EFalse);
+ }
+ else
+ {
+ ReDraw();
+ UpdateArea( Rect() );
+ }
#ifdef RD_TACTILE_FEEDBACK
if ( iKeyboard->GowithPointerDown() )
@@ -673,8 +788,15 @@
{
CFepUiBaseCtrl::CancelPointerDownL();
iKeyboard->ClearBubble(ETrue);
- ReDraw();
- UpdateArea( Rect() );
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ UpdateChangedArea(EFalse);
+ }
+ else
+ {
+ ReDraw();
+ UpdateArea( Rect() );
+ }
}
// ---------------------------------------------------------------------------
// CVirtualKeyCtrl::ReDraw
@@ -684,8 +806,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);
+ }
}
// ---------------------------------------------------------------------------
@@ -903,6 +1041,10 @@
//
void CVirtualRawKeyCtrl::HandlePointerLeave(const TPoint& aPoint)
{
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ UpdateChangedArea(EFalse);
+ }
TRawEvent event;
event.Set(TRawEvent::EButton1Up,aPoint.iX,aPoint.iY);
@@ -919,4 +1061,34 @@
}
#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
+ {
+ TBool flag;
+ CFbsBitmap* bmp;
+ TRect pos;
+ } data;
+ data.flag = aFlag;
+ data.bmp = Keyboard()->Bitmap();//aFlag ? Keyboard()->iBitmap : 0;
+ data.pos = Rect();
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+
+ UiLayout()->SignalOwner(ESignalUpdateChangedArea,ptr);
+ }
//end of file