]> git.saurik.com Git - wxWidgets.git/blob - src/mac/carbon/brush.cpp
MS-DOS cross-compilation w/ DJGPP
[wxWidgets.git] / src / mac / carbon / brush.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: brush.cpp
3 // Purpose: wxBrush
4 // Author: AUTHOR
5 // Modified by:
6 // Created: ??/??/98
7 // RCS-ID: $Id$
8 // Copyright: (c) AUTHOR
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "brush.h"
14 #endif
15
16 #include "wx/setup.h"
17 #include "wx/utils.h"
18 #include "wx/brush.h"
19
20 #if !USE_SHARED_LIBRARIES
21 IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
22 #endif
23
24 wxBrushRefData::wxBrushRefData()
25 {
26 m_style = wxSOLID;
27 }
28
29 wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
30 {
31 m_style = data.m_style;
32 m_stipple = data.m_stipple;
33 m_colour = data.m_colour;
34 }
35
36 wxBrushRefData::~wxBrushRefData()
37 {
38 }
39
40 // Brushes
41 wxBrush::wxBrush()
42 {
43 }
44
45 wxBrush::~wxBrush()
46 {
47 }
48
49 wxBrush::wxBrush(const wxColour& col, int Style)
50 {
51 m_refData = new wxBrushRefData;
52
53 M_BRUSHDATA->m_colour = col;
54 M_BRUSHDATA->m_style = Style;
55
56 RealizeResource();
57 }
58
59 wxBrush::wxBrush(const wxBitmap& stipple)
60 {
61 m_refData = new wxBrushRefData;
62
63 M_BRUSHDATA->m_style = wxSTIPPLE;
64 M_BRUSHDATA->m_stipple = stipple;
65
66 RealizeResource();
67 }
68
69 void wxBrush::Unshare()
70 {
71 // Don't change shared data
72 if (!m_refData)
73 {
74 m_refData = new wxBrushRefData();
75 }
76 else
77 {
78 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
79 UnRef();
80 m_refData = ref;
81 }
82 }
83
84 void wxBrush::SetColour(const wxColour& col)
85 {
86 Unshare();
87
88 M_BRUSHDATA->m_colour = col;
89
90 RealizeResource();
91 }
92
93 void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
94 {
95 Unshare();
96
97 M_BRUSHDATA->m_colour.Set(r, g, b);
98
99 RealizeResource();
100 }
101
102 void wxBrush::SetStyle(int Style)
103 {
104 Unshare();
105
106 M_BRUSHDATA->m_style = Style;
107
108 RealizeResource();
109 }
110
111 void wxBrush::SetStipple(const wxBitmap& Stipple)
112 {
113 Unshare();
114
115 M_BRUSHDATA->m_stipple = Stipple;
116
117 RealizeResource();
118 }
119
120 bool wxBrush::RealizeResource()
121 {
122 return TRUE;
123 }
124