]>
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) \
51 wxLogLastError(_T(#api))
54 // ===========================================================================
56 // ===========================================================================
58 // ---------------------------------------------------------------------------
60 // ---------------------------------------------------------------------------
63 int wxCaretBase::GetBlinkTime()
65 int blinkTime
= ::GetCaretBlinkTime();
68 wxLogLastError(wxT("GetCaretBlinkTime"));
75 void wxCaretBase::SetBlinkTime(int milliseconds
)
77 CALL_CARET_API(SetCaretBlinkTime
, (milliseconds
));
80 // ---------------------------------------------------------------------------
81 // creating/destroying the caret
82 // ---------------------------------------------------------------------------
84 bool wxCaret::MSWCreateCaret()
86 wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be created") );
87 wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be created") );
91 CALL_CARET_API(CreateCaret
, (GetWinHwnd(GetWindow()), 0,
100 void wxCaret::OnSetFocus()
102 if ( m_countVisible
> 0 )
104 if ( MSWCreateCaret() )
106 // the caret was recreated but it doesn't remember its position and
113 //else: caret is invisible, don't waste time creating it
116 void wxCaret::OnKillFocus()
122 CALL_CARET_API(DestroyCaret
, ());
126 // ---------------------------------------------------------------------------
127 // showing/hiding the caret
128 // ---------------------------------------------------------------------------
130 void wxCaret::DoShow()
132 wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be shown") );
133 wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be shown") );
137 CALL_CARET_API(ShowCaret
, (GetWinHwnd(GetWindow())));
139 //else: will be shown when we get the focus
142 void wxCaret::DoHide()
146 CALL_CARET_API(HideCaret
, (GetWinHwnd(GetWindow())));
150 // ---------------------------------------------------------------------------
152 // ---------------------------------------------------------------------------
154 void wxCaret::DoMove()
158 wxASSERT_MSG( wxWindow::FindFocus() == GetWindow(),
159 wxT("how did we lose focus?") );
161 CALL_CARET_API(SetCaretPos
, (m_x
, m_y
));
163 //else: we don't have caret right now, nothing to do (this does happen)
167 // ---------------------------------------------------------------------------
168 // resizing the caret
169 // ---------------------------------------------------------------------------
171 void wxCaret::DoSize()
176 CALL_CARET_API(DestroyCaret
, ());