]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "pen.h"
16 #include "wx/colour.h"
20 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
24 class wxPenRefData
: public wxObjectRefData
31 m_joinStyle
= wxJOIN_ROUND
;
32 m_capStyle
= wxCAP_ROUND
;
33 m_dash
= (wxGTKDash
*) NULL
;
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
;
84 //-----------------------------------------------------------------------------
86 #define M_PENDATA ((wxPenRefData *)m_refData)
88 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
90 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
92 m_refData
= new wxPenRefData();
93 M_PENDATA
->m_width
= width
;
94 M_PENDATA
->m_style
= style
;
95 M_PENDATA
->m_colour
= colour
;
100 // m_refData unrefed in ~wxObject
103 wxObjectRefData
*wxPen::CreateRefData() const
105 return new wxPenRefData
;
108 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*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
= (wxGTKDash
*)dash
;
137 void wxPen::SetColour( int red
, int green
, int blue
)
141 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
144 void wxPen::SetCap( int capStyle
)
148 M_PENDATA
->m_capStyle
= capStyle
;
151 void wxPen::SetJoin( int joinStyle
)
155 M_PENDATA
->m_joinStyle
= joinStyle
;
158 void wxPen::SetStyle( int style
)
162 M_PENDATA
->m_style
= style
;
165 void wxPen::SetWidth( int width
)
169 M_PENDATA
->m_width
= width
;
172 int wxPen::GetDashes( wxDash
**ptr
) const
174 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
175 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
178 int wxPen::GetDashCount() const
180 return (M_PENDATA
->m_countDashes
);
183 wxDash
* wxPen::GetDash() const
185 return (wxDash
*)M_PENDATA
->m_dash
;
188 int wxPen::GetCap() const
190 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
192 return M_PENDATA
->m_capStyle
;
195 int wxPen::GetJoin() const
197 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
199 return M_PENDATA
->m_joinStyle
;
202 int wxPen::GetStyle() const
204 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
206 return M_PENDATA
->m_style
;
209 int wxPen::GetWidth() const
211 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
213 return M_PENDATA
->m_width
;
216 wxColour
&wxPen::GetColour() const
218 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
220 return M_PENDATA
->m_colour
;