fixed (and slightly cleant up) wxGTK compilation

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16520 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2002-08-15 17:55:03 +00:00
parent 1e023926ec
commit 57f2b902bc
2 changed files with 78 additions and 44 deletions

View File

@@ -26,6 +26,26 @@
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#ifndef __WXGTK20__
// ----------------------------------------------------------------------------
// wxGdkRegion: creates a new region in ctor and destroys in dtor
// ----------------------------------------------------------------------------
class wxGdkRegion
{
public:
wxGdkRegion() { m_region = gdk_region_new(); }
~wxGdkRegion() { gdk_region_destroy(m_region); }
operator GdkRegion *() const { return m_region; }
private:
GdkRegion *m_region;
};
#endif // __WXGTK20__
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region // wxRegionRefData: private class containing the information about the region
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -37,20 +57,17 @@ public:
{ {
m_region = NULL; m_region = NULL;
} }
wxRegionRefData(const wxRegionRefData& refData) wxRegionRefData(const wxRegionRefData& refData)
: wxObjectRefData() : wxObjectRefData()
{ {
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_region = gdk_region_copy(refData.m_region); m_region = gdk_region_copy(refData.m_region);
#else #else
m_region = gdk_region_new(); m_region = gdk_regions_union(wxGdkRegion(), refData.m_region);
GdkRegion *regCopy = gdk_regions_union(m_region, refData.m_region);
gdk_region_destroy(m_region);
m_region = regCopy;
#endif #endif
} }
~wxRegionRefData() ~wxRegionRefData()
{ {
if (m_region) if (m_region)
@@ -83,22 +100,24 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
rect.y = y; rect.y = y;
rect.width = w; rect.width = w;
rect.height = h; rect.height = h;
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__ #ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else #else
GdkRegion *reg = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect );
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
gdk_region_destroy( reg );
#endif #endif
} }
wxRegion::wxRegion( GdkRegion *region ) wxRegion::wxRegion( GdkRegion *region )
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_copy( region ); M_REGIONDATA->m_region = gdk_region_copy( region );
#else
M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region);
#endif
} }
wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle )
@@ -149,7 +168,7 @@ bool wxRegion::operator==( const wxRegion& region )
if (m_refData == region.m_refData) return TRUE; if (m_refData == region.m_refData) return TRUE;
if (!m_refData || !region.m_refData) return FALSE; if (!m_refData || !region.m_refData) return FALSE;
// compare the regions themselves, not the pointers to ref data! // compare the regions themselves, not the pointers to ref data!
return gdk_region_equal(M_REGIONDATA->m_region, return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region); M_REGIONDATA_OF(region)->m_region);
@@ -171,16 +190,14 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y; rect.y = y;
rect.width = width; rect.width = width;
rect.height = height; rect.height = height;
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__ #ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else #else
GdkRegion *reg = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_union_with_rect(wxGdkRegion(), &rect);
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
gdk_region_destroy( reg );
#endif #endif
} }
else else
@@ -240,7 +257,7 @@ bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
bool wxRegion::Intersect( const wxRect& rect ) bool wxRegion::Intersect( const wxRect& rect )
{ {
wxRegion reg( rect ); wxRegion reg( rect );
return Intersect( reg ); return Intersect( reg );
} }
@@ -253,8 +270,8 @@ bool wxRegion::Intersect( const wxRegion& region )
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_new();
// leave here // leave here
return TRUE; return TRUE;
} }
else else
@@ -498,16 +515,16 @@ void wxRIRefData::CreateRects( const wxRegion& region )
delete [] m_rects; delete [] m_rects;
Init(); Init();
GdkRegion *gdkregion = region.GetRegion(); GdkRegion *gdkregion = region.GetRegion();
if (!gdkregion) if (!gdkregion)
return; return;
#ifdef __WXGTK20__ #ifdef __WXGTK20__
GdkRectangle *gdkrects = NULL; GdkRectangle *gdkrects = NULL;
gint numRects = 0; gint numRects = 0;
gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects ); gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );
m_numRects = numRects; m_numRects = numRects;
if (numRects) if (numRects)
{ {

View File

@@ -26,6 +26,26 @@
#include "wx/gtk/private.h" #include "wx/gtk/private.h"
#ifndef __WXGTK20__
// ----------------------------------------------------------------------------
// wxGdkRegion: creates a new region in ctor and destroys in dtor
// ----------------------------------------------------------------------------
class wxGdkRegion
{
public:
wxGdkRegion() { m_region = gdk_region_new(); }
~wxGdkRegion() { gdk_region_destroy(m_region); }
operator GdkRegion *() const { return m_region; }
private:
GdkRegion *m_region;
};
#endif // __WXGTK20__
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegionRefData: private class containing the information about the region // wxRegionRefData: private class containing the information about the region
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -37,20 +57,17 @@ public:
{ {
m_region = NULL; m_region = NULL;
} }
wxRegionRefData(const wxRegionRefData& refData) wxRegionRefData(const wxRegionRefData& refData)
: wxObjectRefData() : wxObjectRefData()
{ {
#ifdef __WXGTK20__ #ifdef __WXGTK20__
m_region = gdk_region_copy(refData.m_region); m_region = gdk_region_copy(refData.m_region);
#else #else
m_region = gdk_region_new(); m_region = gdk_regions_union(wxGdkRegion(), refData.m_region);
GdkRegion *regCopy = gdk_regions_union(m_region, refData.m_region);
gdk_region_destroy(m_region);
m_region = regCopy;
#endif #endif
} }
~wxRegionRefData() ~wxRegionRefData()
{ {
if (m_region) if (m_region)
@@ -83,22 +100,24 @@ void wxRegion::InitRect(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
rect.y = y; rect.y = y;
rect.width = w; rect.width = w;
rect.height = h; rect.height = h;
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__ #ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else #else
GdkRegion *reg = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_union_with_rect( wxGdkRegion(), &rect );
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
gdk_region_destroy( reg );
#endif #endif
} }
wxRegion::wxRegion( GdkRegion *region ) wxRegion::wxRegion( GdkRegion *region )
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_copy( region ); M_REGIONDATA->m_region = gdk_region_copy( region );
#else
M_REGIONDATA->m_region = gdk_regions_union(wxGdkRegion(), region);
#endif
} }
wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle ) wxRegion::wxRegion( size_t n, const wxPoint *points, int fillStyle )
@@ -149,7 +168,7 @@ bool wxRegion::operator==( const wxRegion& region )
if (m_refData == region.m_refData) return TRUE; if (m_refData == region.m_refData) return TRUE;
if (!m_refData || !region.m_refData) return FALSE; if (!m_refData || !region.m_refData) return FALSE;
// compare the regions themselves, not the pointers to ref data! // compare the regions themselves, not the pointers to ref data!
return gdk_region_equal(M_REGIONDATA->m_region, return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region); M_REGIONDATA_OF(region)->m_region);
@@ -171,16 +190,14 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y; rect.y = y;
rect.width = width; rect.width = width;
rect.height = height; rect.height = height;
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
#ifdef __WXGTK20__ #ifdef __WXGTK20__
M_REGIONDATA->m_region = gdk_region_rectangle( &rect ); M_REGIONDATA->m_region = gdk_region_rectangle( &rect );
#else #else
GdkRegion *reg = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_union_with_rect(wxGdkRegion(), &rect);
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
gdk_region_destroy( reg );
#endif #endif
} }
else else
@@ -240,7 +257,7 @@ bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
bool wxRegion::Intersect( const wxRect& rect ) bool wxRegion::Intersect( const wxRect& rect )
{ {
wxRegion reg( rect ); wxRegion reg( rect );
return Intersect( reg ); return Intersect( reg );
} }
@@ -253,8 +270,8 @@ bool wxRegion::Intersect( const wxRegion& region )
{ {
m_refData = new wxRegionRefData(); m_refData = new wxRegionRefData();
M_REGIONDATA->m_region = gdk_region_new(); M_REGIONDATA->m_region = gdk_region_new();
// leave here // leave here
return TRUE; return TRUE;
} }
else else
@@ -498,16 +515,16 @@ void wxRIRefData::CreateRects( const wxRegion& region )
delete [] m_rects; delete [] m_rects;
Init(); Init();
GdkRegion *gdkregion = region.GetRegion(); GdkRegion *gdkregion = region.GetRegion();
if (!gdkregion) if (!gdkregion)
return; return;
#ifdef __WXGTK20__ #ifdef __WXGTK20__
GdkRectangle *gdkrects = NULL; GdkRectangle *gdkrects = NULL;
gint numRects = 0; gint numRects = 0;
gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects ); gdk_region_get_rectangles( gdkregion, &gdkrects, &numRects );
m_numRects = numRects; m_numRects = numRects;
if (numRects) if (numRects)
{ {