X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/697e0cdd12c2723397deafab25055b39cc75b77f..c16d276354b116475bf85a0388b4b0f545da0f82:/samples/caret/caret.cpp diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index d62a84c1c9..7415922ae0 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -10,7 +10,7 @@ ///////////////////////////////////////////////////////////////////////////// // For compilers that support precompilation, includes "wx/wx.h". -#include +#include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop @@ -30,7 +30,7 @@ // ressources // ---------------------------------------------------------------------------- // the application icon -#if defined(__WXGTK__) || defined(__WXMOTIF__) +#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) #include "mondrian.xpm" #endif @@ -358,6 +358,7 @@ void MyCanvas::OnSize( wxSizeEvent &event ) // would use GetUpdateRegion() and iterate over rectangles it contains void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) { + wxCaretSuspend cs(this); wxPaintDC dc( this ); PrepareDC( dc ); dc.Clear(); @@ -382,8 +383,6 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) ) void MyCanvas::OnChar( wxKeyEvent &event ) { - bool refresh = FALSE; - switch ( event.KeyCode() ) { case WXK_LEFT: @@ -418,10 +417,17 @@ void MyCanvas::OnChar( wxKeyEvent &event ) default: if ( !event.AltDown() && wxIsprint(event.KeyCode()) ) { - CharAt(m_xCaret, m_yCaret) = (wxChar)event.KeyCode(); - NextChar(); + wxChar ch = (wxChar)event.KeyCode(); + CharAt(m_xCaret, m_yCaret) = ch; + + wxCaretSuspend cs(this); + wxClientDC dc(this); + dc.SetFont(m_font); + dc.SetBackgroundMode(wxSOLID); // overwrite old value + dc.DrawText(ch, m_xMargin + m_xCaret * m_widthChar, + m_yMargin + m_yCaret * m_heightChar ); - refresh = TRUE; + NextChar(); } else { @@ -430,8 +436,5 @@ void MyCanvas::OnChar( wxKeyEvent &event ) } DoMoveCaret(); - - if ( refresh ) - Refresh(); }