]>
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"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 class wxPenRefData
: public wxObjectRefData
26 wxPenRefData(const wxPenRefData
& data
);
35 wxPenRefData::wxPenRefData()
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 wxPen
& pen
)
76 if (wxThePenList
) wxThePenList
->AddPen( this );
79 wxPen::wxPen( const wxPen
* pen
)
84 if (wxThePenList
) wxThePenList
->AddPen( this );
89 if (wxThePenList
) wxThePenList
->RemovePen( this );
92 wxPen
& wxPen::operator = ( const wxPen
& pen
)
94 if (*this == pen
) return (*this);
99 bool wxPen::operator == ( const wxPen
& pen
)
101 return m_refData
== pen
.m_refData
;
104 bool wxPen::operator != ( const wxPen
& pen
)
106 return m_refData
!= pen
.m_refData
;
109 void wxPen::SetColour( const wxColour
&colour
)
112 M_PENDATA
->m_colour
= colour
;
115 void wxPen::SetColour( int red
, int green
, int blue
)
118 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
121 void wxPen::SetCap( int capStyle
)
124 M_PENDATA
->m_capStyle
= capStyle
;
127 void wxPen::SetJoin( int joinStyle
)
130 M_PENDATA
->m_joinStyle
= joinStyle
;
133 void wxPen::SetStyle( int style
)
136 M_PENDATA
->m_style
= style
;
139 void wxPen::SetWidth( int width
)
142 M_PENDATA
->m_width
= width
;
145 int wxPen::GetCap() const
147 wxCHECK_MSG( Ok(), -1, "invalid pen" );
149 return M_PENDATA
->m_capStyle
;
152 int wxPen::GetJoin() const
154 wxCHECK_MSG( Ok(), -1, "invalid pen" );
156 return M_PENDATA
->m_joinStyle
;
159 int wxPen::GetStyle() const
161 wxCHECK_MSG( Ok(), -1, "invalid pen" );
163 return M_PENDATA
->m_style
;
166 int wxPen::GetWidth() const
168 wxCHECK_MSG( Ok(), -1, "invalid pen" );
170 return M_PENDATA
->m_width
;
173 wxColour
&wxPen::GetColour() const
175 wxCHECK_MSG( Ok(), wxNullColour
, "invalid pen" );
177 return M_PENDATA
->m_colour
;
180 bool wxPen::Ok() const
182 return (m_refData
!= NULL
);
185 void wxPen::Unshare()
189 m_refData
= new wxPenRefData();
193 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);