]>
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 wxGDIRefData
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 virtual bool IsOk() const { return m_colour
.IsOk(); }
43 void SetStyle(int style
)
45 if ( style
!= wxSOLID
&& style
!= wxTRANSPARENT
)
47 wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" );
58 //-----------------------------------------------------------------------------
60 #define M_PENDATA ((wxPenRefData *)m_refData)
62 IMPLEMENT_DYNAMIC_CLASS(wxPen
, wxGDIObject
)
64 wxPen::wxPen(const wxColour
&colour
, int width
, int style
)
66 wxASSERT_MSG( width
<= 1, "only width=0,1 are supported" );
68 m_refData
= new wxPenRefData(colour
, style
);
71 wxPen::wxPen(const wxBitmap
& WXUNUSED(stipple
), int WXUNUSED(width
))
73 wxFAIL_MSG( "stipple pens not supported" );
75 m_refData
= new wxPenRefData();
78 bool wxPen::operator==(const wxPen
& pen
) const
80 #warning "this is incorrect (MGL too)"
81 return m_refData
== pen
.m_refData
;
84 void wxPen::SetColour(const wxColour
&colour
)
87 M_PENDATA
->m_colour
= colour
;
90 void wxPen::SetDashes(int WXUNUSED(number_of_dashes
), const wxDash
*WXUNUSED(dash
))
92 wxFAIL_MSG( "SetDashes not implemented" );
95 void wxPen::SetColour(unsigned char red
, unsigned char green
, unsigned char blue
)
98 M_PENDATA
->m_colour
.Set(red
, green
, blue
);
101 void wxPen::SetCap(int WXUNUSED(capStyle
))
103 wxFAIL_MSG( "SetCap not implemented" );
106 void wxPen::SetJoin(int WXUNUSED(joinStyle
))
108 wxFAIL_MSG( "SetJoin not implemented" );
111 void wxPen::SetStyle(int style
)
114 M_PENDATA
->SetStyle(style
);
117 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
119 wxFAIL_MSG( "SetStipple not implemented" );
122 void wxPen::SetWidth(int width
)
124 wxASSERT_MSG( width
<= 1, "only width=0,1 are implemented" );
127 int wxPen::GetDashes(wxDash
**ptr
) const
129 wxFAIL_MSG( "GetDashes not implemented" );
135 int wxPen::GetDashCount() const
137 wxFAIL_MSG( "GetDashCount not implemented" );
142 wxDash
* wxPen::GetDash() const
144 wxFAIL_MSG( "GetDash not implemented" );
149 int wxPen::GetCap() const
151 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
153 wxFAIL_MSG( "GetCap not implemented" );
157 int wxPen::GetJoin() const
159 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
161 wxFAIL_MSG( "GetJoin not implemented" );
165 int wxPen::GetStyle() const
167 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
169 return M_PENDATA
->m_style
;
172 int wxPen::GetWidth() const
174 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
179 wxColour
&wxPen::GetColour() const
181 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
183 return M_PENDATA
->m_colour
;
186 wxBitmap
*wxPen::GetStipple() const
188 wxCHECK_MSG( Ok(), NULL
, wxT("invalid pen") );
190 wxFAIL_MSG( "GetStipple not implemented" );
194 wxGDIRefData
*wxPen::CreateGDIRefData() const
196 return new wxPenRefData
;
199 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
201 return new wxPenRefData(*(wxPenRefData
*)data
);