]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/gtk1/pen.cpp
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
9 // For compilers that support precompilation, includes "wx.h".
10 #include "wx/wxprec.h"
15 #include "wx/colour.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class wxPenRefData
: public wxGDIRefData
30 m_style
= wxPENSTYLE_SOLID
;
31 m_joinStyle
= wxJOIN_ROUND
;
32 m_capStyle
= wxCAP_ROUND
;
37 wxPenRefData( const wxPenRefData
& data
)
40 m_style
= data
.m_style
;
41 m_width
= data
.m_width
;
42 m_joinStyle
= data
.m_joinStyle
;
43 m_capStyle
= data
.m_capStyle
;
44 m_colour
= data
.m_colour
;
45 m_countDashes
= data
.m_countDashes
;
49 bool operator == (const wxPenRefData
& data
) const
51 if ( m_countDashes
!= data
.m_countDashes
)
57 memcmp(m_dash
, data
.m_dash
, m_countDashes
*sizeof(wxGTKDash
)) )
62 else if ( data
.m_dash
)
68 return m_style
== data
.m_style
&&
69 m_width
== data
.m_width
&&
70 m_joinStyle
== data
.m_joinStyle
&&
71 m_capStyle
== data
.m_capStyle
&&
72 m_colour
== data
.m_colour
;
77 wxPenJoin m_joinStyle
;
84 //-----------------------------------------------------------------------------
86 #define M_PENDATA ((wxPenRefData *)m_refData)
88 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
90 wxPen::wxPen( const wxColour
&colour
, int width
, wxPenStyle style
)
92 m_refData
= new wxPenRefData();
93 M_PENDATA
->m_width
= width
;
94 M_PENDATA
->m_style
= style
;
95 M_PENDATA
->m_colour
= colour
;
98 #if FUTURE_WXWIN_COMPATIBILITY_3_0
99 wxPen::wxPen(const wxColour
& colour
, int width
, int style
)
101 m_refData
= new wxPenRefData();
102 M_PENDATA
->m_width
= width
;
103 M_PENDATA
->m_style
= (wxPenStyle
)style
;
104 M_PENDATA
->m_colour
= colour
;
108 wxGDIRefData
*wxPen::CreateGDIRefData() const
110 return new wxPenRefData
;
113 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
115 return new wxPenRefData(*(wxPenRefData
*)data
);
118 bool wxPen::operator == ( const wxPen
& pen
) const
120 if (m_refData
== pen
.m_refData
) return true;
122 if (!m_refData
|| !pen
.m_refData
) return false;
124 return *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
;
127 void wxPen::SetColour( const wxColour
&colour
)
131 M_PENDATA
->m_colour
= colour
;
134 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
138 M_PENDATA
->m_countDashes
= number_of_dashes
;
139 M_PENDATA
->m_dash
= (wxGTKDash
*)dash
;
142 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
146 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
149 void wxPen::SetCap( wxPenCap capStyle
)
153 M_PENDATA
->m_capStyle
= capStyle
;
156 void wxPen::SetJoin( wxPenJoin joinStyle
)
160 M_PENDATA
->m_joinStyle
= joinStyle
;
163 void wxPen::SetStyle( wxPenStyle style
)
167 M_PENDATA
->m_style
= style
;
170 void wxPen::SetWidth( int width
)
174 M_PENDATA
->m_width
= width
;
177 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
179 wxFAIL_MSG( "stippled pens not supported" );
182 int wxPen::GetDashes( wxDash
**ptr
) const
184 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
186 *ptr
= (wxDash
*)M_PENDATA
->m_dash
;
187 return M_PENDATA
->m_countDashes
;
190 int wxPen::GetDashCount() const
192 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
194 return (M_PENDATA
->m_countDashes
);
197 wxDash
* wxPen::GetDash() const
199 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid pen") );
201 return (wxDash
*)M_PENDATA
->m_dash
;
204 wxPenCap
wxPen::GetCap() const
206 wxCHECK_MSG( IsOk(), wxCAP_INVALID
, wxT("invalid pen") );
208 return M_PENDATA
->m_capStyle
;
211 wxPenJoin
wxPen::GetJoin() const
213 wxCHECK_MSG( IsOk(), wxJOIN_INVALID
, wxT("invalid pen") );
215 return M_PENDATA
->m_joinStyle
;
218 wxPenStyle
wxPen::GetStyle() const
220 wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID
, wxT("invalid pen") );
222 return M_PENDATA
->m_style
;
225 int wxPen::GetWidth() const
227 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
229 return M_PENDATA
->m_width
;
232 wxColour
wxPen::GetColour() const
234 wxCHECK_MSG( IsOk(), wxNullColour
, wxT("invalid pen") );
236 return M_PENDATA
->m_colour
;
239 wxBitmap
*wxPen::GetStipple() const