]>
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 return (m_style
== data
.m_style
&&
56 m_width
== data
.m_width
&&
57 m_joinStyle
== data
.m_joinStyle
&&
58 m_capStyle
== data
.m_capStyle
&&
59 m_colour
== data
.m_colour
);
71 //-----------------------------------------------------------------------------
73 #define M_PENDATA ((wxPenRefData *)m_refData)
75 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
77 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
79 m_refData
= new wxPenRefData();
80 M_PENDATA
->m_width
= width
;
81 M_PENDATA
->m_style
= style
;
82 M_PENDATA
->m_colour
= colour
;
87 // m_refData unrefed in ~wxObject
90 wxObjectRefData
*wxPen::CreateRefData() const
92 return new wxPenRefData
;
95 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
97 return new wxPenRefData(*(wxPenRefData
*)data
);
100 bool wxPen::operator == ( const wxPen
& pen
) const
102 if (m_refData
== pen
.m_refData
) return TRUE
;
104 if (!m_refData
|| !pen
.m_refData
) return FALSE
;
106 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
109 void wxPen::SetColour( const wxColour
&colour
)
113 M_PENDATA
->m_colour
= colour
;
116 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
120 M_PENDATA
->m_countDashes
= number_of_dashes
;
121 M_PENDATA
->m_dash
= (wxGTKDash
*)dash
; /* TODO */
124 void wxPen::SetColour( int red
, int green
, int blue
)
128 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
131 void wxPen::SetCap( int capStyle
)
135 M_PENDATA
->m_capStyle
= capStyle
;
138 void wxPen::SetJoin( int joinStyle
)
142 M_PENDATA
->m_joinStyle
= joinStyle
;
145 void wxPen::SetStyle( int style
)
149 M_PENDATA
->m_style
= style
;
152 void wxPen::SetWidth( int width
)
156 M_PENDATA
->m_width
= width
;
159 int wxPen::GetDashes( wxDash
**ptr
) const
161 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
162 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
165 int wxPen::GetDashCount() const
167 return (M_PENDATA
->m_countDashes
);
170 wxDash
* wxPen::GetDash() const
172 return (wxDash
*)M_PENDATA
->m_dash
;
175 int wxPen::GetCap() const
177 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
179 return M_PENDATA
->m_capStyle
;
182 int wxPen::GetJoin() const
184 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
186 return M_PENDATA
->m_joinStyle
;
189 int wxPen::GetStyle() const
191 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
193 return M_PENDATA
->m_style
;
196 int wxPen::GetWidth() const
198 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
200 return M_PENDATA
->m_width
;
203 wxColour
&wxPen::GetColour() const
205 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
207 return M_PENDATA
->m_colour
;