]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/pen.cpp
1. handle Alt-F4 in wxUniv, not wxMGL
[wxWidgets.git] / src / gtk / pen.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: pen.cpp
3// Purpose:
4// Author: Robert Roebling
a81258be
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling
8bbe427f 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifdef __GNUG__
12#pragma implementation "pen.h"
13#endif
14
15#include "wx/pen.h"
16
5e7e9e1b 17#include <gdk/gdk.h>
83624f79 18
c801d85f
KB
19//-----------------------------------------------------------------------------
20// wxPen
21//-----------------------------------------------------------------------------
22
23class wxPenRefData: public wxObjectRefData
24{
907789a0 25public:
c89f5c02
RR
26 wxPenRefData()
27 {
28 m_width = 1;
29 m_style = wxSOLID;
30 m_joinStyle = wxJOIN_ROUND;
31 m_capStyle = wxCAP_ROUND;
32 m_dash = (wxGTKDash*) NULL;
33 m_countDashes = 0;
34 }
35
36 wxPenRefData( const wxPenRefData& data )
37 {
38 m_style = data.m_style;
39 m_width = data.m_width;
40 m_joinStyle = data.m_joinStyle;
41 m_capStyle = data.m_capStyle;
42 m_colour = data.m_colour;
43 m_countDashes = data.m_countDashes;
112c5086 44/*
c89f5c02
RR
45 if (data.m_dash) TODO
46 m_dash = new
112c5086 47*/
c89f5c02
RR
48 m_dash = data.m_dash;
49 }
50
51 bool operator == (const wxPenRefData& data) const
52 {
53 return (m_style == data.m_style &&
54 m_width == data.m_width &&
55 m_joinStyle == data.m_joinStyle &&
56 m_capStyle == data.m_capStyle &&
57 m_colour == data.m_colour);
58 }
59
60 int m_width;
61 int m_style;
62 int m_joinStyle;
63 int m_capStyle;
64 wxColour m_colour;
65 int m_countDashes;
66 wxGTKDash *m_dash;
67};
e55ad60e 68
c801d85f
KB
69//-----------------------------------------------------------------------------
70
71#define M_PENDATA ((wxPenRefData *)m_refData)
72
73IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
74
c801d85f
KB
75wxPen::wxPen( const wxColour &colour, int width, int style )
76{
907789a0
RR
77 m_refData = new wxPenRefData();
78 M_PENDATA->m_width = width;
79 M_PENDATA->m_style = style;
80 M_PENDATA->m_colour = colour;
ff7b1510 81}
c801d85f 82
907789a0 83wxPen::~wxPen()
c801d85f 84{
c89f5c02 85 // m_refData unrefed in ~wxObject
ff7b1510 86}
c801d85f 87
c89f5c02 88wxObjectRefData *wxPen::CreateRefData() const
c801d85f 89{
c89f5c02 90 return new wxPenRefData;
ff7b1510 91}
c801d85f 92
c89f5c02 93wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
c801d85f 94{
c89f5c02 95 return new wxPenRefData(*(wxPenRefData *)data);
ff7b1510 96}
c801d85f 97
c89f5c02 98bool wxPen::operator == ( const wxPen& pen ) const
c801d85f 99{
c89f5c02
RR
100 if (m_refData == pen.m_refData) return TRUE;
101
102 if (!m_refData || !pen.m_refData) return FALSE;
103
104 return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
ff7b1510 105}
c801d85f
KB
106
107void wxPen::SetColour( const wxColour &colour )
108{
c89f5c02
RR
109 AllocExclusive();
110
907789a0 111 M_PENDATA->m_colour = colour;
ff7b1510 112}
c801d85f 113
112c5086
RR
114void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
115{
c89f5c02
RR
116 AllocExclusive();
117
112c5086 118 M_PENDATA->m_countDashes = number_of_dashes;
2eca425d 119 M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
112c5086
RR
120}
121
debe6624 122void wxPen::SetColour( int red, int green, int blue )
c801d85f 123{
c89f5c02
RR
124 AllocExclusive();
125
907789a0 126 M_PENDATA->m_colour.Set( red, green, blue );
ff7b1510 127}
c801d85f
KB
128
129void wxPen::SetCap( int capStyle )
130{
c89f5c02
RR
131 AllocExclusive();
132
907789a0 133 M_PENDATA->m_capStyle = capStyle;
ff7b1510 134}
c801d85f
KB
135
136void wxPen::SetJoin( int joinStyle )
137{
c89f5c02
RR
138 AllocExclusive();
139
907789a0 140 M_PENDATA->m_joinStyle = joinStyle;
ff7b1510 141}
c801d85f
KB
142
143void wxPen::SetStyle( int style )
144{
c89f5c02
RR
145 AllocExclusive();
146
907789a0 147 M_PENDATA->m_style = style;
ff7b1510 148}
c801d85f
KB
149
150void wxPen::SetWidth( int width )
151{
c89f5c02
RR
152 AllocExclusive();
153
907789a0 154 M_PENDATA->m_width = width;
ff7b1510 155}
c801d85f 156
7ecb8b06 157int wxPen::GetDashes( wxDash **ptr ) const
112c5086 158{
7ecb8b06 159 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
112c5086
RR
160 return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
161}
162
7ecb8b06
VZ
163int wxPen::GetDashCount() const
164{
165 return (M_PENDATA->m_countDashes);
112c5086
RR
166}
167
7ecb8b06
VZ
168wxDash* wxPen::GetDash() const
169{
170 return (wxDash*)M_PENDATA->m_dash;
112c5086
RR
171}
172
907789a0 173int wxPen::GetCap() const
c801d85f 174{
223d09f6 175 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
8bbe427f 176
907789a0 177 return M_PENDATA->m_capStyle;
ff7b1510 178}
c801d85f 179
907789a0 180int wxPen::GetJoin() const
c801d85f 181{
223d09f6 182 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
8bbe427f 183
907789a0 184 return M_PENDATA->m_joinStyle;
ff7b1510 185}
c801d85f 186
907789a0 187int wxPen::GetStyle() const
c801d85f 188{
223d09f6 189 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
8bbe427f 190
907789a0 191 return M_PENDATA->m_style;
ff7b1510 192}
c801d85f 193
907789a0 194int wxPen::GetWidth() const
c801d85f 195{
223d09f6 196 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
8bbe427f 197
907789a0 198 return M_PENDATA->m_width;
ff7b1510 199}
c801d85f 200
907789a0 201wxColour &wxPen::GetColour() const
c801d85f 202{
223d09f6 203 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
8bbe427f 204
907789a0 205 return M_PENDATA->m_colour;
ff7b1510 206}
c801d85f 207