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