]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/brush.cpp
Fix wxHtmlHelpData::SetTempDir() to behave correctly without trailing slash.
[wxWidgets.git] / src / gtk1 / brush.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
3cbab641 2// Name: src/gtk1/brush.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
01111366 5// Copyright: (c) 1998 Robert Roebling
65571936 6// Licence: wxWindows licence
c801d85f
KB
7/////////////////////////////////////////////////////////////////////////////
8
14f355c2
VS
9// For compilers that support precompilation, includes "wx.h".
10#include "wx/wxprec.h"
11
c801d85f 12#include "wx/brush.h"
7cf41a5d
WS
13
14#ifndef WX_PRECOMP
15 #include "wx/colour.h"
16#endif
c801d85f 17
20e05ffb 18#include <gdk/gdk.h>
83624f79 19
c801d85f
KB
20//-----------------------------------------------------------------------------
21// wxBrush
22//-----------------------------------------------------------------------------
23
8f884a0d 24class wxBrushRefData: public wxGDIRefData
c801d85f 25{
58c837a4 26public:
c89f5c02
RR
27 wxBrushRefData()
28 {
1d57de48 29 m_style = wxBRUSHSTYLE_INVALID;
c89f5c02 30 }
46562151 31
c89f5c02 32 wxBrushRefData( const wxBrushRefData& data )
8f884a0d 33 : wxGDIRefData()
c89f5c02
RR
34 {
35 m_style = data.m_style;
36 m_stipple = data.m_stipple;
37 m_colour = data.m_colour;
38 }
46562151 39
c89f5c02
RR
40 bool operator == (const wxBrushRefData& data) const
41 {
42 return (m_style == data.m_style &&
a3ab1c18 43 m_stipple.IsSameAs(data.m_stipple) &&
c89f5c02
RR
44 m_colour == data.m_colour);
45 }
46562151 46
3e6858cd
FM
47 wxBrushStyle m_style;
48 wxColour m_colour;
49 wxBitmap m_stipple;
c801d85f
KB
50};
51
c801d85f
KB
52//-----------------------------------------------------------------------------
53
54#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
55
56IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
57
3e6858cd 58wxBrush::wxBrush( const wxColour &colour, wxBrushStyle style )
c801d85f 59{
58c837a4
RR
60 m_refData = new wxBrushRefData();
61 M_BRUSHDATA->m_style = style;
62 M_BRUSHDATA->m_colour = colour;
ff7b1510 63}
c801d85f 64
ac3688c0
FM
65#if FUTURE_WXWIN_COMPATIBILITY_3_0
66wxBrush::wxBrush(const wxColour& col, int style)
67{
68 m_refData = new wxBrushRefData;
69 M_BRUSHDATA->m_style = (wxBrushStyle)style;
1d57de48 70 M_BRUSHDATA->m_colour = col;
ac3688c0
FM
71}
72#endif
73
c801d85f
KB
74wxBrush::wxBrush( const wxBitmap &stippleBitmap )
75{
58c837a4 76 m_refData = new wxBrushRefData();
58c837a4 77 M_BRUSHDATA->m_colour = *wxBLACK;
7ecb8b06 78
58c837a4 79 M_BRUSHDATA->m_stipple = stippleBitmap;
e1208c31 80
de2d2cdc 81 if (M_BRUSHDATA->m_stipple.GetMask())
1d57de48 82 M_BRUSHDATA->m_style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
7ecb8b06 83 else
1d57de48 84 M_BRUSHDATA->m_style = wxBRUSHSTYLE_STIPPLE_MASK;
ff7b1510 85}
c801d85f 86
8bbe427f 87wxBrush::~wxBrush()
c801d85f 88{
c89f5c02 89 // m_refData unrefed in ~wxObject
ff7b1510 90}
c801d85f 91
8f884a0d 92wxGDIRefData *wxBrush::CreateGDIRefData() const
c801d85f 93{
c89f5c02 94 return new wxBrushRefData;
ff7b1510 95}
c801d85f 96
8f884a0d 97wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const
c801d85f 98{
c89f5c02 99 return new wxBrushRefData(*(wxBrushRefData *)data);
ff7b1510 100}
c801d85f 101
c89f5c02 102bool wxBrush::operator == ( const wxBrush& brush ) const
c801d85f 103{
46562151
WS
104 if (m_refData == brush.m_refData) return true;
105
106 if (!m_refData || !brush.m_refData) return false;
107
c89f5c02 108 return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
ff7b1510 109}
c801d85f 110
3e6858cd 111wxBrushStyle wxBrush::GetStyle() const
c801d85f 112{
a1b806b9 113 wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") );
e55ad60e 114
58c837a4 115 return M_BRUSHDATA->m_style;
ff7b1510 116}
c801d85f 117
231b9591 118wxColour wxBrush::GetColour() const
c801d85f 119{
a1b806b9 120 wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid brush") );
8bbe427f 121
58c837a4 122 return M_BRUSHDATA->m_colour;
ff7b1510 123}
c801d85f 124
8bbe427f 125wxBitmap *wxBrush::GetStipple() const
c801d85f 126{
a1b806b9 127 wxCHECK_MSG( IsOk(), NULL, wxT("invalid brush") );
8bbe427f 128
58c837a4 129 return &M_BRUSHDATA->m_stipple;
ff7b1510 130}
c801d85f 131
e55ad60e
RR
132void wxBrush::SetColour( const wxColour& col )
133{
c89f5c02 134 AllocExclusive();
46562151 135
58c837a4 136 M_BRUSHDATA->m_colour = col;
e55ad60e
RR
137}
138
1a1498c0 139void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
e55ad60e 140{
c89f5c02 141 AllocExclusive();
46562151 142
58c837a4 143 M_BRUSHDATA->m_colour.Set( r, g, b );
e55ad60e
RR
144}
145
3e6858cd 146void wxBrush::SetStyle( wxBrushStyle style )
e55ad60e 147{
c89f5c02 148 AllocExclusive();
46562151 149
58c837a4 150 M_BRUSHDATA->m_style = style;
e55ad60e
RR
151}
152
153void wxBrush::SetStipple( const wxBitmap& stipple )
154{
c89f5c02 155 AllocExclusive();
46562151 156
58c837a4 157 M_BRUSHDATA->m_stipple = stipple;
de2d2cdc 158 if (M_BRUSHDATA->m_stipple.GetMask())
1d57de48 159 M_BRUSHDATA->m_style = wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE;
7ecb8b06 160 else
1d57de48 161 M_BRUSHDATA->m_style = wxBRUSHSTYLE_STIPPLE_MASK;
e55ad60e 162}