]>
git.saurik.com Git - wxWidgets.git/blob - src/x11/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/pen.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
13 #pragma implementation "pen.h"
19 #include "wx/colour.h"
20 #include "wx/bitmap.h"
22 //-----------------------------------------------------------------------------
24 //-----------------------------------------------------------------------------
26 class wxPenRefData
: public wxObjectRefData
33 m_joinStyle
= wxJOIN_ROUND
;
34 m_capStyle
= wxCAP_ROUND
;
35 m_dash
= (wxX11Dash
*) NULL
;
39 wxPenRefData( const wxPenRefData
& data
)
41 m_style
= data
.m_style
;
42 m_width
= data
.m_width
;
43 m_joinStyle
= data
.m_joinStyle
;
44 m_capStyle
= data
.m_capStyle
;
45 m_colour
= data
.m_colour
;
46 m_countDashes
= data
.m_countDashes
;
52 m_stipple
= data
.m_stipple
;
55 bool operator == (const wxPenRefData
& data
) const
57 return (m_style
== data
.m_style
&&
58 m_width
== data
.m_width
&&
59 m_joinStyle
== data
.m_joinStyle
&&
60 m_capStyle
== data
.m_capStyle
&&
61 m_colour
== data
.m_colour
);
74 //-----------------------------------------------------------------------------
76 #define M_PENDATA ((wxPenRefData *)m_refData)
78 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
80 wxPen::wxPen( const wxColour
&colour
, int width
, int style
)
82 m_refData
= new wxPenRefData();
83 M_PENDATA
->m_width
= width
;
84 M_PENDATA
->m_style
= style
;
85 M_PENDATA
->m_colour
= colour
;
90 // m_refData unrefed in ~wxObject
93 wxObjectRefData
*wxPen::CreateRefData() const
95 return new wxPenRefData
;
98 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
100 return new wxPenRefData(*(wxPenRefData
*)data
);
103 bool wxPen::operator == ( const wxPen
& pen
) const
105 if (m_refData
== pen
.m_refData
) return TRUE
;
107 if (!m_refData
|| !pen
.m_refData
) return FALSE
;
109 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
112 void wxPen::SetColour( const wxColour
&colour
)
116 M_PENDATA
->m_colour
= colour
;
119 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
123 M_PENDATA
->m_countDashes
= number_of_dashes
;
124 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
127 void wxPen::SetColour( int red
, int green
, int blue
)
131 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
134 void wxPen::SetCap( int capStyle
)
138 M_PENDATA
->m_capStyle
= capStyle
;
141 void wxPen::SetJoin( int joinStyle
)
145 M_PENDATA
->m_joinStyle
= joinStyle
;
148 void wxPen::SetStipple( wxBitmap
*stipple
)
152 M_PENDATA
->m_stipple
= *stipple
;;
155 void wxPen::SetStyle( int style
)
159 M_PENDATA
->m_style
= style
;
162 void wxPen::SetWidth( int width
)
166 M_PENDATA
->m_width
= width
;
169 int wxPen::GetDashes( wxDash
**ptr
) const
171 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
172 return (M_PENDATA
? M_PENDATA
->m_countDashes
: 0);
175 int wxPen::GetDashCount() const
177 return (M_PENDATA
->m_countDashes
);
180 wxDash
* wxPen::GetDash() const
182 return (wxDash
*)M_PENDATA
->m_dash
;
185 int wxPen::GetCap() const
187 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
189 return M_PENDATA
->m_capStyle
;
192 int wxPen::GetJoin() const
194 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
196 return M_PENDATA
->m_joinStyle
;
199 int wxPen::GetStyle() const
201 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
203 return M_PENDATA
->m_style
;
206 int wxPen::GetWidth() const
208 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
210 return M_PENDATA
->m_width
;
213 wxColour
&wxPen::GetColour() const
215 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
217 return M_PENDATA
->m_colour
;
220 wxBitmap
*wxPen::GetStipple() const
222 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
224 return &M_PENDATA
->m_stipple
;