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