]>
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 /////////////////////////////////////////////////////////////////////////////
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
17 #include "wx/colour.h"
18 #include "wx/bitmap.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
;
50 m_stipple
= data
.m_stipple
;
53 bool operator == (const wxPenRefData
& data
) const
55 return (m_style
== data
.m_style
&&
56 m_width
== data
.m_width
&&
57 m_joinStyle
== data
.m_joinStyle
&&
58 m_capStyle
== data
.m_capStyle
&&
59 m_colour
== data
.m_colour
);
72 //-----------------------------------------------------------------------------
74 #define M_PENDATA ((wxPenRefData *)m_refData)
76 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
78 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
80 m_refData
= new wxPenRefData();
81 M_PENDATA
->m_width
= width
;
82 M_PENDATA
->m_style
= style
;
83 M_PENDATA
->m_colour
= colour
;
88 // m_refData unrefed in ~wxObject
91 wxObjectRefData
*wxPen::CreateRefData() const
93 return new wxPenRefData
;
96 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
98 return new wxPenRefData(*(wxPenRefData
*)data
);
101 bool wxPen::operator == ( const wxPen
& pen
) const
103 if (m_refData
== pen
.m_refData
) return true;
105 if (!m_refData
|| !pen
.m_refData
) return false;
107 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
110 void wxPen::SetColour( const wxColour
&colour
)
114 M_PENDATA
->m_colour
= colour
;
117 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
121 M_PENDATA
->m_countDashes
= number_of_dashes
;
122 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
125 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
129 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
132 void wxPen::SetCap( int capStyle
)
136 M_PENDATA
->m_capStyle
= capStyle
;
139 void wxPen::SetJoin( int joinStyle
)
143 M_PENDATA
->m_joinStyle
= joinStyle
;
146 void wxPen::SetStipple( wxBitmap
*stipple
)
150 M_PENDATA
->m_stipple
= *stipple
;
153 void wxPen::SetStyle( int style
)
157 M_PENDATA
->m_style
= style
;
160 void wxPen::SetWidth( int width
)
164 M_PENDATA
->m_width
= width
;
167 int wxPen::GetDashes( wxDash
**ptr
) const
169 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
170 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
173 int wxPen::GetDashCount() const
175 return (M_PENDATA
->m_countDashes
);
178 wxDash
* wxPen::GetDash() const
180 return (wxDash
*)M_PENDATA
->m_dash
;
183 int wxPen::GetCap() const
185 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
187 return M_PENDATA
->m_capStyle
;
190 int wxPen::GetJoin() const
192 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
194 return M_PENDATA
->m_joinStyle
;
197 int wxPen::GetStyle() const
199 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
201 return M_PENDATA
->m_style
;
204 int wxPen::GetWidth() const
206 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
208 return M_PENDATA
->m_width
;
211 wxColour
&wxPen::GetColour() const
213 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
215 return M_PENDATA
->m_colour
;
218 wxBitmap
*wxPen::GetStipple() const
220 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
222 return &M_PENDATA
->m_stipple
;