]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
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; | |
ff7b1510 | 35 | } |
c801d85f KB |
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 ); | |
ff7b1510 | 46 | } |
c801d85f | 47 | |
debe6624 | 48 | wxBrush::wxBrush( const wxColour &colour, int style ) |
c801d85f KB |
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 ); | |
ff7b1510 | 55 | } |
c801d85f | 56 | |
debe6624 | 57 | wxBrush::wxBrush( const wxString &colourName, int style ) |
c801d85f KB |
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 ); | |
ff7b1510 | 64 | } |
c801d85f KB |
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 ); | |
ff7b1510 | 74 | } |
c801d85f KB |
75 | |
76 | wxBrush::wxBrush( const wxBrush &brush ) | |
77 | { | |
78 | Ref( brush ); | |
79 | ||
80 | if (wxTheBrushList) wxTheBrushList->AddBrush( this ); | |
ff7b1510 | 81 | } |
c801d85f KB |
82 | |
83 | wxBrush::wxBrush( const wxBrush *brush ) | |
84 | { | |
85 | if (brush) Ref( *brush ); | |
86 | ||
87 | if (wxTheBrushList) wxTheBrushList->Append( this ); | |
ff7b1510 | 88 | } |
c801d85f KB |
89 | |
90 | wxBrush::~wxBrush(void) | |
91 | { | |
92 | if (wxTheBrushList) wxTheBrushList->RemoveBrush( this ); | |
ff7b1510 | 93 | } |
c801d85f KB |
94 | |
95 | wxBrush& wxBrush::operator = ( const wxBrush& brush ) | |
96 | { | |
97 | if (*this == brush) return (*this); | |
98 | Ref( brush ); | |
99 | return *this; | |
ff7b1510 | 100 | } |
c801d85f KB |
101 | |
102 | bool wxBrush::operator == ( const wxBrush& brush ) | |
103 | { | |
104 | return m_refData == brush.m_refData; | |
ff7b1510 | 105 | } |
c801d85f KB |
106 | |
107 | bool wxBrush::operator != ( const wxBrush& brush ) | |
108 | { | |
109 | return m_refData != brush.m_refData; | |
ff7b1510 | 110 | } |
c801d85f KB |
111 | |
112 | bool wxBrush::Ok(void) const | |
113 | { | |
114 | return ((m_refData) && M_BRUSHDATA->m_colour.Ok()); | |
ff7b1510 | 115 | } |
c801d85f KB |
116 | |
117 | int wxBrush::GetStyle(void) const | |
118 | { | |
119 | return M_BRUSHDATA->m_style; | |
ff7b1510 | 120 | } |
c801d85f KB |
121 | |
122 | wxColour &wxBrush::GetColour(void) const | |
123 | { | |
124 | return M_BRUSHDATA->m_colour; | |
ff7b1510 | 125 | } |
c801d85f KB |
126 | |
127 | wxBitmap *wxBrush::GetStipple(void) const | |
128 | { | |
129 | return &M_BRUSHDATA->m_stipple; | |
ff7b1510 | 130 | } |
c801d85f KB |
131 | |
132 |