]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/brush.cpp
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
16 #include "wx/colour.h"
21 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
25 class wxBrushRefData
: public wxGDIRefData
33 wxBrushRefData( const wxBrushRefData
& data
)
36 m_style
= data
.m_style
;
37 m_stipple
= data
.m_stipple
;
38 m_colour
= data
.m_colour
;
41 bool operator == (const wxBrushRefData
& data
) const
43 return (m_style
== data
.m_style
&&
44 m_stipple
.IsSameAs(data
.m_stipple
) &&
45 m_colour
== data
.m_colour
);
53 //-----------------------------------------------------------------------------
55 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
57 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
)
59 wxBrush::wxBrush( const wxColour
&colour
, wxBrushStyle style
)
61 m_refData
= new wxBrushRefData();
62 M_BRUSHDATA
->m_style
= style
;
63 M_BRUSHDATA
->m_colour
= colour
;
66 #if FUTURE_WXWIN_COMPATIBILITY_3_0
67 wxBrush::wxBrush(const wxColour
& col
, int style
)
69 m_refData
= new wxBrushRefData
;
70 M_BRUSHDATA
->m_style
= (wxBrushStyle
)style
;
71 M_BRUSHDATA
->m_colour
= colour
;
75 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
77 m_refData
= new wxBrushRefData();
78 M_BRUSHDATA
->m_colour
= *wxBLACK
;
80 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
82 if (M_BRUSHDATA
->m_stipple
.GetMask())
83 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
85 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
90 // m_refData unrefed in ~wxObject
93 wxGDIRefData
*wxBrush::CreateGDIRefData() const
95 return new wxBrushRefData
;
98 wxGDIRefData
*wxBrush::CloneGDIRefData(const wxGDIRefData
*data
) const
100 return new wxBrushRefData(*(wxBrushRefData
*)data
);
103 bool wxBrush::operator == ( const wxBrush
& brush
) const
105 if (m_refData
== brush
.m_refData
) return true;
107 if (!m_refData
|| !brush
.m_refData
) return false;
109 return ( *(wxBrushRefData
*)m_refData
== *(wxBrushRefData
*)brush
.m_refData
);
112 wxBrushStyle
wxBrush::GetStyle() const
114 wxCHECK_MSG( Ok(), wxBRUSHSTYLE_INVALID
, _T("invalid brush") );
116 return M_BRUSHDATA
->m_style
;
119 wxColour
&wxBrush::GetColour() const
121 wxCHECK_MSG( Ok(), wxNullColour
, _T("invalid brush") );
123 return M_BRUSHDATA
->m_colour
;
126 wxBitmap
*wxBrush::GetStipple() const
128 wxCHECK_MSG( Ok(), NULL
, _T("invalid brush") );
130 return &M_BRUSHDATA
->m_stipple
;
133 void wxBrush::SetColour( const wxColour
& col
)
137 M_BRUSHDATA
->m_colour
= col
;
140 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
144 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
147 void wxBrush::SetStyle( wxBrushStyle style
)
151 M_BRUSHDATA
->m_style
= style
;
154 void wxBrush::SetStipple( const wxBitmap
& stipple
)
158 M_BRUSHDATA
->m_stipple
= stipple
;
159 if (M_BRUSHDATA
->m_stipple
.GetMask())
161 M_BRUSHDATA
->m_style
= wxSTIPPLE_MASK_OPAQUE
;
165 M_BRUSHDATA
->m_style
= wxSTIPPLE
;