]> git.saurik.com Git - wxWidgets.git/blob - src/gtk/brush.cpp
Added mising AddBitmapList in wxBitmap
[wxWidgets.git] / src / gtk / brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: brush.cpp
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifdef __GNUG__
12 #pragma implementation "brush.h"
13 #endif
14
15 #include "wx/brush.h"
16
17 //-----------------------------------------------------------------------------
18 // wxBrush
19 //-----------------------------------------------------------------------------
20
21 class wxBrushRefData: public wxObjectRefData
22 {
23 public:
24
25 wxBrushRefData(void);
26
27 int m_style;
28 wxBitmap m_stipple;
29 wxColour m_colour;
30 };
31
32 wxBrushRefData::wxBrushRefData(void)
33 {
34 m_style = 0;
35 }
36
37 //-----------------------------------------------------------------------------
38
39 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
40
41 IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
42
43 wxBrush::wxBrush(void)
44 {
45 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
46 }
47
48 wxBrush::wxBrush( const wxColour &colour, int style )
49 {
50 m_refData = new wxBrushRefData();
51 M_BRUSHDATA->m_style = style;
52 M_BRUSHDATA->m_colour = colour;
53
54 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
55 }
56
57 wxBrush::wxBrush( const wxString &colourName, int style )
58 {
59 m_refData = new wxBrushRefData();
60 M_BRUSHDATA->m_style = style;
61 M_BRUSHDATA->m_colour = colourName;
62
63 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
64 }
65
66 wxBrush::wxBrush( const wxBitmap &stippleBitmap )
67 {
68 m_refData = new wxBrushRefData();
69 M_BRUSHDATA->m_style = wxSTIPPLE;
70 M_BRUSHDATA->m_colour = *wxBLACK;
71 M_BRUSHDATA->m_stipple = stippleBitmap;
72
73 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
74 }
75
76 wxBrush::wxBrush( const wxBrush &brush )
77 {
78 Ref( brush );
79
80 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
81 }
82
83 wxBrush::wxBrush( const wxBrush *brush )
84 {
85 if (brush) Ref( *brush );
86
87 if (wxTheBrushList) wxTheBrushList->Append( this );
88 }
89
90 wxBrush::~wxBrush(void)
91 {
92 if (wxTheBrushList) wxTheBrushList->RemoveBrush( this );
93 }
94
95 wxBrush& wxBrush::operator = ( const wxBrush& brush )
96 {
97 if (*this == brush) return (*this);
98 Ref( brush );
99 return *this;
100 }
101
102 bool wxBrush::operator == ( const wxBrush& brush )
103 {
104 return m_refData == brush.m_refData;
105 }
106
107 bool wxBrush::operator != ( const wxBrush& brush )
108 {
109 return m_refData != brush.m_refData;
110 }
111
112 bool wxBrush::Ok(void) const
113 {
114 return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
115 }
116
117 int wxBrush::GetStyle(void) const
118 {
119 return M_BRUSHDATA->m_style;
120 }
121
122 wxColour &wxBrush::GetColour(void) const
123 {
124 return M_BRUSHDATA->m_colour;
125 }
126
127 wxBitmap *wxBrush::GetStipple(void) const
128 {
129 return &M_BRUSHDATA->m_stipple;
130 }
131
132