]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/caret.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: generic/caret.h
3 // Purpose: generic wxCaret class
4 // Author: Vadim Zeitlin (original code by Robert Roebling)
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "caret.h"
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
32 #include "wx/window.h"
33 #include "wx/dcclient.h"
38 // ----------------------------------------------------------------------------
39 // global variables for this module
40 // ----------------------------------------------------------------------------
42 // the blink time (common to all carets for MSW compatibility)
43 static int gs_blinkTime
= 500; // in milliseconds
45 // ============================================================================
47 // ============================================================================
49 wxCaretTimer::wxCaretTimer(wxCaret
*caret
)
54 void wxCaretTimer::Notify()
59 // ----------------------------------------------------------------------------
60 // wxCaret static functions and data
61 // ----------------------------------------------------------------------------
64 int wxCaretBase::GetBlinkTime()
69 void wxCaretBase::SetBlinkTime(int milliseconds
)
71 gs_blinkTime
= milliseconds
;
74 // ----------------------------------------------------------------------------
75 // initialization and destruction
76 // ----------------------------------------------------------------------------
78 void wxCaret::InitGeneric()
91 // ----------------------------------------------------------------------------
92 // showing/hiding/moving the caret (base class interface)
93 // ----------------------------------------------------------------------------
95 void wxCaret::DoShow()
97 m_timer
.Start(GetBlinkTime());
103 void wxCaret::DoHide()
113 void wxCaret::DoMove()
115 if ( IsVisible() && !m_blinkedOut
)
119 //else: will be shown at the correct location next time it blinks
122 // ----------------------------------------------------------------------------
124 // ----------------------------------------------------------------------------
126 void wxCaret::Blink()
128 m_blinkedOut
= !m_blinkedOut
;
130 wxClientDC
dc(GetWindow());
137 // FIXME can't be less efficient than this... (+1 needed!)
138 wxRect
rect(m_x
, m_y
, m_width
+ 1, m_height
+ 1);
139 GetWindow()->Refresh(FALSE
, &rect
);
143 void wxCaret::DoDraw(wxDC
*dc
)
145 dc
->SetPen( *wxBLACK_PEN
);
146 dc
->DrawLine( m_x
, m_y
, m_x
+m_width
, m_y
);
147 dc
->DrawLine( m_x
, m_y
+m_height
, m_x
+m_width
, m_y
+m_height
);
148 dc
->DrawLine( m_x
+(m_width
/2), m_y
, m_x
+(m_width
/2), m_y
+m_height
);
149 // dc->DrawLine( m_x+(m_width/2)+1, m_y, m_x+(m_width/2)+1, m_y+m_height );