]> git.saurik.com Git - wxWidgets.git/blob - src/x11/brush.cpp
fix unused vars for watcom
[wxWidgets.git] / src / x11 / brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/brush.cpp
3 // Purpose: wxBrush
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 17/09/98
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "brush.h"
14 #endif
15
16 #include "wx/setup.h"
17 #include "wx/utils.h"
18 #include "wx/brush.h"
19 #include "wx/colour.h"
20
21 //-----------------------------------------------------------------------------
22 // wxBrush
23 //-----------------------------------------------------------------------------
24
25 class wxBrushRefData: public wxObjectRefData
26 {
27 public:
28 wxBrushRefData()
29 {
30 m_style = 0;
31 }
32
33 wxBrushRefData( const wxBrushRefData& data )
34 {
35 m_style = data.m_style;
36 m_stipple = data.m_stipple;
37 m_colour = data.m_colour;
38 }
39
40 bool operator == (const wxBrushRefData& data) const
41 {
42 return (m_style == data.m_style &&
43 m_stipple == data.m_stipple &&
44 m_colour == data.m_colour);
45 }
46
47 int m_style;
48 wxColour m_colour;
49 wxBitmap m_stipple;
50 };
51
52 //-----------------------------------------------------------------------------
53
54 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
55
56 IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
57
58 wxBrush::wxBrush( const wxColour &colour, int style )
59 {
60 m_refData = new wxBrushRefData();
61 M_BRUSHDATA->m_style = style;
62 M_BRUSHDATA->m_colour = colour;
63 }
64
65 wxBrush::wxBrush( const wxBitmap &stippleBitmap )
66 {
67 m_refData = new wxBrushRefData();
68 M_BRUSHDATA->m_colour = *wxBLACK;
69
70 M_BRUSHDATA->m_stipple = stippleBitmap;
71
72 if (M_BRUSHDATA->m_stipple.GetMask())
73 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
74 else
75 M_BRUSHDATA->m_style = wxSTIPPLE;
76 }
77
78 wxBrush::~wxBrush()
79 {
80 // m_refData unrefed in ~wxObject
81 }
82
83 wxObjectRefData *wxBrush::CreateRefData() const
84 {
85 return new wxBrushRefData;
86 }
87
88 wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
89 {
90 return new wxBrushRefData(*(wxBrushRefData *)data);
91 }
92
93 bool wxBrush::operator == ( const wxBrush& brush ) const
94 {
95 if (m_refData == brush.m_refData) return TRUE;
96
97 if (!m_refData || !brush.m_refData) return FALSE;
98
99 return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
100 }
101
102 int wxBrush::GetStyle() const
103 {
104 if (m_refData == NULL)
105 {
106 wxFAIL_MSG( wxT("invalid brush") );
107 return 0;
108 }
109
110 return M_BRUSHDATA->m_style;
111 }
112
113 wxColour &wxBrush::GetColour() const
114 {
115 if (m_refData == NULL)
116 {
117 wxFAIL_MSG( wxT("invalid brush") );
118 return wxNullColour;
119 }
120
121 return M_BRUSHDATA->m_colour;
122 }
123
124 wxBitmap *wxBrush::GetStipple() const
125 {
126 if (m_refData == NULL)
127 {
128 wxFAIL_MSG( wxT("invalid brush") );
129 return &wxNullBitmap;
130 }
131
132 return &M_BRUSHDATA->m_stipple;
133 }
134
135 void wxBrush::SetColour( const wxColour& col )
136 {
137 AllocExclusive();
138
139 M_BRUSHDATA->m_colour = col;
140 }
141
142 void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
143 {
144 AllocExclusive();
145
146 M_BRUSHDATA->m_colour.Set( r, g, b );
147 }
148
149 void wxBrush::SetStyle( int style )
150 {
151 AllocExclusive();
152
153 M_BRUSHDATA->m_style = style;
154 }
155
156 void wxBrush::SetStipple( const wxBitmap& stipple )
157 {
158 AllocExclusive();
159
160 M_BRUSHDATA->m_stipple = stipple;
161 if (M_BRUSHDATA->m_stipple.GetMask())
162 {
163 M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
164 }
165 else
166 {
167 M_BRUSHDATA->m_style = wxSTIPPLE;
168 }
169 }