]>
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
);
39 wxPenRefData::wxPenRefData()
43 m_joinStyle
= wxJOIN_ROUND
;
44 m_capStyle
= wxCAP_ROUND
;
45 m_dash
= (wxDash
*) NULL
;
49 wxPenRefData::wxPenRefData( const wxPenRefData
& data
)
51 m_style
= data
.m_style
;
52 m_width
= data
.m_width
;
53 m_joinStyle
= data
.m_joinStyle
;
54 m_capStyle
= data
.m_capStyle
;
55 m_colour
= data
.m_colour
;
56 m_countDashes
= data
.m_countDashes
;
64 //-----------------------------------------------------------------------------
66 #define M_PENDATA ((wxPenRefData *)m_refData)
68 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
72 if (wxThePenList
) wxThePenList
->AddPen( this );
75 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
77 m_refData
= new wxPenRefData();
78 M_PENDATA
->m_width
= width
;
79 M_PENDATA
->m_style
= style
;
80 M_PENDATA
->m_colour
= colour
;
82 if (wxThePenList
) wxThePenList
->AddPen( this );
85 wxPen::wxPen( const wxPen
& pen
)
88 if (wxThePenList
) wxThePenList
->AddPen( this );
93 if (wxThePenList
) wxThePenList
->RemovePen( this );
96 wxPen
& wxPen::operator = ( const wxPen
& pen
)
98 if (*this == pen
) return (*this);
103 bool wxPen::operator == ( const wxPen
& pen
)
105 return m_refData
== pen
.m_refData
;
108 bool wxPen::operator != ( const wxPen
& pen
)
110 return m_refData
!= pen
.m_refData
;
113 void wxPen::SetColour( const wxColour
&colour
)
116 M_PENDATA
->m_colour
= colour
;
119 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
122 M_PENDATA
->m_countDashes
= number_of_dashes
;
123 M_PENDATA
->m_dash
= (wxDash
*)dash
; /* TODO */
126 void wxPen::SetColour( int red
, int green
, int blue
)
129 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
132 void wxPen::SetCap( int capStyle
)
135 M_PENDATA
->m_capStyle
= capStyle
;
138 void wxPen::SetJoin( int joinStyle
)
141 M_PENDATA
->m_joinStyle
= joinStyle
;
144 void wxPen::SetStyle( int style
)
147 M_PENDATA
->m_style
= style
;
150 void wxPen::SetWidth( int width
)
153 M_PENDATA
->m_width
= width
;
156 int wxPen::GetDashes( wxDash
**ptr
) const
158 *ptr
= (M_PENDATA
? M_PENDATA
->m_dash
: (wxDash
*) NULL
);
159 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
162 int wxPen::GetDashCount() const
164 return (M_PENDATA
->m_countDashes
);
167 wxDash
* wxPen::GetDash() const
169 return (M_PENDATA
->m_dash
);
172 int wxPen::GetCap() const
174 wxCHECK_MSG( Ok(), -1, T("invalid pen") );
176 return M_PENDATA
->m_capStyle
;
179 int wxPen::GetJoin() const
181 wxCHECK_MSG( Ok(), -1, T("invalid pen") );
183 return M_PENDATA
->m_joinStyle
;
186 int wxPen::GetStyle() const
188 wxCHECK_MSG( Ok(), -1, T("invalid pen") );
190 return M_PENDATA
->m_style
;
193 int wxPen::GetWidth() const
195 wxCHECK_MSG( Ok(), -1, T("invalid pen") );
197 return M_PENDATA
->m_width
;
200 wxColour
&wxPen::GetColour() const
202 wxCHECK_MSG( Ok(), wxNullColour
, T("invalid pen") );
204 return M_PENDATA
->m_colour
;
207 bool wxPen::Ok() const
209 return (m_refData
!= NULL
);
212 void wxPen::Unshare()
216 m_refData
= new wxPenRefData();
220 wxPenRefData
* ref
= new wxPenRefData( *(wxPenRefData
*)m_refData
);