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