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