]>
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"
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
)
53 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
56 wxBrush::wxBrush( const wxColour
&colour
, int style
)
58 m_refData
= new wxBrushRefData();
59 M_BRUSHDATA
->m_style
= style
;
60 M_BRUSHDATA
->m_colour
= colour
;
62 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
65 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
67 m_refData
= new wxBrushRefData();
68 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
69 M_BRUSHDATA
->m_colour
= *wxBLACK
;
70 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
72 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
75 wxBrush::wxBrush( const wxBrush
&brush
)
79 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
84 if (wxTheBrushList
) wxTheBrushList
->RemoveBrush( this );
87 wxBrush
& wxBrush::operator = ( const wxBrush
& brush
)
89 if (*this == brush
) return (*this);
94 bool wxBrush::operator == ( const wxBrush
& brush
)
96 return m_refData
== brush
.m_refData
;
99 bool wxBrush::operator != ( const wxBrush
& brush
)
101 return m_refData
!= brush
.m_refData
;
104 bool wxBrush::Ok() const
106 return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok());
109 int wxBrush::GetStyle() const
111 if (m_refData
== NULL
)
113 wxFAIL_MSG( wxT("invalid brush") );
117 return M_BRUSHDATA
->m_style
;
120 wxColour
&wxBrush::GetColour() const
122 if (m_refData
== NULL
)
124 wxFAIL_MSG( wxT("invalid brush") );
128 return M_BRUSHDATA
->m_colour
;
131 wxBitmap
*wxBrush::GetStipple() const
133 if (m_refData
== NULL
)
135 wxFAIL_MSG( wxT("invalid brush") );
136 return &wxNullBitmap
;
139 return &M_BRUSHDATA
->m_stipple
;
142 void wxBrush::SetColour( const wxColour
& col
)
145 M_BRUSHDATA
->m_colour
= col
;
148 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
151 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
154 void wxBrush::SetStyle( int style
)
157 M_BRUSHDATA
->m_style
= style
;
160 void wxBrush::SetStipple( const wxBitmap
& stipple
)
163 M_BRUSHDATA
->m_stipple
= stipple
;
166 void wxBrush::Unshare()
170 m_refData
= new wxBrushRefData();
174 wxBrushRefData
* ref
= new wxBrushRefData( *(wxBrushRefData
*)m_refData
);