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