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