// Useful helper: create the brush resource
bool RealizeResource();
- // When setting properties, we must make sure we're not changing
- // another object
- void Unshare();
+protected:
+ virtual wxObjectRefData* CreateRefData() const;
+ virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
};
#endif
}
protected:
+ virtual wxObjectRefData* CreateRefData() const;
+ virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
+
int m_width;
int m_style;
int m_join ;
RealizeResource();
}
-void wxBrush::Unshare()
+wxObjectRefData* wxBrush::CreateRefData() const
{
- // Don't change shared data
- 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(*wx_static_cast(const wxBrushRefData*, data));
}
void wxBrush::SetColour(const wxColour& col)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_colour = col;
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_colour.Set(r, g, b);
void wxBrush::SetStyle(int Style)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_style = Style;
void wxBrush::SetStipple(const wxBitmap& Stipple)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
M_BRUSHDATA->m_stipple = Stipple;
void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
{
- Unshare();
+ AllocExclusive();
M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
RealizeResource();
}
-void wxPen::Unshare()
+wxObjectRefData* wxPen::CreateRefData() const
{
- // Don't change shared data
- 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(*wx_static_cast(const wxPenRefData*, data));
}
void wxPen::SetColour(const wxColour& col)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_colour = col;
void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_colour.Set(r, g, b);
void wxPen::SetWidth(int Width)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_width = Width;
void wxPen::SetStyle(int Style)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_style = Style;
void wxPen::SetStipple(const wxBitmap& Stipple)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_stipple = Stipple;
M_PENDATA->m_style = wxSTIPPLE;
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_nbDash = nb_dashes;
M_PENDATA->m_dash = (wxDash *)Dash;
void wxPen::SetJoin(int Join)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_join = Join;
void wxPen::SetCap(int Cap)
{
- Unshare();
+ AllocExclusive();
M_PENDATA->m_cap = Cap;