From fa5593acee9def0bb7e3552dc17cdbe9809518d2 Mon Sep 17 00:00:00 2001 From: David Webster Date: Wed, 22 Nov 2000 06:07:25 +0000 Subject: [PATCH] Update OS/2 Frame WM_PAINT processing git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8770 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/os2/dc.cpp | 85 ++++++++++++++++++++++++++++++++++------------- src/os2/frame.cpp | 3 ++ 2 files changed, 65 insertions(+), 23 deletions(-) diff --git a/src/os2/dc.cpp b/src/os2/dc.cpp index 47ef5b4fc2..134f3f66a9 100644 --- a/src/os2/dc.cpp +++ b/src/os2/dc.cpp @@ -204,34 +204,73 @@ void wxDC::SelectOldObjects(WXHDC dc) // clipping // --------------------------------------------------------------------------- -#define DO_SET_CLIPPING_BOX() \ -{ \ - RECT rect; \ - \ - GetClipBox(GetHdc(), &rect); \ - \ - m_clipX1 = (wxCoord) XDEV2LOG(rect.left); \ - m_clipY1 = (wxCoord) YDEV2LOG(rect.top); \ - m_clipX2 = (wxCoord) XDEV2LOG(rect.right); \ - m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \ -} - -void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y - ,wxCoord width, wxCoord height - ) +#define DO_SET_CLIPPING_BOX() \ +{ \ + RECTL rect; \ + \ + ::GpiQueryClipBox(m_hPS, &rect); \ + \ + m_clipX1 = (wxCoord) XDEV2LOG(rect.xLeft); \ + m_clipY1 = (wxCoord) YDEV2LOG(rect.yTop); \ + m_clipX2 = (wxCoord) XDEV2LOG(rect.xRight); \ + m_clipY2 = (wxCoord) YDEV2LOG(rect.yBottom); \ +} + +void wxDC::DoSetClippingRegion( + wxCoord x +, wxCoord y +, wxCoord width +, wxCoord height +) { - // TODO -} + RECTL vRect; + + m_clipping = TRUE; + vRect.xLeft = XLOG2DEV(x); + vRect.yTop = YLOG2DEV(y + height); + vRect.xRight = XLOG2DEV(x + width); + vRect.yBottom = YLOG2DEV(y); + ::GpiIntersectClipRectangle(m_hPS, &vRect); + DO_SET_CLIPPING_BOX() +} // end of wxDC::DoSetClippingRegion -void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) +void wxDC::DoSetClippingRegionAsRegion( + const wxRegion& rRegion +) { - // TODO -} + wxCHECK_RET(rRegion.GetHRGN(), wxT("invalid clipping region")); + HRGN hRgnOld; + + m_clipping = TRUE; + ::GpiSetClipRegion( m_hPS + ,(HRGN)rRegion.GetHRGN() + ,&hRgnOld + ); + DO_SET_CLIPPING_BOX() +} // end of wxDC::DoSetClippingRegionAsRegion void wxDC::DestroyClippingRegion(void) { - // TODO: -}; + if (m_clipping && m_hPS) + { + HRGN hRgnOld; + RECTL vRect; + + // TODO: this should restore the previous clipped region + // so that OnPaint processing works correctly, and + // the update doesn't get destroyed after the first + // DestroyClippingRegion + vRect.xLeft = XLOG2DEV(0); + vRect.yTop = YLOG2DEV(32000); + vRect.xRight = XLOG2DEV(32000); + vRect.yBottom = YLOG2DEV(0); + + HRGN hRgn = ::GpiCreateRegion(m_hPS, 1, &vRect); + + ::GpiSetClipRegion(m_hPS, hRgn, &hRgnOld); + } + m_clipping = FALSE; +} // end of wxDC::DestroyClippingRegion // --------------------------------------------------------------------------- // query capabilities @@ -300,7 +339,7 @@ bool wxDC::DoGetPixel( vPoint.x = vX; vPoint.y = vY; lColor = ::GpiSetPel(m_hPS, &vPoint); - *pCol = lColor; + pCol->Set((unsigned long)lColor); if(lColor>= 0) return(TRUE); else diff --git a/src/os2/frame.cpp b/src/os2/frame.cpp index ff03611069..4c0870f577 100644 --- a/src/os2/frame.cpp +++ b/src/os2/frame.cpp @@ -1601,12 +1601,15 @@ MRESULT wxFrame::OS2WindowProc( { HPS hPS; RECTL vRect; + wxPaintEvent vEvent; hPS = WinBeginPaint(m_hWnd, 0L, &vRect); ::WinFillRect(hPS, &vRect, CLR_BLUE /* SYSCLR_WINDOW */); ::WinEndPaint(hPS); mRc = (MRESULT)FALSE; + vEvent.SetEventObject(this); + GetEventHandler()->ProcessEvent(vEvent); bProcessed = TRUE; } break; -- 2.45.2