]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/pen.cpp
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // for compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
18 #include "wx/bitmap.h"
19 #include "wx/colour.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 class wxPenRefData
: public wxGDIRefData
32 m_style
= wxPENSTYLE_SOLID
;
33 m_joinStyle
= wxJOIN_ROUND
;
34 m_capStyle
= wxCAP_ROUND
;
39 wxPenRefData( const wxPenRefData
& data
)
41 m_style
= data
.m_style
;
42 m_width
= data
.m_width
;
43 m_joinStyle
= data
.m_joinStyle
;
44 m_capStyle
= data
.m_capStyle
;
45 m_colour
= data
.m_colour
;
46 m_countDashes
= data
.m_countDashes
;
52 m_stipple
= data
.m_stipple
;
55 bool operator == (const wxPenRefData
& data
) const
57 return (m_style
== data
.m_style
&&
58 m_width
== data
.m_width
&&
59 m_joinStyle
== data
.m_joinStyle
&&
60 m_capStyle
== data
.m_capStyle
&&
61 m_colour
== data
.m_colour
);
66 wxPenJoin m_joinStyle
;
74 //-----------------------------------------------------------------------------
76 #define M_PENDATA ((wxPenRefData *)m_refData)
78 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
80 wxPen::wxPen( const wxColour
&colour
, int width
, wxPenStyle style
)
82 m_refData
= new wxPenRefData();
83 M_PENDATA
->m_width
= width
;
84 M_PENDATA
->m_style
= style
;
85 M_PENDATA
->m_colour
= colour
;
88 #if FUTURE_WXWIN_COMPATIBILITY_3_0
89 wxPen::wxPen(const wxColour
& colour
, int width
, int 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
;
100 // m_refData unrefed in ~wxObject
103 wxGDIRefData
*wxPen::CreateGDIRefData() const
105 return new wxPenRefData
;
108 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
110 return new wxPenRefData(*(wxPenRefData
*)data
);
113 bool wxPen::operator == ( const wxPen
& pen
) const
115 if (m_refData
== pen
.m_refData
) return true;
117 if (!m_refData
|| !pen
.m_refData
) return false;
119 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
122 void wxPen::SetColour( const wxColour
&colour
)
126 M_PENDATA
->m_colour
= colour
;
129 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
133 M_PENDATA
->m_countDashes
= number_of_dashes
;
134 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
137 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
141 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
144 void wxPen::SetCap( wxPenCap capStyle
)
148 M_PENDATA
->m_capStyle
= capStyle
;
151 void wxPen::SetJoin( wxPenJoin joinStyle
)
155 M_PENDATA
->m_joinStyle
= joinStyle
;
158 void wxPen::SetStipple( const wxBitmap
& stipple
)
162 M_PENDATA
->m_stipple
= stipple
;
165 void wxPen::SetStyle( wxPenStyle style
)
169 M_PENDATA
->m_style
= style
;
172 void wxPen::SetWidth( int width
)
176 M_PENDATA
->m_width
= width
;
179 int wxPen::GetDashes( wxDash
**ptr
) const
181 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
183 *ptr
= (wxDash
*)M_PENDATA
->m_dash
;
184 return M_PENDATA
->m_countDashes
;
187 int wxPen::GetDashCount() const
189 return (M_PENDATA
->m_countDashes
);
192 wxDash
* wxPen::GetDash() const
194 return (wxDash
*)M_PENDATA
->m_dash
;
197 wxPenCap
wxPen::GetCap() const
199 wxCHECK_MSG( IsOk(), wxCAP_INVALID
, wxT("invalid pen") );
201 return M_PENDATA
->m_capStyle
;
204 wxPenJoin
wxPen::GetJoin() const
206 wxCHECK_MSG( IsOk(), wxJOIN_INVALID
, wxT("invalid pen") );
208 return M_PENDATA
->m_joinStyle
;
211 wxPenStyle
wxPen::GetStyle() const
213 wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID
, wxT("invalid pen") );
215 return M_PENDATA
->m_style
;
218 int wxPen::GetWidth() const
220 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
222 return M_PENDATA
->m_width
;
225 wxColour
wxPen::GetColour() const
227 wxCHECK_MSG( IsOk(), wxNullColour
, wxT("invalid pen") );
229 return M_PENDATA
->m_colour
;
232 wxBitmap
*wxPen::GetStipple() const
234 wxCHECK_MSG( IsOk(), &wxNullBitmap
, wxT("invalid pen") );
236 return &M_PENDATA
->m_stipple
;