]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "brush.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 class wxBrushRefData
: public wxObjectRefData
32 wxBrushRefData::wxBrushRefData(void)
37 //-----------------------------------------------------------------------------
39 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
41 IMPLEMENT_DYNAMIC_CLASS(wxBrush
,wxGDIObject
)
43 wxBrush::wxBrush(void)
45 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
48 wxBrush::wxBrush( const wxColour
&colour
, const int style
)
50 m_refData
= new wxBrushRefData();
51 M_BRUSHDATA
->m_style
= style
;
52 M_BRUSHDATA
->m_colour
= colour
;
54 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
57 wxBrush::wxBrush( const wxString
&colourName
, const int style
)
59 m_refData
= new wxBrushRefData();
60 M_BRUSHDATA
->m_style
= style
;
61 M_BRUSHDATA
->m_colour
= colourName
;
63 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
66 wxBrush::wxBrush( const wxBitmap
&stippleBitmap
)
68 m_refData
= new wxBrushRefData();
69 M_BRUSHDATA
->m_style
= wxSTIPPLE
;
70 M_BRUSHDATA
->m_colour
= *wxBLACK
;
71 M_BRUSHDATA
->m_stipple
= stippleBitmap
;
73 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
76 wxBrush::wxBrush( const wxBrush
&brush
)
80 if (wxTheBrushList
) wxTheBrushList
->AddBrush( this );
83 wxBrush::wxBrush( const wxBrush
*brush
)
85 if (brush
) Ref( *brush
);
87 if (wxTheBrushList
) wxTheBrushList
->Append( this );
90 wxBrush::~wxBrush(void)
92 if (wxTheBrushList
) wxTheBrushList
->RemoveBrush( this );
95 wxBrush
& wxBrush::operator = ( const wxBrush
& brush
)
97 if (*this == brush
) return (*this);
102 bool wxBrush::operator == ( const wxBrush
& brush
)
104 return m_refData
== brush
.m_refData
;
107 bool wxBrush::operator != ( const wxBrush
& brush
)
109 return m_refData
!= brush
.m_refData
;
112 bool wxBrush::Ok(void) const
114 return ((m_refData
) && M_BRUSHDATA
->m_colour
.Ok());
117 int wxBrush::GetStyle(void) const
119 return M_BRUSHDATA
->m_style
;
122 wxColour
&wxBrush::GetColour(void) const
124 return M_BRUSHDATA
->m_colour
;
127 wxBitmap
*wxBrush::GetStipple(void) const
129 return &M_BRUSHDATA
->m_stipple
;