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