]>
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 // --------------------------------------------------------------------------- 
  20 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) 
  21     #pragma implementation "caret.h" 
  24 // For compilers that support precompilation, includes "wx.h". 
  25 #include "wx/wxprec.h" 
  32     #include "wx/window.h" 
  40 #include "wx/msw/private.h" 
  42 // --------------------------------------------------------------------------- 
  44 // --------------------------------------------------------------------------- 
  46 #define CALL_CARET_API(api, args)   \ 
  48             wxLogLastError(_T(#api)) 
  50 // =========================================================================== 
  52 // =========================================================================== 
  54 // --------------------------------------------------------------------------- 
  56 // --------------------------------------------------------------------------- 
  59 int wxCaretBase::GetBlinkTime() 
  61     int blinkTime 
= ::GetCaretBlinkTime(); 
  64         wxLogLastError(wxT("GetCaretBlinkTime")); 
  71 void wxCaretBase::SetBlinkTime(int milliseconds
) 
  73     CALL_CARET_API(SetCaretBlinkTime
, (milliseconds
)); 
  76 // --------------------------------------------------------------------------- 
  77 // creating/destroying the caret 
  78 // --------------------------------------------------------------------------- 
  80 bool wxCaret::MSWCreateCaret() 
  82     wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be created") ); 
  83     wxASSERT_MSG( IsOk(),  wxT("caret of zero size cannot be created") ); 
  87         CALL_CARET_API(CreateCaret
, (GetWinHwnd(GetWindow()), 0, 
  96 void wxCaret::OnSetFocus() 
  98     if ( m_countVisible 
> 0 ) 
 100         if ( MSWCreateCaret() ) 
 102             // the caret was recreated but it doesn't remember its position and 
 109     //else: caret is invisible, don't waste time creating it 
 112 void wxCaret::OnKillFocus() 
 118         CALL_CARET_API(DestroyCaret
, ()); 
 122 // --------------------------------------------------------------------------- 
 123 // showing/hiding the caret 
 124 // --------------------------------------------------------------------------- 
 126 void wxCaret::DoShow() 
 128     wxASSERT_MSG( GetWindow(), wxT("caret without window cannot be shown") ); 
 129     wxASSERT_MSG( IsOk(), wxT("caret of zero size cannot be shown") ); 
 131     // we might not have created the caret yet if we had got the focus first 
 132     // and the caret was shown later - so do it now if we have the focus but 
 134     if ( !m_hasCaret 
&& (wxWindow::FindFocus() == GetWindow()) ) 
 136         if ( MSWCreateCaret() ) 
 144         CALL_CARET_API(ShowCaret
, (GetWinHwnd(GetWindow()))); 
 146     //else: will be shown when we get the focus 
 149 void wxCaret::DoHide() 
 153         CALL_CARET_API(HideCaret
, (GetWinHwnd(GetWindow()))); 
 157 // --------------------------------------------------------------------------- 
 159 // --------------------------------------------------------------------------- 
 161 void wxCaret::DoMove() 
 165         wxASSERT_MSG( wxWindow::FindFocus() == GetWindow(), 
 166                       wxT("how did we lose focus?") ); 
 168         // for compatibility with the generic version, the coordinates are 
 170         wxPoint pt 
= GetWindow()->GetClientAreaOrigin(); 
 171         CALL_CARET_API(SetCaretPos
, (m_x 
+ pt
.x
, m_y 
+ pt
.y
)); 
 173     //else: we don't have caret right now, nothing to do (this does happen) 
 177 // --------------------------------------------------------------------------- 
 178 // resizing the caret 
 179 // --------------------------------------------------------------------------- 
 181 void wxCaret::DoSize() 
 186         CALL_CARET_API(DestroyCaret
, ());