]>
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"
21 #include "wx/colour.h"
22 #include "wx/bitmap.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 class wxPenRefData
: public wxObjectRefData
35 m_joinStyle
= wxJOIN_ROUND
;
36 m_capStyle
= wxCAP_ROUND
;
37 m_dash
= (wxX11Dash
*) NULL
;
41 wxPenRefData( const wxPenRefData
& data
)
43 m_style
= data
.m_style
;
44 m_width
= data
.m_width
;
45 m_joinStyle
= data
.m_joinStyle
;
46 m_capStyle
= data
.m_capStyle
;
47 m_colour
= data
.m_colour
;
48 m_countDashes
= data
.m_countDashes
;
54 m_stipple
= data
.m_stipple
;
57 bool operator == (const wxPenRefData
& data
) const
59 return (m_style
== data
.m_style
&&
60 m_width
== data
.m_width
&&
61 m_joinStyle
== data
.m_joinStyle
&&
62 m_capStyle
== data
.m_capStyle
&&
63 m_colour
== data
.m_colour
);
76 //-----------------------------------------------------------------------------
78 #define M_PENDATA ((wxPenRefData *)m_refData)
80 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
82 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
84 m_refData
= new wxPenRefData();
85 M_PENDATA
->m_width
= width
;
86 M_PENDATA
->m_style
= style
;
87 M_PENDATA
->m_colour
= colour
;
92 // m_refData unrefed in ~wxObject
95 wxObjectRefData
*wxPen::CreateRefData() const
97 return new wxPenRefData
;
100 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
102 return new wxPenRefData(*(wxPenRefData
*)data
);
105 bool wxPen::operator == ( const wxPen
& pen
) const
107 if (m_refData
== pen
.m_refData
) return true;
109 if (!m_refData
|| !pen
.m_refData
) return false;
111 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
114 void wxPen::SetColour( const wxColour
&colour
)
118 M_PENDATA
->m_colour
= colour
;
121 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
125 M_PENDATA
->m_countDashes
= number_of_dashes
;
126 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
129 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
133 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
136 void wxPen::SetCap( int capStyle
)
140 M_PENDATA
->m_capStyle
= capStyle
;
143 void wxPen::SetJoin( int joinStyle
)
147 M_PENDATA
->m_joinStyle
= joinStyle
;
150 void wxPen::SetStipple( wxBitmap
*stipple
)
154 M_PENDATA
->m_stipple
= *stipple
;
157 void wxPen::SetStyle( int style
)
161 M_PENDATA
->m_style
= style
;
164 void wxPen::SetWidth( int width
)
168 M_PENDATA
->m_width
= width
;
171 int wxPen::GetDashes( wxDash
**ptr
) const
173 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
174 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
177 int wxPen::GetDashCount() const
179 return (M_PENDATA
->m_countDashes
);
182 wxDash
* wxPen::GetDash() const
184 return (wxDash
*)M_PENDATA
->m_dash
;
187 int wxPen::GetCap() const
189 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
191 return M_PENDATA
->m_capStyle
;
194 int wxPen::GetJoin() const
196 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
198 return M_PENDATA
->m_joinStyle
;
201 int wxPen::GetStyle() const
203 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
205 return M_PENDATA
->m_style
;
208 int wxPen::GetWidth() const
210 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
212 return M_PENDATA
->m_width
;
215 wxColour
&wxPen::GetColour() const
217 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
219 return M_PENDATA
->m_colour
;
222 wxBitmap
*wxPen::GetStipple() const
224 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
226 return &M_PENDATA
->m_stipple
;