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