]>
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
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 wxString
&colourName
, int width
, int style
)
76 m_refData
= new wxPenRefData();
77 M_PENDATA
->m_width
= width
;
78 M_PENDATA
->m_style
= style
;
79 M_PENDATA
->m_colour
= colourName
;
81 if (wxThePenList
) wxThePenList
->AddPen( this );
84 wxPen::wxPen( const wxPen
& pen
)
87 if (wxThePenList
) wxThePenList
->AddPen( this );
90 wxPen::wxPen( const wxPen
* pen
)
95 if (wxThePenList
) wxThePenList
->AddPen( this );
100 if (wxThePenList
) wxThePenList
->RemovePen( this );
103 wxPen
& wxPen::operator = ( const wxPen
& pen
)
105 if (*this == pen
) return (*this);
110 bool wxPen::operator == ( const wxPen
& pen
)
112 return m_refData
== pen
.m_refData
;
115 bool wxPen::operator != ( const wxPen
& pen
)
117 return m_refData
!= pen
.m_refData
;
120 void wxPen::SetColour( const wxColour
&colour
)
123 M_PENDATA
->m_colour
= colour
;
126 void wxPen::SetColour( const wxString
&colourName
)
129 M_PENDATA
->m_colour
= colourName
;
132 void wxPen::SetColour( int red
, int green
, int blue
)
135 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
138 void wxPen::SetCap( int capStyle
)
141 M_PENDATA
->m_capStyle
= capStyle
;
144 void wxPen::SetJoin( int joinStyle
)
147 M_PENDATA
->m_joinStyle
= joinStyle
;
150 void wxPen::SetStyle( int style
)
153 M_PENDATA
->m_style
= style
;
156 void wxPen::SetWidth( int width
)
159 M_PENDATA
->m_width
= width
;
162 int wxPen::GetCap(void) const
166 wxFAIL_MSG( "invalid pen" );
170 return M_PENDATA
->m_capStyle
;
173 int wxPen::GetJoin(void) const
177 wxFAIL_MSG( "invalid pen" );
181 return M_PENDATA
->m_joinStyle
;
184 int wxPen::GetStyle(void) const
188 wxFAIL_MSG( "invalid pen" );
192 return M_PENDATA
->m_style
;
195 int wxPen::GetWidth(void) const
199 wxFAIL_MSG( "invalid pen" );
203 return M_PENDATA
->m_width
;
206 wxColour
&wxPen::GetColour(void) const
210 wxFAIL_MSG( "invalid pen" );
214 return M_PENDATA
->m_colour
;
217 bool wxPen::Ok(void) const
219 return (m_refData
!= NULL
);
222 void wxPen::Unshare(void)
226 m_refData
= new wxPenRefData();
230 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);