]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "pen.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class wxPenRefData
: public wxObjectRefData
27 wxPenRefData(const wxPenRefData
& data
);
36 wxPenRefData::wxPenRefData(void)
40 m_joinStyle
= wxJOIN_ROUND
;
41 m_capStyle
= wxCAP_ROUND
;
44 wxPenRefData::wxPenRefData( const wxPenRefData
& data
)
46 m_style
= data
.m_style
;
47 m_width
= data
.m_width
;
48 m_joinStyle
= data
.m_joinStyle
;
49 m_capStyle
= data
.m_capStyle
;
50 m_colour
= data
.m_colour
;
53 //-----------------------------------------------------------------------------
55 #define M_PENDATA ((wxPenRefData *)m_refData)
57 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
61 if (wxThePenList
) wxThePenList
->AddPen( this );
64 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
66 m_refData
= new wxPenRefData();
67 M_PENDATA
->m_width
= width
;
68 M_PENDATA
->m_style
= style
;
69 M_PENDATA
->m_colour
= colour
;
71 if (wxThePenList
) wxThePenList
->AddPen( this );
74 wxPen::wxPen( const wxPen
& pen
)
77 if (wxThePenList
) wxThePenList
->AddPen( this );
80 wxPen::wxPen( const wxPen
* pen
)
85 if (wxThePenList
) wxThePenList
->AddPen( this );
90 if (wxThePenList
) wxThePenList
->RemovePen( this );
93 wxPen
& wxPen::operator = ( const wxPen
& pen
)
95 if (*this == pen
) return (*this);
100 bool wxPen::operator == ( const wxPen
& pen
)
102 return m_refData
== pen
.m_refData
;
105 bool wxPen::operator != ( const wxPen
& pen
)
107 return m_refData
!= pen
.m_refData
;
110 void wxPen::SetColour( const wxColour
&colour
)
113 M_PENDATA
->m_colour
= colour
;
116 void wxPen::SetColour( int red
, int green
, int blue
)
119 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
122 void wxPen::SetCap( int capStyle
)
125 M_PENDATA
->m_capStyle
= capStyle
;
128 void wxPen::SetJoin( int joinStyle
)
131 M_PENDATA
->m_joinStyle
= joinStyle
;
134 void wxPen::SetStyle( int style
)
137 M_PENDATA
->m_style
= style
;
140 void wxPen::SetWidth( int width
)
143 M_PENDATA
->m_width
= width
;
146 int wxPen::GetCap(void) const
150 wxFAIL_MSG( "invalid pen" );
154 return M_PENDATA
->m_capStyle
;
157 int wxPen::GetJoin(void) const
161 wxFAIL_MSG( "invalid pen" );
165 return M_PENDATA
->m_joinStyle
;
168 int wxPen::GetStyle(void) const
172 wxFAIL_MSG( "invalid pen" );
176 return M_PENDATA
->m_style
;
179 int wxPen::GetWidth(void) const
183 wxFAIL_MSG( "invalid pen" );
187 return M_PENDATA
->m_width
;
190 wxColour
&wxPen::GetColour(void) const
194 wxFAIL_MSG( "invalid pen" );
198 return M_PENDATA
->m_colour
;
201 bool wxPen::Ok(void) const
203 return (m_refData
!= NULL
);
206 void wxPen::Unshare(void)
210 m_refData
= new wxPenRefData();
214 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);