]>
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
;
53 bool operator == (const wxPenRefData
& data
) const
55 // It is impossible to tell if the dashes have changed
56 // so the only thing to do is assume they have
57 if (m_countDashes
!= 0 || data
.m_countDashes
!= 0)
60 return (m_style
== data
.m_style
&&
61 m_width
== data
.m_width
&&
62 m_joinStyle
== data
.m_joinStyle
&&
63 m_capStyle
== data
.m_capStyle
&&
64 m_colour
== data
.m_colour
);
76 //-----------------------------------------------------------------------------
78 #define M_PENDATA ((wxPenRefData *)m_refData)
80 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
82 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
84 m_refData
= new wxPenRefData();
85 M_PENDATA
->m_width
= width
;
86 M_PENDATA
->m_style
= style
;
87 M_PENDATA
->m_colour
= colour
;
92 // m_refData unrefed in ~wxObject
95 wxObjectRefData
*wxPen::CreateRefData() const
97 return new wxPenRefData
;
100 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
102 return new wxPenRefData(*(wxPenRefData
*)data
);
105 bool wxPen::operator == ( const wxPen
& pen
) const
107 if (m_refData
== pen
.m_refData
) return TRUE
;
109 if (!m_refData
|| !pen
.m_refData
) return FALSE
;
111 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
114 void wxPen::SetColour( const wxColour
&colour
)
118 M_PENDATA
->m_colour
= colour
;
121 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
125 M_PENDATA
->m_countDashes
= number_of_dashes
;
126 M_PENDATA
->m_dash
= (wxGTKDash
*)dash
; /* TODO */
129 void wxPen::SetColour( int red
, int green
, int blue
)
133 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
136 void wxPen::SetCap( int capStyle
)
140 M_PENDATA
->m_capStyle
= capStyle
;
143 void wxPen::SetJoin( int joinStyle
)
147 M_PENDATA
->m_joinStyle
= joinStyle
;
150 void wxPen::SetStyle( int style
)
154 M_PENDATA
->m_style
= style
;
157 void wxPen::SetWidth( int width
)
161 M_PENDATA
->m_width
= width
;
164 int wxPen::GetDashes( wxDash
**ptr
) const
166 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
167 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
170 int wxPen::GetDashCount() const
172 return (M_PENDATA
->m_countDashes
);
175 wxDash
* wxPen::GetDash() const
177 return (wxDash
*)M_PENDATA
->m_dash
;
180 int wxPen::GetCap() const
182 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
184 return M_PENDATA
->m_capStyle
;
187 int wxPen::GetJoin() const
189 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
191 return M_PENDATA
->m_joinStyle
;
194 int wxPen::GetStyle() const
196 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
198 return M_PENDATA
->m_style
;
201 int wxPen::GetWidth() const
203 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
205 return M_PENDATA
->m_width
;
208 wxColour
&wxPen::GetColour() const
210 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
212 return M_PENDATA
->m_colour
;