]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "brush.h"
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 class wxBrushRefData
: public wxObjectRefData
25 wxBrushRefData( const wxBrushRefData
& data
);
32 wxBrushRefData::wxBrushRefData(void)
37 wxBrushRefData::wxBrushRefData( const wxBrushRefData
& data
)
39 m_style
= data
.m_style
;
40 m_stipple
= data
.m_stipple
;
41 m_colour
= data
.m_colour
;
44 //-----------------------------------------------------------------------------
46 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
48 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
)
50 wxBrush::wxBrush(void)
52 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
55 wxBrush::wxBrush( const wxColour
&colour
, int style
)
57 m_refData
= new wxBrushRefData();
58 M_BRUSHDATA
->m_style
= style
;
59 M_BRUSHDATA
->m_colour
= colour
;
61 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
64 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
66 m_refData
= new wxBrushRefData();
67 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
68 M_BRUSHDATA
->m_colour
= *wxBLACK
;
69 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
71 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
74 wxBrush::wxBrush( const wxBrush
&brush
)
78 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
81 wxBrush::wxBrush( const wxBrush
*brush
)
83 if (brush
) Ref( *brush
);
85 if (wxTheBrushList
) wxTheBrushList
->Append( this );
88 wxBrush::~wxBrush(void)
90 if (wxTheBrushList
) wxTheBrushList
->RemoveBrush( this );
93 wxBrush
& wxBrush::operator = ( const wxBrush
& brush
)
95 if (*this == brush
) return (*this);
100 bool wxBrush::operator == ( const wxBrush
& brush
)
102 return m_refData
== brush
.m_refData
;
105 bool wxBrush::operator != ( const wxBrush
& brush
)
107 return m_refData
!= brush
.m_refData
;
110 bool wxBrush::Ok(void) const
112 return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok());
115 int wxBrush::GetStyle(void) const
117 if (m_refData
== NULL
)
119 wxFAIL_MSG( "invalid brush" );
123 return M_BRUSHDATA
->m_style
;
126 wxColour
&wxBrush::GetColour(void) const
128 if (m_refData
== NULL
)
130 wxFAIL_MSG( "invalid brush" );
134 return M_BRUSHDATA
->m_colour
;
137 wxBitmap
*wxBrush::GetStipple(void) const
139 if (m_refData
== NULL
)
141 wxFAIL_MSG( "invalid brush" );
142 return &wxNullBitmap
;
145 return &M_BRUSHDATA
->m_stipple
;
148 void wxBrush::SetColour( const wxColour
& col
)
151 M_BRUSHDATA
->m_colour
= col
;
154 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
157 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
160 void wxBrush::SetStyle( int style
)
163 M_BRUSHDATA
->m_style
= style
;
166 void wxBrush::SetStipple( const wxBitmap
& stipple
)
169 M_BRUSHDATA
->m_stipple
= stipple
;
172 void wxBrush::Unshare(void)
176 m_refData
= new wxBrushRefData();
180 wxBrushRefData
* ref
= new wxBrushRefData( *(wxBrushRefData
*)m_refData
);