]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/brush.cpp
Add more _T() in asserts...
[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
83624f79
RR
16#include "gdk/gdk.h"
17
c801d85f
KB
18//-----------------------------------------------------------------------------
19// wxBrush
20//-----------------------------------------------------------------------------
21
22class wxBrushRefData: public wxObjectRefData
23{
24 public:
8bbe427f
VZ
25
26 wxBrushRefData();
e55ad60e 27 wxBrushRefData( const wxBrushRefData& data );
8bbe427f 28
c801d85f
KB
29 int m_style;
30 wxBitmap m_stipple;
31 wxColour m_colour;
32};
33
8bbe427f 34wxBrushRefData::wxBrushRefData()
c801d85f
KB
35{
36 m_style = 0;
ff7b1510 37}
c801d85f 38
e55ad60e
RR
39wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
40{
41 m_style = data.m_style;
42 m_stipple = data.m_stipple;
43 m_colour = data.m_colour;
44}
45
c801d85f
KB
46//-----------------------------------------------------------------------------
47
48#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
49
50IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
51
8bbe427f 52wxBrush::wxBrush()
c801d85f
KB
53{
54 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 55}
c801d85f 56
debe6624 57wxBrush::wxBrush( const wxColour &colour, int style )
c801d85f
KB
58{
59 m_refData = new wxBrushRefData();
60 M_BRUSHDATA->m_style = style;
61 M_BRUSHDATA->m_colour = colour;
8bbe427f 62
c801d85f 63 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 64}
c801d85f 65
c801d85f
KB
66wxBrush::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;
8bbe427f 72
c801d85f 73 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 74}
c801d85f
KB
75
76wxBrush::wxBrush( const wxBrush &brush )
77{
78 Ref( brush );
c801d85f 79
8bbe427f 80 if (wxTheBrushList) wxTheBrushList->AddBrush( this );
ff7b1510 81}
c801d85f 82
8bbe427f 83wxBrush::~wxBrush()
c801d85f
KB
84{
85 if (wxTheBrushList) wxTheBrushList->RemoveBrush( this );
ff7b1510 86}
c801d85f
KB
87
88wxBrush& wxBrush::operator = ( const wxBrush& brush )
89{
8bbe427f
VZ
90 if (*this == brush) return (*this);
91 Ref( brush );
92 return *this;
ff7b1510 93}
8bbe427f 94
c801d85f
KB
95bool wxBrush::operator == ( const wxBrush& brush )
96{
8bbe427f 97 return m_refData == brush.m_refData;
ff7b1510 98}
c801d85f
KB
99
100bool wxBrush::operator != ( const wxBrush& brush )
101{
8bbe427f 102 return m_refData != brush.m_refData;
ff7b1510 103}
c801d85f 104
8bbe427f 105bool wxBrush::Ok() const
c801d85f
KB
106{
107 return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
ff7b1510 108}
c801d85f 109
8bbe427f 110int wxBrush::GetStyle() const
c801d85f 111{
e55ad60e
RR
112 if (m_refData == NULL)
113 {
62bd5cf0 114 wxFAIL_MSG( _T("invalid brush") );
e55ad60e
RR
115 return 0;
116 }
117
c801d85f 118 return M_BRUSHDATA->m_style;
ff7b1510 119}
c801d85f 120
8bbe427f 121wxColour &wxBrush::GetColour() const
c801d85f 122{
e55ad60e
RR
123 if (m_refData == NULL)
124 {
62bd5cf0 125 wxFAIL_MSG( _T("invalid brush") );
e55ad60e
RR
126 return wxNullColour;
127 }
8bbe427f 128
c801d85f 129 return M_BRUSHDATA->m_colour;
ff7b1510 130}
c801d85f 131
8bbe427f 132wxBitmap *wxBrush::GetStipple() const
c801d85f 133{
e55ad60e
RR
134 if (m_refData == NULL)
135 {
62bd5cf0 136 wxFAIL_MSG( _T("invalid brush") );
e55ad60e
RR
137 return &wxNullBitmap;
138 }
8bbe427f 139
c801d85f 140 return &M_BRUSHDATA->m_stipple;
ff7b1510 141}
c801d85f 142
e55ad60e
RR
143void wxBrush::SetColour( const wxColour& col )
144{
145 Unshare();
146 M_BRUSHDATA->m_colour = col;
147}
148
e55ad60e
RR
149void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
150{
151 Unshare();
152 M_BRUSHDATA->m_colour.Set( r, g, b );
153}
154
155void wxBrush::SetStyle( int style )
156{
157 Unshare();
158 M_BRUSHDATA->m_style = style;
159}
160
161void wxBrush::SetStipple( const wxBitmap& stipple )
162{
163 Unshare();
164 M_BRUSHDATA->m_stipple = stipple;
165}
166
8bbe427f 167void wxBrush::Unshare()
e55ad60e
RR
168{
169 if (!m_refData)
170 {
171 m_refData = new wxBrushRefData();
172 }
173 else
174 {
175 wxBrushRefData* ref = new wxBrushRefData( *(wxBrushRefData*)m_refData );
176 UnRef();
177 m_refData = ref;
178 }
179}
c801d85f 180