]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/pen.cpp
merged MapBitmap() from 2.2 branch
[wxWidgets.git] / src / motif / pen.cpp
... / ...
CommitLineData
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
20IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
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 ;
29 m_dash = (wxMOTIFDash*)NULL;
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;
41}
42
43wxPenRefData::~wxPenRefData()
44{
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;
65
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 ;
72 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
73
74 RealizeResource();
75
76 if (wxThePenList)
77 wxThePenList->AddPen(this);
78}
79
80wxPen::wxPen(const wxBitmap& stipple, int Width)
81{
82 m_refData = new wxPenRefData;
83
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 ;
90 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
91
92 RealizeResource();
93
94 if ( wxThePenList )
95 wxThePenList->AddPen(this);
96}
97
98void wxPen::Unshare()
99{
100 // Don't change shared data
101 if (!m_refData)
102 {
103 m_refData = new wxPenRefData();
104 }
105 else
106 {
107 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
108 UnRef();
109 m_refData = ref;
110 }
111}
112
113void wxPen::SetColour(const wxColour& col)
114{
115 Unshare();
116
117 M_PENDATA->m_colour = col;
118
119 RealizeResource();
120}
121
122void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
123{
124 Unshare();
125
126 M_PENDATA->m_colour.Set(r, g, b);
127
128 RealizeResource();
129}
130
131void wxPen::SetWidth(int Width)
132{
133 Unshare();
134
135 M_PENDATA->m_width = Width;
136
137 RealizeResource();
138}
139
140void wxPen::SetStyle(int Style)
141{
142 Unshare();
143
144 M_PENDATA->m_style = Style;
145
146 RealizeResource();
147}
148
149void wxPen::SetStipple(const wxBitmap& Stipple)
150{
151 Unshare();
152
153 M_PENDATA->m_stipple = Stipple;
154 M_PENDATA->m_style = wxSTIPPLE;
155
156 RealizeResource();
157}
158
159void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
160{
161 Unshare();
162
163 M_PENDATA->m_nbDash = nb_dashes;
164 M_PENDATA->m_dash = (wxMOTIFDash *)Dash;
165
166 RealizeResource();
167}
168
169void wxPen::SetJoin(int Join)
170{
171 Unshare();
172
173 M_PENDATA->m_join = Join;
174
175 RealizeResource();
176}
177
178void wxPen::SetCap(int Cap)
179{
180 Unshare();
181
182 M_PENDATA->m_cap = Cap;
183
184 RealizeResource();
185}
186
187bool wxPen::RealizeResource()
188{
189 // Nothing more to do
190 return TRUE;
191}
192