]> git.saurik.com Git - wxWidgets.git/blame - src/mac/pen.cpp
made SetDirectory() work, minor code cleanup (much is left to do)
[wxWidgets.git] / src / mac / 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)
9f081f02 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;
64
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 ;
e9576ca5
SC
72
73 RealizeResource();
e9576ca5
SC
74}
75
76wxPen::wxPen(const wxBitmap& stipple, int Width)
77{
78 m_refData = new wxPenRefData;
79
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 ;
e9576ca5
SC
87
88 RealizeResource();
e9576ca5
SC
89}
90
91void wxPen::Unshare()
92{
93 // Don't change shared data
94 if (!m_refData)
95 {
96 m_refData = new wxPenRefData();
97 }
98 else
99 {
100 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
101 UnRef();
102 m_refData = ref;
103 }
104}
105
106void wxPen::SetColour(const wxColour& col)
107{
108 Unshare();
109
110 M_PENDATA->m_colour = col;
111
112 RealizeResource();
113}
114
115void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
116{
117 Unshare();
118
119 M_PENDATA->m_colour.Set(r, g, b);
120
121 RealizeResource();
122}
123
124void wxPen::SetWidth(int Width)
125{
126 Unshare();
127
128 M_PENDATA->m_width = Width;
129
130 RealizeResource();
131}
132
133void wxPen::SetStyle(int Style)
134{
135 Unshare();
136
137 M_PENDATA->m_style = Style;
138
139 RealizeResource();
140}
141
142void wxPen::SetStipple(const wxBitmap& Stipple)
143{
144 Unshare();
145
146 M_PENDATA->m_stipple = Stipple;
147 M_PENDATA->m_style = wxSTIPPLE;
148
149 RealizeResource();
150}
151
152void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
153{
154 Unshare();
155
156 M_PENDATA->m_nbDash = nb_dashes;
2f1ae414 157 M_PENDATA->m_dash = (wxDash *)Dash;
e9576ca5
SC
158
159 RealizeResource();
160}
161
162void wxPen::SetJoin(int Join)
163{
164 Unshare();
165
166 M_PENDATA->m_join = Join;
167
168 RealizeResource();
169}
170
171void wxPen::SetCap(int Cap)
172{
173 Unshare();
174
175 M_PENDATA->m_cap = Cap;
176
177 RealizeResource();
178}
179
180bool wxPen::RealizeResource()
181{
0b014ec7
SC
182 // nothing to do here for mac
183 return TRUE;
e9576ca5
SC
184}
185
186