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.
|
// arrange status bar, toolbar etc.
|
||||||
virtual bool PreResize();
|
virtual bool PreResize();
|
||||||
|
|
||||||
// Generates paint events
|
// Generates paint events from m_updateRegion
|
||||||
void X11SendPaintEvents();
|
void SendPaintEvents();
|
||||||
|
|
||||||
|
// Generates erase events from m_clearRegion
|
||||||
|
void SendEraseEvents();
|
||||||
|
|
||||||
// Clip to paint region?
|
// Clip to paint region?
|
||||||
bool GetClipPaintRegion() { return m_clipPaintRegion; }
|
bool GetClipPaintRegion() { return m_clipPaintRegion; }
|
||||||
|
@@ -188,6 +188,18 @@ void MyCanvas::OnPaint( wxPaintEvent &event )
|
|||||||
|
|
||||||
dc.SetBrush( *wxRED_BRUSH );
|
dc.SetBrush( *wxRED_BRUSH );
|
||||||
dc.DrawRectangle( 100, 100, 200, 200 );
|
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 )
|
void MyCanvas::OnEraseBackground( wxEraseEvent &event )
|
||||||
|
@@ -158,6 +158,7 @@ void wxColour::InitFromName( const wxString &colourName )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_refData = new wxColourRefData();
|
m_refData = new wxColourRefData();
|
||||||
|
|
||||||
if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
|
if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
|
||||||
{
|
{
|
||||||
// VZ: asserts are good in general but this one is triggered by
|
// VZ: asserts are good in general but this one is triggered by
|
||||||
|
@@ -158,6 +158,7 @@ void wxColour::InitFromName( const wxString &colourName )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_refData = new wxColourRefData();
|
m_refData = new wxColourRefData();
|
||||||
|
|
||||||
if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
|
if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color ))
|
||||||
{
|
{
|
||||||
// VZ: asserts are good in general but this one is triggered by
|
// 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,
|
win->GetClearRegion().Union( event->xexpose.x, event->xexpose.y,
|
||||||
event->xexpose.width, event->xexpose.height);
|
event->xexpose.width, event->xexpose.height);
|
||||||
|
|
||||||
// if (event->xexpose.count == 0)
|
if (event->xexpose.count == 0)
|
||||||
// win->Update();
|
{
|
||||||
|
// Only erase background, paint in idle time.
|
||||||
|
win->SendEraseEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
@@ -565,8 +568,11 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
|
win->GetClearRegion().Union( event->xgraphicsexpose.x, event->xgraphicsexpose.y,
|
||||||
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
|
event->xgraphicsexpose.width, event->xgraphicsexpose.height);
|
||||||
|
|
||||||
// if (event->xgraphicsexpose.count == 0)
|
if (event->xgraphicsexpose.count == 0)
|
||||||
// win->Update();
|
{
|
||||||
|
// Only erase background, paint in idle time.
|
||||||
|
win->SendEraseEvents();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/gdicmn.h"
|
||||||
|
#include "wx/app.h"
|
||||||
|
|
||||||
#include "wx/x11/private.h"
|
#include "wx/x11/private.h"
|
||||||
|
|
||||||
@@ -154,6 +155,9 @@ void wxColour::InitFromName( const wxString &colourName )
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_refData = new wxColourRefData();
|
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 ))
|
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
|
// 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 )
|
void wxColour::CalcPixel( WXColormap cmap )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
wxCHECK_RET( Ok(), wxT("invalid colour") );
|
||||||
|
|
||||||
|
wxCHECK_RET( cmap, wxT("invalid colormap") );
|
||||||
|
|
||||||
M_COLDATA->AllocColour( cmap );
|
M_COLDATA->AllocColour( cmap );
|
||||||
}
|
}
|
||||||
|
@@ -741,7 +741,7 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
|
|||||||
if (m_pen.GetStyle () != wxTRANSPARENT)
|
if (m_pen.GetStyle () != wxTRANSPARENT)
|
||||||
{
|
{
|
||||||
XDrawRectangle( (Display*) m_display, (Window) m_window,
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug("Grabbed pointer");
|
/// wxLogDebug("Grabbed pointer");
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier,
|
res = XGrabButton(wxGlobalDisplay(), AnyButton, AnyModifier,
|
||||||
@@ -416,7 +416,8 @@ void wxWindowX11::DoReleaseMouse()
|
|||||||
XUngrabKeyboard( wxGlobalDisplay(), CurrentTime );
|
XUngrabKeyboard( wxGlobalDisplay(), CurrentTime );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
wxLogDebug("Ungrabbed pointer");
|
|
||||||
|
// wxLogDebug("Ungrabbed pointer");
|
||||||
|
|
||||||
m_winCaptured = FALSE;
|
m_winCaptured = FALSE;
|
||||||
}
|
}
|
||||||
@@ -940,8 +941,11 @@ void wxWindowX11::Update()
|
|||||||
{
|
{
|
||||||
if (!m_updateRegion.IsEmpty())
|
if (!m_updateRegion.IsEmpty())
|
||||||
{
|
{
|
||||||
// Actually send erase and paint events.
|
// Actually send erase events.
|
||||||
X11SendPaintEvents();
|
SendEraseEvents();
|
||||||
|
|
||||||
|
// Actually send paint events.
|
||||||
|
SendPaintEvents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -953,12 +957,12 @@ void wxWindowX11::Clear()
|
|||||||
dc.Clear();
|
dc.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowX11::X11SendPaintEvents()
|
void wxWindowX11::SendEraseEvents()
|
||||||
{
|
{
|
||||||
m_clipPaintRegion = TRUE;
|
|
||||||
|
|
||||||
if (!m_clearRegion.IsEmpty())
|
if (!m_clearRegion.IsEmpty())
|
||||||
{
|
{
|
||||||
|
m_clipPaintRegion = TRUE;
|
||||||
|
|
||||||
wxWindowDC dc( (wxWindow*)this );
|
wxWindowDC dc( (wxWindow*)this );
|
||||||
dc.SetClippingRegion( m_clearRegion );
|
dc.SetClippingRegion( m_clearRegion );
|
||||||
|
|
||||||
@@ -982,7 +986,15 @@ void wxWindowX11::X11SendPaintEvents()
|
|||||||
XFreeGC( xdisplay, xgc );
|
XFreeGC( xdisplay, xgc );
|
||||||
}
|
}
|
||||||
m_clearRegion.Clear();
|
m_clearRegion.Clear();
|
||||||
|
|
||||||
|
m_clipPaintRegion = FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void wxWindowX11::SendPaintEvents()
|
||||||
|
{
|
||||||
|
m_clipPaintRegion = TRUE;
|
||||||
|
|
||||||
wxNcPaintEvent nc_paint_event( GetId() );
|
wxNcPaintEvent nc_paint_event( GetId() );
|
||||||
nc_paint_event.SetEventObject( this );
|
nc_paint_event.SetEventObject( this );
|
||||||
|
Reference in New Issue
Block a user