]>
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 // under Win16 the caret APIs are void but under Win32 they may return an
45 // error code which we want to check - this macro does just this
47 #define CALL_CARET_API(api, args) api args
49 #define CALL_CARET_API(api, args) if ( !api args ) wxLogLastError(#api)
52 // ===========================================================================
54 // ===========================================================================
56 // ---------------------------------------------------------------------------
58 // ---------------------------------------------------------------------------
61 int wxCaretBase::GetBlinkTime()
63 int blinkTime
= ::GetCaretBlinkTime();
66 wxLogLastError("GetCaretBlinkTime");
73 void wxCaretBase::SetBlinkTime(int milliseconds
)
75 CALL_CARET_API(SetCaretBlinkTime
, (milliseconds
));
78 // ---------------------------------------------------------------------------
79 // creating/destroying the caret
80 // ---------------------------------------------------------------------------
82 bool wxCaret::MSWCreateCaret()
84 wxASSERT_MSG( GetWindow(), _T("caret without window cannot be created") );
85 wxASSERT_MSG( IsOk(), _T("caret of zero size cannot be created") );
89 CALL_CARET_API(CreateCaret
, (GetWinHwnd(GetWindow()), 0,
98 void wxCaret::OnSetFocus()
100 if ( m_countVisible
> 0 )
102 if ( MSWCreateCaret() )
104 // the caret was recreated but it doesn't remember its position and
111 //else: caret is invisible, don't waste time creating it
114 void wxCaret::OnKillFocus()
120 CALL_CARET_API(DestroyCaret
, ());
124 // ---------------------------------------------------------------------------
125 // showing/hiding the caret
126 // ---------------------------------------------------------------------------
128 void wxCaret::DoShow()
130 wxASSERT_MSG( GetWindow(), _T("caret without window cannot be shown") );
131 wxASSERT_MSG( IsOk(), _T("caret of zero size cannot be shown") );
135 CALL_CARET_API(ShowCaret
, (GetWinHwnd(GetWindow())));
137 //else: will be shown when we get the focus
140 void wxCaret::DoHide()
144 CALL_CARET_API(HideCaret
, (GetWinHwnd(GetWindow())));
148 // ---------------------------------------------------------------------------
150 // ---------------------------------------------------------------------------
152 void wxCaret::DoMove()
156 wxWindow
*winFocus
= wxWindow::FindFocus();
157 wxASSERT_MSG( winFocus
== GetWindow(), _T("how did we lose focus?") );
159 CALL_CARET_API(SetCaretPos
, (m_x
, m_y
));
161 //else: we don't have caret right now, nothing to do (this does happen)