]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/caret/caret.cpp
Fix so OGL can build without wxBuffer
[wxWidgets.git] / samples / caret / caret.cpp
index d62a84c1c95d61c405af65af36c7e6d4f6004c73..f023d9e6f8460a84ff6f985a00bb3df0c96c0a81 100644 (file)
@@ -10,7 +10,7 @@
 /////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx/wx.h".
-#include <wx/wxprec.h>
+#include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
     #pragma hdrstop
@@ -19,9 +19,9 @@
 // for all others, include the necessary headers (this file is usually all you
 // need because it includes almost all <standard< wxWindows headers
 #ifndef WX_PRECOMP
-    #include <wx/wx.h>
+    #include "wx/wx.h"
 
-    #include <wx/log.h>
+    #include "wx/log.h"
 #endif
 
 #include "wx/caret.h"
@@ -30,7 +30,7 @@
 // ressources
 // ----------------------------------------------------------------------------
 // the application icon
-#if defined(__WXGTK__) || defined(__WXMOTIF__)
+#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__)
     #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();
 }