GdkGC *m_bgGC;
GdkColormap *m_cmap;
bool m_isMemDC;
+ bool m_isScreenDC;
wxWindow *m_owner;
wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion;
virtual bool GetVisible() { return m_visible; }
virtual void SetVisible( bool visible ) { m_visible = visible; }
+ bool IsNull() const { return (m_refData == 0); }
+
protected:
bool m_visible; /* can a pointer to this object be safely taken?
* - only if created within FindOrCreate... */
enum wxRegionContain
{
- wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
+ wxOutRegion = 0,
+ wxPartRegion = 1,
+ wxInRegion = 2
};
// So far, for internal use only
-enum wxRegionOp {
-wxRGN_AND, // Creates the intersection of the two combined regions.
-wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
-wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
-wxRGN_OR, // Creates the union of two combined regions.
-wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
+enum wxRegionOp
+{
+ wxRGN_AND, // Creates the intersection of the two combined regions.
+ wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
+ wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
+ wxRGN_OR, // Creates the union of two combined regions.
+ wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
//-----------------------------------------------------------------------------
class wxRegion : public wxGDIObject
{
- DECLARE_DYNAMIC_CLASS(wxRegion);
-
- public:
-
+public:
wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h );
wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight );
wxRegion( const wxRect& rect );
wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const;
- public:
-
+public:
wxList *GetRectList() const;
GdkRegion *GetRegion() const;
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxRegion);
};
class wxRegionIterator: public wxObject
GdkGC *m_bgGC;
GdkColormap *m_cmap;
bool m_isMemDC;
+ bool m_isScreenDC;
wxWindow *m_owner;
wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion;
virtual bool GetVisible() { return m_visible; }
virtual void SetVisible( bool visible ) { m_visible = visible; }
+ bool IsNull() const { return (m_refData == 0); }
+
protected:
bool m_visible; /* can a pointer to this object be safely taken?
* - only if created within FindOrCreate... */
enum wxRegionContain
{
- wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
+ wxOutRegion = 0,
+ wxPartRegion = 1,
+ wxInRegion = 2
};
// So far, for internal use only
-enum wxRegionOp {
-wxRGN_AND, // Creates the intersection of the two combined regions.
-wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
-wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
-wxRGN_OR, // Creates the union of two combined regions.
-wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
+enum wxRegionOp
+{
+ wxRGN_AND, // Creates the intersection of the two combined regions.
+ wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
+ wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
+ wxRGN_OR, // Creates the union of two combined regions.
+ wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
//-----------------------------------------------------------------------------
class wxRegion : public wxGDIObject
{
- DECLARE_DYNAMIC_CLASS(wxRegion);
-
- public:
-
+public:
wxRegion( wxCoord x, wxCoord y, wxCoord w, wxCoord h );
wxRegion( const wxPoint& topLeft, const wxPoint& bottomRight );
wxRegion( const wxRect& rect );
wxRegionContain Contains(const wxPoint& pt) const;
wxRegionContain Contains(const wxRect& rect) const;
- public:
-
+public:
wxList *GetRectList() const;
GdkRegion *GetRegion() const;
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxRegion);
};
class wxRegionIterator: public wxObject
gs_bmpMask,
gs_bmpWithMask,
gs_bmp4,
+ gs_bmp4_mono,
gs_bmp36;
// ----------------------------------------------------------------------------
wxString path = pathList.FindValidPath("pat4.bmp");
if ( !path )
return FALSE;
+ /* 4 colour bitmap */
gs_bmp4.LoadFile(path, wxBITMAP_TYPE_BMP);
- wxMask* mask4 = new wxMask(gs_bmp4, *wxBLACK);
- gs_bmp4.SetMask(mask4);
+ /* turn into mono-bitmap */
+ gs_bmp4_mono.LoadFile(path, wxBITMAP_TYPE_BMP);
+ wxMask* mask4 = new wxMask(gs_bmp4_mono, *wxBLACK);
+ gs_bmp4_mono.SetMask(mask4);
path = pathList.FindValidPath("pat36.bmp");
if ( !path )
m_std_icon = wxTheApp->GetStdIcon(wxICON_INFORMATION);
}
-//draw a polygon and an overlapping rectangle
-//is transparent is 1, the fill pattern are made transparent
-//is transparent is 2, the fill pattern are made transparent but inversed
-//is transparent is 0 the text for and background color will be used to represent/map
-//the colors of the monochrome bitmap pixels to the fillpattern
+// Draw a polygon and an overlapping rectangle
+// If transparent is 1, the fill pattern is made transparent.
+// If transparent is 2, the fill pattern is made transparent but inversed
+// If is transparent is 0 the text for and background color will be used to represent/map
+// the colors of the monochrome bitmap pixels to the fillpattern
//
-//i miss_used the the menu items for setting so called back and fore ground color
-//just to show how the those colors do influence the fillpatterns
-//just play with those,
-//and with the code
-//variations are endless using other logical functions
+// I abused the the menu items for setting so called back and fore ground color
+// just to show how the those colors do influence the fillpatterns just play
+// with those, and with the code variations are endless using other logical
+// functions.
+
void MyCanvas::DrawTestPoly( int x, int y,wxDC &dc,int transparent )
{
- wxBrush* brush4 = new wxBrush(gs_bmp4);
+ wxBrush* brush4 = new wxBrush(gs_bmp4);
+ wxBrush* brush4_mono = new wxBrush(gs_bmp4_mono);
wxBrush* brush36 = new wxBrush(gs_bmp36);
wxPoint todraw[5];
{
case 0:
{
+ dc.SetLogicalFunction(wxCOPY);
+
dc.SetPen( wxPen( "black", 4, wxSOLID) );
dc.SetBrush( *brush4 );
- dc.SetTextForeground(*wxGREEN);
- dc.SetTextBackground(m_owner->m_colourForeground);
- dc.SetLogicalFunction(wxCOPY);
dc.DrawPolygon(5,todraw,0,0,wxWINDING_RULE);
- //don't understand hwo but the outline is also depending on logicalfunction
dc.SetPen( wxPen( "red", 4, wxSOLID) );
dc.SetBrush( *brush36 );
dc.SetTextForeground(*wxCYAN);
dc.SetTextBackground(m_owner->m_colourBackground);
- dc.SetLogicalFunction(wxCOPY);
dc.DrawRectangle( x+10, y+10, 200, 200 );
+
+ dc.SetPen( wxPen( "green", 4, wxSOLID) );
+ dc.SetBrush( *brush4_mono );
+ dc.SetTextForeground(*wxCYAN);
+ dc.SetTextBackground(m_owner->m_colourBackground);
+ dc.DrawRectangle( x+50, y+50, 200, 200 );
+
dc.SetBrush(wxNullBrush);
dc.SetPen(wxNullPen);
break;
}
delete brush4;
+ delete brush4_mono;
delete brush36;
}
}
}
-// dc.Clear();
+ dc.Clear();
if ( m_owner->m_textureBackground) {
dc.SetPen(*wxMEDIUM_GREY_PEN);
case Show_Polygons:
DrawTestPoly( 0, 100, dc, 0 );
+/*
DrawTestPoly( 33, 500, dc, 1 );
DrawTestPoly( 43, 1000, dc, 2 );
+*/
break;
case Show_Mask:
if (y+lineSpacing-6 >= clientHeight) // -6 for earlier "line breaking"
{
m_currentVisibleLines = 0;
- y = 5;
+ y = 2;
x += maxWidth+6;
entireWidth += maxWidth+6;
maxWidth = 0;
{
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_colour = *wxBLACK;
+
M_BRUSHDATA->m_stipple = stippleBitmap;
+
if (M_BRUSHDATA->m_stipple.GetMask())
- {
- M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
- }
- else
- {
- M_BRUSHDATA->m_style = wxSTIPPLE;
- }
+ M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
+ else
+ M_BRUSHDATA->m_style = wxSTIPPLE;
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
// local defines
//-----------------------------------------------------------------------------
-#define USE_PAINT_REGION 0
+#define USE_PAINT_REGION 1
//-----------------------------------------------------------------------------
// local data
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
+#define GC_POOL_SIZE 200
+
enum wxPoolGCType
{
wxGC_ERROR = 0,
bool m_used;
};
-static wxGC wxGCPool[200];
+static wxGC wxGCPool[GC_POOL_SIZE];
static void wxInitGCPool()
{
- memset( wxGCPool, 0, 200*sizeof(wxGC) );
+ memset( wxGCPool, 0, GC_POOL_SIZE*sizeof(wxGC) );
}
static void wxCleanUpGCPool()
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (wxGCPool[i].m_gc)
gdk_gc_unref( wxGCPool[i].m_gc );
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (!wxGCPool[i].m_gc)
{
static void wxFreePoolGC( GdkGC *gc )
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (wxGCPool[i].m_gc == gc)
{
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_isMemDC = FALSE;
+ m_isScreenDC = FALSE;
m_owner = (wxWindow *)NULL;
}
m_cmap = (GdkColormap *) NULL;
m_owner = (wxWindow *)NULL;
m_isMemDC = FALSE;
+ m_isScreenDC = FALSE;
m_font = window->GetFont();
wxASSERT_MSG( window, wxT("DC needs a window") );
if (m_window)
{
- if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
- gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
- else
+ if (m_brush.GetStyle() != wxTRANSPARENT)
{
- if ((m_brush.GetStyle() != wxTRANSPARENT))
- gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n );
+ gdk_gc_set_ts_origin( m_textGC, 0, 0 );
+ } else
+ if (m_brush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
+ }
}
- }
- // To do: Fillstyle
+ // To do: Fillstyle
- if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window)
- {
- for (i = 0 ; i < n ; i++)
+ if (m_pen.GetStyle() != wxTRANSPARENT)
{
- gdk_draw_line( m_window, m_penGC,
- gdkpoints[i%n].x,
- gdkpoints[i%n].y,
- gdkpoints[(i+1)%n].x,
- gdkpoints[(i+1)%n].y);
+ for (i = 0 ; i < n ; i++)
+ {
+ gdk_draw_line( m_window, m_penGC,
+ gdkpoints[i%n].x,
+ gdkpoints[i%n].y,
+ gdkpoints[(i+1)%n].x,
+ gdkpoints[(i+1)%n].y);
+ }
}
}
if (m_window)
{
- if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
- {
- gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
- }
- else
+ if (m_brush.GetStyle() != wxTRANSPARENT)
{
- if (m_brush.GetStyle() != wxTRANSPARENT)
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
+ gdk_gc_set_ts_origin( m_textGC, 0, 0 );
+ }
+ else if (m_brush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
+ }
}
+
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
CalcBoundingBox( x, y );
int hh = YLOG2DEVREL(h);
/* compare to current clipping region */
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (useMask && mask)
{
GdkBitmap *new_mask = (GdkBitmap*) NULL;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, ww, hh, 1 );
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
}
else
{
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
wxCoord hh = YLOG2DEVREL(height);
/* compare to current clipping region */
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (useMask && mask)
{
GdkBitmap *new_mask = (GdkBitmap*) NULL;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, bm_ww, bm_hh, 1 );
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
}
else
{
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
wxBitmap bitmap( width, height );
- /* We have to use the srcDC's GC as it might be a
- wxScreenDC and we only have the GDK_INCLUDE_INFERIORS
- flag set there. */
-
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
- gdk_window_copy_area( bitmap.GetPixmap(), srcDC->m_penGC, 0, 0,
+ gdk_window_copy_area( bitmap.GetPixmap(), m_penGC, 0, 0,
srcDC->GetWindow(),
xsrc, ysrc, width, height );
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
/* scale image */
{
/* No scaling and not a memory dc with a mask either */
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
gdk_window_copy_area( m_window, m_penGC, xx, yy,
srcDC->GetWindow(),
xsrc, ysrc, width, height );
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
}
}
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
- gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
+ gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
+ gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
if (IS_HATCH(m_brush.GetStyle()))
rect.width = XLOG2DEVREL(width);
rect.height = YLOG2DEVREL(height);
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( rect );
else
m_currentClippingRegion.Union( rect );
#if USE_PAINT_REGION
- if (!m_paintClippingRegion.IsEmpty())
+ if (!m_paintClippingRegion.IsNull())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
if (!m_window) return;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( region );
else
m_currentClippingRegion.Union( region );
#if USE_PAINT_REGION
- if (!m_paintClippingRegion.IsEmpty())
+ if (!m_paintClippingRegion.IsNull())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
: wxWindowDC( win )
{
#if USE_PAINT_REGION
- if (!win->GetUpdateRegion().IsEmpty())
- {
- m_paintClippingRegion = win->GetUpdateRegion();
- m_currentClippingRegion.Union( m_paintClippingRegion );
+ m_paintClippingRegion = win->GetUpdateRegion();
+ m_currentClippingRegion.Union( m_paintClippingRegion );
- gdk_gc_set_clip_region( m_penGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_brushGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
- }
+ gdk_gc_set_clip_region( m_penGC, m_paintClippingRegion.GetRegion() );
+ gdk_gc_set_clip_region( m_brushGC, m_paintClippingRegion.GetRegion() );
+ gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
+ gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
#endif
}
m_cmap = gdk_colormap_get_system();
m_window = GDK_ROOT_PARENT();
+ m_isScreenDC = TRUE;
+
SetUpDC();
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
g_rect.height = rect.height;
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &g_rect );
gdk_region_destroy( reg );
-
- wxNode *node = M_REGIONDATA->m_rects.First();
- while (node)
- {
- wxRect *r = (wxRect*)node->Data();
- M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(r->x,r->y,r->width,r->height) );
- node = node->Next();
- }
+ M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(rect.x,rect.y,rect.width,rect.height) );
}
wxRegion::wxRegion()
{
- m_refData = new wxRegionRefData();
- M_REGIONDATA->m_region = gdk_region_new();
}
wxRegion::~wxRegion()
void wxRegion::Clear()
{
UnRef();
- m_refData = new wxRegionRefData();
- M_REGIONDATA->m_region = gdk_region_new();
}
bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y;
rect.width = width;
rect.height = height;
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ GdkRegion *reg = gdk_region_new();
+ M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
+ gdk_region_destroy( reg );
+ }
+ else
+ {
+ GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
+ gdk_region_destroy( M_REGIONDATA->m_region );
+ M_REGIONDATA->m_region = reg;
+ }
+
M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(x,y,width,height) );
+
return TRUE;
}
bool wxRegion::Union( const wxRect& rect )
{
- GdkRectangle g_rect;
- g_rect.x = rect.x;
- g_rect.y = rect.y;
- g_rect.width = rect.width;
- g_rect.height = rect.height;
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &g_rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
- M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(rect.x,rect.y,rect.width,rect.height) );
- return TRUE;
+ return Union( rect.x, rect.y, rect.width, rect.height );
}
bool wxRegion::Union( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Intersect( reg );
return TRUE;
bool wxRegion::Intersect( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Intersect( reg );
return TRUE;
bool wxRegion::Intersect( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ return TRUE;
+ }
+
GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Subtract( reg );
return TRUE;
bool wxRegion::Subtract( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Subtract( reg );
return TRUE;
bool wxRegion::Subtract( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Xor( reg );
return TRUE;
bool wxRegion::Xor( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Xor( reg );
return TRUE;
bool wxRegion::Xor( const wxRegion& region )
{
+ if (region.IsNull())
+ return NULL;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
return TRUE;
}
-void wxRegion::GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const
+void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
{
x = 0;
y = 0;
w = -1;
h = -1;
+ if (m_refData)
+ return;
+
GdkRectangle rect;
gdk_region_get_clipbox( M_REGIONDATA->m_region, &rect );
x = rect.x;
bool wxRegion::Empty() const
{
+ if (!m_refData)
+ return TRUE;
+
return gdk_region_empty( M_REGIONDATA->m_region );
}
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
{
+ if (!m_refData)
+ return wxOutRegion;
+
if (gdk_region_point_in( M_REGIONDATA->m_region, x, y ))
return wxInRegion;
else
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const
{
+ if (!m_refData)
+ return wxOutRegion;
+
GdkRectangle rect;
rect.x = x;
rect.y = y;
GdkRegion *wxRegion::GetRegion() const
{
+ if (!m_refData)
+ return (GdkRegion*) NULL;
+
return M_REGIONDATA->m_region;
}
wxList *wxRegion::GetRectList() const
{
+ if (!m_refData)
+ return (wxList*) NULL;
+
return &(M_REGIONDATA->m_rects);
}
{
m_refData = new wxBrushRefData();
M_BRUSHDATA->m_colour = *wxBLACK;
+
M_BRUSHDATA->m_stipple = stippleBitmap;
+
if (M_BRUSHDATA->m_stipple.GetMask())
- {
- M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
- }
- else
- {
- M_BRUSHDATA->m_style = wxSTIPPLE;
- }
+ M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
+ else
+ M_BRUSHDATA->m_style = wxSTIPPLE;
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}
// local defines
//-----------------------------------------------------------------------------
-#define USE_PAINT_REGION 0
+#define USE_PAINT_REGION 1
//-----------------------------------------------------------------------------
// local data
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
+#define GC_POOL_SIZE 200
+
enum wxPoolGCType
{
wxGC_ERROR = 0,
bool m_used;
};
-static wxGC wxGCPool[200];
+static wxGC wxGCPool[GC_POOL_SIZE];
static void wxInitGCPool()
{
- memset( wxGCPool, 0, 200*sizeof(wxGC) );
+ memset( wxGCPool, 0, GC_POOL_SIZE*sizeof(wxGC) );
}
static void wxCleanUpGCPool()
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (wxGCPool[i].m_gc)
gdk_gc_unref( wxGCPool[i].m_gc );
static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (!wxGCPool[i].m_gc)
{
static void wxFreePoolGC( GdkGC *gc )
{
- for (int i = 0; i < 200; i++)
+ for (int i = 0; i < GC_POOL_SIZE; i++)
{
if (wxGCPool[i].m_gc == gc)
{
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_isMemDC = FALSE;
+ m_isScreenDC = FALSE;
m_owner = (wxWindow *)NULL;
}
m_cmap = (GdkColormap *) NULL;
m_owner = (wxWindow *)NULL;
m_isMemDC = FALSE;
+ m_isScreenDC = FALSE;
m_font = window->GetFont();
wxASSERT_MSG( window, wxT("DC needs a window") );
if (m_window)
{
- if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
- gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
- else
+ if (m_brush.GetStyle() != wxTRANSPARENT)
{
- if ((m_brush.GetStyle() != wxTRANSPARENT))
- gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_polygon( m_window, m_textGC, TRUE, gdkpoints, n );
+ gdk_gc_set_ts_origin( m_textGC, 0, 0 );
+ } else
+ if (m_brush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
+ }
}
- }
- // To do: Fillstyle
+ // To do: Fillstyle
- if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window)
- {
- for (i = 0 ; i < n ; i++)
+ if (m_pen.GetStyle() != wxTRANSPARENT)
{
- gdk_draw_line( m_window, m_penGC,
- gdkpoints[i%n].x,
- gdkpoints[i%n].y,
- gdkpoints[(i+1)%n].x,
- gdkpoints[(i+1)%n].y);
+ for (i = 0 ; i < n ; i++)
+ {
+ gdk_draw_line( m_window, m_penGC,
+ gdkpoints[i%n].x,
+ gdkpoints[i%n].y,
+ gdkpoints[(i+1)%n].x,
+ gdkpoints[(i+1)%n].y);
+ }
}
}
if (m_window)
{
- if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
- {
- gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
- }
- else
+ if (m_brush.GetStyle() != wxTRANSPARENT)
{
- if (m_brush.GetStyle() != wxTRANSPARENT)
+ if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
+ {
+ gdk_gc_set_ts_origin( m_textGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
+ gdk_draw_rectangle( m_window, m_textGC, TRUE, xx, yy, ww, hh );
+ gdk_gc_set_ts_origin( m_textGC, 0, 0 );
+ }
+ else if (m_brush.GetStyle() == wxSTIPPLE)
+ {
+ gdk_gc_set_ts_origin( m_brushGC,
+ m_deviceOriginX % m_brush.GetStipple()->GetWidth(),
+ m_deviceOriginY % m_brush.GetStipple()->GetHeight() );
gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
-
- if (m_pen.GetStyle() != wxTRANSPARENT)
- gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
+ gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
+ }
+ else
+ {
+ gdk_draw_rectangle( m_window, m_brushGC, TRUE, xx, yy, ww, hh );
+ }
}
+
+ if (m_pen.GetStyle() != wxTRANSPARENT)
+ gdk_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
}
CalcBoundingBox( x, y );
int hh = YLOG2DEVREL(h);
/* compare to current clipping region */
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (useMask && mask)
{
GdkBitmap *new_mask = (GdkBitmap*) NULL;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, ww, hh, 1 );
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
}
else
{
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
wxCoord hh = YLOG2DEVREL(height);
/* compare to current clipping region */
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
wxRegion tmp( xx,yy,ww,hh );
tmp.Intersect( m_currentClippingRegion );
if (useMask && mask)
{
GdkBitmap *new_mask = (GdkBitmap*) NULL;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
{
GdkColor col;
new_mask = gdk_pixmap_new( wxRootWindow->window, bm_ww, bm_hh, 1 );
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_textGC, m_currentClippingRegion.GetRegion() );
}
else
{
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 );
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
gdk_gc_set_clip_region( m_penGC, m_currentClippingRegion.GetRegion() );
}
}
wxBitmap bitmap( width, height );
- /* We have to use the srcDC's GC as it might be a
- wxScreenDC and we only have the GDK_INCLUDE_INFERIORS
- flag set there. */
-
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
- gdk_window_copy_area( bitmap.GetPixmap(), srcDC->m_penGC, 0, 0,
+ gdk_window_copy_area( bitmap.GetPixmap(), m_penGC, 0, 0,
srcDC->GetWindow(),
xsrc, ysrc, width, height );
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
/* scale image */
{
/* No scaling and not a memory dc with a mask either */
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
gdk_window_copy_area( m_window, m_penGC, xx, yy,
srcDC->GetWindow(),
xsrc, ysrc, width, height );
- if (srcDC->GetWindow() == GDK_ROOT_PARENT())
+ if (srcDC->m_isScreenDC)
gdk_gc_set_subwindow( m_penGC, GDK_CLIP_BY_CHILDREN );
}
}
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
{
- gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
- gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
+ gdk_gc_set_fill( m_textGC, GDK_OPAQUE_STIPPLED);
+ gdk_gc_set_stipple( m_textGC, m_brush.GetStipple()->GetMask()->GetBitmap() );
}
if (IS_HATCH(m_brush.GetStyle()))
rect.width = XLOG2DEVREL(width);
rect.height = YLOG2DEVREL(height);
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( rect );
else
m_currentClippingRegion.Union( rect );
#if USE_PAINT_REGION
- if (!m_paintClippingRegion.IsEmpty())
+ if (!m_paintClippingRegion.IsNull())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
if (!m_window) return;
- if (!m_currentClippingRegion.IsEmpty())
+ if (!m_currentClippingRegion.IsNull())
m_currentClippingRegion.Intersect( region );
else
m_currentClippingRegion.Union( region );
#if USE_PAINT_REGION
- if (!m_paintClippingRegion.IsEmpty())
+ if (!m_paintClippingRegion.IsNull())
m_currentClippingRegion.Intersect( m_paintClippingRegion );
#endif
: wxWindowDC( win )
{
#if USE_PAINT_REGION
- if (!win->GetUpdateRegion().IsEmpty())
- {
- m_paintClippingRegion = win->GetUpdateRegion();
- m_currentClippingRegion.Union( m_paintClippingRegion );
+ m_paintClippingRegion = win->GetUpdateRegion();
+ m_currentClippingRegion.Union( m_paintClippingRegion );
- gdk_gc_set_clip_region( m_penGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_brushGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
- gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
- }
+ gdk_gc_set_clip_region( m_penGC, m_paintClippingRegion.GetRegion() );
+ gdk_gc_set_clip_region( m_brushGC, m_paintClippingRegion.GetRegion() );
+ gdk_gc_set_clip_region( m_textGC, m_paintClippingRegion.GetRegion() );
+ gdk_gc_set_clip_region( m_bgGC, m_paintClippingRegion.GetRegion() );
#endif
}
m_cmap = gdk_colormap_get_system();
m_window = GDK_ROOT_PARENT();
+ m_isScreenDC = TRUE;
+
SetUpDC();
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );
g_rect.height = rect.height;
M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &g_rect );
gdk_region_destroy( reg );
-
- wxNode *node = M_REGIONDATA->m_rects.First();
- while (node)
- {
- wxRect *r = (wxRect*)node->Data();
- M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(r->x,r->y,r->width,r->height) );
- node = node->Next();
- }
+ M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(rect.x,rect.y,rect.width,rect.height) );
}
wxRegion::wxRegion()
{
- m_refData = new wxRegionRefData();
- M_REGIONDATA->m_region = gdk_region_new();
}
wxRegion::~wxRegion()
void wxRegion::Clear()
{
UnRef();
- m_refData = new wxRegionRefData();
- M_REGIONDATA->m_region = gdk_region_new();
}
bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y;
rect.width = width;
rect.height = height;
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ GdkRegion *reg = gdk_region_new();
+ M_REGIONDATA->m_region = gdk_region_union_with_rect( reg, &rect );
+ gdk_region_destroy( reg );
+ }
+ else
+ {
+ GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &rect );
+ gdk_region_destroy( M_REGIONDATA->m_region );
+ M_REGIONDATA->m_region = reg;
+ }
+
M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(x,y,width,height) );
+
return TRUE;
}
bool wxRegion::Union( const wxRect& rect )
{
- GdkRectangle g_rect;
- g_rect.x = rect.x;
- g_rect.y = rect.y;
- g_rect.width = rect.width;
- g_rect.height = rect.height;
- GdkRegion *reg = gdk_region_union_with_rect( M_REGIONDATA->m_region, &g_rect );
- gdk_region_destroy( M_REGIONDATA->m_region );
- M_REGIONDATA->m_region = reg;
- M_REGIONDATA->m_rects.Append( (wxObject*) new wxRect(rect.x,rect.y,rect.width,rect.height) );
- return TRUE;
+ return Union( rect.x, rect.y, rect.width, rect.height );
}
bool wxRegion::Union( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_union( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Intersect( reg );
return TRUE;
bool wxRegion::Intersect( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Intersect( reg );
return TRUE;
bool wxRegion::Intersect( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ return TRUE;
+ }
+
GdkRegion *reg = gdk_regions_intersect( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Subtract( reg );
return TRUE;
bool wxRegion::Subtract( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Subtract( reg );
return TRUE;
bool wxRegion::Subtract( const wxRegion& region )
{
+ if (region.IsNull())
+ return FALSE;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_subtract( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( x, y, width, height );
Xor( reg );
return TRUE;
bool wxRegion::Xor( const wxRect& rect )
{
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
wxRegion reg( rect );
Xor( reg );
return TRUE;
bool wxRegion::Xor( const wxRegion& region )
{
+ if (region.IsNull())
+ return NULL;
+
+ if (!m_refData)
+ {
+ m_refData = new wxRegionRefData();
+ M_REGIONDATA->m_region = gdk_region_new();
+ }
+
GdkRegion *reg = gdk_regions_xor( M_REGIONDATA->m_region, region.GetRegion() );
gdk_region_destroy( M_REGIONDATA->m_region );
M_REGIONDATA->m_region = reg;
return TRUE;
}
-void wxRegion::GetBox( wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h ) const
+void wxRegion::GetBox( wxCoord &x, wxCoord &y, wxCoord &w, wxCoord &h ) const
{
x = 0;
y = 0;
w = -1;
h = -1;
+ if (m_refData)
+ return;
+
GdkRectangle rect;
gdk_region_get_clipbox( M_REGIONDATA->m_region, &rect );
x = rect.x;
bool wxRegion::Empty() const
{
+ if (!m_refData)
+ return TRUE;
+
return gdk_region_empty( M_REGIONDATA->m_region );
}
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
{
+ if (!m_refData)
+ return wxOutRegion;
+
if (gdk_region_point_in( M_REGIONDATA->m_region, x, y ))
return wxInRegion;
else
wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y, wxCoord w, wxCoord h ) const
{
+ if (!m_refData)
+ return wxOutRegion;
+
GdkRectangle rect;
rect.x = x;
rect.y = y;
GdkRegion *wxRegion::GetRegion() const
{
+ if (!m_refData)
+ return (GdkRegion*) NULL;
+
return M_REGIONDATA->m_region;
}
wxList *wxRegion::GetRectList() const
{
+ if (!m_refData)
+ return (wxList*) NULL;
+
return &(M_REGIONDATA->m_rects);
}