]> git.saurik.com Git - wxWidgets.git/blame - src/x11/pen.cpp
don't override INSTALL as install path is made absolute in configure
[wxWidgets.git] / src / x11 / pen.cpp
CommitLineData
83df96d6 1/////////////////////////////////////////////////////////////////////////////
7266b672 2// Name: src/x11/pen.cpp
83df96d6
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
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
74dc5eb6
RR
20//-----------------------------------------------------------------------------
21// wxPen
22//-----------------------------------------------------------------------------
83df96d6 23
74dc5eb6 24class wxPenRefData: public wxObjectRefData
83df96d6 25{
74dc5eb6
RR
26public:
27 wxPenRefData()
28 {
29 m_width = 1;
30 m_style = wxSOLID;
31 m_joinStyle = wxJOIN_ROUND;
32 m_capStyle = wxCAP_ROUND;
33 m_dash = (wxX11Dash*) NULL;
34 m_countDashes = 0;
35 }
36
37 wxPenRefData( const wxPenRefData& data )
38 {
39 m_style = data.m_style;
40 m_width = data.m_width;
41 m_joinStyle = data.m_joinStyle;
42 m_capStyle = data.m_capStyle;
43 m_colour = data.m_colour;
44 m_countDashes = data.m_countDashes;
45/*
46 if (data.m_dash) TODO
47 m_dash = new
48*/
49 m_dash = data.m_dash;
50 }
83df96d6 51
74dc5eb6
RR
52 bool operator == (const wxPenRefData& data) const
53 {
54 return (m_style == data.m_style &&
55 m_width == data.m_width &&
56 m_joinStyle == data.m_joinStyle &&
57 m_capStyle == data.m_capStyle &&
58 m_colour == data.m_colour);
59 }
60
61 int m_width;
62 int m_style;
63 int m_joinStyle;
64 int m_capStyle;
65 wxColour m_colour;
66 int m_countDashes;
67 wxX11Dash *m_dash;
68};
83df96d6 69
74dc5eb6
RR
70//-----------------------------------------------------------------------------
71
72#define M_PENDATA ((wxPenRefData *)m_refData)
83df96d6 73
74dc5eb6 74IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
83df96d6 75
74dc5eb6 76wxPen::wxPen( const wxColour &colour, int width, int style )
83df96d6 77{
74dc5eb6
RR
78 m_refData = new wxPenRefData();
79 M_PENDATA->m_width = width;
80 M_PENDATA->m_style = style;
81 M_PENDATA->m_colour = colour;
83df96d6
JS
82}
83
84wxPen::~wxPen()
85{
74dc5eb6 86 // m_refData unrefed in ~wxObject
83df96d6
JS
87}
88
74dc5eb6 89wxObjectRefData *wxPen::CreateRefData() const
83df96d6 90{
74dc5eb6 91 return new wxPenRefData;
83df96d6
JS
92}
93
74dc5eb6 94wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
83df96d6 95{
74dc5eb6 96 return new wxPenRefData(*(wxPenRefData *)data);
83df96d6
JS
97}
98
74dc5eb6 99bool wxPen::operator == ( const wxPen& pen ) const
83df96d6 100{
74dc5eb6
RR
101 if (m_refData == pen.m_refData) return TRUE;
102
103 if (!m_refData || !pen.m_refData) return FALSE;
104
105 return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
83df96d6
JS
106}
107
74dc5eb6 108void wxPen::SetColour( const wxColour &colour )
83df96d6 109{
74dc5eb6
RR
110 AllocExclusive();
111
112 M_PENDATA->m_colour = colour;
83df96d6
JS
113}
114
74dc5eb6 115void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
83df96d6 116{
74dc5eb6
RR
117 AllocExclusive();
118
119 M_PENDATA->m_countDashes = number_of_dashes;
120 M_PENDATA->m_dash = (wxX11Dash *)dash; // TODO
121}
83df96d6 122
74dc5eb6
RR
123void wxPen::SetColour( int red, int green, int blue )
124{
125 AllocExclusive();
126
127 M_PENDATA->m_colour.Set( red, green, blue );
83df96d6
JS
128}
129
74dc5eb6 130void wxPen::SetCap( int capStyle )
83df96d6 131{
74dc5eb6
RR
132 AllocExclusive();
133
134 M_PENDATA->m_capStyle = capStyle;
135}
83df96d6 136
74dc5eb6
RR
137void wxPen::SetJoin( int joinStyle )
138{
139 AllocExclusive();
140
141 M_PENDATA->m_joinStyle = joinStyle;
142}
83df96d6 143
74dc5eb6
RR
144void wxPen::SetStyle( int style )
145{
146 AllocExclusive();
147
148 M_PENDATA->m_style = style;
83df96d6
JS
149}
150
74dc5eb6 151void wxPen::SetWidth( int width )
83df96d6 152{
74dc5eb6
RR
153 AllocExclusive();
154
155 M_PENDATA->m_width = width;
156}
83df96d6 157
74dc5eb6
RR
158int wxPen::GetDashes( wxDash **ptr ) const
159{
160 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
161 return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
162}
83df96d6 163
74dc5eb6
RR
164int wxPen::GetDashCount() const
165{
166 return (M_PENDATA->m_countDashes);
83df96d6
JS
167}
168
74dc5eb6 169wxDash* wxPen::GetDash() const
83df96d6 170{
74dc5eb6
RR
171 return (wxDash*)M_PENDATA->m_dash;
172}
83df96d6 173
74dc5eb6
RR
174int wxPen::GetCap() const
175{
176 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
83df96d6 177
74dc5eb6 178 return M_PENDATA->m_capStyle;
83df96d6
JS
179}
180
74dc5eb6 181int wxPen::GetJoin() const
83df96d6 182{
74dc5eb6 183 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
83df96d6 184
74dc5eb6 185 return M_PENDATA->m_joinStyle;
83df96d6
JS
186}
187
74dc5eb6 188int wxPen::GetStyle() const
83df96d6 189{
74dc5eb6 190 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
83df96d6 191
74dc5eb6 192 return M_PENDATA->m_style;
83df96d6
JS
193}
194
74dc5eb6 195int wxPen::GetWidth() const
83df96d6 196{
74dc5eb6 197 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
83df96d6 198
74dc5eb6 199 return M_PENDATA->m_width;
83df96d6
JS
200}
201
74dc5eb6 202wxColour &wxPen::GetColour() const
83df96d6 203{
74dc5eb6 204 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
83df96d6 205
74dc5eb6
RR
206 return M_PENDATA->m_colour;
207}