]>
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 // ---------------------------------------------------------------------------
46 // ---------------------------------------------------------------------------
49 int wxCaretBase::GetBlinkTime()
51 int blinkTime
= ::GetCaretBlinkTime();
54 wxLogLastError("GetCaretBlinkTime");
61 void wxCaretBase::SetBlinkTime(int milliseconds
)
64 ::SetCaretBlinkTime(milliseconds
) ;
66 if ( !::SetCaretBlinkTime(milliseconds
) )
68 wxLogLastError("SetCaretBlinkTime");
73 // ---------------------------------------------------------------------------
74 // creating/destroying the caret
75 // ---------------------------------------------------------------------------
77 bool wxCaret::MSWCreateCaret()
79 wxASSERT_MSG( GetWindow(), _T("caret without window cannot be created") );
80 wxASSERT_MSG( IsOk(), _T("caret of zero size cannot be created") );
85 ::CreateCaret(GetWinHwnd(GetWindow()), 0, m_width
, m_height
) ;
88 if ( !::CreateCaret(GetWinHwnd(GetWindow()), 0, m_width
, m_height
) )
90 wxLogLastError("CreateCaret");
102 void wxCaret::OnSetFocus()
104 if ( m_countVisible
> 0 )
106 if ( MSWCreateCaret() )
108 // the caret was recreated but it doesn't remember its position and
115 //else: caret is invisible, don't waste time creating it
118 void wxCaret::OnKillFocus()
127 if ( !::DestroyCaret() )
129 wxLogLastError("DestroyCaret");
135 // ---------------------------------------------------------------------------
136 // showing/hiding the caret
137 // ---------------------------------------------------------------------------
139 void wxCaret::DoShow()
141 wxASSERT_MSG( GetWindow(), _T("caret without window cannot be shown") );
142 wxASSERT_MSG( IsOk(), _T("caret of zero size cannot be shown") );
146 (void)MSWCreateCaret();
150 ::ShowCaret(GetWinHwnd(GetWindow())) ;
152 if ( !::ShowCaret(GetWinHwnd(GetWindow())) )
154 wxLogLastError("ShowCaret");
159 void wxCaret::DoHide()
164 ::HideCaret(GetWinHwnd(GetWindow())) ;
166 if ( !::HideCaret(GetWinHwnd(GetWindow())) )
168 wxLogLastError("HideCaret");
174 // ---------------------------------------------------------------------------
176 // ---------------------------------------------------------------------------
178 void wxCaret::DoMove()
183 ::SetCaretPos(m_x
, m_y
) ;
185 if ( !::SetCaretPos(m_x
, m_y
) )
187 wxLogLastError("SetCaretPos");
191 //else: we don't have caret right now, nothing to do (this does happen)