]>
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"
19 #include "wx/bitmap.h"
20 #include "wx/colour.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 class wxPenRefData
: public wxGDIRefData
34 m_joinStyle
= wxJOIN_ROUND
;
35 m_capStyle
= wxCAP_ROUND
;
36 m_dash
= (wxX11Dash
*) NULL
;
40 wxPenRefData( const wxPenRefData
& data
)
42 m_style
= data
.m_style
;
43 m_width
= data
.m_width
;
44 m_joinStyle
= data
.m_joinStyle
;
45 m_capStyle
= data
.m_capStyle
;
46 m_colour
= data
.m_colour
;
47 m_countDashes
= data
.m_countDashes
;
53 m_stipple
= data
.m_stipple
;
56 bool operator == (const wxPenRefData
& data
) const
58 return (m_style
== data
.m_style
&&
59 m_width
== data
.m_width
&&
60 m_joinStyle
== data
.m_joinStyle
&&
61 m_capStyle
== data
.m_capStyle
&&
62 m_colour
== data
.m_colour
);
67 wxPenJoin m_joinStyle
;
75 //-----------------------------------------------------------------------------
77 #define M_PENDATA ((wxPenRefData *)m_refData)
79 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
81 wxPen::wxPen( const wxColour
&colour
, int width
, wxPenStyle style
)
83 m_refData
= new wxPenRefData();
84 M_PENDATA
->m_width
= width
;
85 M_PENDATA
->m_style
= style
;
86 M_PENDATA
->m_colour
= colour
;
89 wxPen::wxPen(const wxColour
& colour
, int width
, wxBrushStyle style
)
91 m_refData
= new wxPenRefData();
92 M_PENDATA
->m_width
= width
;
93 M_PENDATA
->m_style
= (wxPenStyle
)style
;
94 M_PENDATA
->m_colour
= colour
;
99 // m_refData unrefed in ~wxObject
102 wxGDIRefData
*wxPen::CreateGDIRefData() const
104 return new wxPenRefData
;
107 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
109 return new wxPenRefData(*(wxPenRefData
*)data
);
112 bool wxPen::operator == ( const wxPen
& pen
) const
114 if (m_refData
== pen
.m_refData
) return true;
116 if (!m_refData
|| !pen
.m_refData
) return false;
118 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
121 void wxPen::SetColour( const wxColour
&colour
)
125 M_PENDATA
->m_colour
= colour
;
128 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
132 M_PENDATA
->m_countDashes
= number_of_dashes
;
133 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
136 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
140 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
143 void wxPen::SetCap( wxPenCap capStyle
)
147 M_PENDATA
->m_capStyle
= capStyle
;
150 void wxPen::SetJoin( wxPenJoin joinStyle
)
154 M_PENDATA
->m_joinStyle
= joinStyle
;
157 void wxPen::SetStipple( wxBitmap
*stipple
)
161 M_PENDATA
->m_stipple
= *stipple
;
164 void wxPen::SetStyle( wxPenStyle style
)
168 M_PENDATA
->m_style
= style
;
171 void wxPen::SetWidth( int width
)
175 M_PENDATA
->m_width
= width
;
178 int wxPen::GetDashes( wxDash
**ptr
) const
180 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
181 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
184 int wxPen::GetDashCount() const
186 return (M_PENDATA
->m_countDashes
);
189 wxDash
* wxPen::GetDash() const
191 return (wxDash
*)M_PENDATA
->m_dash
;
194 wxPenCap
wxPen::GetCap() const
196 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
198 return M_PENDATA
->m_capStyle
;
201 wxPenJoin
wxPen::GetJoin() const
203 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
205 return M_PENDATA
->m_joinStyle
;
208 wxPenStyle
wxPen::GetStyle() const
210 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
212 return M_PENDATA
->m_style
;
215 int wxPen::GetWidth() const
217 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
219 return M_PENDATA
->m_width
;
222 wxColour
&wxPen::GetColour() const
224 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
226 return M_PENDATA
->m_colour
;
229 wxBitmap
*wxPen::GetStipple() const
231 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
233 return &M_PENDATA
->m_stipple
;