]>
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)   \ 
  44             wxLogLastError(_T(#api)) 
  46 // =========================================================================== 
  48 // =========================================================================== 
  50 // --------------------------------------------------------------------------- 
  52 // --------------------------------------------------------------------------- 
  55 int wxCaretBase::GetBlinkTime() 
  57     int blinkTime 
= ::GetCaretBlinkTime(); 
  60         wxLogLastError(wxT("GetCaretBlinkTime")); 
  67 void wxCaretBase::SetBlinkTime(int milliseconds
) 
  69     CALL_CARET_API(SetCaretBlinkTime
, (milliseconds
)); 
  72 // --------------------------------------------------------------------------- 
  73 // creating/destroying the caret 
  74 // --------------------------------------------------------------------------- 
  76 bool wxCaret::MSWCreateCaret() 
  78     wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be created") ); 
  79     wxASSERT_MSG( IsOk(),  wxT("caret of zero size cannot be created") ); 
  83         CALL_CARET_API(CreateCaret
, (GetWinHwnd(GetWindow()), 0, 
  92 void wxCaret::OnSetFocus() 
  94     if ( m_countVisible 
> 0 ) 
  96         if ( MSWCreateCaret() ) 
  98             // the caret was recreated but it doesn't remember its position and 
 105     //else: caret is invisible, don't waste time creating it 
 108 void wxCaret::OnKillFocus() 
 114         CALL_CARET_API(DestroyCaret
, ()); 
 118 // --------------------------------------------------------------------------- 
 119 // showing/hiding the caret 
 120 // --------------------------------------------------------------------------- 
 122 void wxCaret::DoShow() 
 124     wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be shown") ); 
 125     wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be shown") ); 
 127     // we might not have created the caret yet if we had got the focus first 
 128     // and the caret was shown later - so do it now if we have the focus but 
 130     if ( !m_hasCaret 
&& (wxWindow::FindFocus() == GetWindow()) ) 
 132         if ( MSWCreateCaret() ) 
 140         CALL_CARET_API(ShowCaret
, (GetWinHwnd(GetWindow()))); 
 142     //else: will be shown when we get the focus 
 145 void wxCaret::DoHide() 
 149         CALL_CARET_API(HideCaret
, (GetWinHwnd(GetWindow()))); 
 153 // --------------------------------------------------------------------------- 
 155 // --------------------------------------------------------------------------- 
 157 void wxCaret::DoMove() 
 161         wxASSERT_MSG( wxWindow::FindFocus() == GetWindow(), 
 162                       wxT("how did we lose focus?") ); 
 164         // for compatibility with the generic version, the coordinates are 
 166         wxPoint pt 
= GetWindow()->GetClientAreaOrigin(); 
 167         CALL_CARET_API(SetCaretPos
, (m_x 
+ pt
.x
, m_y 
+ pt
.y
)); 
 169     //else: we don't have caret right now, nothing to do (this does happen) 
 173 // --------------------------------------------------------------------------- 
 174 // resizing the caret 
 175 // --------------------------------------------------------------------------- 
 177 void wxCaret::DoSize() 
 182         CALL_CARET_API(DestroyCaret
, ());