]> git.saurik.com Git - wxWidgets.git/commitdiff
Added more wxRegion tests to erase sample.
authorRobert Roebling <robert@roebling.de>
Mon, 18 Feb 2002 22:13:23 +0000 (22:13 +0000)
committerRobert Roebling <robert@roebling.de>
Mon, 18 Feb 2002 22:13:23 +0000 (22:13 +0000)
  Implemented "clear now, paint later".
  Corrected colour-by-name lookup.
  Corrected DrawRectangle code which produced
    redraw garbage under wxX11.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14297 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/x11/window.h
samples/erase/erase.cpp
src/gtk/colour.cpp
src/gtk1/colour.cpp
src/x11/app.cpp
src/x11/colour.cpp
src/x11/dcclient.cpp
src/x11/window.cpp

index 29b646cafe7fff6f56d1922d83c88c60fe7185cd..e7ef074f99572bf7aed23287589b9e82b8775e2d 100644 (file)
@@ -120,8 +120,11 @@ public:
     // arrange status bar, toolbar etc.
     virtual bool PreResize();
     
-    // Generates paint events
-    void X11SendPaintEvents();
+    // Generates paint events from m_updateRegion
+    void SendPaintEvents();
+    
+    // Generates erase events from m_clearRegion
+    void SendEraseEvents();
     
     // Clip to paint region?
     bool GetClipPaintRegion() { return m_clipPaintRegion; }
index eeddaad927f139de58c763ad612692a15535fd09..f25a7927394886ccc6073af133a04c147e7f0b27 100644 (file)
@@ -188,6 +188,18 @@ void MyCanvas::OnPaint( wxPaintEvent &event )
     
     dc.SetBrush( *wxRED_BRUSH );
     dc.DrawRectangle( 100, 100, 200, 200 );
+    
+    dc.DestroyClipingRegion();
+
+    dc.SetPen( *wxTRANSPARENT_PEN );
+    
+    wxRegion strip( 110, 200, 30, 1 );
+    wxRegionIterator it( strip );
+    while (it)
+    {
+        dc.DrawRectangle( it.GetX(), it.GetY(), it.GetWidth(), it.GetHeight() );
+        it ++;
+    }
 }
 
 void MyCanvas::OnEraseBackground( wxEraseEvent &event )
index 8ee81076b50c2e2492ccbc76742f9b1dbad43892..d4b919414586f8bbfac6371fba3492c1e048edc0 100644 (file)
@@ -158,6 +158,7 @@ void wxColour::InitFromName( const wxString &colourName )
     else
     {
         m_refData = new wxColourRefData();
+        
         if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
         {
             // VZ: asserts are good in general but this one is triggered by
index 8ee81076b50c2e2492ccbc76742f9b1dbad43892..d4b919414586f8bbfac6371fba3492c1e048edc0 100644 (file)
@@ -158,6 +158,7 @@ void wxColour::InitFromName( const wxString &colourName )
     else
     {
         m_refData = new wxColourRefData();
+        
         if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
         {
             // VZ: asserts are good in general but this one is triggered by
index 511b5fb034717810252b868c3426f87f864bdfb9..d45ff95d4a9230ba17bff32026c146f450699902 100644 (file)
@@ -544,9 +544,12 @@ void wxApp::ProcessXEvent(WXEvent* _event)
                                               
                 win->GetClearRegion().Union( event->xexpose.x, event->xexpose.y,
                                              event->xexpose.width, event->xexpose.height);
-                                              
-                // if (event->xexpose.count == 0)
-                //    win->Update();
+                
+                if (event->xexpose.count == 0)
+                {
+                    // Only erase background, paint in idle time.
+                    win->SendEraseEvents();
+                }
             }
 
             return;
@@ -565,8 +568,11 @@ void wxApp::ProcessXEvent(WXEvent* _event)
                 win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
                                              event->xgraphicsexpose.width, event->xgraphicsexpose.height);
                                               
-                // if (event->xgraphicsexpose.count == 0)
-                //    win->Update();
+                if (event->xgraphicsexpose.count == 0)
+                {
+                    // Only erase background, paint in idle time.
+                    win->SendEraseEvents();
+                }
             }
 
             return;
index cf8302dd51c967fe68647ed9ef6c53b0c33f8bbb..f989be7f44a6f32aeb7e9375dd72e3190cf47dad 100644 (file)
@@ -15,6 +15,7 @@
 #endif
 
 #include "wx/gdicmn.h"
+#include "wx/app.h"
 
 #include "wx/x11/private.h"
 
@@ -154,6 +155,9 @@ void wxColour::InitFromName( const wxString &colourName )
     else
     {
         m_refData = new wxColourRefData();
+        
+        M_COLDATA->m_colormap = wxTheApp->GetMainColormap( wxGlobalDisplay() );
+        
         if (!XParseColor( wxGlobalDisplay(), (Colormap) M_COLDATA->m_colormap, colourName.mb_str(), &M_COLDATA->m_color ))
         {
             // VZ: asserts are good in general but this one is triggered by
@@ -234,7 +238,9 @@ unsigned char wxColour::Blue() const
 
 void wxColour::CalcPixel( WXColormap cmap )
 {
-    if (!Ok()) return;
+    wxCHECK_RET( Ok(), wxT("invalid colour") );
+
+    wxCHECK_RET( cmap, wxT("invalid colormap") );
 
     M_COLDATA->AllocColour( cmap );
 }
index 286375fa0e272b12f46140e9cd1320b200dcf9bf..68b68bf7b8d773fe70ad28e5ccdf3d48092f1af4 100644 (file)
@@ -741,7 +741,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
         if (m_pen.GetStyle () != wxTRANSPARENT)
         {
             XDrawRectangle( (Display*) m_display, (Window) m_window,
-                (GC) m_penGC, xx, yy, ww, hh );
+                (GC) m_penGC, xx, yy, ww-1, hh-1 );
         }
     }
 
index ed580bbb2eb0bb29355461f97a6b79f444b95e5b..0ddb71547623ab9d78cc6e6dd097414993e0efc2 100644 (file)
@@ -357,7 +357,7 @@ void wxWindowX11::DoCaptureMouse()
             return;
         }
 
-        wxLogDebug("Grabbed pointer");
+        /// wxLogDebug("Grabbed pointer");
 
 #if 0
         res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier,
@@ -416,7 +416,8 @@ void wxWindowX11::DoReleaseMouse()
         XUngrabKeyboard( wxGlobalDisplay(), CurrentTime );
 #endif
     }
-    wxLogDebug("Ungrabbed pointer");
+    
+    // wxLogDebug("Ungrabbed pointer");
 
     m_winCaptured = FALSE;
 }
@@ -940,8 +941,11 @@ void wxWindowX11::Update()
 {
     if (!m_updateRegion.IsEmpty())
     {
-        // Actually send erase and paint events.
-        X11SendPaintEvents();
+        // Actually send erase events.
+        SendEraseEvents();
+        
+        // Actually send paint events.
+        SendPaintEvents();
     }
 }
 
@@ -953,12 +957,12 @@ void wxWindowX11::Clear()
     dc.Clear();
 }
 
-void wxWindowX11::X11SendPaintEvents()
+void wxWindowX11::SendEraseEvents()
 {
-    m_clipPaintRegion = TRUE;
-
     if (!m_clearRegion.IsEmpty())
     {
+        m_clipPaintRegion = TRUE;
+
         wxWindowDC dc( (wxWindow*)this );
         dc.SetClippingRegion( m_clearRegion );
         
@@ -982,7 +986,15 @@ void wxWindowX11::X11SendPaintEvents()
             XFreeGC( xdisplay, xgc );
         }
         m_clearRegion.Clear();
+
+        m_clipPaintRegion = FALSE;
     }
+}
+
+
+void wxWindowX11::SendPaintEvents()
+{
+    m_clipPaintRegion = TRUE;
 
     wxNcPaintEvent nc_paint_event( GetId() );
     nc_paint_event.SetEventObject( this );