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