]>
Commit | Line | Data |
---|---|---|
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 | 29 | class wxBrushRefData : public wxGDIRefData |
b3c86150 VS |
30 | { |
31 | public: | |
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") ); |
b3c86150 VS |
51 | style = wxSOLID; |
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 | ||
65 | IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject) | |
66 | ||
3e6858cd | 67 | wxBrush::wxBrush(const wxColour &colour, wxBrushStyle style) |
b3c86150 VS |
68 | { |
69 | m_refData = new wxBrushRefData(colour, style); | |
70 | } | |
71 | ||
72 | wxBrush::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 | ||
79 | bool wxBrush::operator==(const wxBrush& brush) const | |
80 | { | |
81 | #warning "this is incorrect (MGL too)" | |
82 | return m_refData == brush.m_refData; | |
83 | } | |
84 | ||
3e6858cd | 85 | wxBrushStyle wxBrush::GetStyle() const |
b3c86150 VS |
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 | ||
96 | wxColour& 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 | ||
107 | wxBitmap *wxBrush::GetStipple() const | |
108 | { | |
ec5006bd | 109 | wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") ); |
b3c86150 VS |
110 | return &wxNullBitmap; |
111 | } | |
112 | ||
113 | void wxBrush::SetColour(const wxColour& col) | |
114 | { | |
115 | AllocExclusive(); | |
116 | M_BRUSHDATA->m_colour = col; | |
117 | } | |
118 | ||
119 | void 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 | ||
3e6858cd | 125 | void wxBrush::SetStyle(wxBrushStyle style) |
b3c86150 VS |
126 | { |
127 | AllocExclusive(); | |
128 | M_BRUSHDATA->SetStyle(style); | |
129 | } | |
130 | ||
131 | void wxBrush::SetStipple(const wxBitmap& WXUNUSED(stipple)) | |
132 | { | |
ec5006bd | 133 | wxFAIL_MSG( wxT("brushes with stipple bitmaps not implemented") ); |
b3c86150 VS |
134 | } |
135 | ||
8f884a0d | 136 | wxGDIRefData *wxBrush::CreateGDIRefData() const |
b3c86150 VS |
137 | { |
138 | return new wxBrushRefData; | |
139 | } | |
140 | ||
8f884a0d | 141 | wxGDIRefData *wxBrush::CloneGDIRefData(const wxGDIRefData *data) const |
b3c86150 VS |
142 | { |
143 | return new wxBrushRefData(*(wxBrushRefData *)data); | |
144 | } |