]> git.saurik.com Git - wxWidgets.git/blob - src/motif/pen.cpp
don't inherit the controls colours from the parent - at least for the background...
[wxWidgets.git] / src / motif / pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/motif/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 IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
21
22 wxPenRefData::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
32 wxPenRefData::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
43 wxPenRefData::~wxPenRefData()
44 {
45 }
46
47 // Pens
48
49 wxPen::wxPen()
50 {
51 }
52
53 wxPen::~wxPen()
54 {
55 }
56
57 // Should implement Create
58 wxPen::wxPen(const wxColour& col, int Width, int Style)
59 {
60 m_refData = new wxPenRefData;
61
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 ;
68 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
69
70 RealizeResource();
71 }
72
73 wxPen::wxPen(const wxBitmap& stipple, int Width)
74 {
75 m_refData = new wxPenRefData;
76
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 ;
83 M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
84
85 RealizeResource();
86 }
87
88 void wxPen::Unshare()
89 {
90 // Don't change shared data
91 if (!m_refData)
92 {
93 m_refData = new wxPenRefData();
94 }
95 else
96 {
97 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
98 UnRef();
99 m_refData = ref;
100 }
101 }
102
103 void wxPen::SetColour(const wxColour& col)
104 {
105 Unshare();
106
107 M_PENDATA->m_colour = col;
108
109 RealizeResource();
110 }
111
112 void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
113 {
114 Unshare();
115
116 M_PENDATA->m_colour.Set(r, g, b);
117
118 RealizeResource();
119 }
120
121 void wxPen::SetWidth(int Width)
122 {
123 Unshare();
124
125 M_PENDATA->m_width = Width;
126
127 RealizeResource();
128 }
129
130 void wxPen::SetStyle(int Style)
131 {
132 Unshare();
133
134 M_PENDATA->m_style = Style;
135
136 RealizeResource();
137 }
138
139 void wxPen::SetStipple(const wxBitmap& Stipple)
140 {
141 Unshare();
142
143 M_PENDATA->m_stipple = Stipple;
144 M_PENDATA->m_style = wxSTIPPLE;
145
146 RealizeResource();
147 }
148
149 void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
150 {
151 Unshare();
152
153 M_PENDATA->m_nbDash = nb_dashes;
154 M_PENDATA->m_dash = (wxMOTIFDash *)Dash;
155
156 RealizeResource();
157 }
158
159 void wxPen::SetJoin(int Join)
160 {
161 Unshare();
162
163 M_PENDATA->m_join = Join;
164
165 RealizeResource();
166 }
167
168 void wxPen::SetCap(int Cap)
169 {
170 Unshare();
171
172 M_PENDATA->m_cap = Cap;
173
174 RealizeResource();
175 }
176
177 bool wxPen::RealizeResource()
178 {
179 // Nothing more to do
180 return TRUE;
181 }
182