]>
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 // ----------------------------------------------------------------------------
50 // wxCaret static functions and data
51 // ----------------------------------------------------------------------------
54 int wxCaretBase::GetBlinkTime()
59 void wxCaretBase::SetBlinkTime(int milliseconds
)
61 gs_blinkTime
= milliseconds
;
64 // ----------------------------------------------------------------------------
65 // initialization and destruction
66 // ----------------------------------------------------------------------------
68 void wxCaret::InitGeneric()
81 // ----------------------------------------------------------------------------
82 // showing/hiding/moving the caret (base class interface)
83 // ----------------------------------------------------------------------------
85 void wxCaret::DoShow()
87 m_timer
.Start(GetBlinkTime());
93 void wxCaret::DoHide()
103 void wxCaret::DoMove()
105 if ( IsVisible() && !m_blinkedOut
)
109 //else: will be shown at the correct location next time it blinks
112 // ----------------------------------------------------------------------------
114 // ----------------------------------------------------------------------------
116 void wxCaret::Blink()
118 m_blinkedOut
= !m_blinkedOut
;
120 wxClientDC
dc(GetWindow());
127 // FIXME can't be less efficient than this... (+1 needed!)
128 wxRect
rect(m_x
, m_y
, m_width
+ 1, m_height
+ 1);
129 GetWindow()->Refresh(FALSE
, &rect
);
133 void wxCaret::DoDraw(wxDC
*dc
)
135 dc
->SetPen( *wxBLACK_PEN
);
136 dc
->DrawLine( m_x
, m_y
, m_x
+m_width
, m_y
);
137 dc
->DrawLine( m_x
, m_y
+m_height
, m_x
+m_width
, m_y
+m_height
);
138 dc
->DrawLine( m_x
+(m_width
/2), m_y
, m_x
+(m_width
/2), m_y
+m_height
);
139 // dc->DrawLine( m_x+(m_width/2)+1, m_y, m_x+(m_width/2)+1, m_y+m_height );