]>
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"
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 class wxBrushRefData
: public wxObjectRefData
25 wxBrushRefData( const wxBrushRefData
& data
);
32 wxBrushRefData::wxBrushRefData()
37 wxBrushRefData::wxBrushRefData( const wxBrushRefData
& data
)
39 m_style
= data
.m_style
;
40 m_stipple
= data
.m_stipple
;
41 m_colour
= data
.m_colour
;
44 //-----------------------------------------------------------------------------
46 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
48 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
)
52 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
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
;
61 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
64 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
66 m_refData
= new wxBrushRefData();
67 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
68 M_BRUSHDATA
->m_colour
= *wxBLACK
;
69 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
71 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
74 wxBrush::wxBrush( const wxBrush
&brush
)
78 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
83 if (wxTheBrushList
) wxTheBrushList
->RemoveBrush( this );
86 wxBrush
& wxBrush::operator = ( const wxBrush
& brush
)
88 if (*this == brush
) return (*this);
93 bool wxBrush::operator == ( const wxBrush
& brush
)
95 return m_refData
== brush
.m_refData
;
98 bool wxBrush::operator != ( const wxBrush
& brush
)
100 return m_refData
!= brush
.m_refData
;
103 bool wxBrush::Ok() const
105 return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok());
108 int wxBrush::GetStyle() const
110 if (m_refData
== NULL
)
112 wxFAIL_MSG( "invalid brush" );
116 return M_BRUSHDATA
->m_style
;
119 wxColour
&wxBrush::GetColour() const
121 if (m_refData
== NULL
)
123 wxFAIL_MSG( "invalid brush" );
127 return M_BRUSHDATA
->m_colour
;
130 wxBitmap
*wxBrush::GetStipple() const
132 if (m_refData
== NULL
)
134 wxFAIL_MSG( "invalid brush" );
135 return &wxNullBitmap
;
138 return &M_BRUSHDATA
->m_stipple
;
141 void wxBrush::SetColour( const wxColour
& col
)
144 M_BRUSHDATA
->m_colour
= col
;
147 void wxBrush::SetColour( unsigned char r
, unsigned char g
, unsigned char b
)
150 M_BRUSHDATA
->m_colour
.Set( r
, g
, b
);
153 void wxBrush::SetStyle( int style
)
156 M_BRUSHDATA
->m_style
= style
;
159 void wxBrush::SetStipple( const wxBitmap
& stipple
)
162 M_BRUSHDATA
->m_stipple
= stipple
;
165 void wxBrush::Unshare()
169 m_refData
= new wxBrushRefData();
173 wxBrushRefData
* ref
= new wxBrushRefData( *(wxBrushRefData
*)m_refData
);