]>
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 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
19 #include "wx/bitmap.h"
20 #include "wx/colour.h"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
27 class wxPenRefData
: public wxGDIRefData
33 m_style
= wxPENSTYLE_SOLID
;
34 m_joinStyle
= wxJOIN_ROUND
;
35 m_capStyle
= wxCAP_ROUND
;
36 m_dash
= (wxX11Dash
*) NULL
;
40 wxPenRefData( const wxPenRefData
& data
)
42 m_style
= data
.m_style
;
43 m_width
= data
.m_width
;
44 m_joinStyle
= data
.m_joinStyle
;
45 m_capStyle
= data
.m_capStyle
;
46 m_colour
= data
.m_colour
;
47 m_countDashes
= data
.m_countDashes
;
53 m_stipple
= data
.m_stipple
;
56 bool operator == (const wxPenRefData
& data
) const
58 return (m_style
== data
.m_style
&&
59 m_width
== data
.m_width
&&
60 m_joinStyle
== data
.m_joinStyle
&&
61 m_capStyle
== data
.m_capStyle
&&
62 m_colour
== data
.m_colour
);
67 wxPenJoin m_joinStyle
;
75 //-----------------------------------------------------------------------------
77 #define M_PENDATA ((wxPenRefData *)m_refData)
79 IMPLEMENT_DYNAMIC_CLASS(wxPen
,wxGDIObject
)
81 wxPen::wxPen( const wxColour
&colour
, int width
, wxPenStyle style
)
83 m_refData
= new wxPenRefData();
84 M_PENDATA
->m_width
= width
;
85 M_PENDATA
->m_style
= style
;
86 M_PENDATA
->m_colour
= colour
;
89 #if FUTURE_WXWIN_COMPATIBILITY_3_0
90 wxPen::wxPen(const wxColour
& colour
, int width
, int style
)
92 m_refData
= new wxPenRefData();
93 M_PENDATA
->m_width
= width
;
94 M_PENDATA
->m_style
= (wxPenStyle
)style
;
95 M_PENDATA
->m_colour
= colour
;
101 // m_refData unrefed in ~wxObject
104 wxGDIRefData
*wxPen::CreateGDIRefData() const
106 return new wxPenRefData
;
109 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
111 return new wxPenRefData(*(wxPenRefData
*)data
);
114 bool wxPen::operator == ( const wxPen
& pen
) const
116 if (m_refData
== pen
.m_refData
) return true;
118 if (!m_refData
|| !pen
.m_refData
) return false;
120 return ( *(wxPenRefData
*)m_refData
== *(wxPenRefData
*)pen
.m_refData
);
123 void wxPen::SetColour( const wxColour
&colour
)
127 M_PENDATA
->m_colour
= colour
;
130 void wxPen::SetDashes( int number_of_dashes
, const wxDash
*dash
)
134 M_PENDATA
->m_countDashes
= number_of_dashes
;
135 M_PENDATA
->m_dash
= (wxX11Dash
*)dash
; // TODO
138 void wxPen::SetColour( unsigned char red
, unsigned char green
, unsigned char blue
)
142 M_PENDATA
->m_colour
.Set( red
, green
, blue
);
145 void wxPen::SetCap( wxPenCap capStyle
)
149 M_PENDATA
->m_capStyle
= capStyle
;
152 void wxPen::SetJoin( wxPenJoin joinStyle
)
156 M_PENDATA
->m_joinStyle
= joinStyle
;
159 void wxPen::SetStipple( const wxBitmap
& stipple
)
163 M_PENDATA
->m_stipple
= stipple
;
166 void wxPen::SetStyle( wxPenStyle style
)
170 M_PENDATA
->m_style
= style
;
173 void wxPen::SetWidth( int width
)
177 M_PENDATA
->m_width
= width
;
180 int wxPen::GetDashes( wxDash
**ptr
) const
182 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
184 *ptr
= (wxDash
*)M_PENDATA
->m_dash
;
185 return M_PENDATA
->m_countDashes
;
188 int wxPen::GetDashCount() const
190 return (M_PENDATA
->m_countDashes
);
193 wxDash
* wxPen::GetDash() const
195 return (wxDash
*)M_PENDATA
->m_dash
;
198 wxPenCap
wxPen::GetCap() const
200 wxCHECK_MSG( Ok(), wxCAP_INVALID
, wxT("invalid pen") );
202 return M_PENDATA
->m_capStyle
;
205 wxPenJoin
wxPen::GetJoin() const
207 wxCHECK_MSG( Ok(), wxJOIN_INVALID
, wxT("invalid pen") );
209 return M_PENDATA
->m_joinStyle
;
212 wxPenStyle
wxPen::GetStyle() const
214 wxCHECK_MSG( Ok(), wxPENSTYLE_INVALID
, wxT("invalid pen") );
216 return M_PENDATA
->m_style
;
219 int wxPen::GetWidth() const
221 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
223 return M_PENDATA
->m_width
;
226 wxColour
&wxPen::GetColour() const
228 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
230 return M_PENDATA
->m_colour
;
233 wxBitmap
*wxPen::GetStipple() const
235 wxCHECK_MSG( Ok(), &wxNullBitmap
, wxT("invalid pen") );
237 return &M_PENDATA
->m_stipple
;