]> git.saurik.com Git - wxWidgets.git/blame - src/mac/brush.cpp
correction to maintain data array in synch with string array
[wxWidgets.git] / src / mac / brush.cpp
CommitLineData
e9576ca5
SC
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
2f1ae414 20#if !USE_SHARED_LIBRARIES
e9576ca5 21IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
2f1ae414 22#endif
e9576ca5
SC
23
24wxBrushRefData::wxBrushRefData()
25{
26 m_style = wxSOLID;
e9576ca5
SC
27}
28
29wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
30{
31 m_style = data.m_style;
32 m_stipple = data.m_stipple;
33 m_colour = data.m_colour;
e9576ca5
SC
34}
35
36wxBrushRefData::~wxBrushRefData()
37{
e9576ca5
SC
38}
39
40// Brushes
41wxBrush::wxBrush()
42{
43 if ( wxTheBrushList )
44 wxTheBrushList->AddBrush(this);
45}
46
47wxBrush::~wxBrush()
48{
49 if ( wxTheBrushList )
50 wxTheBrushList->RemoveBrush(this);
51}
52
53wxBrush::wxBrush(const wxColour& col, int Style)
54{
55 m_refData = new wxBrushRefData;
56
57 M_BRUSHDATA->m_colour = col;
58 M_BRUSHDATA->m_style = Style;
59
60 RealizeResource();
61
62 if ( wxTheBrushList )
63 wxTheBrushList->AddBrush(this);
64}
65
66wxBrush::wxBrush(const wxBitmap& stipple)
67{
68 m_refData = new wxBrushRefData;
69
70 M_BRUSHDATA->m_style = wxSTIPPLE;
71 M_BRUSHDATA->m_stipple = stipple;
72
73 RealizeResource();
74
75 if ( wxTheBrushList )
76 wxTheBrushList->AddBrush(this);
77}
78
79void wxBrush::Unshare()
80{
81 // Don't change shared data
82 if (!m_refData)
83 {
84 m_refData = new wxBrushRefData();
85 }
86 else
87 {
88 wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
89 UnRef();
90 m_refData = ref;
91 }
92}
93
94void wxBrush::SetColour(const wxColour& col)
95{
96 Unshare();
97
98 M_BRUSHDATA->m_colour = col;
99
100 RealizeResource();
101}
102
103void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
104{
105 Unshare();
106
107 M_BRUSHDATA->m_colour.Set(r, g, b);
108
109 RealizeResource();
110}
111
112void wxBrush::SetStyle(int Style)
113{
114 Unshare();
115
116 M_BRUSHDATA->m_style = Style;
117
118 RealizeResource();
119}
120
121void wxBrush::SetStipple(const wxBitmap& Stipple)
122{
123 Unshare();
124
125 M_BRUSHDATA->m_stipple = Stipple;
126
127 RealizeResource();
128}
129
130bool wxBrush::RealizeResource()
131{
519cb848 132 return TRUE;
e9576ca5
SC
133}
134