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