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" |
|
26 |
24 |
27 const TInt KDefaultCursorHeight = 10; |
25 const TInt KDefaultCursorHeight = 10; |
28 // ============================ MEMBER FUNCTIONS ============================= |
26 // ============================ MEMBER FUNCTIONS ============================= |
29 |
27 |
30 // --------------------------------------------------------------------------- |
28 // --------------------------------------------------------------------------- |
54 void CFepUiCursor::ConstructL() |
52 void CFepUiCursor::ConstructL() |
55 { |
53 { |
56 CFepUiBaseCtrl::BaseConstructL(); |
54 CFepUiBaseCtrl::BaseConstructL(); |
57 iCursorBlinkingTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
55 iCursorBlinkingTimer = CPeriodic::NewL(CActive::EPriorityStandard); |
58 iRestoreCursorTimer = CLayoutTimer::NewL(this,CLayoutTimer::EOthers); |
56 iRestoreCursorTimer = CLayoutTimer::NewL(this,CLayoutTimer::EOthers); |
59 CreateCursorBmpL(); |
|
60 } |
57 } |
61 |
58 |
62 // --------------------------------------------------------------------------- |
59 // --------------------------------------------------------------------------- |
63 // CFepUiCursor::NewL |
60 // CFepUiCursor::NewL |
64 // Two-phased constructor. |
61 // Two-phased constructor. |
85 iCursorBlinkingTimer->Cancel(); |
82 iCursorBlinkingTimer->Cancel(); |
86 delete iCursorBlinkingTimer; |
83 delete iCursorBlinkingTimer; |
87 } |
84 } |
88 |
85 |
89 delete iRestoreCursorTimer; |
86 delete iRestoreCursorTimer; |
90 delete iBitmap; |
|
91 delete iBitmapDevice; |
|
92 delete iGc; |
|
93 } |
87 } |
94 |
88 |
95 |
89 |
96 // --------------------------------------------------------------------------- |
90 // --------------------------------------------------------------------------- |
97 // CFepUiCursor::SetPosition |
91 // CFepUiCursor::SetPosition |
100 // --------------------------------------------------------------------------- |
94 // --------------------------------------------------------------------------- |
101 // |
95 // |
102 EXPORT_C void CFepUiCursor::SetPosition(const TPoint& aPosition) |
96 EXPORT_C void CFepUiCursor::SetPosition(const TPoint& aPosition) |
103 { |
97 { |
104 |
98 |
105 if( iPosition != aPosition ) |
99 TBool isOn = iIsOn; |
106 { |
100 if (isOn) |
107 TBool isOn = iIsOn; |
101 { |
108 if (isOn) |
102 SetOn(EFalse); |
109 { |
103 } |
110 SetOn(EFalse); |
104 iPosition=aPosition; |
111 |
105 TPoint correction(KCursorPosCorrectionX,KCursorPosCorrectionY ); |
112 } |
106 TRect rect = TRect(iPosition + correction , TSize(KCursorWidth,iHeight)); |
113 iPosition=aPosition; |
107 if(rect != iCursorRect) |
114 TPoint correction(KCursorPosCorrectionX,KCursorPosCorrectionY ); |
108 { |
115 TRect rect = TRect(iPosition + correction , TSize(KCursorWidth,iHeight)); |
109 SetRect(rect); |
116 if(rect != iCursorRect) |
110 iCursorRect = rect; |
117 { |
111 //must update clip region again. |
118 SetRect(rect); |
112 for(TInt i = 0 ; i < RootControl()->PopCtrlList().Count(); ++i) |
119 iCursorRect = rect; |
113 { |
120 //must update clip region again. |
114 UpdateValidRegion(RootControl()->PopCtrlList()[i],EFalse); |
121 for(TInt i = 0 ; i < RootControl()->PopCtrlList().Count(); ++i) |
115 } |
122 { |
116 } |
123 UpdateValidRegion(RootControl()->PopCtrlList()[i],EFalse); |
117 |
124 } |
118 if (isOn) |
125 } |
119 { |
126 |
120 SetOn(ETrue); |
127 if (isOn) |
121 } |
128 { |
|
129 SetOn(ETrue); |
|
130 } |
|
131 } |
|
132 |
|
133 } |
122 } |
134 |
123 |
135 // --------------------------------------------------------------------------- |
124 // --------------------------------------------------------------------------- |
136 // CFepUiCursor::Position |
125 // CFepUiCursor::Position |
137 // get the cursor position |
126 // get the cursor position |
188 KCursorBlinkPerioid,TCallBack(CursorBlinkCallBack , this)); |
176 KCursorBlinkPerioid,TCallBack(CursorBlinkCallBack , this)); |
189 } |
177 } |
190 } |
178 } |
191 |
179 |
192 // Invalidate InsertionPoint's rect, so it will be removed from editarea |
180 // Invalidate InsertionPoint's rect, so it will be removed from editarea |
193 //InvalidateInsertionPoint(); |
181 InvalidateInsertionPoint(); |
194 } |
182 } |
195 |
183 |
196 // --------------------------------------------------------------------------- |
184 // --------------------------------------------------------------------------- |
197 // CFepUiCursor::SetHeight |
185 // CFepUiCursor::SetHeight |
198 // Sets caret height |
186 // Sets caret height |
225 EXPORT_C void CFepUiCursor::ReDraw(TBool aReset) |
213 EXPORT_C void CFepUiCursor::ReDraw(TBool aReset) |
226 { |
214 { |
227 if(aReset) |
215 if(aReset) |
228 iIsVisible = EFalse; |
216 iIsVisible = EFalse; |
229 Draw(); |
217 Draw(); |
230 //UpdateArea(iCursorRect,EFalse); |
218 UpdateArea(iCursorRect,EFalse); |
231 UpdateCursorArea(iCursorRect,EFalse); |
219 } |
232 } |
220 |
233 |
221 |
234 void CFepUiCursor::DrawCursor(CFbsBitGc* aGc,CFbsBitmapDevice* aDevice) |
|
235 { |
|
236 aGc->Activate(aDevice); |
|
237 |
|
238 // draw cursor by inverting colors in the selected text rectancle |
|
239 //aGc->SetClippingRegion(ValidClipRegion()); |
|
240 |
|
241 aGc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
|
242 aGc->SetBrushColor(KRgbBlack); |
|
243 //aGc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
|
244 aGc->Clear(); |
|
245 aGc->SetPenColor(KRgbBlack); |
|
246 aGc->SetPenStyle(CGraphicsContext::ESolidPen); |
|
247 aGc->SetPenSize( TSize(1,1)); |
|
248 |
|
249 // When the blink timer out and cursor is visible, do nothing |
|
250 // else draw the cursor and set the visible flag |
|
251 //aGc->DrawRect(iCursorRect); |
|
252 //iIsVisible = !iIsVisible; |
|
253 |
|
254 // restore normal draw mode |
|
255 aGc->SetDrawMode(CGraphicsContext::EDrawModePEN); |
|
256 aGc->SetBrushStyle(CGraphicsContext::ENullBrush); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
222 // --------------------------------------------------------------------------- |
260 // CFepUiCursor::Draw |
223 // CFepUiCursor::Draw |
261 // Draws insertion point's Rect and starts blinking timer |
224 // Draws insertion point's Rect and starts blinking timer |
262 // (other items were commented in a header). |
225 // (other items were commented in a header). |
263 // --------------------------------------------------------------------------- |
226 // --------------------------------------------------------------------------- |
297 gc->Activate( BitmapDevice()); |
242 gc->Activate( BitmapDevice()); |
298 if(iIsOn) |
243 if(iIsOn) |
299 { |
244 { |
300 // draw cursor by inverting colors in the selected text rectancle |
245 // draw cursor by inverting colors in the selected text rectancle |
301 gc->SetClippingRegion(ValidClipRegion()); |
246 gc->SetClippingRegion(ValidClipRegion()); |
302 |
247 |
303 const TRegion& tr = ValidClipRegion(); |
|
304 const TRect* rl = tr.RectangleList(); |
|
305 TRect rr; |
|
306 for(TInt id = 0; id < tr.Count(); ++id) |
|
307 { |
|
308 rr = rl[id]; |
|
309 } |
|
310 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
248 gc->SetBrushStyle(CGraphicsContext::ESolidBrush); |
311 gc->SetBrushColor(KRgbBlack); |
249 gc->SetBrushColor(KRgbBlack); |
312 gc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
250 gc->SetDrawMode(CGraphicsContext::EDrawModeNOTSCREEN); |
313 |
251 |
314 gc->SetPenColor(KRgbBlack); |
252 gc->SetPenColor(KRgbBlack); |
384 // (other items were commented in a header). |
322 // (other items were commented in a header). |
385 // --------------------------------------------------------------------------- |
323 // --------------------------------------------------------------------------- |
386 // |
324 // |
387 void CFepUiCursor::InvalidateInsertionPoint() |
325 void CFepUiCursor::InvalidateInsertionPoint() |
388 { |
326 { |
389 if(AbleToDraw()) |
327 //if(iEditor) |
390 { |
328 { |
391 Draw(); |
329 Draw(); |
392 //UpdateArea(iCursorRect,EFalse); |
330 UpdateArea(iCursorRect,EFalse); |
393 |
|
394 UpdateCursorArea(iCursorRect,EFalse); |
|
395 } |
331 } |
396 } |
332 } |
397 |
333 |
398 // --------------------------------------------------------------------------- |
334 // --------------------------------------------------------------------------- |
399 // CFepUiCursor::DelayCursorWhileDraging |
335 // CFepUiCursor::DelayCursorWhileDraging |
441 void CFepUiCursor::HandleTimerOut(TInt /*aTimeType*/) |
377 void CFepUiCursor::HandleTimerOut(TInt /*aTimeType*/) |
442 { |
378 { |
443 iCursorTempDisabled = EFalse; |
379 iCursorTempDisabled = EFalse; |
444 iIsOn = ETrue; |
380 iIsOn = ETrue; |
445 //To avoid the ugly first shown, we draw the cursor directly here. |
381 //To avoid the ugly first shown, we draw the cursor directly here. |
446 //InvalidateInsertionPoint(); |
382 InvalidateInsertionPoint(); |
447 SetOn(ETrue, EFalse); |
383 SetOn(ETrue, EFalse); |
448 } |
384 } |
449 |
385 |
450 |
386 |
451 // --------------------------------------------------------------------------- |
387 // --------------------------------------------------------------------------- |
497 iClipRegion.AddRect(iRect); |
433 iClipRegion.AddRect(iRect); |
498 } |
434 } |
499 |
435 |
500 void CFepUiCursor::UpdateCursorArea(const TRect& aRect, TBool aFlag) |
436 void CFepUiCursor::UpdateCursorArea(const TRect& aRect, TBool aFlag) |
501 { |
437 { |
502 if(UiLayout()->NotDrawToLayoutDevice()) |
|
503 { |
|
504 //CopyToBmp(); |
|
505 //signal special update |
|
506 |
|
507 struct SData |
|
508 { |
|
509 TBool onOff; |
|
510 CFbsBitmap* bmp; |
|
511 TRect rect; |
|
512 } data; |
|
513 data.onOff = iIsVisible; |
|
514 data.bmp = iBitmap; |
|
515 data.rect = iCursorRect; |
|
516 TPtrC ptr; |
|
517 ptr.Set(reinterpret_cast<const TUint16*>(&data),sizeof(data)/sizeof(TUint16)); |
|
518 |
|
519 UiLayout()->SignalOwner(ESignalUpdateCursor,ptr); |
|
520 |
|
521 return; |
|
522 } |
|
523 |
|
524 CFepUiBaseCtrl* parent = iEditor->ParentCtrl(); |
438 CFepUiBaseCtrl* parent = iEditor->ParentCtrl(); |
525 |
439 |
526 if(parent) |
440 if(parent) |
527 { |
441 { |
528 if(parent->IsKindOfControl(ECtrlControlGroup)) |
442 if(parent->IsKindOfControl(ECtrlControlGroup)) |
531 iEditor->ParentCtrl()->UpdateArea(aRect,aFlag); |
445 iEditor->ParentCtrl()->UpdateArea(aRect,aFlag); |
532 } |
446 } |
533 else |
447 else |
534 UpdateArea(aRect,aFlag); |
448 UpdateArea(aRect,aFlag); |
535 } |
449 } |
536 |
|
537 void CFepUiCursor::CreateCursorBmpL() |
|
538 { |
|
539 iBitmap = new ( ELeave ) CFbsBitmap; |
|
540 |
|
541 TRect rect = TRect(TPoint(0,0) , TSize(KCursorWidth,iHeight)); |
|
542 |
|
543 User::LeaveIfError( iBitmap->Create( rect.Size(), BitmapDevice()->DisplayMode() ) ); |
|
544 |
|
545 iBitmapDevice = CFbsBitmapDevice::NewL(iBitmap); |
|
546 iGc = CFbsBitGc::NewL(); |
|
547 iGc->Reset(); |
|
548 DrawCursor(iGc,iBitmapDevice); |
|
549 } |
|
550 |
|
551 void CFepUiCursor::ResizeCursorBmp() |
|
552 { |
|
553 TRect rect = TRect(TPoint(0,0) , TSize(KCursorWidth,iHeight)); |
|
554 iBitmap->Resize(rect.Size()); |
|
555 |
|
556 iBitmapDevice->Resize( rect.Size()); |
|
557 //gc must be adjusted |
|
558 iGc->Activate(iBitmapDevice); |
|
559 iGc->Resized(); |
|
560 DrawCursor(iGc,iBitmapDevice); |
|
561 } |
|
562 // End of File |
450 // End of File |