]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: brush.cpp | |
3 | // Purpose: wxBrush | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
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 | if ( wxTheBrushList ) | |
44 | wxTheBrushList->AddBrush(this); | |
45 | } | |
46 | ||
47 | wxBrush::~wxBrush() | |
48 | { | |
49 | if ( wxTheBrushList ) | |
50 | wxTheBrushList->RemoveBrush(this); | |
51 | } | |
52 | ||
53 | wxBrush::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 | ||
66 | wxBrush::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 | ||
79 | void 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 | ||
94 | void wxBrush::SetColour(const wxColour& col) | |
95 | { | |
96 | Unshare(); | |
97 | ||
98 | M_BRUSHDATA->m_colour = col; | |
99 | ||
100 | RealizeResource(); | |
101 | } | |
102 | ||
103 | void 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 | ||
112 | void wxBrush::SetStyle(int Style) | |
113 | { | |
114 | Unshare(); | |
115 | ||
116 | M_BRUSHDATA->m_style = Style; | |
117 | ||
118 | RealizeResource(); | |
119 | } | |
120 | ||
121 | void wxBrush::SetStipple(const wxBitmap& Stipple) | |
122 | { | |
123 | Unshare(); | |
124 | ||
125 | M_BRUSHDATA->m_stipple = Stipple; | |
126 | ||
127 | RealizeResource(); | |
128 | } | |
129 | ||
130 | bool wxBrush::RealizeResource() | |
131 | { | |
132 | // Nothing more to do | |
133 | return TRUE; | |
134 | } | |
135 |