]>
git.saurik.com Git - wxWidgets.git/blob - src/gtk/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
35 wxPenRefData::wxPenRefData(void)
39 m_joinStyle
= wxJOIN_ROUND
;
40 m_capStyle
= wxCAP_ROUND
;
43 //-----------------------------------------------------------------------------
45 #define M_PENDATA ((wxPenRefData *)m_refData)
47 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
51 if (wxThePenList
) wxThePenList
->AddPen( this );
54 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
56 m_refData
= new wxPenRefData();
57 M_PENDATA
->m_width
= width
;
58 M_PENDATA
->m_style
= style
;
59 M_PENDATA
->m_colour
= colour
;
60 if (wxThePenList
) wxThePenList
->AddPen( this );
63 wxPen::wxPen( const wxString
&colourName
, 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
= colourName
;
69 if (wxThePenList
) wxThePenList
->AddPen( this );
72 wxPen::wxPen( const wxPen
& pen
)
75 if (wxThePenList
) wxThePenList
->AddPen( this );
78 wxPen::wxPen( const wxPen
* pen
)
82 if (wxThePenList
) wxThePenList
->AddPen( this );
87 if (wxThePenList
) wxThePenList
->RemovePen( this );
90 wxPen
& wxPen::operator = ( const wxPen
& pen
)
92 if (*this == pen
) return (*this);
97 bool wxPen::operator == ( const wxPen
& pen
)
99 return m_refData
== pen
.m_refData
;
102 bool wxPen::operator != ( const wxPen
& pen
)
104 return m_refData
!= pen
.m_refData
;
107 void wxPen::SetColour( const wxColour
&colour
)
110 m_refData
= new wxPenRefData();
112 M_PENDATA
->m_colour
= colour
;
115 void wxPen::SetColour( const wxString
&colourName
)
118 m_refData
= new wxPenRefData();
120 M_PENDATA
->m_colour
= colourName
;
123 void wxPen::SetColour( int red
, int green
, int blue
)
126 m_refData
= new wxPenRefData();
128 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
131 void wxPen::SetCap( int capStyle
)
134 m_refData
= new wxPenRefData();
136 M_PENDATA
->m_capStyle
= capStyle
;
139 void wxPen::SetJoin( int joinStyle
)
142 m_refData
= new wxPenRefData();
144 M_PENDATA
->m_joinStyle
= joinStyle
;
147 void wxPen::SetStyle( int style
)
150 m_refData
= new wxPenRefData();
152 M_PENDATA
->m_style
= style
;
155 void wxPen::SetWidth( int width
)
158 m_refData
= new wxPenRefData();
160 M_PENDATA
->m_width
= width
;
163 int wxPen::GetCap(void) const
165 return M_PENDATA
->m_capStyle
;
168 int wxPen::GetJoin(void) const
173 return M_PENDATA
->m_joinStyle
;
176 int wxPen::GetStyle(void) const
181 return M_PENDATA
->m_style
;
184 int wxPen::GetWidth(void) const
189 return M_PENDATA
->m_width
;
192 wxColour
&wxPen::GetColour(void) const
197 return M_PENDATA
->m_colour
;
200 bool wxPen::Ok(void) const