]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/brush.cpp
Use string column identifiers with NSTableColumns in wxDataViewCtrl.
[wxWidgets.git] / src / dfb / brush.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/brush.cpp
3// Purpose: wxBrush class implementation
4// Author: Vaclav Slavik
5// Created: 2006-08-04
6// RCS-ID: $Id$
7// Copyright: (c) 2006 REA Elektronik GmbH
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#include "wx/brush.h"
19
20#ifndef WX_PRECOMP
21 #include "wx/colour.h"
22#endif
23
24
25//-----------------------------------------------------------------------------
26// wxBrush
27//-----------------------------------------------------------------------------
28
8f884a0d 29class wxBrushRefData : public wxGDIRefData
b3c86150
VS
30{
31public:
3e6858cd 32 wxBrushRefData(const wxColour& clr = wxNullColour, wxBrushStyle style = wxBRUSHSTYLE_SOLID)
b3c86150
VS
33 {
34 m_colour = clr;
35 SetStyle(style);
36 }
37
38 wxBrushRefData(const wxBrushRefData& data)
39 {
40 m_colour = data.m_colour;
41 m_style = data.m_style;
42 }
43
8f884a0d
VZ
44 virtual bool IsOk() const { return m_colour.IsOk(); }
45
3e6858cd 46 void SetStyle(wxBrushStyle style)
b3c86150 47 {
e17cd59f 48 if ( style != wxSOLID && style != wxTRANSPARENT )
b3c86150 49 {
ec5006bd 50 wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") );
4439f88a 51 style = wxBRUSHSTYLE_SOLID;
b3c86150
VS
52 }
53
54 m_style = style;
55 }
56
57 wxColour m_colour;
3e6858cd 58 wxBrushStyle m_style;
b3c86150
VS
59};
60
61//-----------------------------------------------------------------------------
62
63#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
64
65IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
66
3e6858cd 67wxBrush::wxBrush(const wxColour &colour, wxBrushStyle style)
b3c86150
VS
68{
69 m_refData = new wxBrushRefData(colour, style);
70}
71
ac3688c0
FM
72#if FUTURE_WXWIN_COMPATIBILITY_3_0
73wxBrush::wxBrush(const wxColour& col, int style)
74{
75 m_refData = new wxBrushRefData(col, (wxBrushStyle)style);
76}
77#endif
78
b3c86150
VS
79wxBrush::wxBrush(const wxBitmap &stippleBitmap)
80{
ec5006bd 81 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
b3c86150
VS
82
83 m_refData = new wxBrushRefData(*wxBLACK);
84}
85
86bool wxBrush::operator==(const wxBrush& brush) const
87{
88#warning "this is incorrect (MGL too)"
89 return m_refData == brush.m_refData;
90}
91
3e6858cd 92wxBrushStyle wxBrush::GetStyle() const
b3c86150 93{
a1b806b9 94 wxCHECK_MSG( IsOk(), wxBRUSHSTYLE_INVALID, wxT("invalid brush") );
b3c86150
VS
95
96 return M_BRUSHDATA->m_style;
97}
98
231b9591 99wxColour wxBrush::GetColour() const
b3c86150 100{
a1b806b9 101 wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid brush") );
b3c86150
VS
102
103 return M_BRUSHDATA->m_colour;
104}
105
106wxBitmap *wxBrush::GetStipple() const
107{
ec5006bd 108 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
b3c86150
VS
109 return &wxNullBitmap;
110}
111
112void wxBrush::SetColour(const wxColour& col)
113{
114 AllocExclusive();
115 M_BRUSHDATA->m_colour = col;
116}
117
118void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
119{
120 AllocExclusive();
121 M_BRUSHDATA->m_colour.Set(r, g, b);
122}
123
3e6858cd 124void wxBrush::SetStyle(wxBrushStyle style)
b3c86150
VS
125{
126 AllocExclusive();
127 M_BRUSHDATA->SetStyle(style);
128}
129
130void wxBrush::SetStipple(const wxBitmap& WXUNUSED(stipple))
131{
ec5006bd 132 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
b3c86150
VS
133}
134
8f884a0d 135wxGDIRefData *wxBrush::CreateGDIRefData() const
b3c86150
VS
136{
137 return new wxBrushRefData;
138}
139
8f884a0d 140wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
141{
142 return new wxBrushRefData(*(wxBrushRefData *)data);
143}