]>
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"
37 #include "wx/msw/private.h"
39 // ===========================================================================
41 // ===========================================================================
43 // ---------------------------------------------------------------------------
45 // ---------------------------------------------------------------------------
48 int wxCaretBase::GetBlinkTime()
50 int blinkTime
= ::GetCaretBlinkTime();
53 wxLogLastError("GetCaretBlinkTime");
60 void wxCaretBase::SetBlinkTime(int milliseconds
)
62 if ( !::SetCaretBlinkTime(milliseconds
) )
64 wxLogLastError("SetCaretBlinkTime");
68 // ---------------------------------------------------------------------------
69 // creating/destroying the caret
70 // ---------------------------------------------------------------------------
72 bool wxCaret::MSWCreateCaret()
74 wxASSERT_MSG( GetWindow(), "caret without window cannot be created" );
75 wxASSERT_MSG( IsOk(), "caret of zero size cannot be created" );
79 if ( !::CreateCaret(GetWinHwnd(GetWindow()), 0, m_width
, m_height
) )
81 wxLogLastError("CreateCaret");
92 void wxCaret::OnSetFocus()
94 if ( m_countVisible
> 0 )
96 if ( MSWCreateCaret() )
98 // the caret was recreated but it doesn't remember its position and
105 //else: caret is invisible, don't waste time creating it
108 void wxCaret::OnKillFocus()
114 if ( !::DestroyCaret() )
116 wxLogLastError("DestroyCaret");
121 // ---------------------------------------------------------------------------
122 // showing/hiding the caret
123 // ---------------------------------------------------------------------------
125 void wxCaret::DoShow()
127 wxASSERT_MSG( GetWindow(), "caret without window cannot be shown" );
128 wxASSERT_MSG( IsOk(), "caret of zero size cannot be shown" );
132 (void)MSWCreateCaret();
135 if ( !::ShowCaret(GetWinHwnd(GetWindow())) )
137 wxLogLastError("ShowCaret");
141 void wxCaret::DoHide()
143 wxASSERT_MSG( m_hasCaret
, "cannot hide non existent caret" );
145 if ( !::HideCaret(GetWinHwnd(GetWindow())) )
147 wxLogLastError("HideCaret");
151 // ---------------------------------------------------------------------------
153 // ---------------------------------------------------------------------------
155 void wxCaret::DoMove()
159 if ( !::SetCaretPos(m_x
, m_y
) )
161 wxLogLastError("SetCaretPos");
164 //else: we don't have caret right now, nothing to do (this does happen)