X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/697e0cdd12c2723397deafab25055b39cc75b77f..18a1f588e7f9c71b4941da549a9ff4370675818c:/samples/caret/caret.cpp?ds=sidebyside diff --git a/samples/caret/caret.cpp b/samples/caret/caret.cpp index d62a84c1c9..600c6e5b0d 100644 --- a/samples/caret/caret.cpp +++ b/samples/caret/caret.cpp @@ -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(); }