X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/48850fa74dee8ace36f70059f1938488c4196a97..bd996abe63a8ed6aa07b26856a0d7935002e3e81:/src/gtk1/region.cpp diff --git a/src/gtk1/region.cpp b/src/gtk1/region.cpp index 2159fea32e..11ca072cd3 100644 --- a/src/gtk1/region.cpp +++ b/src/gtk1/region.cpp @@ -20,12 +20,11 @@ // headers // ---------------------------------------------------------------------------- -#include "wx/region.h" +#include "wx/log.h" -#include -#include +#include "wx/region.h" -#include "wx/log.h" +#include "wx/gtk/private.h" // ---------------------------------------------------------------------------- // wxRegionRefData: private class containing the information about the region @@ -40,6 +39,7 @@ public: } wxRegionRefData(const wxRegionRefData& refData) + : wxObjectRefData() { #ifdef __WXGTK20__ m_region = gdk_region_copy(refData.m_region); @@ -67,8 +67,8 @@ public: #define M_REGIONDATA ((wxRegionRefData *)m_refData) #define M_REGIONDATA_OF(rgn) ((wxRegionRefData *)(rgn.m_refData)) -IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject); -IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject); +IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject) +IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator,wxObject) // ---------------------------------------------------------------------------- // wxRegion construction @@ -87,7 +87,7 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h) m_refData = new wxRegionRefData(); #ifdef __WXGTK20__ - M_REGIONDATA->m_region = gdk_region_rectangle( rect ); + M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); #else GdkRegion *reg = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect ); @@ -133,22 +133,22 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const { return new wxRegionRefData(*(wxRegionRefData *)data); } + // ---------------------------------------------------------------------------- // wxRegion comparison // ---------------------------------------------------------------------------- bool wxRegion::operator==( const wxRegion& region ) { + if (m_refData == region.m_refData) return TRUE; + + if (!m_refData || !region.m_refData) return FALSE; + // compare the regions themselves, not the pointers to ref data! return gdk_region_equal(M_REGIONDATA->m_region, M_REGIONDATA_OF(region)->m_region); } -bool wxRegion::operator != ( const wxRegion& region ) -{ - return !(*this == region); -} - // ---------------------------------------------------------------------------- // wxRegion operations // ---------------------------------------------------------------------------- @@ -170,7 +170,7 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height ) { m_refData = new wxRegionRefData(); #ifdef __WXGTK20__ - M_REGIONDATA->m_region = gdk_region_rectangle( rect ); + M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); #else GdkRegion *reg = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect ); @@ -471,36 +471,36 @@ struct _XRegion { class wxRIRefData: public wxObjectRefData { public: + wxRIRefData() { Init(); } + virtual ~wxRIRefData(); + + void CreateRects( const wxRegion& r ); - wxRIRefData() : m_rects(0), m_numRects(0){} - ~wxRIRefData(); + void Init() { m_rects = NULL; m_numRects = 0; } wxRect *m_rects; size_t m_numRects; - - void CreateRects( const wxRegion& r ); }; wxRIRefData::~wxRIRefData() { - delete m_rects; + delete [] m_rects; } void wxRIRefData::CreateRects( const wxRegion& region ) { - if (m_rects) - delete m_rects; + delete [] m_rects; - m_rects = 0; - m_numRects = 0; + Init(); GdkRegion *gdkregion = region.GetRegion(); - if (!gdkregion) return; + if (!gdkregion) + return; #ifdef __WXGTK20__ - GdkRectangles *gdkrects = NULL; + GdkRectangle *gdkrects = NULL; gint numRects = 0; - gdk_region_get_rectangles( gdkregion, &gdkrect, &numRects ); + gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects ); m_numRects = numRects; if (numRects) @@ -516,8 +516,8 @@ void wxRIRefData::CreateRects( const wxRegion& region ) wr.height = gr.height; } } - g_delete( gdkrects ); // delete [] -#else + g_free( gdkrects ); +#else // GTK+ 1.x Region r = ((GdkRegionPrivate *)gdkregion)->xregion; if (r) { @@ -536,7 +536,7 @@ void wxRIRefData::CreateRects( const wxRegion& region ) } } } -#endif +#endif // GTK+ 2.0/1.x } wxRegionIterator::wxRegionIterator()