]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk1/pen.cpp
0a785a8deea700397375a82e2074e5c37aeee60c
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
35 wxPenRefData::wxPenRefData(void)
39 m_joinStyle
= wxJOIN_ROUND
;
40 m_capStyle
= wxCAP_ROUND
;
43 wxPenRefData::wxPenRefData( const wxPenRefData
& data
)
45 m_style
= data
.m_style
;
46 m_width
= data
.m_width
;
47 m_joinStyle
= data
.m_joinStyle
;
48 m_capStyle
= data
.m_capStyle
;
49 m_colour
= data
.m_colour
;
52 //-----------------------------------------------------------------------------
54 #define M_PENDATA ((wxPenRefData *)m_refData)
56 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
60 if (wxThePenList
) wxThePenList
->AddPen( this );
63 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
65 m_refData
= new wxPenRefData();
66 M_PENDATA
->m_width
= width
;
67 M_PENDATA
->m_style
= style
;
68 M_PENDATA
->m_colour
= colour
;
70 if (wxThePenList
) wxThePenList
->AddPen( this );
73 wxPen::wxPen( const wxString
&colourName
, int width
, int style
)
75 m_refData
= new wxPenRefData();
76 M_PENDATA
->m_width
= width
;
77 M_PENDATA
->m_style
= style
;
78 M_PENDATA
->m_colour
= colourName
;
80 if (wxThePenList
) wxThePenList
->AddPen( this );
83 wxPen::wxPen( const wxPen
& pen
)
86 if (wxThePenList
) wxThePenList
->AddPen( this );
89 wxPen::wxPen( const wxPen
* pen
)
94 if (wxThePenList
) wxThePenList
->AddPen( this );
99 if (wxThePenList
) wxThePenList
->RemovePen( this );
102 wxPen
& wxPen::operator = ( const wxPen
& pen
)
104 if (*this == pen
) return (*this);
109 bool wxPen::operator == ( const wxPen
& pen
)
111 return m_refData
== pen
.m_refData
;
114 bool wxPen::operator != ( const wxPen
& pen
)
116 return m_refData
!= pen
.m_refData
;
119 void wxPen::SetColour( const wxColour
&colour
)
122 M_PENDATA
->m_colour
= colour
;
125 void wxPen::SetColour( const wxString
&colourName
)
128 M_PENDATA
->m_colour
= colourName
;
131 void wxPen::SetColour( int red
, int green
, int blue
)
134 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
137 void wxPen::SetCap( int capStyle
)
140 M_PENDATA
->m_capStyle
= capStyle
;
143 void wxPen::SetJoin( int joinStyle
)
146 M_PENDATA
->m_joinStyle
= joinStyle
;
149 void wxPen::SetStyle( int style
)
152 M_PENDATA
->m_style
= style
;
155 void wxPen::SetWidth( int width
)
158 M_PENDATA
->m_width
= width
;
161 int wxPen::GetCap(void) const
165 wxFAIL_MSG( "invalid pen" );
169 return M_PENDATA
->m_capStyle
;
172 int wxPen::GetJoin(void) const
176 wxFAIL_MSG( "invalid pen" );
180 return M_PENDATA
->m_joinStyle
;
183 int wxPen::GetStyle(void) const
187 wxFAIL_MSG( "invalid pen" );
191 return M_PENDATA
->m_style
;
194 int wxPen::GetWidth(void) const
198 wxFAIL_MSG( "invalid pen" );
202 return M_PENDATA
->m_width
;
205 wxColour
&wxPen::GetColour(void) const
209 wxFAIL_MSG( "invalid pen" );
213 return M_PENDATA
->m_colour
;
216 bool wxPen::Ok(void) const
218 return (m_refData
!= NULL
);
221 void wxPen::Unshare(void)
225 m_refData
= new wxPenRefData();
229 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);