From 2e76da5450f61bbd5d5aa926378ba8817641b378 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 5 May 2004 22:41:54 +0000 Subject: [PATCH] made GetClippingBox() work even for clipping region (pre)set by Windows and not only for clipping regions set using our own SetClippingXXX() functions git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27106 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/dc.h | 9 +++++++++ src/msw/dc.cpp | 19 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h index 280fba8333..8490f2b7d9 100644 --- a/include/wx/msw/dc.h +++ b/include/wx/msw/dc.h @@ -118,6 +118,13 @@ public: { m_hDC = dc; m_bOwnsDC = bOwnsDC; + + // we might have a pre existing clipping region, make sure that we + // return it if asked -- but avoid calling ::GetClipBox() right now as + // it could be unnecessary wasteful + m_clipping = true; + m_clipX1 = + m_clipX2 = 0; } const wxBitmap& GetSelectedBitmap() const { return m_selectedBitmap; } @@ -182,6 +189,8 @@ protected: { GetClippingBox(x, y, width, height); } + virtual void DoGetClippingBox(wxCoord *x, wxCoord *y, + wxCoord *w, wxCoord *h) const; virtual void DoGetSize(int *width, int *height) const; virtual void DoGetSizeMM(int* width, int* height) const; diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp index 5a72decc62..2139cee4cb 100644 --- a/src/msw/dc.cpp +++ b/src/msw/dc.cpp @@ -383,6 +383,23 @@ void wxDC::UpdateClipBox() m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); } +void +wxDC::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) const +{ + // check if we should try to retrieve the clipping region possibly not set + // by our SetClippingRegion() but preset by Windows:this can only happen + // when we're associated with an existing HDC usign SetHDC(), see there + if ( m_clipping && !m_clipX1 && !m_clipX2 ) + { + UpdateClipBox(); + + if ( !m_clipX1 && !m_clipX2 ) + m_clipping = false; + } + + return wxDCBase::DoGetClippingBox(x, y, w, h); +} + // common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion() void wxDC::SetClippingHrgn(WXHRGN hrgn) { @@ -465,7 +482,7 @@ void wxDC::DestroyClippingRegion() ::DeleteObject(rgn); } - m_clipping = false; + wxDCBase::DestroyClippingRegion(); } // --------------------------------------------------------------------------- -- 2.45.2