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