]> git.saurik.com Git - wxWidgets.git/blame - src/motif/pen.cpp
More Motif additions: mdi and sashtest samples now just about work!
[wxWidgets.git] / src / motif / pen.cpp
CommitLineData
4bb6408c
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: pen.cpp
3// Purpose: wxPen
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
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
20#if !USE_SHARED_LIBRARIES
21IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
22#endif
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 ;
31 m_dash = 0 ;
4bb6408c
JS
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;
4bb6408c
JS
43}
44
45wxPenRefData::~wxPenRefData()
46{
4bb6408c
JS
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 ;
74 M_PENDATA->m_dash = 0 ;
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 ;
92 M_PENDATA->m_dash = 0 ;
93
94 RealizeResource();
95
96 if ( wxThePenList )
97 wxThePenList->AddPen(this);
98}
99
100wxPen::wxPen(const wxString& col, int Width, int Style)
101{
102 m_refData = new wxPenRefData;
103
104 M_PENDATA->m_colour = col;
105 M_PENDATA->m_width = Width;
106 M_PENDATA->m_style = Style;
107 M_PENDATA->m_join = wxJOIN_ROUND ;
108 M_PENDATA->m_cap = wxCAP_ROUND ;
109 M_PENDATA->m_nbDash = 0 ;
110 M_PENDATA->m_dash = 0 ;
111
112 RealizeResource();
113
114 if ( wxThePenList )
115 wxThePenList->AddPen(this);
116}
117
118void wxPen::Unshare()
119{
120 // Don't change shared data
121 if (!m_refData)
122 {
123 m_refData = new wxPenRefData();
124 }
125 else
126 {
127 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
128 UnRef();
129 m_refData = ref;
130 }
131}
132
133void wxPen::SetColour(const wxColour& col)
134{
135 Unshare();
136
137 M_PENDATA->m_colour = col;
138
139 RealizeResource();
140}
141
142void wxPen::SetColour(const wxString& col)
143{
144 Unshare();
145
146 M_PENDATA->m_colour = col;
147
148 RealizeResource();
149}
150
151void wxPen::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
152{
153 Unshare();
154
155 M_PENDATA->m_colour.Set(r, g, b);
156
157 RealizeResource();
158}
159
160void wxPen::SetWidth(int Width)
161{
162 Unshare();
163
164 M_PENDATA->m_width = Width;
165
166 RealizeResource();
167}
168
169void wxPen::SetStyle(int Style)
170{
171 Unshare();
172
173 M_PENDATA->m_style = Style;
174
175 RealizeResource();
176}
177
178void wxPen::SetStipple(const wxBitmap& Stipple)
179{
180 Unshare();
181
182 M_PENDATA->m_stipple = Stipple;
183 M_PENDATA->m_style = wxSTIPPLE;
184
185 RealizeResource();
186}
187
188void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
189{
190 Unshare();
191
192 M_PENDATA->m_nbDash = nb_dashes;
193 M_PENDATA->m_dash = (wxDash *)Dash;
194
195 RealizeResource();
196}
197
198void wxPen::SetJoin(int Join)
199{
200 Unshare();
201
202 M_PENDATA->m_join = Join;
203
204 RealizeResource();
205}
206
207void wxPen::SetCap(int Cap)
208{
209 Unshare();
210
211 M_PENDATA->m_cap = Cap;
212
213 RealizeResource();
214}
215
216bool wxPen::RealizeResource()
217{
dfc54541
JS
218 // Nothing more to do
219 return TRUE;
4bb6408c
JS
220}
221
222