]> git.saurik.com Git - wxWidgets.git/blame - src/motif/pen.cpp
fix for toolbar radio buttons event generation
[wxWidgets.git] / src / motif / pen.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
7ecb8b06 2// Name: src/motif/pen.cpp
4bb6408c
JS
3// Purpose: wxPen
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
7ecb8b06 9// Licence: wxWindows licence
4bb6408c
JS
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{
4bb6408c
JS
51}
52
53wxPen::~wxPen()
54{
4bb6408c
JS
55}
56
57// Should implement Create
58wxPen::wxPen(const wxColour& col, int Width, int Style)
59{
60 m_refData = new wxPenRefData;
7ecb8b06 61
4bb6408c
JS
62 M_PENDATA->m_colour = col;
63 M_PENDATA->m_width = Width;
64 M_PENDATA->m_style = Style;
65 M_PENDATA->m_join = wxJOIN_ROUND ;
66 M_PENDATA->m_cap = wxCAP_ROUND ;
67 M_PENDATA->m_nbDash = 0 ;
236a9de3 68 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
7ecb8b06 69
4bb6408c 70 RealizeResource();
4bb6408c
JS
71}
72
73wxPen::wxPen(const wxBitmap& stipple, int Width)
74{
75 m_refData = new wxPenRefData;
7ecb8b06 76
4bb6408c
JS
77 M_PENDATA->m_stipple = stipple;
78 M_PENDATA->m_width = Width;
79 M_PENDATA->m_style = wxSTIPPLE;
80 M_PENDATA->m_join = wxJOIN_ROUND ;
81 M_PENDATA->m_cap = wxCAP_ROUND ;
82 M_PENDATA->m_nbDash = 0 ;
236a9de3 83 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
7ecb8b06 84
4bb6408c 85 RealizeResource();
4bb6408c
JS
86}
87
4bb6408c
JS
88void wxPen::Unshare()
89{
2d120f83
JS
90 // Don't change shared data
91 if (!m_refData)
4bb6408c 92 {
2d120f83
JS
93 m_refData = new wxPenRefData();
94 }
4bb6408c
JS
95 else
96 {
2d120f83
JS
97 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
98 UnRef();
99 m_refData = ref;
100 }
4bb6408c
JS
101}
102
103void wxPen::SetColour(const wxColour& col)
104{
105 Unshare();
7ecb8b06 106
4bb6408c 107 M_PENDATA->m_colour = col;
7ecb8b06 108
4bb6408c
JS
109 RealizeResource();
110}
111
e4a81a2e 112void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
4bb6408c
JS
113{
114 Unshare();
7ecb8b06 115
4bb6408c 116 M_PENDATA->m_colour.Set(r, g, b);
7ecb8b06 117
4bb6408c
JS
118 RealizeResource();
119}
120
121void wxPen::SetWidth(int Width)
122{
123 Unshare();
7ecb8b06 124
4bb6408c 125 M_PENDATA->m_width = Width;
7ecb8b06 126
4bb6408c
JS
127 RealizeResource();
128}
129
130void wxPen::SetStyle(int Style)
131{
132 Unshare();
7ecb8b06 133
4bb6408c 134 M_PENDATA->m_style = Style;
7ecb8b06 135
4bb6408c
JS
136 RealizeResource();
137}
138
139void wxPen::SetStipple(const wxBitmap& Stipple)
140{
141 Unshare();
7ecb8b06 142
4bb6408c
JS
143 M_PENDATA->m_stipple = Stipple;
144 M_PENDATA->m_style = wxSTIPPLE;
7ecb8b06 145
4bb6408c
JS
146 RealizeResource();
147}
148
149void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
150{
151 Unshare();
7ecb8b06 152
4bb6408c 153 M_PENDATA->m_nbDash = nb_dashes;
236a9de3 154 M_PENDATA->m_dash = (wxMOTIFDash *)Dash;
7ecb8b06 155
4bb6408c
JS
156 RealizeResource();
157}
158
159void wxPen::SetJoin(int Join)
160{
161 Unshare();
7ecb8b06 162
4bb6408c 163 M_PENDATA->m_join = Join;
7ecb8b06 164
4bb6408c
JS
165 RealizeResource();
166}
167
168void wxPen::SetCap(int Cap)
169{
170 Unshare();
7ecb8b06 171
4bb6408c 172 M_PENDATA->m_cap = Cap;
7ecb8b06 173
4bb6408c
JS
174 RealizeResource();
175}
176
177bool wxPen::RealizeResource()
178{
dfc54541
JS
179 // Nothing more to do
180 return TRUE;
4bb6408c
JS
181}
182