]>
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"
19 //-----------------------------------------------------------------------------
21 //-----------------------------------------------------------------------------
23 class wxPenRefData
: public wxObjectRefData
30 m_joinStyle
= wxJOIN_ROUND
;
31 m_capStyle
= wxCAP_ROUND
;
32 m_dash
= (wxGTKDash
*) NULL
;
36 wxPenRefData( const wxPenRefData
& data
)
38 m_style
= data
.m_style
;
39 m_width
= data
.m_width
;
40 m_joinStyle
= data
.m_joinStyle
;
41 m_capStyle
= data
.m_capStyle
;
42 m_colour
= data
.m_colour
;
43 m_countDashes
= data
.m_countDashes
;
51 bool operator == (const wxPenRefData
& data
) const
53 return (m_style
== data
.m_style
&&
54 m_width
== data
.m_width
&&
55 m_joinStyle
== data
.m_joinStyle
&&
56 m_capStyle
== data
.m_capStyle
&&
57 m_colour
== data
.m_colour
);
69 //-----------------------------------------------------------------------------
71 #define M_PENDATA ((wxPenRefData *)m_refData)
73 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
75 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
77 m_refData
= new wxPenRefData();
78 M_PENDATA
->m_width
= width
;
79 M_PENDATA
->m_style
= style
;
80 M_PENDATA
->m_colour
= colour
;
85 // m_refData unrefed in ~wxObject
88 wxObjectRefData
*wxPen::CreateRefData() const
90 return new wxPenRefData
;
93 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
95 return new wxPenRefData(*(wxPenRefData
*)data
);
98 bool wxPen::operator == ( const wxPen
& pen
) const
100 if (m_refData
== pen
.m_refData
) return TRUE
;
102 if (!m_refData
|| !pen
.m_refData
) return FALSE
;
104 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
107 void wxPen::SetColour( const wxColour
&colour
)
111 M_PENDATA
->m_colour
= colour
;
114 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
118 M_PENDATA
->m_countDashes
= number_of_dashes
;
119 M_PENDATA
->m_dash
= (wxGTKDash
*)dash
; /* TODO */
122 void wxPen::SetColour( int red
, int green
, int blue
)
126 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
129 void wxPen::SetCap( int capStyle
)
133 M_PENDATA
->m_capStyle
= capStyle
;
136 void wxPen::SetJoin( int joinStyle
)
140 M_PENDATA
->m_joinStyle
= joinStyle
;
143 void wxPen::SetStyle( int style
)
147 M_PENDATA
->m_style
= style
;
150 void wxPen::SetWidth( int width
)
154 M_PENDATA
->m_width
= width
;
157 int wxPen::GetDashes( wxDash
**ptr
) const
159 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
160 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
163 int wxPen::GetDashCount() const
165 return (M_PENDATA
->m_countDashes
);
168 wxDash
* wxPen::GetDash() const
170 return (wxDash
*)M_PENDATA
->m_dash
;
173 int wxPen::GetCap() const
175 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
177 return M_PENDATA
->m_capStyle
;
180 int wxPen::GetJoin() const
182 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
184 return M_PENDATA
->m_joinStyle
;
187 int wxPen::GetStyle() const
189 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
191 return M_PENDATA
->m_style
;
194 int wxPen::GetWidth() const
196 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
198 return M_PENDATA
->m_width
;
201 wxColour
&wxPen::GetColour() const
203 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
205 return M_PENDATA
->m_colour
;