deprecate wxDC::SetClippingRegion(wxRegion) overload and replace it with SetDeviceClippingRegion() to avoid confusion due to use of different kind of coordinates in this and other overloads of the same function; also rename wxDCImpl::DoSetClippingRegionAsRegion() to DoSetDeviceClippingRegion(); finally use bounding box of the region passed to wxDCClipper ctor to avoid interpreting coordinates differently for different ctors of the same class (see #8970)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54024 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2008-06-08 01:45:56 +00:00
parent c39d2e0a38
commit fdaad94e75
30 changed files with 89 additions and 59 deletions

View File

@ -218,6 +218,13 @@ Deprecated methods and their replacements
- EVT_CALENDAR_MONTH and EVT_CALENDAR_YEAR events are deprecated,
use EVT_CALENDAR_PAGE_CHANGED which replaces both of them.
- wxCalendarCtrl::EnableYearChange() and wxCAL_NO_YEAR_CHANGE are deprecated.
There is no replacement for this functionality, it is being dropped as it is
not available in native wxCalendarCtrl implementations.
- wxDC::SetClippingRegion(const wxRegion&) overload is deprecated as it used
different convention from the other SetClippingRegion() overloads: wxRegion
passed to it was interpreted in physical, not logical, coordinates. Replace
it with SetDeviceClippingRegion() if this was the correct thing to do in your
code.

View File

@ -158,7 +158,7 @@ protected:
// this is gnarly - we can't even call this function DoSetClippingRegion()
// because of virtual function hiding
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);

View File

@ -316,7 +316,9 @@ public:
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height) = 0;
virtual void DoSetClippingRegionAsRegion(const wxRegion& region) = 0;
// NB: this function works with device coordinates, not the logical ones!
virtual void DoSetDeviceClippingRegion(const wxRegion& region) = 0;
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
wxCoord *w, wxCoord *h) const
@ -796,8 +798,21 @@ public:
{ m_pimpl->DoSetClippingRegion(pt.x, pt.y, sz.x, sz.y); }
void SetClippingRegion(const wxRect& rect)
{ m_pimpl->DoSetClippingRegion(rect.x, rect.y, rect.width, rect.height); }
void SetClippingRegion(const wxRegion& region)
{ m_pimpl->DoSetClippingRegionAsRegion(region); }
// unlike the functions above, the coordinates of the region used in this
// one are in device coordinates, not the logical ones
void SetDeviceClippingRegion(const wxRegion& region)
{ m_pimpl->DoSetDeviceClippingRegion(region); }
// this function is deprecated because its name is confusing: you may
// expect it to work with logical coordinates but, in fact, it does exactly
// the same thing as SetDeviceClippingRegion()
//
// please review the code using it and either replace it with calls to
// SetDeviceClippingRegion() or correct it if it was [wrongly] passing
// logical coordinates to this function
wxDEPRECATED_INLINE(void SetClippingRegion(const wxRegion& region),
SetDeviceClippingRegion(region); )
void DestroyClippingRegion()
{ m_pimpl->DestroyClippingRegion(); }
@ -1212,7 +1227,7 @@ class WXDLLIMPEXP_CORE wxDCClipper
{
public:
wxDCClipper(wxDC& dc, const wxRegion& r) : m_dc(dc)
{ dc.SetClippingRegion(r); }
{ dc.SetClippingRegion(r.GetBox()); }
wxDCClipper(wxDC& dc, const wxRect& r) : m_dc(dc)
{ dc.SetClippingRegion(r.x, r.y, r.width, r.height); }
wxDCClipper(wxDC& dc, wxCoord x, wxCoord y, wxCoord w, wxCoord h) : m_dc(dc)

View File

@ -168,7 +168,7 @@ public:
wxCoord xoffset, wxCoord yoffset,
int fillStyle);
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);

View File

@ -246,7 +246,7 @@ protected:
Mirror(n, points);
}
virtual void DoSetClippingRegionAsRegion(const wxRegion& WXUNUSED(region))
virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region))
{
wxFAIL_MSG( _T("not implemented") );
}

View File

@ -166,9 +166,9 @@ private:
wxCoord *externalLeading = NULL,
const wxFont *font = NULL) const;
virtual void DoSetClippingRegionAsRegion(const wxRegion& WXUNUSED(region))
virtual void DoSetDeviceClippingRegion(const wxRegion& WXUNUSED(region))
{
wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion not yet implemented"));
wxFAIL_MSG(wxT("wxSVGFILEDC::DoSetDeviceClippingRegion not yet implemented"));
}
virtual void DoSetClippingRegion( int WXUNUSED(x), int WXUNUSED(y), int WXUNUSED(width), int WXUNUSED(height) )

View File

@ -124,11 +124,9 @@ protected:
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
// this is gnarly - we can't even call this function DoSetClippingRegion()
// because of virtual function hiding
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetSizeMM(int* width, int* height) const;

View File

@ -119,7 +119,10 @@ protected:
void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip)) { }
void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip))
{
wxFAIL_MSG( "not implemented" );
}
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,

View File

@ -71,7 +71,7 @@ public:
const wxFont *theFont = (wxFont *) NULL) const;
virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
virtual void DoSetClippingRegionAsRegion( const wxRegion &region );
virtual void DoSetDeviceClippingRegion( const wxRegion &region );
virtual wxCoord GetCharWidth() const;
virtual wxCoord GetCharHeight() const;

View File

@ -274,7 +274,10 @@ protected:
void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip) )
{
wxFAIL_MSG( "not implemented" );
}
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = (wxCoord *) NULL,
wxCoord *externalLeading = (wxCoord *) NULL,

View File

@ -281,7 +281,10 @@ protected:
void DoDrawText(const wxString& text, wxCoord x, wxCoord y );
void DoDrawRotatedText(const wxString& text, wxCoord x, wxCoord y, double angle);
void DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
void DoSetClippingRegionAsRegion( const wxRegion &WXUNUSED(clip) ) { }
void DoSetDeviceClippingRegion( const wxRegion &WXUNUSED(clip) )
{
wxFAIL_MSG( "not implemented" );
}
void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
wxCoord *descent = (wxCoord *) NULL,
wxCoord *externalLeading = (wxCoord *) NULL,

View File

@ -94,7 +94,7 @@ public:
virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
virtual void DestroyClippingRegion();
virtual void DoSetClippingRegionAsRegion( const wxRegion &region );
virtual void DoSetDeviceClippingRegion( const wxRegion &region );
// Resolution in pixels per logical inch
virtual wxSize GetPPI() const;

View File

@ -140,11 +140,9 @@ protected:
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
// this is gnarly - we can't even call this function DoSetClippingRegion()
// because of virtual function hiding
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetSizeMM(int* width, int* height) const;

View File

@ -117,9 +117,9 @@ protected:
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset);

View File

@ -225,11 +225,9 @@ public:
int rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
// this is gnarly - we can't even call this function DoSetClippingRegion()
// because of virtual function hiding
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
wxCoord *w, wxCoord *h) const;
@ -265,7 +263,7 @@ protected:
// common part of DoDrawText() and DoDrawRotatedText()
void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
// common part of DoSetClippingRegion() and DoSetDeviceClippingRegion()
void SetClippingHrgn(WXHRGN hrgn);
// implementation of DoGetSize() for wxScreen/PrinterDC: this simply

View File

@ -321,12 +321,12 @@ public:
,wxCoord vYsrcMask = -1
);
virtual void DoSetClippingRegionAsRegion(const wxRegion& rRegion);
virtual void DoSetClippingRegion( wxCoord vX
,wxCoord vY
,wxCoord vWidth
,wxCoord vHeight
);
virtual void DoSetDeviceClippingRegion(const wxRegion& rRegion);
virtual void DoGetSize( int* pWidth
,int* pHeight

View File

@ -225,11 +225,9 @@ public:
int rop = wxCOPY, bool useMask = false,
wxCoord xsrcMask = wxDefaultCoord, wxCoord ysrcMask = wxDefaultCoord);
// this is gnarly - we can't even call this function DoSetClippingRegion()
// because of virtual function hiding
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoGetClippingBox(wxCoord *x, wxCoord *y,
wxCoord *w, wxCoord *h) const;
@ -265,9 +263,6 @@ protected:
// common part of DoDrawText() and DoDrawRotatedText()
void DrawAnyText(const wxString& text, wxCoord x, wxCoord y);
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
void SetClippingHrgn(WXHRGN hrgn);
// implementation of DoGetSize() for wxScreen/PrinterDC: this simply
// returns the size of the entire device this DC is associated with
//

View File

@ -71,9 +71,9 @@ protected:
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = false, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoSetDeviceClippingRegion(const wxRegion& region);
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset);

View File

@ -869,9 +869,16 @@ public:
wxCoord height);
void SetClippingRegion(const wxPoint& pt, const wxSize& sz);
void SetClippingRegion(const wxRect& rect);
void SetClippingRegion(const wxRegion& region);
//@}
/**
Sets the clipping region for this device context.
Unlike SetClippingRegion(), this function works with physical
coordinates and not with the logical ones.
*/
void SetDeviceClippingRegion(const wxRegion& region);
/**
Sets the device origin (i.e., the origin in pixels after scaling has
been applied). This function may be useful in Windows printing

View File

@ -237,10 +237,10 @@ void wxGCDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h
}
}
void wxGCDCImpl::DoSetClippingRegionAsRegion( const wxRegion &region )
void wxGCDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
{
// region is in device coordinates
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetClippingRegionAsRegion - invalid DC") );
wxCHECK_RET( IsOk(), wxT("wxGCDC(cg)::DoSetDeviceClippingRegion - invalid DC") );
if (region.Empty())
{

View File

@ -65,7 +65,7 @@ wxBitmap wxRegionBase::ConvertToBitmap() const
dc.SelectObject(bmp);
dc.SetBackground(*wxBLACK_BRUSH);
dc.Clear();
dc.SetClippingRegion(*wx_static_cast(const wxRegion *, this));
dc.SetDeviceClippingRegion(*wx_static_cast(const wxRegion *, this));
dc.SetBackground(*wxWHITE_BRUSH);
dc.Clear();
dc.SelectObject(wxNullBitmap);

View File

@ -95,10 +95,19 @@ void wxDFBDCImpl::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoor
m_clipping = true;
}
void wxDFBDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
void wxDFBDCImpl::DoSetDeviceClippingRegion(const wxRegion& region)
{
// NB: this can be done because wxDFB only supports rectangular regions
GetOwner()->SetClippingRegion(region.AsRect());
wxRect rect = region.AsRect();
// our parameter is in physical coordinates while DoSetClippingRegion()
// takes logical ones
rect.x = XDEV2LOG(rect.x);
rect.y = YDEV2LOG(rect.y);
rect.width = XDEV2LOG(rect.width);
rect.height = YDEV2LOG(rect.height);
DoSetClippingRegion(rect);
}
void wxDFBDCImpl::DestroyClippingRegion()

View File

@ -2115,7 +2115,7 @@ void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, w
gdk_gc_set_clip_region(m_bgGC, gdkRegion);
}
void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion &region )
void wxWindowDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );

View File

@ -2021,7 +2021,7 @@ void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, w
gdk_gc_set_clip_region( m_bgGC, m_currentClippingRegion.GetRegion() );
}
void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion &region )
void wxWindowDCImpl::DoSetDeviceClippingRegion( const wxRegion &region )
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );

View File

@ -220,7 +220,7 @@ void wxDC::DoSetClippingRegion(wxCoord cx, wxCoord cy, wxCoord cw, wxCoord ch)
DO_SET_CLIPPING_BOX(m_currentClippingRegion)
}
void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
void wxDC::DoSetDeviceClippingRegion(const wxRegion& region)
{
wxCHECK_RET( Ok(), wxT("invalid dc") );

View File

@ -2099,7 +2099,7 @@ void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y,
}
}
void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion& region )
void wxWindowDCImpl::DoSetDeviceClippingRegion( const wxRegion& region )
{
SetDCClipping(region.GetX11Region());
@ -2110,10 +2110,10 @@ void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion& region )
wxRect box = region.GetBox();
XRectangle rects[1];
rects[0].x = (short)XLOG2DEV_2(box.x);
rects[0].y = (short)YLOG2DEV_2(box.y);
rects[0].width = (unsigned short)XLOG2DEVREL(box.width);
rects[0].height = (unsigned short)YLOG2DEVREL(box.height);
rects[0].x = (short)box.x;
rects[0].y = (short)box.y;
rects[0].width = (unsigned short)box.width;
rects[0].height = (unsigned short)box.height;
XSetClipRectangles((Display*) m_display, (GC) m_gcBacking,
0, 0, rects, 1, Unsorted);
}

View File

@ -525,7 +525,7 @@ wxMSWDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) co
wxDCImpl::DoGetClippingBox(x, y, w, h);
}
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
// common part of DoSetClippingRegion() and DoSetDeviceClippingRegion()
void wxMSWDCImpl::SetClippingHrgn(WXHRGN hrgn)
{
wxCHECK_RET( hrgn, wxT("invalid clipping region") );
@ -593,7 +593,7 @@ void wxMSWDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h
}
}
void wxMSWDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
void wxMSWDCImpl::DoSetDeviceClippingRegion(const wxRegion& region)
{
SetClippingHrgn(region.GetHRGN());
}

View File

@ -444,7 +444,7 @@ void wxPMDCImpl::DoSetClippingRegion(
DO_SET_CLIPPING_BOX()
} // end of wxPMDCImpl::DoSetClippingRegion
void wxPMDCImpl::DoSetClippingRegionAsRegion(
void wxPMDCImpl::DoSetDeviceClippingRegion(
const wxRegion& rRegion
)
{
@ -457,7 +457,7 @@ void wxPMDCImpl::DoSetClippingRegionAsRegion(
,&hRgnOld
);
DO_SET_CLIPPING_BOX()
} // end of wxPMDCImpl::DoSetClippingRegionAsRegion
} // end of wxPMDCImpl::DoSetDeviceClippingRegion
void wxPMDCImpl::DestroyClippingRegion(void)
{

View File

@ -197,17 +197,11 @@ wxPalmDCImpl::DoGetClippingBox(wxCoord *x, wxCoord *y, wxCoord *w, wxCoord *h) c
{
}
// common part of DoSetClippingRegion() and DoSetClippingRegionAsRegion()
void wxPalmDCImpl::SetClippingHrgn(WXHRGN hrgn)
{
wxCHECK_RET( hrgn, wxT("invalid clipping region") );
}
void wxPalmDCImpl::DoSetClippingRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
}
void wxPalmDCImpl::DoSetClippingRegionAsRegion(const wxRegion& region)
void wxPalmDCImpl::DoSetDeviceClippingRegion(const wxRegion& region)
{
}

View File

@ -2222,7 +2222,7 @@ void wxWindowDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, w
XSetRegion( (Display*) m_display, (GC) m_bgGC, (Region) m_currentClippingRegion.GetX11Region() );
}
void wxWindowDCImpl::DoSetClippingRegionAsRegion( const wxRegion& region )
void wxWindowDCImpl::DoSetDeviceClippingRegion( const wxRegion& region )
{
wxCHECK_RET( IsOk(), wxT("invalid window dc") );