]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/brush.cpp
Removed a few old wxDebugMsg (now wxLogDebug)
[wxWidgets.git] / src / gtk1 / brush.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: brush.cpp
3// Purpose:
4// Author: Robert Roebling
f96aa4d9 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
c801d85f
KB
7// Licence: wxWindows licence
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "brush.h"
12#endif
13
14#include "wx/brush.h"
15
16//-----------------------------------------------------------------------------
17// wxBrush
18//-----------------------------------------------------------------------------
19
20class wxBrushRefData: public wxObjectRefData
21{
22 public:
8bbe427f
VZ
23
24 wxBrushRefData();
e55ad60e 25 wxBrushRefData( const wxBrushRefData& data );
8bbe427f 26
c801d85f
KB
27 int m_style;
28 wxBitmap m_stipple;
29 wxColour m_colour;
30};
31
8bbe427f 32wxBrushRefData::wxBrushRefData()
c801d85f
KB
33{
34 m_style = 0;
ff7b1510 35}
c801d85f 36
e55ad60e
RR
37wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
38{
39 m_style = data.m_style;
40 m_stipple = data.m_stipple;
41 m_colour = data.m_colour;
42}
43
c801d85f
KB
44//-----------------------------------------------------------------------------
45
46#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
47
48IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
49
8bbe427f 50wxBrush::wxBrush()
c801d85f
KB
51{
52 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 53}
c801d85f 54
debe6624 55wxBrush::wxBrush( const wxColour &colour, int style )
c801d85f
KB
56{
57 m_refData = new wxBrushRefData();
58 M_BRUSHDATA->m_style = style;
59 M_BRUSHDATA->m_colour = colour;
8bbe427f 60
c801d85f 61 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 62}
c801d85f 63
c801d85f
KB
64wxBrush::wxBrush( const wxBitmap &stippleBitmap )
65{
66 m_refData = new wxBrushRefData();
67 M_BRUSHDATA->m_style = wxSTIPPLE;
68 M_BRUSHDATA->m_colour = *wxBLACK;
69 M_BRUSHDATA->m_stipple = stippleBitmap;
8bbe427f 70
c801d85f 71 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 72}
c801d85f
KB
73
74wxBrush::wxBrush( const wxBrush &brush )
75{
76 Ref( brush );
c801d85f 77
8bbe427f 78 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 79}
c801d85f 80
8bbe427f 81wxBrush::~wxBrush()
c801d85f
KB
82{
83 if (wxTheBrushList) wxTheBrushList->RemoveBrush( this );
ff7b1510 84}
c801d85f
KB
85
86wxBrush& wxBrush::operator = ( const wxBrush& brush )
87{
8bbe427f
VZ
88 if (*this == brush) return (*this);
89 Ref( brush );
90 return *this;
ff7b1510 91}
8bbe427f 92
c801d85f
KB
93bool wxBrush::operator == ( const wxBrush& brush )
94{
8bbe427f 95 return m_refData == brush.m_refData;
ff7b1510 96}
c801d85f
KB
97
98bool wxBrush::operator != ( const wxBrush& brush )
99{
8bbe427f 100 return m_refData != brush.m_refData;
ff7b1510 101}
c801d85f 102
8bbe427f 103bool wxBrush::Ok() const
c801d85f
KB
104{
105 return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
ff7b1510 106}
c801d85f 107
8bbe427f 108int wxBrush::GetStyle() const
c801d85f 109{
e55ad60e
RR
110 if (m_refData == NULL)
111 {
112 wxFAIL_MSG( "invalid brush" );
113 return 0;
114 }
115
c801d85f 116 return M_BRUSHDATA->m_style;
ff7b1510 117}
c801d85f 118
8bbe427f 119wxColour &wxBrush::GetColour() const
c801d85f 120{
e55ad60e
RR
121 if (m_refData == NULL)
122 {
123 wxFAIL_MSG( "invalid brush" );
124 return wxNullColour;
125 }
8bbe427f 126
c801d85f 127 return M_BRUSHDATA->m_colour;
ff7b1510 128}
c801d85f 129
8bbe427f 130wxBitmap *wxBrush::GetStipple() const
c801d85f 131{
e55ad60e
RR
132 if (m_refData == NULL)
133 {
134 wxFAIL_MSG( "invalid brush" );
135 return &wxNullBitmap;
136 }
8bbe427f 137
c801d85f 138 return &M_BRUSHDATA->m_stipple;
ff7b1510 139}
c801d85f 140
e55ad60e
RR
141void wxBrush::SetColour( const wxColour& col )
142{
143 Unshare();
144 M_BRUSHDATA->m_colour = col;
145}
146
e55ad60e
RR
147void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
148{
149 Unshare();
150 M_BRUSHDATA->m_colour.Set( r, g, b );
151}
152
153void wxBrush::SetStyle( int style )
154{
155 Unshare();
156 M_BRUSHDATA->m_style = style;
157}
158
159void wxBrush::SetStipple( const wxBitmap& stipple )
160{
161 Unshare();
162 M_BRUSHDATA->m_stipple = stipple;
163}
164
8bbe427f 165void wxBrush::Unshare()
e55ad60e
RR
166{
167 if (!m_refData)
168 {
169 m_refData = new wxBrushRefData();
170 }
171 else
172 {
173 wxBrushRefData* ref = new wxBrushRefData( *(wxBrushRefData*)m_refData );
174 UnRef();
175 m_refData = ref;
176 }
177}
c801d85f 178