textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutcursor.cpp
branchRCL_3
changeset 12 5e18d8c489d6
parent 0 eb1f2e154e89
child 13 1bbdde98cc2d
--- a/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutcursor.cpp	Tue May 11 16:31:42 2010 +0300
+++ b/textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutcursor.cpp	Tue May 25 13:03:44 2010 +0300
@@ -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;
     }
 
 
@@ -215,10 +221,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 +262,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 +293,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 +380,12 @@
 //
 void CFepUiCursor::InvalidateInsertionPoint()
     {    
-    //if(iEditor)
+    //if(AbleToDraw())
         {        
         Draw();
-        UpdateArea(iCursorRect,EFalse);
+        //UpdateArea(iCursorRect,EFalse);
+        
+        UpdateCursorArea(iCursorRect,EFalse);
         }
     }
   
@@ -435,6 +493,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 +527,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