]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "brush.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class wxBrushRefData
: public wxObjectRefData
27 wxBrushRefData( const wxBrushRefData
& data
);
34 wxBrushRefData::wxBrushRefData()
39 wxBrushRefData::wxBrushRefData( const wxBrushRefData
& data
)
41 m_style
= data
.m_style
;
42 m_stipple
= data
.m_stipple
;
43 m_colour
= data
.m_colour
;
46 //-----------------------------------------------------------------------------
48 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
50 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
)
54 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
57 wxBrush::wxBrush( const wxColour
&colour
, int style
)
59 m_refData
= new wxBrushRefData();
60 M_BRUSHDATA
->m_style
= style
;
61 M_BRUSHDATA
->m_colour
= colour
;
63 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
66 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
68 m_refData
= new wxBrushRefData();
69 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
70 M_BRUSHDATA
->m_colour
= *wxBLACK
;
71 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
73 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
76 wxBrush::wxBrush( const wxBrush
&brush
)
80 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
85 if (wxTheBrushList
) wxTheBrushList
->RemoveBrush( this );
88 wxBrush
& wxBrush::operator = ( const wxBrush
& brush
)
90 if (*this == brush
) return (*this);
95 bool wxBrush::operator == ( const wxBrush
& brush
)
97 return m_refData
== brush
.m_refData
;
100 bool wxBrush::operator != ( const wxBrush
& brush
)
102 return m_refData
!= brush
.m_refData
;
105 bool wxBrush::Ok() const
107 return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok());
110 int wxBrush::GetStyle() const
112 if (m_refData
== NULL
)
114 wxFAIL_MSG( wxT("invalid brush") );
118 return M_BRUSHDATA
->m_style
;
121 wxColour
&wxBrush::GetColour() const
123 if (m_refData
== NULL
)
125 wxFAIL_MSG( wxT("invalid brush") );
129 return M_BRUSHDATA
->m_colour
;
132 wxBitmap
*wxBrush::GetStipple() const
134 if (m_refData
== NULL
)
136 wxFAIL_MSG( wxT("invalid brush") );
137 return &wxNullBitmap
;
140 return &M_BRUSHDATA
->m_stipple
;
143 void wxBrush::SetColour( const wxColour
& col
)
146 M_BRUSHDATA
->m_colour
= col
;
149 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
152 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
155 void wxBrush::SetStyle( int style
)
158 M_BRUSHDATA
->m_style
= style
;
161 void wxBrush::SetStipple( const wxBitmap
& stipple
)
164 M_BRUSHDATA
->m_stipple
= stipple
;
167 void wxBrush::Unshare()
171 m_refData
= new wxBrushRefData();
175 wxBrushRefData
* ref
= new wxBrushRefData( *(wxBrushRefData
*)m_refData
);