]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/brush.cpp
68d4d985f9722bef02dac87bac37afae3935c41c
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk/brush.cpp
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
26 wxBrushRefData( const wxBrushRefData
& data
);
33 wxBrushRefData::wxBrushRefData()
38 wxBrushRefData::wxBrushRefData( const wxBrushRefData
& data
)
40 m_style
= data
.m_style
;
41 m_stipple
= data
.m_stipple
;
42 m_colour
= data
.m_colour
;
45 //-----------------------------------------------------------------------------
47 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
49 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
)
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
;
62 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
64 m_refData
= new wxBrushRefData();
65 M_BRUSHDATA
->m_colour
= *wxBLACK
;
67 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
69 if (M_BRUSHDATA
->m_stipple
.GetMask())
70 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
72 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
75 wxBrush::wxBrush( const wxBrush
&brush
)
84 wxBrush
& wxBrush::operator = ( const wxBrush
& brush
)
86 if ( m_refData
!= brush
.m_refData
)
92 bool wxBrush::operator == ( const wxBrush
& brush
) const
94 return m_refData
== brush
.m_refData
;
97 bool wxBrush::operator != ( const wxBrush
& brush
) const
99 return m_refData
!= brush
.m_refData
;
102 bool wxBrush::Ok() const
104 return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok());
107 int wxBrush::GetStyle() const
109 if (m_refData
== NULL
)
111 wxFAIL_MSG( wxT("invalid brush") );
115 return M_BRUSHDATA
->m_style
;
118 wxColour
&wxBrush::GetColour() const
120 if (m_refData
== NULL
)
122 wxFAIL_MSG( wxT("invalid brush") );
126 return M_BRUSHDATA
->m_colour
;
129 wxBitmap
*wxBrush::GetStipple() const
131 if (m_refData
== NULL
)
133 wxFAIL_MSG( wxT("invalid brush") );
134 return &wxNullBitmap
;
137 return &M_BRUSHDATA
->m_stipple
;
140 void wxBrush::SetColour( const wxColour
& col
)
143 M_BRUSHDATA
->m_colour
= col
;
146 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
149 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
152 void wxBrush::SetStyle( int style
)
155 M_BRUSHDATA
->m_style
= style
;
158 void wxBrush::SetStipple( const wxBitmap
& stipple
)
161 M_BRUSHDATA
->m_stipple
= stipple
;
162 if (M_BRUSHDATA
->m_stipple
.GetMask())
164 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
168 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
172 void wxBrush::Unshare()
176 m_refData
= new wxBrushRefData();
180 wxBrushRefData
* ref
= new wxBrushRefData( *(wxBrushRefData
*)m_refData
);