Added more wxRegion tests to erase sample.
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
This commit is contained in:
@@ -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; }
|
||||
|
@@ -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 )
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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;
|
||||
|
@@ -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 );
|
||||
}
|
||||
|
@@ -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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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 );
|
||||
|
Reference in New Issue
Block a user