]>
git.saurik.com Git - wxWidgets.git/blob - src/msw/caret.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/caret.cpp
3 // Purpose: MSW implementation of wxCaret
4 // Author: Vadim Zeitlin
7 // Copyright: (c) wxWidgets team
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ===========================================================================
13 // ===========================================================================
15 // ---------------------------------------------------------------------------
17 // ---------------------------------------------------------------------------
19 // For compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
27 #include "wx/window.h"
35 #include "wx/msw/private.h"
37 // ---------------------------------------------------------------------------
39 // ---------------------------------------------------------------------------
41 #define CALL_CARET_API(api, args) \
44 wxLogLastError(wxT(#api)); \
47 // ===========================================================================
49 // ===========================================================================
51 // ---------------------------------------------------------------------------
53 // ---------------------------------------------------------------------------
56 int wxCaretBase::GetBlinkTime()
58 int blinkTime
= ::GetCaretBlinkTime();
61 wxLogLastError(wxT("GetCaretBlinkTime"));
68 void wxCaretBase::SetBlinkTime(int milliseconds
)
70 CALL_CARET_API(SetCaretBlinkTime
, (milliseconds
));
73 // ---------------------------------------------------------------------------
74 // creating/destroying the caret
75 // ---------------------------------------------------------------------------
77 bool wxCaret::MSWCreateCaret()
79 wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be created") );
80 wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be created") );
84 CALL_CARET_API(CreateCaret
, (GetWinHwnd(GetWindow()), 0,
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 CALL_CARET_API(DestroyCaret
, ());
119 // ---------------------------------------------------------------------------
120 // showing/hiding the caret
121 // ---------------------------------------------------------------------------
123 void wxCaret::DoShow()
125 wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be shown") );
126 wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be shown") );
128 // we might not have created the caret yet if we had got the focus first
129 // and the caret was shown later - so do it now if we have the focus but
131 if ( !m_hasCaret
&& (wxWindow::FindFocus() == GetWindow()) )
133 if ( MSWCreateCaret() )
141 CALL_CARET_API(ShowCaret
, (GetWinHwnd(GetWindow())));
143 //else: will be shown when we get the focus
146 void wxCaret::DoHide()
150 CALL_CARET_API(HideCaret
, (GetWinHwnd(GetWindow())));
154 // ---------------------------------------------------------------------------
156 // ---------------------------------------------------------------------------
158 void wxCaret::DoMove()
162 wxASSERT_MSG( wxWindow::FindFocus() == GetWindow(),
163 wxT("how did we lose focus?") );
165 // for compatibility with the generic version, the coordinates are
167 wxPoint pt
= GetWindow()->GetClientAreaOrigin();
168 CALL_CARET_API(SetCaretPos
, (m_x
+ pt
.x
, m_y
+ pt
.y
));
170 //else: we don't have caret right now, nothing to do (this does happen)
174 // ---------------------------------------------------------------------------
175 // resizing the caret
176 // ---------------------------------------------------------------------------
178 void wxCaret::DoSize()
183 CALL_CARET_API(DestroyCaret
, ());