// implementation:
- void Unshare();
-
void* GetMaskPattern() const;
void* GetPixPattern() const;
+protected:
+ // ref counting code
+ virtual wxObjectRefData *CreateRefData() const;
+ virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
+
private:
DECLARE_DYNAMIC_CLASS(wxBrush)
};
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);
- // implementation from now on
- void Unshare();
-
struct font_t *GetMGLfont_t(float scale, bool antialiased);
- // no data :-)
-
protected:
// common part of all ctors
void Init() {}
+ // ref counting code
+ virtual wxObjectRefData *CreateRefData() const;
+ virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
+
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
bool Ok() const;
- void Unshare();
-
// implementation:
void* GetPixPattern() const;
+protected:
+ // ref counting code
+ virtual wxObjectRefData *CreateRefData() const;
+ virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
+
private:
DECLARE_DYNAMIC_CLASS(wxPen)
};
// Clear current region
void Clear(void);
+ bool Offset(wxCoord x, wxCoord y);
+
// Union rectangle or region with this.
bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
bool Union(const wxRect& rect) { return Union(rect.x, rect.y, rect.width, rect.height); }
// implementation from now on:
const MGLRegion& GetMGLRegion() const;
-
-private:
- void Unshare();
+
+protected:
+ // ref counting code
+ virtual wxObjectRefData *CreateRefData() const;
+ virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
};
void wxBrush::SetColour(const wxColour& col)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_colour = col;
}
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_colour.Set(r, g, b);
}
void wxBrush::SetStyle( int style )
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_style = style;
}
void wxBrush::SetStipple(const wxBitmap& stipple)
{
- Unshare();
+ AllocExclusive();
wxCHECK_RET( stipple.Ok(), _T("invalid bitmap") );
wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8,
M_BRUSHDATA->m_style = wxSTIPPLE;
}
-void wxBrush::Unshare()
+wxObjectRefData *wxBrush::CreateRefData() const
{
- if (!m_refData)
- {
- m_refData = new wxBrushRefData();
- }
- else
- {
- wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
+ return new wxBrushRefData;
+}
+
+wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxBrushRefData(*(wxBrushRefData *)data);
}
return instance->GetMGLfont_t();
}
-void wxFont::Unshare()
+wxObjectRefData *wxFont::CreateRefData() const
{
- if ( !m_refData )
- {
- m_refData = new wxFontRefData();
- }
- else
- {
- wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
+ return new wxFontRefData;
}
+wxObjectRefData *wxFont::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxFontRefData(*(wxFontRefData *)data);
+}
+
+
// ----------------------------------------------------------------------------
// accessors
// ----------------------------------------------------------------------------
void wxFont::SetPointSize(int pointSize)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_pointSize = pointSize;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetFamily(int family)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_family = family;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetStyle(int style)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_style = style;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetWeight(int weight)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_weight = weight;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetFaceName(const wxString& faceName)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_faceName = faceName;
M_FONTDATA->m_valid = FALSE;
void wxFont::SetUnderlined(bool underlined)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_underlined = underlined;
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
- Unshare();
+ AllocExclusive();
M_FONTDATA->m_encoding = encoding;
M_FONTDATA->m_valid = FALSE;
void wxPen::SetColour(const wxColour &colour)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_colour = colour;
}
void wxPen::SetDashes(int number_of_dashes, const wxDash *dash)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxDash *)dash; /* TODO */
}
void wxPen::SetColour(int red, int green, int blue)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_colour.Set(red, green, blue);
}
void wxPen::SetCap(int capStyle)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_capStyle = capStyle;
}
void wxPen::SetJoin(int joinStyle)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_joinStyle = joinStyle;
}
void wxPen::SetStyle(int style)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_style = style;
}
wxCHECK_RET( stipple.GetWidth() == 8 && stipple.GetHeight() == 8,
_T("stipple bitmap must be 8x8") );
- Unshare();
+ AllocExclusive();
M_PENDATA->m_stipple = stipple;
wxBitmapToPixPattern(stipple, &(M_PENDATA->m_pixPattern), NULL);
}
void wxPen::SetWidth(int width)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_width = width;
}
return (m_refData != NULL);
}
-void wxPen::Unshare()
+wxObjectRefData *wxPen::CreateRefData() const
{
- if (!m_refData)
- {
- m_refData = new wxPenRefData();
- }
- else
- {
- wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData );
- UnRef();
- m_refData = ref;
- }
+ return new wxPenRefData;
+}
+
+wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxPenRefData(*(wxPenRefData *)data);
}
class WXDLLEXPORT wxRegionRefData : public wxGDIRefData
{
public:
- wxRegionRefData()
- {
- }
+ wxRegionRefData() {}
wxRegionRefData(const wxRegionRefData& data)
{
m_region = data.m_region;
}
- ~wxRegionRefData()
- {
- }
+ ~wxRegionRefData() {}
MGLRegion m_region;
};
// wxRegion
//-----------------------------------------------------------------------------
+wxObjectRefData *wxRegion::CreateRefData() const
+{
+ return new wxRegionRefData;
+}
+
+wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
+{
+ return new wxRegionRefData(*(wxRegionRefData *)data);
+}
+
/*
* Create an empty region.
*/
wxRegion::wxRegion()
{
- m_refData = (wxRegionRefData *)NULL;
+ m_refData = NULL;
}
wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
// Modifications
//-----------------------------------------------------------------------------
+bool wxRegion::Offset(wxCoord x, wxCoord y)
+{
+ AllocExclusive();
+ M_REGION.offset(x, y);
+ return TRUE;
+}
+
// Union rectangle or region with this.
bool wxRegion::Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
M_REGION += MGLRect(x, y, x + width, y + height);
return TRUE;
}
bool wxRegion::Union(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
M_REGION += M_REGION_OF(region);
return TRUE;
}
// Intersect rectangle or region with this.
bool wxRegion::Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
M_REGION &= MGLRect(x, y, x + width, y + height);
return TRUE;
}
bool wxRegion::Intersect(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
M_REGION &= M_REGION_OF(region);
return TRUE;
}
// Combines the parts of 'this' that are not part of the second region.
bool wxRegion::Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
M_REGION -= MGLRect(x, y, x + width, y + height);
return TRUE;
}
bool wxRegion::Subtract(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
M_REGION -= M_REGION_OF(region);
return TRUE;
}
// XOR: the union of two combined regions except for any overlapping areas.
bool wxRegion::Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
{
- Unshare();
+ AllocExclusive();
MGLRect rect(x, y, x + width, y + height);
MGLRegion rg1 = M_REGION + rect,
rg2 = M_REGION & rect;
bool wxRegion::Xor(const wxRegion& region)
{
- Unshare();
+ AllocExclusive();
MGLRegion rg1 = M_REGION + M_REGION_OF(region),
rg2 = M_REGION & M_REGION_OF(region);
M_REGION = rg1 - rg2;
}
-
-void wxRegion::Unshare()
-{
- if (!m_refData)
- {
- m_refData = new wxRegionRefData();
- }
- else
- {
- wxRegionRefData* ref = new wxRegionRefData(*(wxRegionRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
-}
-
-
-
-
-
///////////////////////////////////////////////////////////////////////////////
// wxRegionIterator //
///////////////////////////////////////////////////////////////////////////////
else
return 0;
}
-