]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/caret.cpp
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: MSW implementation of wxCaret
4 // Author: Vadim Zeitlin
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"
38 #include "wx/msw/private.h"
40 // ===========================================================================
42 // ===========================================================================
44 // ---------------------------------------------------------------------------
46 // ---------------------------------------------------------------------------
49 int wxCaretBase::GetBlinkTime()
51 int blinkTime
= ::GetCaretBlinkTime();
54 wxLogLastError("GetCaretBlinkTime");
61 void wxCaretBase::SetBlinkTime(int milliseconds
)
63 if ( !::SetCaretBlinkTime(milliseconds
) )
65 wxLogLastError("SetCaretBlinkTime");
69 // ---------------------------------------------------------------------------
70 // creating/destroying the caret
71 // ---------------------------------------------------------------------------
73 bool wxCaret::MSWCreateCaret()
75 wxASSERT_MSG( GetWindow(), "caret without window cannot be created" );
76 wxASSERT_MSG( IsOk(), "caret of zero size cannot be created" );
80 if ( !::CreateCaret(GetWinHwnd(GetWindow()), 0, m_width
, m_height
) )
82 wxLogLastError("CreateCaret");
93 void wxCaret::OnSetFocus()
95 if ( m_countVisible
> 0 )
97 if ( MSWCreateCaret() )
99 // the caret was recreated but it doesn't remember its position and
106 //else: caret is invisible, don't waste time creating it
109 void wxCaret::OnKillFocus()
115 if ( !::DestroyCaret() )
117 wxLogLastError("DestroyCaret");
122 // ---------------------------------------------------------------------------
123 // showing/hiding the caret
124 // ---------------------------------------------------------------------------
126 void wxCaret::DoShow()
128 wxASSERT_MSG( GetWindow(), "caret without window cannot be shown" );
129 wxASSERT_MSG( IsOk(), "caret of zero size cannot be shown" );
133 (void)MSWCreateCaret();
136 if ( !::ShowCaret(GetWinHwnd(GetWindow())) )
138 wxLogLastError("ShowCaret");
142 void wxCaret::DoHide()
146 if ( !::HideCaret(GetWinHwnd(GetWindow())) )
148 wxLogLastError("HideCaret");
153 // ---------------------------------------------------------------------------
155 // ---------------------------------------------------------------------------
157 void wxCaret::DoMove()
161 if ( !::SetCaretPos(m_x
, m_y
) )
163 wxLogLastError("SetCaretPos");
166 //else: we don't have caret right now, nothing to do (this does happen)