Lotta stuff for drawing etc.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@6436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-03-04 16:23:26 +00:00
parent a85139a1b7
commit e1208c3103
16 changed files with 478 additions and 238 deletions

View File

@@ -115,6 +115,7 @@ public:
GdkGC *m_bgGC;
GdkColormap *m_cmap;
bool m_isMemDC;
bool m_isScreenDC;
wxWindow *m_owner;
wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion;

View File

@@ -26,6 +26,8 @@ public:
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... */

View File

@@ -30,16 +30,19 @@ class wxRegion;
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.
};
//-----------------------------------------------------------------------------
@@ -48,10 +51,7 @@ wxRGN_XOR // Creates the union of two combined regions except for any
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 );
@@ -95,10 +95,12 @@ class wxRegion : public wxGDIObject
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

View File

@@ -115,6 +115,7 @@ public:
GdkGC *m_bgGC;
GdkColormap *m_cmap;
bool m_isMemDC;
bool m_isScreenDC;
wxWindow *m_owner;
wxRegion m_currentClippingRegion;
wxRegion m_paintClippingRegion;

View File

@@ -26,6 +26,8 @@ public:
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... */

View File

@@ -30,16 +30,19 @@ class wxRegion;
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.
};
//-----------------------------------------------------------------------------
@@ -48,10 +51,7 @@ wxRGN_XOR // Creates the union of two combined regions except for any
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 );
@@ -95,10 +95,12 @@ class wxRegion : public wxGDIObject
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

View File

@@ -73,6 +73,7 @@ static wxBitmap gs_bmpNoMask,
gs_bmpMask,
gs_bmpWithMask,
gs_bmp4,
gs_bmp4_mono,
gs_bmp36;
// ----------------------------------------------------------------------------
@@ -243,9 +244,12 @@ bool MyApp::LoadImages()
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 )
@@ -325,20 +329,21 @@ MyCanvas::MyCanvas( MyFrame *parent ) : wxScrolledWindow( parent )
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_mono = new wxBrush(gs_bmp4_mono);
wxBrush* brush36 = new wxBrush(gs_bmp36);
wxPoint todraw[5];
@@ -369,20 +374,24 @@ void MyCanvas::DrawTestPoly( int x, int y,wxDC &dc,int transparent )
{
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;
@@ -523,6 +532,7 @@ void MyCanvas::DrawTestPoly( int x, int y,wxDC &dc,int transparent )
}
delete brush4;
delete brush4_mono;
delete brush36;
}
@@ -943,7 +953,7 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
}
}
// dc.Clear();
dc.Clear();
if ( m_owner->m_textureBackground) {
dc.SetPen(*wxMEDIUM_GREY_PEN);
@@ -974,8 +984,10 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
case Show_Polygons:
DrawTestPoly( 0, 100, dc, 0 );
/*
DrawTestPoly( 33, 500, dc, 1 );
DrawTestPoly( 43, 1000, dc, 2 );
*/
break;
case Show_Mask:

View File

@@ -2657,7 +2657,7 @@ void wxListMainWindow::CalculatePositions()
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;

View File

@@ -66,15 +66,13 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap )
{
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;
}
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}

View File

@@ -28,7 +28,7 @@
// local defines
//-----------------------------------------------------------------------------
#define USE_PAINT_REGION 0
#define USE_PAINT_REGION 1
//-----------------------------------------------------------------------------
// local data
@@ -110,6 +110,8 @@ void gdk_draw_bitmap (GdkDrawable *drawable,
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
#define GC_POOL_SIZE 200
enum wxPoolGCType
{
wxGC_ERROR = 0,
@@ -130,16 +132,16 @@ struct wxGC
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 );
@@ -148,7 +150,7 @@ static void wxCleanUpGCPool()
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)
{
@@ -171,7 +173,7 @@ static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
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)
{
@@ -197,6 +199,7 @@ wxWindowDC::wxWindowDC()
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_isMemDC = FALSE;
m_isScreenDC = FALSE;
m_owner = (wxWindow *)NULL;
}
@@ -209,6 +212,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
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") );
@@ -523,19 +527,34 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor
}
if (m_window)
{
if (m_brush.GetStyle() != wxTRANSPARENT)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
{
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
{
if ((m_brush.GetStyle() != wxTRANSPARENT))
gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
}
}
// To do: Fillstyle
if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window)
if (m_pen.GetStyle() != wxTRANSPARENT)
{
for (i = 0 ; i < n ; i++)
{
@@ -546,6 +565,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor
gdkpoints[(i+1)%n].y);
}
}
}
delete[] gdkpoints;
}
@@ -567,21 +587,34 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
if (hh < 0) { hh = -hh; yy = yy - hh; }
if (m_window)
{
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_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
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 );
gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
}
else
{
if (m_brush.GetStyle() != wxTRANSPARENT)
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 );
CalcBoundingBox( x + width, y + height );
@@ -717,7 +750,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
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 );
@@ -748,7 +781,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
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 );
@@ -810,14 +843,14 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
{
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() );
}
}
@@ -896,7 +929,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
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 );
@@ -941,7 +974,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
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 );
@@ -996,14 +1029,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
{
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() );
}
}
@@ -1027,18 +1060,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
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 */
@@ -1059,14 +1088,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
{
/* 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 );
}
}
@@ -1650,13 +1679,13 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo
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
@@ -1683,13 +1712,13 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion &region )
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
@@ -1960,8 +1989,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
#if USE_PAINT_REGION
if (!win->GetUpdateRegion().IsEmpty())
{
m_paintClippingRegion = win->GetUpdateRegion();
m_currentClippingRegion.Union( m_paintClippingRegion );
@@ -1969,7 +1996,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
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
}

View File

@@ -38,6 +38,8 @@ wxScreenDC::wxScreenDC()
m_cmap = gdk_colormap_get_system();
m_window = GDK_ROOT_PARENT();
m_isScreenDC = TRUE;
SetUpDC();
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );

View File

@@ -94,20 +94,11 @@ wxRegion::wxRegion( const wxRect& rect )
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()
@@ -127,8 +118,6 @@ bool wxRegion::operator != ( const wxRegion& region )
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 )
@@ -138,29 +127,41 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y;
rect.width = width;
rect.height = height;
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;
@@ -178,6 +179,12 @@ bool wxRegion::Union( const wxRegion& region )
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;
@@ -185,6 +192,12 @@ bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
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;
@@ -192,6 +205,16 @@ bool wxRegion::Intersect( const wxRect& rect )
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;
@@ -200,6 +223,12 @@ bool wxRegion::Intersect( const wxRegion& region )
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;
@@ -207,6 +236,12 @@ bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
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;
@@ -214,6 +249,15 @@ bool wxRegion::Subtract( const wxRect& rect )
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;
@@ -222,6 +266,12 @@ bool wxRegion::Subtract( const wxRegion& region )
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;
@@ -229,6 +279,12 @@ bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
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;
@@ -236,6 +292,15 @@ bool wxRegion::Xor( const wxRect& rect )
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;
@@ -251,12 +316,15 @@ bool wxRegion::Xor( const wxRegion& region )
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;
@@ -277,11 +345,17 @@ wxRect wxRegion::GetBox() const
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
@@ -290,6 +364,9 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
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;
@@ -317,11 +394,17 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const
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);
}

View File

@@ -66,15 +66,13 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap )
{
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;
}
if (wxTheBrushList) wxTheBrushList->AddBrush( this );
}

View File

@@ -28,7 +28,7 @@
// local defines
//-----------------------------------------------------------------------------
#define USE_PAINT_REGION 0
#define USE_PAINT_REGION 1
//-----------------------------------------------------------------------------
// local data
@@ -110,6 +110,8 @@ void gdk_draw_bitmap (GdkDrawable *drawable,
// Implement Pool of Graphic contexts. Creating them takes too much time.
//-----------------------------------------------------------------------------
#define GC_POOL_SIZE 200
enum wxPoolGCType
{
wxGC_ERROR = 0,
@@ -130,16 +132,16 @@ struct wxGC
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 );
@@ -148,7 +150,7 @@ static void wxCleanUpGCPool()
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)
{
@@ -171,7 +173,7 @@ static GdkGC* wxGetPoolGC( GdkWindow *window, wxPoolGCType type )
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)
{
@@ -197,6 +199,7 @@ wxWindowDC::wxWindowDC()
m_bgGC = (GdkGC *) NULL;
m_cmap = (GdkColormap *) NULL;
m_isMemDC = FALSE;
m_isScreenDC = FALSE;
m_owner = (wxWindow *)NULL;
}
@@ -209,6 +212,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
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") );
@@ -523,19 +527,34 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor
}
if (m_window)
{
if (m_brush.GetStyle() != wxTRANSPARENT)
{
if ((m_brush.GetStyle() == wxSTIPPLE_MASK_OPAQUE) && (m_brush.GetStipple()->GetMask()))
gdk_draw_polygon (m_window, m_textGC, TRUE, gdkpoints, n);
{
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
{
if ((m_brush.GetStyle() != wxTRANSPARENT))
gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n);
gdk_draw_polygon( m_window, m_brushGC, TRUE, gdkpoints, n );
}
}
// To do: Fillstyle
if ((m_pen.GetStyle() != wxTRANSPARENT) && m_window)
if (m_pen.GetStyle() != wxTRANSPARENT)
{
for (i = 0 ; i < n ; i++)
{
@@ -546,6 +565,7 @@ void wxWindowDC::DoDrawPolygon( int n, wxPoint points[], wxCoord xoffset, wxCoor
gdkpoints[(i+1)%n].y);
}
}
}
delete[] gdkpoints;
}
@@ -567,21 +587,34 @@ void wxWindowDC::DoDrawRectangle( wxCoord x, wxCoord y, wxCoord width, wxCoord h
if (hh < 0) { hh = -hh; yy = yy - hh; }
if (m_window)
{
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_draw_rectangle( m_window, m_penGC, FALSE, xx, yy, ww-1, hh-1 );
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 );
gdk_gc_set_ts_origin( m_brushGC, 0, 0 );
}
else
{
if (m_brush.GetStyle() != wxTRANSPARENT)
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 );
CalcBoundingBox( x + width, y + height );
@@ -717,7 +750,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
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 );
@@ -748,7 +781,7 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
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 );
@@ -810,14 +843,14 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
{
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() );
}
}
@@ -896,7 +929,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
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 );
@@ -941,7 +974,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
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 );
@@ -996,14 +1029,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
{
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() );
}
}
@@ -1027,18 +1060,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
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 */
@@ -1059,14 +1088,14 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
{
/* 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 );
}
}
@@ -1650,13 +1679,13 @@ void wxWindowDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoo
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
@@ -1683,13 +1712,13 @@ void wxWindowDC::DoSetClippingRegionAsRegion( const wxRegion &region )
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
@@ -1960,8 +1989,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
: wxWindowDC( win )
{
#if USE_PAINT_REGION
if (!win->GetUpdateRegion().IsEmpty())
{
m_paintClippingRegion = win->GetUpdateRegion();
m_currentClippingRegion.Union( m_paintClippingRegion );
@@ -1969,7 +1996,6 @@ wxPaintDC::wxPaintDC( wxWindow *win )
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
}

View File

@@ -38,6 +38,8 @@ wxScreenDC::wxScreenDC()
m_cmap = gdk_colormap_get_system();
m_window = GDK_ROOT_PARENT();
m_isScreenDC = TRUE;
SetUpDC();
gdk_gc_set_subwindow( m_penGC, GDK_INCLUDE_INFERIORS );

View File

@@ -94,20 +94,11 @@ wxRegion::wxRegion( const wxRect& rect )
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()
@@ -127,8 +118,6 @@ bool wxRegion::operator != ( const wxRegion& region )
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 )
@@ -138,29 +127,41 @@ bool wxRegion::Union( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
rect.y = y;
rect.width = width;
rect.height = height;
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;
@@ -178,6 +179,12 @@ bool wxRegion::Union( const wxRegion& region )
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;
@@ -185,6 +192,12 @@ bool wxRegion::Intersect( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
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;
@@ -192,6 +205,16 @@ bool wxRegion::Intersect( const wxRect& rect )
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;
@@ -200,6 +223,12 @@ bool wxRegion::Intersect( const wxRegion& region )
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;
@@ -207,6 +236,12 @@ bool wxRegion::Subtract( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
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;
@@ -214,6 +249,15 @@ bool wxRegion::Subtract( const wxRect& rect )
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;
@@ -222,6 +266,12 @@ bool wxRegion::Subtract( const wxRegion& region )
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;
@@ -229,6 +279,12 @@ bool wxRegion::Xor( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
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;
@@ -236,6 +292,15 @@ bool wxRegion::Xor( const wxRect& rect )
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;
@@ -251,12 +316,15 @@ bool wxRegion::Xor( const wxRegion& region )
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;
@@ -277,11 +345,17 @@ wxRect wxRegion::GetBox() const
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
@@ -290,6 +364,9 @@ wxRegionContain wxRegion::Contains( wxCoord x, wxCoord y ) const
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;
@@ -317,11 +394,17 @@ wxRegionContain wxRegion::Contains(const wxRect& rect) const
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);
}