]>
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 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/colour.h"
16 #include "wx/bitmap.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class wxPenRefData
: public wxObjectRefData
29 m_joinStyle
= wxJOIN_ROUND
;
30 m_capStyle
= wxCAP_ROUND
;
31 m_dash
= (wxX11Dash
*) NULL
;
35 wxPenRefData( const wxPenRefData
& data
)
37 m_style
= data
.m_style
;
38 m_width
= data
.m_width
;
39 m_joinStyle
= data
.m_joinStyle
;
40 m_capStyle
= data
.m_capStyle
;
41 m_colour
= data
.m_colour
;
42 m_countDashes
= data
.m_countDashes
;
48 m_stipple
= data
.m_stipple
;
51 bool operator == (const wxPenRefData
& data
) const
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
);
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::SetStipple( wxBitmap
*stipple
)
148 M_PENDATA
->m_stipple
= *stipple
;;
151 void wxPen::SetStyle( int style
)
155 M_PENDATA
->m_style
= style
;
158 void wxPen::SetWidth( int width
)
162 M_PENDATA
->m_width
= width
;
165 int wxPen::GetDashes( wxDash
**ptr
) const
167 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
168 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
171 int wxPen::GetDashCount() const
173 return (M_PENDATA
->m_countDashes
);
176 wxDash
* wxPen::GetDash() const
178 return (wxDash
*)M_PENDATA
->m_dash
;
181 int wxPen::GetCap() const
183 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
185 return M_PENDATA
->m_capStyle
;
188 int wxPen::GetJoin() const
190 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
192 return M_PENDATA
->m_joinStyle
;
195 int wxPen::GetStyle() const
197 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
199 return M_PENDATA
->m_style
;
202 int wxPen::GetWidth() const
204 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
206 return M_PENDATA
->m_width
;
209 wxColour
&wxPen::GetColour() const
211 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
213 return M_PENDATA
->m_colour
;
216 wxBitmap
*wxPen::GetStipple() const
218 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
220 return &M_PENDATA
->m_stipple
;