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