]>
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 wxObjectRefData
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
);
75 //-----------------------------------------------------------------------------
77 #define M_PENDATA ((wxPenRefData *)m_refData)
79 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
81 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
83 m_refData
= new wxPenRefData();
84 M_PENDATA
->m_width
= width
;
85 M_PENDATA
->m_style
= style
;
86 M_PENDATA
->m_colour
= colour
;
91 // m_refData unrefed in ~wxObject
94 wxObjectRefData
*wxPen::CreateRefData() const
96 return new wxPenRefData
;
99 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
101 return new wxPenRefData(*(wxPenRefData
*)data
);
104 bool wxPen::operator == ( const wxPen
& pen
) const
106 if (m_refData
== pen
.m_refData
) return true;
108 if (!m_refData
|| !pen
.m_refData
) return false;
110 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
113 void wxPen::SetColour( const wxColour
&colour
)
117 M_PENDATA
->m_colour
= colour
;
120 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
124 M_PENDATA
->m_countDashes
= number_of_dashes
;
125 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
128 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
132 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
135 void wxPen::SetCap( int capStyle
)
139 M_PENDATA
->m_capStyle
= capStyle
;
142 void wxPen::SetJoin( int joinStyle
)
146 M_PENDATA
->m_joinStyle
= joinStyle
;
149 void wxPen::SetStipple( wxBitmap
*stipple
)
153 M_PENDATA
->m_stipple
= *stipple
;
156 void wxPen::SetStyle( int style
)
160 M_PENDATA
->m_style
= style
;
163 void wxPen::SetWidth( int width
)
167 M_PENDATA
->m_width
= width
;
170 int wxPen::GetDashes( wxDash
**ptr
) const
172 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
173 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
176 int wxPen::GetDashCount() const
178 return (M_PENDATA
->m_countDashes
);
181 wxDash
* wxPen::GetDash() const
183 return (wxDash
*)M_PENDATA
->m_dash
;
186 int wxPen::GetCap() const
188 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
190 return M_PENDATA
->m_capStyle
;
193 int wxPen::GetJoin() const
195 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
197 return M_PENDATA
->m_joinStyle
;
200 int wxPen::GetStyle() const
202 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
204 return M_PENDATA
->m_style
;
207 int wxPen::GetWidth() const
209 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
211 return M_PENDATA
->m_width
;
214 wxColour
&wxPen::GetColour() const
216 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
218 return M_PENDATA
->m_colour
;
221 wxBitmap
*wxPen::GetStipple() const
223 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
225 return &M_PENDATA
->m_stipple
;