]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/caret/caret.cpp
compilation warning fixed
[wxWidgets.git] / samples / caret / caret.cpp
index d62a84c1c95d61c405af65af36c7e6d4f6004c73..600c6e5b0df66a7763ccdbecc4e0f9aec8bed109 100644 (file)
@@ -30,7 +30,7 @@
 // ressources
 // ----------------------------------------------------------------------------
 // the application icon
 // ressources
 // ----------------------------------------------------------------------------
 // the application icon
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__)
     #include "mondrian.xpm"
 #endif
 
     #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) )
 {
 //     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();
     wxPaintDC dc( this );
     PrepareDC( dc );
     dc.Clear();
@@ -382,8 +383,6 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
 
 void MyCanvas::OnChar( wxKeyEvent &event )
 {
 
 void MyCanvas::OnChar( wxKeyEvent &event )
 {
-    bool refresh = FALSE;
-
     switch ( event.KeyCode() )
     {
         case WXK_LEFT:
     switch ( event.KeyCode() )
     {
         case WXK_LEFT:
@@ -418,10 +417,17 @@ void MyCanvas::OnChar( wxKeyEvent &event )
         default:
             if ( !event.AltDown() && wxIsprint(event.KeyCode()) )
             {
         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
             {
             }
             else
             {
@@ -430,8 +436,5 @@ void MyCanvas::OnChar( wxKeyEvent &event )
     }
 
     DoMoveCaret();
     }
 
     DoMoveCaret();
-
-    if ( refresh )
-        Refresh();
 }
 
 }