]> git.saurik.com Git - wxWidgets.git/blame - src/motif/pen.cpp
updates for swig generated code
[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
4bb6408c 20IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
4bb6408c
JS
21
22wxPenRefData::wxPenRefData()
23{
24 m_style = wxSOLID;
25 m_width = 1;
26 m_join = wxJOIN_ROUND ;
27 m_cap = wxCAP_ROUND ;
28 m_nbDash = 0 ;
236a9de3 29 m_dash = (wxMOTIFDash*)NULL;
4bb6408c
JS
30}
31
32wxPenRefData::wxPenRefData(const wxPenRefData& data)
33{
34 m_style = data.m_style;
35 m_width = data.m_width;
36 m_join = data.m_join;
37 m_cap = data.m_cap;
38 m_nbDash = data.m_nbDash;
39 m_dash = data.m_dash;
40 m_colour = data.m_colour;
4bb6408c
JS
41}
42
43wxPenRefData::~wxPenRefData()
44{
4bb6408c
JS
45}
46
47// Pens
48
49wxPen::wxPen()
50{
51 if ( wxThePenList )
52 wxThePenList->AddPen(this);
53}
54
55wxPen::~wxPen()
56{
57 if (wxThePenList)
58 wxThePenList->RemovePen(this);
59}
60
61// Should implement Create
62wxPen::wxPen(const wxColour& col, int Width, int Style)
63{
64 m_refData = new wxPenRefData;
2d120f83 65
4bb6408c
JS
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 ;
236a9de3 72 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
2d120f83 73
4bb6408c 74 RealizeResource();
2d120f83 75
112c5086 76 if (wxThePenList)
4bb6408c
JS
77 wxThePenList->AddPen(this);
78}
79
80wxPen::wxPen(const wxBitmap& stipple, int Width)
81{
82 m_refData = new wxPenRefData;
2d120f83 83
4bb6408c
JS
84 M_PENDATA->m_stipple = stipple;
85 M_PENDATA->m_width = Width;
86 M_PENDATA->m_style = wxSTIPPLE;
87 M_PENDATA->m_join = wxJOIN_ROUND ;
88 M_PENDATA->m_cap = wxCAP_ROUND ;
89 M_PENDATA->m_nbDash = 0 ;
236a9de3 90 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
2d120f83 91
4bb6408c 92 RealizeResource();
2d120f83 93
4bb6408c
JS
94 if ( wxThePenList )
95 wxThePenList->AddPen(this);
96}
97
4bb6408c
JS
98void wxPen::Unshare()
99{
2d120f83
JS
100 // Don't change shared data
101 if (!m_refData)
4bb6408c 102 {
2d120f83
JS
103 m_refData = new wxPenRefData();
104 }
4bb6408c
JS
105 else
106 {
2d120f83
JS
107 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
108 UnRef();
109 m_refData = ref;
110 }
4bb6408c
JS
111}
112
113void wxPen::SetColour(const wxColour& col)
114{
115 Unshare();
2d120f83 116
4bb6408c 117 M_PENDATA->m_colour = col;
2d120f83 118
4bb6408c
JS
119 RealizeResource();
120}
121
e4a81a2e 122void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
4bb6408c
JS
123{
124 Unshare();
2d120f83 125
4bb6408c 126 M_PENDATA->m_colour.Set(r, g, b);
2d120f83 127
4bb6408c
JS
128 RealizeResource();
129}
130
131void wxPen::SetWidth(int Width)
132{
133 Unshare();
2d120f83 134
4bb6408c 135 M_PENDATA->m_width = Width;
2d120f83 136
4bb6408c
JS
137 RealizeResource();
138}
139
140void wxPen::SetStyle(int Style)
141{
142 Unshare();
2d120f83 143
4bb6408c 144 M_PENDATA->m_style = Style;
2d120f83 145
4bb6408c
JS
146 RealizeResource();
147}
148
149void wxPen::SetStipple(const wxBitmap& Stipple)
150{
151 Unshare();
2d120f83 152
4bb6408c
JS
153 M_PENDATA->m_stipple = Stipple;
154 M_PENDATA->m_style = wxSTIPPLE;
2d120f83 155
4bb6408c
JS
156 RealizeResource();
157}
158
159void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
160{
161 Unshare();
2d120f83 162
4bb6408c 163 M_PENDATA->m_nbDash = nb_dashes;
236a9de3 164 M_PENDATA->m_dash = (wxMOTIFDash *)Dash;
2d120f83 165
4bb6408c
JS
166 RealizeResource();
167}
168
169void wxPen::SetJoin(int Join)
170{
171 Unshare();
2d120f83 172
4bb6408c 173 M_PENDATA->m_join = Join;
2d120f83 174
4bb6408c
JS
175 RealizeResource();
176}
177
178void wxPen::SetCap(int Cap)
179{
180 Unshare();
2d120f83 181
4bb6408c 182 M_PENDATA->m_cap = Cap;
2d120f83 183
4bb6408c
JS
184 RealizeResource();
185}
186
187bool wxPen::RealizeResource()
188{
dfc54541
JS
189 // Nothing more to do
190 return TRUE;
4bb6408c
JS
191}
192