]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/brush.cpp
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
30 wxBrushRefData( const wxBrushRefData
& data
)
32 m_style
= data
.m_style
;
33 m_stipple
= data
.m_stipple
;
34 m_colour
= data
.m_colour
;
37 bool operator == (const wxBrushRefData
& data
) const
39 return (m_style
== data
.m_style
&&
40 m_stipple
== data
.m_stipple
&&
41 m_colour
== data
.m_colour
);
49 //-----------------------------------------------------------------------------
51 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
53 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
;
77 // m_refData unrefed in ~wxObject
80 wxObjectRefData
*wxBrush::CreateRefData() const
82 return new wxBrushRefData
;
85 wxObjectRefData
*wxBrush::CloneRefData(const wxObjectRefData
*data
) const
87 return new wxBrushRefData(*(wxBrushRefData
*)data
);
90 bool wxBrush::operator == ( const wxBrush
& brush
) const
92 if (m_refData
== brush
.m_refData
) return TRUE
;
94 if (!m_refData
|| !brush
.m_refData
) return FALSE
;
96 return ( *(wxBrushRefData
*)m_refData
== *(wxBrushRefData
*)brush
.m_refData
);
99 int wxBrush::GetStyle() const
101 if (m_refData
== NULL
)
103 wxFAIL_MSG( wxT("invalid brush") );
107 return M_BRUSHDATA
->m_style
;
110 wxColour
&wxBrush::GetColour() const
112 if (m_refData
== NULL
)
114 wxFAIL_MSG( wxT("invalid brush") );
118 return M_BRUSHDATA
->m_colour
;
121 wxBitmap
*wxBrush::GetStipple() const
123 if (m_refData
== NULL
)
125 wxFAIL_MSG( wxT("invalid brush") );
126 return &wxNullBitmap
;
129 return &M_BRUSHDATA
->m_stipple
;
132 void wxBrush::SetColour( const wxColour
& col
)
136 M_BRUSHDATA
->m_colour
= col
;
139 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
143 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
146 void wxBrush::SetStyle( int style
)
150 M_BRUSHDATA
->m_style
= style
;
153 void wxBrush::SetStipple( const wxBitmap
& stipple
)
157 M_BRUSHDATA
->m_stipple
= stipple
;
158 if (M_BRUSHDATA
->m_stipple
.GetMask())
160 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
164 M_BRUSHDATA
->m_style
= wxSTIPPLE
;