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