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