]>
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) wxWidgets team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 // ===========================================================================
14 // ===========================================================================
16 // ---------------------------------------------------------------------------
18 // ---------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
28 #include "wx/window.h"
36 #include "wx/msw/private.h"
38 // ---------------------------------------------------------------------------
40 // ---------------------------------------------------------------------------
42 #define CALL_CARET_API(api, args) \
45 wxLogLastError(wxT(#api)); \
48 // ===========================================================================
50 // ===========================================================================
52 // ---------------------------------------------------------------------------
54 // ---------------------------------------------------------------------------
57 int wxCaretBase::GetBlinkTime()
59 int blinkTime
= ::GetCaretBlinkTime();
62 wxLogLastError(wxT("GetCaretBlinkTime"));
69 void wxCaretBase::SetBlinkTime(int milliseconds
)
71 CALL_CARET_API(SetCaretBlinkTime
, (milliseconds
));
74 // ---------------------------------------------------------------------------
75 // creating/destroying the caret
76 // ---------------------------------------------------------------------------
78 bool wxCaret::MSWCreateCaret()
80 wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be created") );
81 wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be created") );
85 CALL_CARET_API(CreateCaret
, (GetWinHwnd(GetWindow()), 0,
94 void wxCaret::OnSetFocus()
96 if ( m_countVisible
> 0 )
98 if ( MSWCreateCaret() )
100 // the caret was recreated but it doesn't remember its position and
107 //else: caret is invisible, don't waste time creating it
110 void wxCaret::OnKillFocus()
116 CALL_CARET_API(DestroyCaret
, ());
120 // ---------------------------------------------------------------------------
121 // showing/hiding the caret
122 // ---------------------------------------------------------------------------
124 void wxCaret::DoShow()
126 wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be shown") );
127 wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be shown") );
129 // we might not have created the caret yet if we had got the focus first
130 // and the caret was shown later - so do it now if we have the focus but
132 if ( !m_hasCaret
&& (wxWindow::FindFocus() == GetWindow()) )
134 if ( MSWCreateCaret() )
142 CALL_CARET_API(ShowCaret
, (GetWinHwnd(GetWindow())));
144 //else: will be shown when we get the focus
147 void wxCaret::DoHide()
151 CALL_CARET_API(HideCaret
, (GetWinHwnd(GetWindow())));
155 // ---------------------------------------------------------------------------
157 // ---------------------------------------------------------------------------
159 void wxCaret::DoMove()
163 wxASSERT_MSG( wxWindow::FindFocus() == GetWindow(),
164 wxT("how did we lose focus?") );
166 // for compatibility with the generic version, the coordinates are
168 wxPoint pt
= GetWindow()->GetClientAreaOrigin();
169 CALL_CARET_API(SetCaretPos
, (m_x
+ pt
.x
, m_y
+ pt
.y
));
171 //else: we don't have caret right now, nothing to do (this does happen)
175 // ---------------------------------------------------------------------------
176 // resizing the caret
177 // ---------------------------------------------------------------------------
179 void wxCaret::DoSize()
184 CALL_CARET_API(DestroyCaret
, ());