]>
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"
37 // ----------------------------------------------------------------------------
38 // global variables for this module
39 // ----------------------------------------------------------------------------
41 // the blink time (common to all carets for MSW compatibility)
42 static int gs_blinkTime
= 500; // in milliseconds
44 // ============================================================================
46 // ============================================================================
48 // ----------------------------------------------------------------------------
49 // wxCaret static functions and data
50 // ----------------------------------------------------------------------------
53 int wxCaretBase::GetBlinkTime()
58 void wxCaretBase::SetBlinkTime(int milliseconds
)
60 gs_blinkTime
= milliseconds
;
63 // ----------------------------------------------------------------------------
64 // initialization and destruction
65 // ----------------------------------------------------------------------------
67 void wxCaret::InitGeneric()
80 // ----------------------------------------------------------------------------
81 // showing/hiding/moving the caret (base class interface)
82 // ----------------------------------------------------------------------------
84 void wxCaret::DoShow()
86 m_timer
.Start(GetBlinkTime());
92 void wxCaret::DoHide()
102 void wxCaret::DoMove()
104 if ( IsVisible() && !m_blinkedOut
)
108 //else: will be shown at the correct location next time it blinks
111 // ----------------------------------------------------------------------------
113 // ----------------------------------------------------------------------------
115 void wxCaret::Blink()
117 m_blinkedOut
= !m_blinkedOut
;
119 wxClientDC
dc(GetWindow());
126 // FIXME can't be less efficient than this... (+1 needed!)
127 wxRect
rect(m_x
, m_y
, m_width
+ 1, m_height
+ 1);
128 GetWindow()->Refresh(FALSE
, &rect
);
132 void wxCaret::DoDraw(wxDC
*dc
)
134 dc
->SetPen( *wxBLACK_PEN
);
135 dc
->DrawLine( m_x
, m_y
, m_x
+m_width
, m_y
);
136 dc
->DrawLine( m_x
, m_y
+m_height
, m_x
+m_width
, m_y
+m_height
);
137 dc
->DrawLine( m_x
+(m_width
/2), m_y
, m_x
+(m_width
/2), m_y
+m_height
);
138 // dc->DrawLine( m_x+(m_width/2)+1, m_y, m_x+(m_width/2)+1, m_y+m_height );