--- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutcursor.cpp Tue Aug 31 15:31:50 2010 +0300
+++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutcursor.cpp Wed Sep 01 12:23:33 2010 +0100
@@ -21,6 +21,8 @@
#include "peninputlayouteditareabase.h"
#include "peninputlayouttimer.h"
#include "peninputlayoutrootctrl.h"
+#include "peninputcmd.h"
+#include "peninputlayout.h"
const TInt KDefaultCursorHeight = 10;
// ============================ MEMBER FUNCTIONS =============================
@@ -54,6 +56,7 @@
CFepUiBaseCtrl::BaseConstructL();
iCursorBlinkingTimer = CPeriodic::NewL(CActive::EPriorityStandard);
iRestoreCursorTimer = CLayoutTimer::NewL(this,CLayoutTimer::EOthers);
+ CreateCursorBmpL();
}
// ---------------------------------------------------------------------------
@@ -84,6 +87,9 @@
}
delete iRestoreCursorTimer;
+ delete iBitmap;
+ delete iBitmapDevice;
+ delete iGc;
}
@@ -96,29 +102,34 @@
EXPORT_C void CFepUiCursor::SetPosition(const TPoint& aPosition)
{
- TBool isOn = iIsOn;
- if (isOn)
- {
- SetOn(EFalse);
- }
- iPosition=aPosition;
- TPoint correction(KCursorPosCorrectionX,KCursorPosCorrectionY );
- TRect rect = TRect(iPosition + correction , TSize(KCursorWidth,iHeight));
- if(rect != iCursorRect)
- {
- SetRect(rect);
- iCursorRect = rect;
- //must update clip region again.
- for(TInt i = 0 ; i < RootControl()->PopCtrlList().Count(); ++i)
- {
- UpdateValidRegion(RootControl()->PopCtrlList()[i],EFalse);
- }
- }
-
- if (isOn)
- {
- SetOn(ETrue);
- }
+ if( iPosition != aPosition )
+ {
+ TBool isOn = iIsOn;
+ if (isOn)
+ {
+ SetOn(EFalse);
+
+ }
+ iPosition=aPosition;
+ TPoint correction(KCursorPosCorrectionX,KCursorPosCorrectionY );
+ TRect rect = TRect(iPosition + correction , TSize(KCursorWidth,iHeight));
+ if(rect != iCursorRect)
+ {
+ SetRect(rect);
+ iCursorRect = rect;
+ //must update clip region again.
+ for(TInt i = 0 ; i < RootControl()->PopCtrlList().Count(); ++i)
+ {
+ UpdateValidRegion(RootControl()->PopCtrlList()[i],EFalse);
+ }
+ }
+
+ if (isOn)
+ {
+ SetOn(ETrue);
+ }
+ }
+
}
// ---------------------------------------------------------------------------
@@ -162,6 +173,7 @@
{
iCursorBlinkingTimer->Cancel();
}
+ InvalidateInsertionPoint();
}
else
{
@@ -178,7 +190,7 @@
}
// Invalidate InsertionPoint's rect, so it will be removed from editarea
- InvalidateInsertionPoint();
+ //InvalidateInsertionPoint();
}
// ---------------------------------------------------------------------------
@@ -215,10 +227,35 @@
if(aReset)
iIsVisible = EFalse;
Draw();
- UpdateArea(iCursorRect,EFalse);
+ //UpdateArea(iCursorRect,EFalse);
+ UpdateCursorArea(iCursorRect,EFalse);
}
+void CFepUiCursor::DrawCursor(CFbsBitGc* aGc,CFbsBitmapDevice* aDevice)
+ {
+ aGc->Activate(aDevice);
+
+ // draw cursor by inverting colors in the selected text rectancle
+ //aGc->SetClippingRegion(ValidClipRegion());
+
+ aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
+ aGc->SetBrushColor(KRgbBlack);
+ //aGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
+ aGc->Clear();
+ aGc->SetPenColor(KRgbBlack);
+ aGc->SetPenStyle(CGraphicsContext::ESolidPen);
+ aGc->SetPenSize( TSize(1,1));
+ // When the blink timer out and cursor is visible, do nothing
+ // else draw the cursor and set the visible flag
+ //aGc->DrawRect(iCursorRect);
+ //iIsVisible = !iIsVisible;
+
+ // restore normal draw mode
+ aGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
+ aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
+ }
+
// ---------------------------------------------------------------------------
// CFepUiCursor::Draw
// Draws insertion point's Rect and starts blinking timer
@@ -231,7 +268,25 @@
{
return;
}
-
+
+//#ifdef FIX_FOR_NGA
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ if(iIsOn)
+ {
+ iIsVisible = !iIsVisible;
+ }
+ else
+ {
+ if(iIsVisible) //only do when already shown
+ {
+ iIsVisible = EFalse;
+ }
+ }
+
+ return;
+ }
+//#endif
/*if (aReset)
{
iIsVisible = EFalse;
@@ -244,7 +299,14 @@
{
// draw cursor by inverting colors in the selected text rectancle
gc->SetClippingRegion(ValidClipRegion());
-
+
+ const TRegion& tr = ValidClipRegion();
+ const TRect* rl = tr.RectangleList();
+ TRect rr;
+ for(TInt id = 0; id < tr.Count(); ++id)
+ {
+ rr = rl[id];
+ }
gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
gc->SetBrushColor(KRgbBlack);
gc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
@@ -324,10 +386,12 @@
//
void CFepUiCursor::InvalidateInsertionPoint()
{
- //if(iEditor)
+ if(AbleToDraw())
{
Draw();
- UpdateArea(iCursorRect,EFalse);
+ //UpdateArea(iCursorRect,EFalse);
+
+ UpdateCursorArea(iCursorRect,EFalse);
}
}
@@ -379,7 +443,7 @@
iCursorTempDisabled = EFalse;
iIsOn = ETrue;
//To avoid the ugly first shown, we draw the cursor directly here.
- InvalidateInsertionPoint();
+ //InvalidateInsertionPoint();
SetOn(ETrue, EFalse);
}
@@ -435,6 +499,28 @@
void CFepUiCursor::UpdateCursorArea(const TRect& aRect, TBool aFlag)
{
+ if(UiLayout()->NotDrawToLayoutDevice())
+ {
+ //CopyToBmp();
+ //signal special update
+
+ struct SData
+ {
+ TBool onOff;
+ CFbsBitmap* bmp;
+ TRect rect;
+ } data;
+ data.onOff = iIsVisible;
+ data.bmp = iBitmap;
+ data.rect = iCursorRect;
+ TPtrC ptr;
+ ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
+
+ UiLayout()->SignalOwner(ESignalUpdateCursor,ptr);
+
+ return;
+ }
+
CFepUiBaseCtrl* parent = iEditor->ParentCtrl();
if(parent)
@@ -447,4 +533,30 @@
else
UpdateArea(aRect,aFlag);
}
+
+void CFepUiCursor::CreateCursorBmpL()
+ {
+ iBitmap = new ( ELeave ) CFbsBitmap;
+
+ TRect rect = TRect(TPoint(0,0) , TSize(KCursorWidth,iHeight));
+
+ User::LeaveIfError( iBitmap->Create( rect.Size(), BitmapDevice()->DisplayMode() ) );
+
+ iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
+ iGc = CFbsBitGc::NewL();
+ iGc->Reset();
+ DrawCursor(iGc,iBitmapDevice);
+ }
+
+void CFepUiCursor::ResizeCursorBmp()
+ {
+ TRect rect = TRect(TPoint(0,0) , TSize(KCursorWidth,iHeight));
+ iBitmap->Resize(rect.Size());
+
+ iBitmapDevice->Resize( rect.Size());
+ //gc must be adjusted
+ iGc->Activate(iBitmapDevice);
+ iGc->Resized();
+ DrawCursor(iGc,iBitmapDevice);
+ }
// End of File