]>
Commit | Line | Data |
---|---|---|
e9576ca5 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: pen.cpp | |
3 | // Purpose: wxPen | |
a31a5f85 | 4 | // Author: Stefan Csomor |
e9576ca5 | 5 | // Modified by: |
a31a5f85 | 6 | // Created: 1998-01-01 |
e9576ca5 | 7 | // RCS-ID: $Id$ |
a31a5f85 | 8 | // Copyright: (c) Stefan Csomor |
65571936 | 9 | // Licence: wxWindows licence |
e9576ca5 SC |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
3d1a4878 | 12 | #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) |
e9576ca5 SC |
13 | #pragma implementation "pen.h" |
14 | #endif | |
15 | ||
3d1a4878 SC |
16 | #include "wx/wxprec.h" |
17 | ||
e9576ca5 SC |
18 | #include "wx/utils.h" |
19 | #include "wx/pen.h" | |
20 | ||
e9576ca5 | 21 | IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) |
e9576ca5 SC |
22 | |
23 | wxPenRefData::wxPenRefData() | |
24 | { | |
25 | m_style = wxSOLID; | |
26 | m_width = 1; | |
27 | m_join = wxJOIN_ROUND ; | |
28 | m_cap = wxCAP_ROUND ; | |
29 | m_nbDash = 0 ; | |
2f1ae414 | 30 | m_dash = 0 ; |
e9576ca5 SC |
31 | } |
32 | ||
33 | wxPenRefData::wxPenRefData(const wxPenRefData& data) | |
e40298d5 | 34 | : wxGDIRefData() |
e9576ca5 SC |
35 | { |
36 | m_style = data.m_style; | |
37 | m_width = data.m_width; | |
38 | m_join = data.m_join; | |
39 | m_cap = data.m_cap; | |
40 | m_nbDash = data.m_nbDash; | |
41 | m_dash = data.m_dash; | |
42 | m_colour = data.m_colour; | |
e9576ca5 SC |
43 | } |
44 | ||
45 | wxPenRefData::~wxPenRefData() | |
46 | { | |
e9576ca5 SC |
47 | } |
48 | ||
49 | // Pens | |
50 | ||
51 | wxPen::wxPen() | |
52 | { | |
e9576ca5 SC |
53 | } |
54 | ||
55 | wxPen::~wxPen() | |
56 | { | |
e9576ca5 SC |
57 | } |
58 | ||
59 | // Should implement Create | |
60 | wxPen::wxPen(const wxColour& col, int Width, int Style) | |
61 | { | |
62 | m_refData = new wxPenRefData; | |
e40298d5 | 63 | |
e9576ca5 SC |
64 | M_PENDATA->m_colour = col; |
65 | M_PENDATA->m_width = Width; | |
66 | M_PENDATA->m_style = Style; | |
67 | M_PENDATA->m_join = wxJOIN_ROUND ; | |
68 | M_PENDATA->m_cap = wxCAP_ROUND ; | |
69 | M_PENDATA->m_nbDash = 0 ; | |
2f1ae414 | 70 | M_PENDATA->m_dash = 0 ; |
e40298d5 | 71 | |
e9576ca5 | 72 | RealizeResource(); |
e9576ca5 SC |
73 | } |
74 | ||
75 | wxPen::wxPen(const wxBitmap& stipple, int Width) | |
76 | { | |
77 | m_refData = new wxPenRefData; | |
e40298d5 | 78 | |
e9576ca5 SC |
79 | M_PENDATA->m_stipple = stipple; |
80 | M_PENDATA->m_width = Width; | |
81 | M_PENDATA->m_style = wxSTIPPLE; | |
82 | M_PENDATA->m_join = wxJOIN_ROUND ; | |
83 | M_PENDATA->m_cap = wxCAP_ROUND ; | |
84 | M_PENDATA->m_nbDash = 0 ; | |
2f1ae414 | 85 | M_PENDATA->m_dash = 0 ; |
e40298d5 | 86 | |
e9576ca5 | 87 | RealizeResource(); |
e9576ca5 SC |
88 | } |
89 | ||
90 | void wxPen::Unshare() | |
91 | { | |
e40298d5 JS |
92 | // Don't change shared data |
93 | if (!m_refData) | |
e9576ca5 | 94 | { |
e40298d5 JS |
95 | m_refData = new wxPenRefData(); |
96 | } | |
e9576ca5 SC |
97 | else |
98 | { | |
e40298d5 JS |
99 | wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); |
100 | UnRef(); | |
101 | m_refData = ref; | |
102 | } | |
e9576ca5 SC |
103 | } |
104 | ||
105 | void wxPen::SetColour(const wxColour& col) | |
106 | { | |
107 | Unshare(); | |
e40298d5 | 108 | |
e9576ca5 | 109 | M_PENDATA->m_colour = col; |
e40298d5 | 110 | |
e9576ca5 SC |
111 | RealizeResource(); |
112 | } | |
113 | ||
114 | void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) | |
115 | { | |
116 | Unshare(); | |
e40298d5 | 117 | |
e9576ca5 | 118 | M_PENDATA->m_colour.Set(r, g, b); |
e40298d5 | 119 | |
e9576ca5 SC |
120 | RealizeResource(); |
121 | } | |
122 | ||
123 | void wxPen::SetWidth(int Width) | |
124 | { | |
125 | Unshare(); | |
e40298d5 | 126 | |
e9576ca5 | 127 | M_PENDATA->m_width = Width; |
e40298d5 | 128 | |
e9576ca5 SC |
129 | RealizeResource(); |
130 | } | |
131 | ||
132 | void wxPen::SetStyle(int Style) | |
133 | { | |
134 | Unshare(); | |
e40298d5 | 135 | |
e9576ca5 | 136 | M_PENDATA->m_style = Style; |
e40298d5 | 137 | |
e9576ca5 SC |
138 | RealizeResource(); |
139 | } | |
140 | ||
141 | void wxPen::SetStipple(const wxBitmap& Stipple) | |
142 | { | |
143 | Unshare(); | |
e40298d5 | 144 | |
e9576ca5 SC |
145 | M_PENDATA->m_stipple = Stipple; |
146 | M_PENDATA->m_style = wxSTIPPLE; | |
e40298d5 | 147 | |
e9576ca5 SC |
148 | RealizeResource(); |
149 | } | |
150 | ||
151 | void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) | |
152 | { | |
153 | Unshare(); | |
e40298d5 | 154 | |
e9576ca5 | 155 | M_PENDATA->m_nbDash = nb_dashes; |
2f1ae414 | 156 | M_PENDATA->m_dash = (wxDash *)Dash; |
e40298d5 | 157 | |
e9576ca5 SC |
158 | RealizeResource(); |
159 | } | |
160 | ||
161 | void wxPen::SetJoin(int Join) | |
162 | { | |
163 | Unshare(); | |
e40298d5 | 164 | |
e9576ca5 | 165 | M_PENDATA->m_join = Join; |
e40298d5 | 166 | |
e9576ca5 SC |
167 | RealizeResource(); |
168 | } | |
169 | ||
170 | void wxPen::SetCap(int Cap) | |
171 | { | |
172 | Unshare(); | |
e40298d5 | 173 | |
e9576ca5 | 174 | M_PENDATA->m_cap = Cap; |
e40298d5 | 175 | |
e9576ca5 SC |
176 | RealizeResource(); |
177 | } | |
178 | ||
179 | bool wxPen::RealizeResource() | |
180 | { | |
e40298d5 | 181 | // nothing to do here for mac |
0b014ec7 | 182 | return TRUE; |
e9576ca5 SC |
183 | } |
184 | ||
185 |