]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/pen.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/dfb/pen.cpp
3 // Purpose: wxPen class implementation
4 // Author: Vaclav Slavik
7 // Copyright: (c) 2006 REA Elektronik GmbH
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // For compilers that support precompilation, includes "wx.h".
12 #include "wx/wxprec.h"
21 #include "wx/bitmap.h"
22 #include "wx/colour.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 class wxPenRefData
: public wxObjectRefData
32 wxPenRefData(const wxColour
& clr
= wxNullColour
, int style
= wxSOLID
)
38 wxPenRefData(const wxPenRefData
& data
)
39 : m_style(data
.m_style
), m_colour(data
.m_colour
) {}
41 void SetStyle(int style
)
43 if ( style
!= wxSOLID
&& style
!= wxTRANSPARENT
)
45 wxFAIL_MSG( _T("only wxSOLID and wxTRANSPARENT styles are supported") );
56 //-----------------------------------------------------------------------------
58 #define M_PENDATA ((wxPenRefData *)m_refData)
60 IMPLEMENT_DYNAMIC_CLASS(wxPen
, wxGDIObject
)
62 wxPen::wxPen(const wxColour
&colour
, int width
, int style
)
64 wxASSERT_MSG( width
<= 1, _T("only width=0,1 are supported") );
66 m_refData
= new wxPenRefData(colour
, style
);
69 wxPen::wxPen(const wxBitmap
& WXUNUSED(stipple
), int WXUNUSED(width
))
71 wxFAIL_MSG( _T("stipple pens not supported") );
73 m_refData
= new wxPenRefData();
76 bool wxPen::operator==(const wxPen
& pen
) const
78 #warning "this is incorrect (MGL too)"
79 return m_refData
== pen
.m_refData
;
82 void wxPen::SetColour(const wxColour
&colour
)
85 M_PENDATA
->m_colour
= colour
;
88 void wxPen::SetDashes(int WXUNUSED(number_of_dashes
), const wxDash
*WXUNUSED(dash
))
90 wxFAIL_MSG( _T("SetDashes not implemented") );
93 void wxPen::SetColour(unsigned char red
, unsigned char green
, unsigned char blue
)
96 M_PENDATA
->m_colour
.Set(red
, green
, blue
);
99 void wxPen::SetCap(int WXUNUSED(capStyle
))
101 wxFAIL_MSG( _T("SetCap not implemented") );
104 void wxPen::SetJoin(int WXUNUSED(joinStyle
))
106 wxFAIL_MSG( _T("SetJoin not implemented") );
109 void wxPen::SetStyle(int style
)
112 M_PENDATA
->SetStyle(style
);
115 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
117 wxFAIL_MSG( _T("SetStipple not implemented") );
120 void wxPen::SetWidth(int width
)
122 wxASSERT_MSG( width
<= 1, _T("only width=0,1 are implemented") );
125 int wxPen::GetDashes(wxDash
**ptr
) const
127 wxFAIL_MSG( _T("GetDashes not implemented") );
133 int wxPen::GetDashCount() const
135 wxFAIL_MSG( _T("GetDashCount not implemented") );
140 wxDash
* wxPen::GetDash() const
142 wxFAIL_MSG( _T("GetDash not implemented") );
147 int wxPen::GetCap() const
149 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
151 wxFAIL_MSG( _T("GetCap not implemented") );
155 int wxPen::GetJoin() const
157 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
159 wxFAIL_MSG( _T("GetJoin not implemented") );
163 int wxPen::GetStyle() const
165 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
167 return M_PENDATA
->m_style
;
170 int wxPen::GetWidth() const
172 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
177 wxColour
&wxPen::GetColour() const
179 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
181 return M_PENDATA
->m_colour
;
184 wxBitmap
*wxPen::GetStipple() const
186 wxCHECK_MSG( Ok(), NULL
, wxT("invalid pen") );
188 wxFAIL_MSG( _T("GetStipple not implemented") );
192 bool wxPen::IsOk() const
194 return ((m_refData
) && M_PENDATA
->m_colour
.Ok());
197 wxObjectRefData
*wxPen::CreateRefData() const
199 return new wxPenRefData
;
202 wxObjectRefData
*wxPen::CloneRefData(const wxObjectRefData
*data
) const
204 return new wxPenRefData(*(wxPenRefData
*)data
);