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