]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/pen.cpp
Patch from Hartwig for wxMac implementation
[wxWidgets.git] / src / mac / carbon / pen.cpp
CommitLineData
e9576ca5 1/////////////////////////////////////////////////////////////////////////////
46562151 2// Name: src/mac/carbon/pen.cpp
e9576ca5 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
46562151 9// Licence: wxWindows licence
e9576ca5
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
e9576ca5
SC
14#include "wx/pen.h"
15
de6185e2
WS
16#ifndef WX_PRECOMP
17 #include "wx/utils.h"
18#endif
19
e9576ca5 20IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
e9576ca5
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 ;
2f1ae414 29 m_dash = 0 ;
e9576ca5
SC
30}
31
32wxPenRefData::wxPenRefData(const wxPenRefData& data)
e40298d5 33: wxGDIRefData()
e9576ca5
SC
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;
e9576ca5
SC
42}
43
44wxPenRefData::~wxPenRefData()
45{
e9576ca5
SC
46}
47
48// Pens
49
50wxPen::wxPen()
51{
e9576ca5
SC
52}
53
54wxPen::~wxPen()
55{
e9576ca5
SC
56}
57
58// Should implement Create
59wxPen::wxPen(const wxColour& col, int Width, int Style)
60{
61 m_refData = new wxPenRefData;
46562151 62
e9576ca5
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 ;
2f1ae414 69 M_PENDATA->m_dash = 0 ;
46562151 70
e9576ca5 71 RealizeResource();
e9576ca5
SC
72}
73
74wxPen::wxPen(const wxBitmap& stipple, int Width)
75{
76 m_refData = new wxPenRefData;
46562151 77
e9576ca5
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 ;
2f1ae414 84 M_PENDATA->m_dash = 0 ;
46562151 85
e9576ca5 86 RealizeResource();
e9576ca5
SC
87}
88
83dcd781 89void wxPen::Unshare()
e9576ca5 90{
83dcd781
PC
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 }
e9576ca5
SC
102}
103
104void wxPen::SetColour(const wxColour& col)
105{
83dcd781 106 Unshare();
46562151 107
e9576ca5 108 M_PENDATA->m_colour = col;
46562151 109
e9576ca5
SC
110 RealizeResource();
111}
112
1a1498c0 113void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
e9576ca5 114{
83dcd781 115 Unshare();
46562151 116
e9576ca5 117 M_PENDATA->m_colour.Set(r, g, b);
46562151 118
e9576ca5
SC
119 RealizeResource();
120}
121
122void wxPen::SetWidth(int Width)
123{
83dcd781 124 Unshare();
46562151 125
e9576ca5 126 M_PENDATA->m_width = Width;
46562151 127
e9576ca5
SC
128 RealizeResource();
129}
130
131void wxPen::SetStyle(int Style)
132{
83dcd781 133 Unshare();
46562151 134
e9576ca5 135 M_PENDATA->m_style = Style;
46562151 136
e9576ca5
SC
137 RealizeResource();
138}
139
140void wxPen::SetStipple(const wxBitmap& Stipple)
141{
83dcd781 142 Unshare();
46562151 143
e9576ca5
SC
144 M_PENDATA->m_stipple = Stipple;
145 M_PENDATA->m_style = wxSTIPPLE;
46562151 146
e9576ca5
SC
147 RealizeResource();
148}
149
150void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
151{
83dcd781 152 Unshare();
46562151 153
e9576ca5 154 M_PENDATA->m_nbDash = nb_dashes;
2f1ae414 155 M_PENDATA->m_dash = (wxDash *)Dash;
46562151 156
e9576ca5
SC
157 RealizeResource();
158}
159
160void wxPen::SetJoin(int Join)
161{
83dcd781 162 Unshare();
46562151 163
e9576ca5 164 M_PENDATA->m_join = Join;
46562151 165
e9576ca5
SC
166 RealizeResource();
167}
168
169void wxPen::SetCap(int Cap)
170{
83dcd781 171 Unshare();
46562151 172
e9576ca5 173 M_PENDATA->m_cap = Cap;
46562151 174
e9576ca5
SC
175 RealizeResource();
176}
177
178bool wxPen::RealizeResource()
179{
e40298d5 180 // nothing to do here for mac
46562151 181 return true;
e9576ca5 182}