]> git.saurik.com Git - wxWidgets.git/blame - src/qt/pen.cpp
Added lots of files. Enough now so that all wxHTML samples link.
[wxWidgets.git] / src / qt / pen.cpp
CommitLineData
7c78e7c7
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: pen.cpp
01b2eeec
KB
3// Purpose: wxPen
4// Author: AUTHOR
5// Modified by:
6// Created: ??/??/98
7// RCS-ID: $Id$
8// Copyright: (c) AUTHOR
7c78e7c7
RR
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
7c78e7c7
RR
12#ifdef __GNUG__
13#pragma implementation "pen.h"
14#endif
15
01b2eeec
KB
16#include "wx/setup.h"
17#include "wx/utils.h"
7c78e7c7
RR
18#include "wx/pen.h"
19
01b2eeec
KB
20#if !USE_SHARED_LIBRARIES
21IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
22#endif
7c78e7c7 23
01b2eeec 24wxPenRefData::wxPenRefData()
7c78e7c7 25{
01b2eeec
KB
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 ;
32/* TODO: null data
33 m_hPen = 0;
34*/
35}
7c78e7c7 36
01b2eeec
KB
37wxPenRefData::wxPenRefData(const wxPenRefData& data)
38{
39 m_style = data.m_style;
40 m_width = data.m_width;
41 m_join = data.m_join;
42 m_cap = data.m_cap;
43 m_nbDash = data.m_nbDash;
44 m_dash = data.m_dash;
45 m_colour = data.m_colour;
46/* TODO: null data
47 m_hPen = 0;
48*/
49}
7c78e7c7 50
01b2eeec
KB
51wxPenRefData::~wxPenRefData()
52{
53 // TODO: delete data
54}
7c78e7c7 55
01b2eeec 56// Pens
7c78e7c7 57
01b2eeec 58wxPen::wxPen()
7c78e7c7 59{
01b2eeec
KB
60 if ( wxThePenList )
61 wxThePenList->AddPen(this);
62}
7c78e7c7 63
01b2eeec 64wxPen::~wxPen()
7c78e7c7 65{
01b2eeec
KB
66 if (wxThePenList)
67 wxThePenList->RemovePen(this);
68}
7c78e7c7 69
01b2eeec
KB
70// Should implement Create
71wxPen::wxPen(const wxColour& col, int Width, int Style)
7c78e7c7 72{
01b2eeec 73 m_refData = new wxPenRefData;
7c78e7c7 74
01b2eeec
KB
75 M_PENDATA->m_colour = col;
76 M_PENDATA->m_width = Width;
77 M_PENDATA->m_style = Style;
78 M_PENDATA->m_join = wxJOIN_ROUND ;
79 M_PENDATA->m_cap = wxCAP_ROUND ;
80 M_PENDATA->m_nbDash = 0 ;
81 M_PENDATA->m_dash = 0 ;
7c78e7c7 82
01b2eeec 83 RealizeResource();
7c78e7c7 84
01b2eeec
KB
85 if ( wxThePenList )
86 wxThePenList->AddPen(this);
87}
7c78e7c7 88
01b2eeec 89wxPen::wxPen(const wxBitmap& stipple, int Width)
7c78e7c7 90{
01b2eeec
KB
91 m_refData = new wxPenRefData;
92
93 M_PENDATA->m_stipple = stipple;
94 M_PENDATA->m_width = Width;
95 M_PENDATA->m_style = wxSTIPPLE;
96 M_PENDATA->m_join = wxJOIN_ROUND ;
97 M_PENDATA->m_cap = wxCAP_ROUND ;
98 M_PENDATA->m_nbDash = 0 ;
99 M_PENDATA->m_dash = 0 ;
7c78e7c7 100
01b2eeec
KB
101 RealizeResource();
102
103 if ( wxThePenList )
104 wxThePenList->AddPen(this);
105}
106
107wxPen::wxPen(const wxString& col, int Width, int Style)
7c78e7c7 108{
01b2eeec
KB
109 m_refData = new wxPenRefData;
110
111 M_PENDATA->m_colour = col;
112 M_PENDATA->m_width = Width;
113 M_PENDATA->m_style = Style;
114 M_PENDATA->m_join = wxJOIN_ROUND ;
115 M_PENDATA->m_cap = wxCAP_ROUND ;
116 M_PENDATA->m_nbDash = 0 ;
117 M_PENDATA->m_dash = 0 ;
7c78e7c7 118
01b2eeec
KB
119 RealizeResource();
120
121 if ( wxThePenList )
122 wxThePenList->AddPen(this);
123}
124
125void wxPen::Unshare()
7c78e7c7 126{
01b2eeec
KB
127 // Don't change shared data
128 if (!m_refData)
129 {
130 m_refData = new wxPenRefData();
131 }
132 else
133 {
134 wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
135 UnRef();
136 m_refData = ref;
137 }
138}
7c78e7c7 139
01b2eeec 140void wxPen::SetColour(const wxColour& col)
7c78e7c7 141{
01b2eeec 142 Unshare();
7c78e7c7 143
01b2eeec
KB
144 M_PENDATA->m_colour = col;
145
146 RealizeResource();
147}
7c78e7c7 148
01b2eeec 149void wxPen::SetColour(const wxString& col)
7c78e7c7 150{
01b2eeec 151 Unshare();
7c78e7c7 152
01b2eeec
KB
153 M_PENDATA->m_colour = col;
154
155 RealizeResource();
156}
7c78e7c7 157
01b2eeec 158void wxPen::SetColour(const unsigned char r, const unsigned char g, const unsigned char b)
7c78e7c7 159{
01b2eeec 160 Unshare();
7c78e7c7 161
01b2eeec
KB
162 M_PENDATA->m_colour.Set(r, g, b);
163
164 RealizeResource();
165}
7c78e7c7 166
01b2eeec 167void wxPen::SetWidth(int Width)
7c78e7c7 168{
01b2eeec
KB
169 Unshare();
170
171 M_PENDATA->m_width = Width;
7c78e7c7 172
01b2eeec
KB
173 RealizeResource();
174}
7c78e7c7 175
01b2eeec 176void wxPen::SetStyle(int Style)
7c78e7c7 177{
01b2eeec
KB
178 Unshare();
179
180 M_PENDATA->m_style = Style;
7c78e7c7 181
01b2eeec
KB
182 RealizeResource();
183}
7c78e7c7 184
01b2eeec 185void wxPen::SetStipple(const wxBitmap& Stipple)
7c78e7c7 186{
01b2eeec 187 Unshare();
7c78e7c7 188
01b2eeec
KB
189 M_PENDATA->m_stipple = Stipple;
190 M_PENDATA->m_style = wxSTIPPLE;
191
192 RealizeResource();
193}
7c78e7c7 194
01b2eeec 195void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
7c78e7c7 196{
01b2eeec 197 Unshare();
7c78e7c7 198
01b2eeec
KB
199 M_PENDATA->m_nbDash = nb_dashes;
200 M_PENDATA->m_dash = (wxDash *)Dash;
201
202 RealizeResource();
203}
7c78e7c7 204
01b2eeec 205void wxPen::SetJoin(int Join)
7c78e7c7 206{
01b2eeec 207 Unshare();
7c78e7c7 208
01b2eeec 209 M_PENDATA->m_join = Join;
7c78e7c7 210
01b2eeec
KB
211 RealizeResource();
212}
7c78e7c7 213
01b2eeec 214void wxPen::SetCap(int Cap)
7c78e7c7 215{
01b2eeec 216 Unshare();
7c78e7c7 217
01b2eeec
KB
218 M_PENDATA->m_cap = Cap;
219
220 RealizeResource();
221}
7c78e7c7 222
01b2eeec 223bool wxPen::RealizeResource()
7c78e7c7 224{
01b2eeec
KB
225 // TODO: create actual pen
226 return FALSE;
227}
228
7c78e7c7 229