better windows painting in wxMGL
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -182,16 +182,9 @@ void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC)
|
|||||||
m_MGLDC = mgldc;
|
m_MGLDC = mgldc;
|
||||||
m_OwnsMGLDC = OwnsMGLDC;
|
m_OwnsMGLDC = OwnsMGLDC;
|
||||||
m_ok = TRUE;
|
m_ok = TRUE;
|
||||||
|
|
||||||
if ( mgldc->getDC()->a.clipRegion )
|
if ( !m_globalClippingRegion.IsNull() )
|
||||||
{
|
SetClippingRegion(m_globalClippingRegion);
|
||||||
MGLRegion clip;
|
|
||||||
mgldc->getClipRegion(clip);
|
|
||||||
m_globalClippingRegion = wxRegion(clip);
|
|
||||||
// FIXME_MGL -- reuse wxWindows::m_updateRegion ?
|
|
||||||
m_currentClippingRegion = m_globalClippingRegion;
|
|
||||||
m_clipping = TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
InitializeMGLDC();
|
InitializeMGLDC();
|
||||||
}
|
}
|
||||||
@@ -288,7 +281,7 @@ void wxDC::DestroyClippingRegion()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_MGLDC->setClipRect(MGLRect(0, 0, m_MGLDC->sizex(), m_MGLDC->sizey()));
|
m_MGLDC->setClipRect(MGLRect(0, 0, m_MGLDC->sizex()+1, m_MGLDC->sizey()+1));
|
||||||
m_clipping = FALSE;
|
m_clipping = FALSE;
|
||||||
m_currentClippingRegion.Clear();
|
m_currentClippingRegion.Clear();
|
||||||
}
|
}
|
||||||
@@ -1370,8 +1363,8 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
|
|||||||
|
|
||||||
void wxDC::DoGetSize(int *w, int *h) const
|
void wxDC::DoGetSize(int *w, int *h) const
|
||||||
{
|
{
|
||||||
if (w) *w = m_MGLDC->sizex();
|
if (w) *w = m_MGLDC->sizex()+1;
|
||||||
if (h) *h = m_MGLDC->sizey();
|
if (h) *h = m_MGLDC->sizey()+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDC::DoGetSizeMM(int *width, int *height) const
|
void wxDC::DoGetSizeMM(int *width, int *height) const
|
||||||
|
@@ -35,12 +35,20 @@ wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
|
|||||||
if ( dc )
|
if ( dc )
|
||||||
{
|
{
|
||||||
m_inPaintHandler = TRUE;
|
m_inPaintHandler = TRUE;
|
||||||
|
|
||||||
|
m_globalClippingRegion = win->GetUpdateRegion();
|
||||||
SetMGLDC(dc, FALSE);
|
SetMGLDC(dc, FALSE);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_inPaintHandler = FALSE;
|
m_inPaintHandler = FALSE;
|
||||||
SetMGLDC(new MGLDevCtx(MGL_wmBeginPaint(m_wnd->GetHandle())), TRUE);
|
|
||||||
|
dc = new MGLDevCtx(MGL_wmBeginPaint(win->GetHandle()));
|
||||||
|
|
||||||
|
MGLRegion clip;
|
||||||
|
dc->getClipRegion(clip);
|
||||||
|
m_globalClippingRegion = wxRegion(clip);
|
||||||
|
SetMGLDC(dc, TRUE);
|
||||||
// TRUE means that dtor will delete MGLDevCtx object
|
// TRUE means that dtor will delete MGLDevCtx object
|
||||||
// but it won't destroy MGLDC returned by MGL_wmBeginPaint because
|
// but it won't destroy MGLDC returned by MGL_wmBeginPaint because
|
||||||
// ~MGLDevCtx() doesn't call destroy()
|
// ~MGLDevCtx() doesn't call destroy()
|
||||||
@@ -49,14 +57,7 @@ wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win)
|
|||||||
|
|
||||||
wxWindowDC::~wxWindowDC()
|
wxWindowDC::~wxWindowDC()
|
||||||
{
|
{
|
||||||
if ( m_inPaintHandler )
|
if ( !m_inPaintHandler )
|
||||||
{
|
|
||||||
// This is neccessary so that subsequently created wxPaintDCs won't get
|
|
||||||
// confused about clipping. Another reason is that the same MGL dc is reused
|
|
||||||
// for wxEraseEvent, wxNcPaintEvent and wxPaintEvent
|
|
||||||
DestroyClippingRegion();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
GetMGLDC()->setDC(NULL);
|
GetMGLDC()->setDC(NULL);
|
||||||
MGL_wmEndPaint(m_wnd->GetHandle());
|
MGL_wmEndPaint(m_wnd->GetHandle());
|
||||||
@@ -66,6 +67,6 @@ wxWindowDC::~wxWindowDC()
|
|||||||
wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
|
wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win)
|
||||||
{
|
{
|
||||||
wxRect r = m_wnd->GetClientRect();
|
wxRect r = m_wnd->GetClientRect();
|
||||||
SetClippingRegion(r);
|
m_globalClippingRegion.Intersect(r);
|
||||||
SetDeviceOrigin(r.x, r.y);
|
SetDeviceOrigin(r.x, r.y);
|
||||||
}
|
}
|
||||||
|
@@ -77,7 +77,10 @@ bool wxTopLevelWindowMGL::Create(wxWindow *parent,
|
|||||||
size.y = sizeDpy.y / 5;
|
size.y = sizeDpy.y / 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::Create(parent, id, pos, sizeOrig, style, name);
|
wxWindow::Create(NULL, id, pos, sizeOrig, style, name);
|
||||||
|
SetParent(parent);
|
||||||
|
if ( parent )
|
||||||
|
parent->AddChild(this);
|
||||||
|
|
||||||
wxTopLevelWindows.Append(this);
|
wxTopLevelWindows.Append(this);
|
||||||
|
|
||||||
|
@@ -43,17 +43,17 @@ void wxBell()
|
|||||||
void wxDisplaySize(int *width, int *height)
|
void wxDisplaySize(int *width, int *height)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") );
|
wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") );
|
||||||
if (width) *width = g_displayDC->sizex();
|
if (width) *width = g_displayDC->sizex()+1;
|
||||||
if (height) *height = g_displayDC->sizey();
|
if (height) *height = g_displayDC->sizey()+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxDisplaySizeMM(int *width, int *height)
|
void wxDisplaySizeMM(int *width, int *height)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") );
|
wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") );
|
||||||
if ( width )
|
if ( width )
|
||||||
*width = g_displayDC->sizex() * 25/72;
|
*width = (g_displayDC->sizex()+1) * 25/72;
|
||||||
if ( height )
|
if ( height )
|
||||||
*height = g_displayDC->sizey() * 25/72;
|
*height = (g_displayDC->sizey()+1) * 25/72;
|
||||||
// FIXME_MGL -- what about returning *real* monitor dimensions?
|
// FIXME_MGL -- what about returning *real* monitor dimensions?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1098,6 +1098,12 @@ void wxWindowMGL::HandlePaint(MGLDevCtx *dc)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 // FIXME_MGL -- debugging stuff!
|
||||||
|
dc->setColorRGB(255,0,255);
|
||||||
|
dc->fillRect(-1000,-1000,2000,2000);
|
||||||
|
wxUsleep(100);
|
||||||
|
#endif
|
||||||
|
|
||||||
MGLRegion clip;
|
MGLRegion clip;
|
||||||
dc->getClipRegion(clip);
|
dc->getClipRegion(clip);
|
||||||
m_updateRegion = wxRegion(clip);
|
m_updateRegion = wxRegion(clip);
|
||||||
|
Reference in New Issue
Block a user