// Useful helper: create the brush resource
bool RealizeResource();
-protected:
- virtual wxObjectRefData* CreateRefData() const;
- virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+private:
+ void Unshare();
};
#endif
// Returns an ATSUStyle not ATSUStyle*
void* MacGetATSUStyle() const ;
-protected:
- virtual wxObjectRefData* CreateRefData() const;
- virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+private:
+ void Unshare();
DECLARE_DYNAMIC_CLASS(wxFont)
};
// Useful helper: create the brush resource
bool RealizeResource();
-protected:
- virtual wxObjectRefData* CreateRefData() const;
- virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+private:
+ void Unshare();
};
#endif
RealizeResource();
}
-wxObjectRefData* wxBrush::CreateRefData() const
+void wxBrush::Unshare()
{
- return new wxBrushRefData;
-}
-
-wxObjectRefData* wxBrush::CloneRefData(const wxObjectRefData* data) const
-{
- return new wxBrushRefData(*wx_static_cast(const wxBrushRefData*, data));
+ // Don't change shared data
+ if (!m_refData)
+ {
+ m_refData = new wxBrushRefData();
+ }
+ else
+ {
+ wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
+ UnRef();
+ m_refData = ref;
+ }
}
void wxBrush::SetColour(const wxColour& col)
{
- AllocExclusive();
+ Unshare();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_colour = col;
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
- AllocExclusive();
+ Unshare();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_colour.Set(r, g, b);
void wxBrush::SetStyle(int Style)
{
- AllocExclusive();
+ Unshare();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_style = Style;
void wxBrush::SetStipple(const wxBitmap& Stipple)
{
- AllocExclusive();
+ Unshare();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_stipple = Stipple;
void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
{
- AllocExclusive();
+ Unshare();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
{
- AllocExclusive();
+ Unshare();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
void wxFont::SetEncoding(wxFontEncoding encoding)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_encoding = encoding;
RealizeResource();
}
-wxObjectRefData* wxFont::CreateRefData() const
+void wxFont::Unshare()
{
- return new wxFontRefData;
-}
-
-wxObjectRefData* wxFont::CloneRefData(const wxObjectRefData* data) const
-{
- return new wxFontRefData(*wx_static_cast(const wxFontRefData*, data));
+ // Don't change shared data
+ if (!m_refData)
+ {
+ m_refData = new wxFontRefData();
+ }
+ else
+ {
+ wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
+ UnRef();
+ m_refData = ref;
+ }
}
void wxFont::SetPointSize(int pointSize)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_pointSize = pointSize;
void wxFont::SetFamily(int family)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_family = family;
void wxFont::SetStyle(int style)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_style = style;
void wxFont::SetWeight(int weight)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_weight = weight;
bool wxFont::SetFaceName(const wxString& faceName)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_faceName = faceName;
void wxFont::SetUnderlined(bool underlined)
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->m_underlined = underlined;
void wxFont::SetNoAntiAliasing( bool no )
{
- AllocExclusive();
+ Unshare();
M_FONTDATA->SetNoAntiAliasing( no );
RealizeResource();
}
-wxObjectRefData* wxPen::CreateRefData() const
+void wxPen::Unshare()
{
- return new wxPenRefData;
-}
-
-wxObjectRefData* wxPen::CloneRefData(const wxObjectRefData* data) const
-{
- return new wxPenRefData(*wx_static_cast(const wxPenRefData*, data));
+ // Don't change shared data
+ if (!m_refData)
+ {
+ m_refData = new wxPenRefData();
+ }
+ else
+ {
+ wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
+ UnRef();
+ m_refData = ref;
+ }
}
void wxPen::SetColour(const wxColour& col)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_colour = col;
void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_colour.Set(r, g, b);
void wxPen::SetWidth(int Width)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_width = Width;
void wxPen::SetStyle(int Style)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_style = Style;
void wxPen::SetStipple(const wxBitmap& Stipple)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_stipple = Stipple;
M_PENDATA->m_style = wxSTIPPLE;
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_nbDash = nb_dashes;
M_PENDATA->m_dash = (wxDash *)Dash;
void wxPen::SetJoin(int Join)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_join = Join;
void wxPen::SetCap(int Cap)
{
- AllocExclusive();
+ Unshare();
M_PENDATA->m_cap = Cap;