]>
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
28 wxPenRefData( const wxPenRefData
& data
);
39 wxPenRefData::wxPenRefData()
43 m_joinStyle
= wxJOIN_ROUND
;
44 m_capStyle
= wxCAP_ROUND
;
45 m_dash
= (wxGTKDash
*) NULL
;
49 wxPenRefData::wxPenRefData( const wxPenRefData
& data
)
51 m_style
= data
.m_style
;
52 m_width
= data
.m_width
;
53 m_joinStyle
= data
.m_joinStyle
;
54 m_capStyle
= data
.m_capStyle
;
55 m_colour
= data
.m_colour
;
56 m_countDashes
= data
.m_countDashes
;
64 //-----------------------------------------------------------------------------
66 #define M_PENDATA ((wxPenRefData *)m_refData)
68 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
74 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
76 m_refData
= new wxPenRefData();
77 M_PENDATA
->m_width
= width
;
78 M_PENDATA
->m_style
= style
;
79 M_PENDATA
->m_colour
= colour
;
82 wxPen::wxPen( const wxPen
& pen
)
91 wxPen
& wxPen::operator = ( const wxPen
& pen
)
93 if ( m_refData
!= pen
.m_refData
)
99 bool wxPen::operator == ( const wxPen
& pen
) const
101 return m_refData
== pen
.m_refData
;
104 bool wxPen::operator != ( const wxPen
& pen
) const
106 return m_refData
!= pen
.m_refData
;
109 void wxPen::SetColour( const wxColour
&colour
)
112 M_PENDATA
->m_colour
= colour
;
115 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
)
125 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
128 void wxPen::SetCap( int capStyle
)
131 M_PENDATA
->m_capStyle
= capStyle
;
134 void wxPen::SetJoin( int joinStyle
)
137 M_PENDATA
->m_joinStyle
= joinStyle
;
140 void wxPen::SetStyle( int style
)
143 M_PENDATA
->m_style
= style
;
146 void wxPen::SetWidth( int width
)
149 M_PENDATA
->m_width
= width
;
152 int wxPen::GetDashes( wxDash
**ptr
) const
154 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
155 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
158 int wxPen::GetDashCount() const
160 return (M_PENDATA
->m_countDashes
);
163 wxDash
* wxPen::GetDash() const
165 return (wxDash
*)M_PENDATA
->m_dash
;
168 int wxPen::GetCap() const
170 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
172 return M_PENDATA
->m_capStyle
;
175 int wxPen::GetJoin() const
177 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
179 return M_PENDATA
->m_joinStyle
;
182 int wxPen::GetStyle() const
184 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
186 return M_PENDATA
->m_style
;
189 int wxPen::GetWidth() const
191 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
193 return M_PENDATA
->m_width
;
196 wxColour
&wxPen::GetColour() const
198 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
200 return M_PENDATA
->m_colour
;
203 bool wxPen::Ok() const
205 return (m_refData
!= NULL
);
208 void wxPen::Unshare()
212 m_refData
= new wxPenRefData();
216 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);