From b8c0528db3989dcfbc32e034f4a3e059021f28e7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sat, 13 Oct 2001 22:49:57 +0000 Subject: [PATCH 1/1] better windows painting in wxMGL git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11976 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mgl/dc.cpp | 19 ++++++------------- src/mgl/dcclient.cpp | 21 +++++++++++---------- src/mgl/toplevel.cpp | 5 ++++- src/mgl/utils.cpp | 8 ++++---- src/mgl/window.cpp | 6 ++++++ 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp index 551f542019..203e37aa77 100644 --- a/src/mgl/dc.cpp +++ b/src/mgl/dc.cpp @@ -182,16 +182,9 @@ void wxDC::SetMGLDC(MGLDevCtx *mgldc, bool OwnsMGLDC) m_MGLDC = mgldc; m_OwnsMGLDC = OwnsMGLDC; m_ok = TRUE; - - if ( mgldc->getDC()->a.clipRegion ) - { - MGLRegion clip; - mgldc->getClipRegion(clip); - m_globalClippingRegion = wxRegion(clip); - // FIXME_MGL -- reuse wxWindows::m_updateRegion ? - m_currentClippingRegion = m_globalClippingRegion; - m_clipping = TRUE; - } + + if ( !m_globalClippingRegion.IsNull() ) + SetClippingRegion(m_globalClippingRegion); InitializeMGLDC(); } @@ -288,7 +281,7 @@ void wxDC::DestroyClippingRegion() } 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_currentClippingRegion.Clear(); } @@ -1370,8 +1363,8 @@ wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const void wxDC::DoGetSize(int *w, int *h) const { - if (w) *w = m_MGLDC->sizex(); - if (h) *h = m_MGLDC->sizey(); + if (w) *w = m_MGLDC->sizex()+1; + if (h) *h = m_MGLDC->sizey()+1; } void wxDC::DoGetSizeMM(int *width, int *height) const diff --git a/src/mgl/dcclient.cpp b/src/mgl/dcclient.cpp index 8edae04c3b..54ade252ff 100644 --- a/src/mgl/dcclient.cpp +++ b/src/mgl/dcclient.cpp @@ -35,12 +35,20 @@ wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win) if ( dc ) { m_inPaintHandler = TRUE; + + m_globalClippingRegion = win->GetUpdateRegion(); SetMGLDC(dc, FALSE); } else { 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 // but it won't destroy MGLDC returned by MGL_wmBeginPaint because // ~MGLDevCtx() doesn't call destroy() @@ -49,14 +57,7 @@ wxWindowDC::wxWindowDC(wxWindow *win) : m_wnd(win) wxWindowDC::~wxWindowDC() { - 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 + if ( !m_inPaintHandler ) { GetMGLDC()->setDC(NULL); MGL_wmEndPaint(m_wnd->GetHandle()); @@ -66,6 +67,6 @@ wxWindowDC::~wxWindowDC() wxClientDC::wxClientDC(wxWindow *win) : wxWindowDC(win) { wxRect r = m_wnd->GetClientRect(); - SetClippingRegion(r); + m_globalClippingRegion.Intersect(r); SetDeviceOrigin(r.x, r.y); } diff --git a/src/mgl/toplevel.cpp b/src/mgl/toplevel.cpp index 595b1a828b..3f2bbcd209 100644 --- a/src/mgl/toplevel.cpp +++ b/src/mgl/toplevel.cpp @@ -77,7 +77,10 @@ bool wxTopLevelWindowMGL::Create(wxWindow *parent, 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); diff --git a/src/mgl/utils.cpp b/src/mgl/utils.cpp index 3017bbf4f3..e3c3c53606 100644 --- a/src/mgl/utils.cpp +++ b/src/mgl/utils.cpp @@ -43,17 +43,17 @@ void wxBell() void wxDisplaySize(int *width, int *height) { wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") ); - if (width) *width = g_displayDC->sizex(); - if (height) *height = g_displayDC->sizey(); + if (width) *width = g_displayDC->sizex()+1; + if (height) *height = g_displayDC->sizey()+1; } void wxDisplaySizeMM(int *width, int *height) { wxASSERT_MSG( g_displayDC, wxT("MGL display DC not created yet.") ); if ( width ) - *width = g_displayDC->sizex() * 25/72; + *width = (g_displayDC->sizex()+1) * 25/72; if ( height ) - *height = g_displayDC->sizey() * 25/72; + *height = (g_displayDC->sizey()+1) * 25/72; // FIXME_MGL -- what about returning *real* monitor dimensions? } diff --git a/src/mgl/window.cpp b/src/mgl/window.cpp index 55dfa75291..d03dfa66bd 100644 --- a/src/mgl/window.cpp +++ b/src/mgl/window.cpp @@ -1098,6 +1098,12 @@ void wxWindowMGL::HandlePaint(MGLDevCtx *dc) return; } +#if 0 // FIXME_MGL -- debugging stuff! + dc->setColorRGB(255,0,255); + dc->fillRect(-1000,-1000,2000,2000); + wxUsleep(100); +#endif + MGLRegion clip; dc->getClipRegion(clip); m_updateRegion = wxRegion(clip); -- 2.45.2