]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/brush.cpp
include 'Version' in version string, it's what Apple apps do
[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:
32 wxBrushRefData(const wxColour& clr = wxNullColour, int style = wxSOLID)
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
b3c86150
VS
46 void SetStyle(int style)
47 {
e17cd59f 48 if ( style != wxSOLID && style != wxTRANSPARENT )
b3c86150 49 {
ec5006bd 50 wxFAIL_MSG( wxT("only wxSOLID and wxTRANSPARENT styles are supported") );
b3c86150
VS
51 style = wxSOLID;
52 }
53
54 m_style = style;
55 }
56
57 wxColour m_colour;
58 int m_style;
59};
60
61//-----------------------------------------------------------------------------
62
63#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
64
65IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
66
67wxBrush::wxBrush(const wxColour &colour, int style)
68{
69 m_refData = new wxBrushRefData(colour, style);
70}
71
72wxBrush::wxBrush(const wxBitmap &stippleBitmap)
73{
ec5006bd 74 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
b3c86150
VS
75
76 m_refData = new wxBrushRefData(*wxBLACK);
77}
78
79bool wxBrush::operator==(const wxBrush& brush) const
80{
81#warning "this is incorrect (MGL too)"
82 return m_refData == brush.m_refData;
83}
84
b3c86150
VS
85int wxBrush::GetStyle() const
86{
87 if (m_refData == NULL)
88 {
89 wxFAIL_MSG( wxT("invalid brush") );
90 return 0;
91 }
92
93 return M_BRUSHDATA->m_style;
94}
95
96wxColour& wxBrush::GetColour() const
97{
98 if (m_refData == NULL)
99 {
100 wxFAIL_MSG( wxT("invalid brush") );
101 return wxNullColour;
102 }
103
104 return M_BRUSHDATA->m_colour;
105}
106
107wxBitmap *wxBrush::GetStipple() const
108{
ec5006bd 109 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
b3c86150
VS
110 return &wxNullBitmap;
111}
112
113void wxBrush::SetColour(const wxColour& col)
114{
115 AllocExclusive();
116 M_BRUSHDATA->m_colour = col;
117}
118
119void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
120{
121 AllocExclusive();
122 M_BRUSHDATA->m_colour.Set(r, g, b);
123}
124
125void wxBrush::SetStyle(int style)
126{
127 AllocExclusive();
128 M_BRUSHDATA->SetStyle(style);
129}
130
131void wxBrush::SetStipple(const wxBitmap& WXUNUSED(stipple))
132{
ec5006bd 133 wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") );
b3c86150
VS
134}
135
8f884a0d 136wxGDIRefData *wxBrush::CreateGDIRefData() const
b3c86150
VS
137{
138 return new wxBrushRefData;
139}
140
8f884a0d 141wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
142{
143 return new wxBrushRefData(*(wxBrushRefData *)data);
144}