]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/pen.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "pen.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class wxPenRefData
: public wxObjectRefData
31 m_joinStyle
= wxJOIN_ROUND
;
32 m_capStyle
= wxCAP_ROUND
;
33 m_dash
= (wxX11Dash
*) NULL
;
37 wxPenRefData( const wxPenRefData
& data
)
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
;
52 bool operator == (const wxPenRefData
& data
) const
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
);
70 //-----------------------------------------------------------------------------
72 #define M_PENDATA ((wxPenRefData *)m_refData)
74 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
76 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
78 m_refData
= new wxPenRefData();
79 M_PENDATA
->m_width
= width
;
80 M_PENDATA
->m_style
= style
;
81 M_PENDATA
->m_colour
= colour
;
86 // m_refData unrefed in ~wxObject
89 wxObjectRefData
*wxPen::CreateRefData() const
91 return new wxPenRefData
;
94 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
96 return new wxPenRefData(*(wxPenRefData
*)data
);
99 bool wxPen::operator == ( const wxPen
& pen
) const
101 if (m_refData
== pen
.m_refData
) return TRUE
;
103 if (!m_refData
|| !pen
.m_refData
) return FALSE
;
105 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
108 void wxPen::SetColour( const wxColour
&colour
)
112 M_PENDATA
->m_colour
= colour
;
115 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
119 M_PENDATA
->m_countDashes
= number_of_dashes
;
120 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
123 void wxPen::SetColour( int red
, int green
, int blue
)
127 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
130 void wxPen::SetCap( int capStyle
)
134 M_PENDATA
->m_capStyle
= capStyle
;
137 void wxPen::SetJoin( int joinStyle
)
141 M_PENDATA
->m_joinStyle
= joinStyle
;
144 void wxPen::SetStyle( int style
)
148 M_PENDATA
->m_style
= style
;
151 void wxPen::SetWidth( int width
)
155 M_PENDATA
->m_width
= width
;
158 int wxPen::GetDashes( wxDash
**ptr
) const
160 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
161 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
164 int wxPen::GetDashCount() const
166 return (M_PENDATA
->m_countDashes
);
169 wxDash
* wxPen::GetDash() const
171 return (wxDash
*)M_PENDATA
->m_dash
;
174 int wxPen::GetCap() const
176 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
178 return M_PENDATA
->m_capStyle
;
181 int wxPen::GetJoin() const
183 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
185 return M_PENDATA
->m_joinStyle
;
188 int wxPen::GetStyle() const
190 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
192 return M_PENDATA
->m_style
;
195 int wxPen::GetWidth() const
197 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
199 return M_PENDATA
->m_width
;
202 wxColour
&wxPen::GetColour() const
204 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
206 return M_PENDATA
->m_colour
;