]>
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
);
37 wxPenRefData::wxPenRefData()
41 m_joinStyle
= wxJOIN_ROUND
;
42 m_capStyle
= wxCAP_ROUND
;
45 wxPenRefData::wxPenRefData( const wxPenRefData
& data
)
47 m_style
= data
.m_style
;
48 m_width
= data
.m_width
;
49 m_joinStyle
= data
.m_joinStyle
;
50 m_capStyle
= data
.m_capStyle
;
51 m_colour
= data
.m_colour
;
54 //-----------------------------------------------------------------------------
56 #define M_PENDATA ((wxPenRefData *)m_refData)
58 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
62 if (wxThePenList
) wxThePenList
->AddPen( this );
65 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
67 m_refData
= new wxPenRefData();
68 M_PENDATA
->m_width
= width
;
69 M_PENDATA
->m_style
= style
;
70 M_PENDATA
->m_colour
= colour
;
72 if (wxThePenList
) wxThePenList
->AddPen( this );
75 wxPen::wxPen( const wxPen
& pen
)
78 if (wxThePenList
) wxThePenList
->AddPen( this );
83 if (wxThePenList
) wxThePenList
->RemovePen( this );
86 wxPen
& wxPen::operator = ( const wxPen
& pen
)
88 if (*this == pen
) return (*this);
93 bool wxPen::operator == ( const wxPen
& pen
)
95 return m_refData
== pen
.m_refData
;
98 bool wxPen::operator != ( const wxPen
& pen
)
100 return m_refData
!= pen
.m_refData
;
103 void wxPen::SetColour( const wxColour
&colour
)
106 M_PENDATA
->m_colour
= colour
;
109 void wxPen::SetColour( int red
, int green
, int blue
)
112 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
115 void wxPen::SetCap( int capStyle
)
118 M_PENDATA
->m_capStyle
= capStyle
;
121 void wxPen::SetJoin( int joinStyle
)
124 M_PENDATA
->m_joinStyle
= joinStyle
;
127 void wxPen::SetStyle( int style
)
130 M_PENDATA
->m_style
= style
;
133 void wxPen::SetWidth( int width
)
136 M_PENDATA
->m_width
= width
;
139 int wxPen::GetCap() const
141 wxCHECK_MSG( Ok(), -1, _T("invalid pen") );
143 return M_PENDATA
->m_capStyle
;
146 int wxPen::GetJoin() const
148 wxCHECK_MSG( Ok(), -1, _T("invalid pen") );
150 return M_PENDATA
->m_joinStyle
;
153 int wxPen::GetStyle() const
155 wxCHECK_MSG( Ok(), -1, _T("invalid pen") );
157 return M_PENDATA
->m_style
;
160 int wxPen::GetWidth() const
162 wxCHECK_MSG( Ok(), -1, _T("invalid pen") );
164 return M_PENDATA
->m_width
;
167 wxColour
&wxPen::GetColour() const
169 wxCHECK_MSG( Ok(), wxNullColour
, _T("invalid pen") );
171 return M_PENDATA
->m_colour
;
174 bool wxPen::Ok() const
176 return (m_refData
!= NULL
);
179 void wxPen::Unshare()
183 m_refData
= new wxPenRefData();
187 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);