textinput/peninputarc/src/peninputlayoutcontrol/peninputlayoutcursor.cpp
branchRCL_3
changeset 12 5e18d8c489d6
parent 0 eb1f2e154e89
child 13 1bbdde98cc2d
equal deleted inserted replaced
11:c8fb4cf7b3ae 12:5e18d8c489d6
    19 
    19 
    20 #include "peninputlayoutcursor.h"
    20 #include "peninputlayoutcursor.h"
    21 #include "peninputlayouteditareabase.h"
    21 #include "peninputlayouteditareabase.h"
    22 #include "peninputlayouttimer.h"
    22 #include "peninputlayouttimer.h"
    23 #include "peninputlayoutrootctrl.h"
    23 #include "peninputlayoutrootctrl.h"
       
    24 #include "peninputcmd.h"
       
    25 #include "peninputlayout.h"
    24 
    26 
    25 const TInt KDefaultCursorHeight = 10;
    27 const TInt KDefaultCursorHeight = 10;
    26 // ============================ MEMBER FUNCTIONS =============================
    28 // ============================ MEMBER FUNCTIONS =============================
    27 
    29 
    28 // ---------------------------------------------------------------------------
    30 // ---------------------------------------------------------------------------
    52 void CFepUiCursor::ConstructL()
    54 void CFepUiCursor::ConstructL()
    53     {
    55     {
    54     CFepUiBaseCtrl::BaseConstructL();
    56     CFepUiBaseCtrl::BaseConstructL();
    55     iCursorBlinkingTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    57     iCursorBlinkingTimer = CPeriodic::NewL(CActive::EPriorityStandard);
    56     iRestoreCursorTimer = CLayoutTimer::NewL(this,CLayoutTimer::EOthers);
    58     iRestoreCursorTimer = CLayoutTimer::NewL(this,CLayoutTimer::EOthers);
       
    59     CreateCursorBmpL();
    57     }
    60     }
    58 
    61 
    59 // ---------------------------------------------------------------------------
    62 // ---------------------------------------------------------------------------
    60 // CFepUiCursor::NewL
    63 // CFepUiCursor::NewL
    61 // Two-phased constructor.
    64 // Two-phased constructor.
    82         iCursorBlinkingTimer->Cancel();
    85         iCursorBlinkingTimer->Cancel();
    83         delete iCursorBlinkingTimer;
    86         delete iCursorBlinkingTimer;
    84         }    
    87         }    
    85    
    88    
    86     delete iRestoreCursorTimer;
    89     delete iRestoreCursorTimer;
       
    90     delete iBitmap;
       
    91     delete iBitmapDevice;
       
    92     delete iGc;
    87     }
    93     }
    88 
    94 
    89 
    95 
    90 // ---------------------------------------------------------------------------
    96 // ---------------------------------------------------------------------------
    91 // CFepUiCursor::SetPosition
    97 // CFepUiCursor::SetPosition
   213 EXPORT_C void CFepUiCursor::ReDraw(TBool aReset)
   219 EXPORT_C void CFepUiCursor::ReDraw(TBool aReset)
   214     {
   220     {
   215     if(aReset)
   221     if(aReset)
   216         iIsVisible = EFalse;
   222         iIsVisible = EFalse;
   217     Draw();
   223     Draw();
   218     UpdateArea(iCursorRect,EFalse);
   224     //UpdateArea(iCursorRect,EFalse);
   219     }
   225     UpdateCursorArea(iCursorRect,EFalse);
   220     
   226     }
   221 
   227     
       
   228 void CFepUiCursor::DrawCursor(CFbsBitGc* aGc,CFbsBitmapDevice* aDevice)
       
   229     {
       
   230     aGc->Activate(aDevice);    
       
   231    
       
   232    // draw cursor by inverting colors in the selected text rectancle
       
   233     //aGc->SetClippingRegion(ValidClipRegion());                   
       
   234     
       
   235     aGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   236     aGc->SetBrushColor(KRgbBlack);
       
   237     //aGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
       
   238     aGc->Clear();
       
   239     aGc->SetPenColor(KRgbBlack);
       
   240     aGc->SetPenStyle(CGraphicsContext::ESolidPen);
       
   241     aGc->SetPenSize( TSize(1,1));
       
   242 
       
   243     // When the blink timer out and cursor is visible, do nothing
       
   244     // else draw the cursor and set the visible flag
       
   245     //aGc->DrawRect(iCursorRect);
       
   246     //iIsVisible = !iIsVisible;
       
   247 
       
   248     // restore normal draw mode
       
   249     aGc->SetDrawMode(CGraphicsContext::EDrawModePEN);
       
   250     aGc->SetBrushStyle(CGraphicsContext::ENullBrush);
       
   251     }
       
   252 	
   222 // ---------------------------------------------------------------------------
   253 // ---------------------------------------------------------------------------
   223 // CFepUiCursor::Draw
   254 // CFepUiCursor::Draw
   224 // Draws insertion point's Rect and starts blinking timer
   255 // Draws insertion point's Rect and starts blinking timer
   225 // (other items were commented in a header).
   256 // (other items were commented in a header).
   226 // ---------------------------------------------------------------------------
   257 // ---------------------------------------------------------------------------
   229     {
   260     {
   230     if(!AbleToDraw())
   261     if(!AbleToDraw())
   231         {
   262         {
   232         return;
   263         return;
   233         }
   264         }
   234     
   265 
       
   266 //#ifdef FIX_FOR_NGA
       
   267     if(UiLayout()->NotDrawToLayoutDevice())
       
   268         {
       
   269         if(iIsOn)
       
   270             {   
       
   271             iIsVisible = !iIsVisible;
       
   272             } 
       
   273         else
       
   274             {
       
   275             if(iIsVisible) //only do when already shown
       
   276                 {                
       
   277                 iIsVisible = EFalse;                       
       
   278                 }   
       
   279             }
       
   280         
       
   281         return;
       
   282         }
       
   283 //#endif
   235     /*if (aReset)    
   284     /*if (aReset)    
   236         {
   285         {
   237         iIsVisible = EFalse;
   286         iIsVisible = EFalse;
   238         }
   287         }
   239       */  
   288       */  
   242     gc->Activate( BitmapDevice());    
   291     gc->Activate( BitmapDevice());    
   243     if(iIsOn)
   292     if(iIsOn)
   244         {        
   293         {        
   245         // draw cursor by inverting colors in the selected text rectancle
   294         // draw cursor by inverting colors in the selected text rectancle
   246         gc->SetClippingRegion(ValidClipRegion());        	        
   295         gc->SetClippingRegion(ValidClipRegion());        	        
   247         
   296 
       
   297         const TRegion& tr = ValidClipRegion();
       
   298         const TRect* rl = tr.RectangleList();
       
   299         TRect rr;
       
   300         for(TInt id = 0; id < tr.Count(); ++id)
       
   301             {
       
   302             rr = rl[id];
       
   303             }
   248         gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   304         gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
   249         gc->SetBrushColor(KRgbBlack);
   305         gc->SetBrushColor(KRgbBlack);
   250         gc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
   306         gc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN);
   251 
   307 
   252         gc->SetPenColor(KRgbBlack);
   308         gc->SetPenColor(KRgbBlack);
   322 // (other items were commented in a header).
   378 // (other items were commented in a header).
   323 // ---------------------------------------------------------------------------
   379 // ---------------------------------------------------------------------------
   324 //
   380 //
   325 void CFepUiCursor::InvalidateInsertionPoint()
   381 void CFepUiCursor::InvalidateInsertionPoint()
   326     {    
   382     {    
   327     //if(iEditor)
   383     //if(AbleToDraw())
   328         {        
   384         {        
   329         Draw();
   385         Draw();
   330         UpdateArea(iCursorRect,EFalse);
   386         //UpdateArea(iCursorRect,EFalse);
       
   387         
       
   388         UpdateCursorArea(iCursorRect,EFalse);
   331         }
   389         }
   332     }
   390     }
   333   
   391   
   334 // ---------------------------------------------------------------------------
   392 // ---------------------------------------------------------------------------
   335 // CFepUiCursor::DelayCursorWhileDraging
   393 // CFepUiCursor::DelayCursorWhileDraging
   433     iClipRegion.AddRect(iRect);
   491     iClipRegion.AddRect(iRect);
   434     }
   492     }
   435     
   493     
   436 void CFepUiCursor::UpdateCursorArea(const TRect& aRect, TBool aFlag)
   494 void CFepUiCursor::UpdateCursorArea(const TRect& aRect, TBool aFlag)
   437     {
   495     {
       
   496     if(UiLayout()->NotDrawToLayoutDevice())
       
   497         {
       
   498         //CopyToBmp();
       
   499         //signal special update
       
   500     
       
   501         struct SData
       
   502             {
       
   503             TBool onOff;
       
   504             CFbsBitmap* bmp;
       
   505             TRect rect;
       
   506             } data;
       
   507         data.onOff = iIsVisible;
       
   508         data.bmp = iBitmap;
       
   509         data.rect = iCursorRect;
       
   510         TPtrC ptr;
       
   511         ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16));
       
   512         
       
   513         UiLayout()->SignalOwner(ESignalUpdateCursor,ptr);
       
   514         
       
   515 		return;
       
   516 		}
       
   517 
   438     CFepUiBaseCtrl* parent = iEditor->ParentCtrl();
   518     CFepUiBaseCtrl* parent = iEditor->ParentCtrl();
   439     
   519     
   440     if(parent)
   520     if(parent)
   441         {
   521         {
   442         if(parent->IsKindOfControl(ECtrlControlGroup))     
   522         if(parent->IsKindOfControl(ECtrlControlGroup))     
   445             iEditor->ParentCtrl()->UpdateArea(aRect,aFlag);
   525             iEditor->ParentCtrl()->UpdateArea(aRect,aFlag);
   446         }
   526         }
   447     else
   527     else
   448         UpdateArea(aRect,aFlag);    
   528         UpdateArea(aRect,aFlag);    
   449     }
   529     }
       
   530 
       
   531 void CFepUiCursor::CreateCursorBmpL()
       
   532     {
       
   533     iBitmap = new ( ELeave ) CFbsBitmap;    
       
   534     
       
   535     TRect rect = TRect(TPoint(0,0) , TSize(KCursorWidth,iHeight));
       
   536 
       
   537     User::LeaveIfError( iBitmap->Create( rect.Size(), BitmapDevice()->DisplayMode() ) );
       
   538     
       
   539     iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap);
       
   540     iGc = CFbsBitGc::NewL();
       
   541     iGc->Reset();
       
   542     DrawCursor(iGc,iBitmapDevice);
       
   543     }
       
   544 
       
   545 void CFepUiCursor::ResizeCursorBmp()
       
   546     {
       
   547     TRect rect = TRect(TPoint(0,0) , TSize(KCursorWidth,iHeight));
       
   548     iBitmap->Resize(rect.Size());
       
   549     
       
   550     iBitmapDevice->Resize( rect.Size());
       
   551     //gc must be adjusted
       
   552     iGc->Activate(iBitmapDevice);
       
   553     iGc->Resized();
       
   554     DrawCursor(iGc,iBitmapDevice);    
       
   555     }
   450 //  End of File  
   556 //  End of File