]>
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
6 // Copyright: (c) 2006 REA Elektronik GmbH
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
20 #include "wx/bitmap.h"
21 #include "wx/colour.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
28 class wxPenRefData
: public wxGDIRefData
31 wxPenRefData(const wxColour
& clr
= wxNullColour
, wxPenStyle style
= wxPENSTYLE_SOLID
)
37 wxPenRefData(const wxPenRefData
& data
)
38 : m_style(data
.m_style
), m_colour(data
.m_colour
) {}
40 virtual bool IsOk() const { return m_colour
.IsOk(); }
42 void SetStyle(wxPenStyle style
)
44 if ( style
!= wxPENSTYLE_SOLID
&& style
!= wxPENSTYLE_TRANSPARENT
)
46 wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" );
47 style
= wxPENSTYLE_SOLID
;
57 //-----------------------------------------------------------------------------
59 #define M_PENDATA ((wxPenRefData *)m_refData)
61 IMPLEMENT_DYNAMIC_CLASS(wxPen
, wxGDIObject
)
63 wxPen::wxPen(const wxColour
&colour
, int width
, wxPenStyle style
)
65 wxASSERT_MSG( width
<= 1, "only width=0,1 are supported" );
67 m_refData
= new wxPenRefData(colour
, style
);
70 #if FUTURE_WXWIN_COMPATIBILITY_3_0
71 wxPen::wxPen(const wxColour
& col
, int width
, int style
)
73 m_refData
= new wxPenRefData(col
, (wxPenStyle
)style
);
77 wxPen::wxPen(const wxBitmap
& WXUNUSED(stipple
), int WXUNUSED(width
))
79 wxFAIL_MSG( "stipple pens not supported" );
81 m_refData
= new wxPenRefData();
84 bool wxPen::operator==(const wxPen
& pen
) const
86 #warning "this is incorrect"
87 return m_refData
== pen
.m_refData
;
90 void wxPen::SetColour(const wxColour
&colour
)
93 M_PENDATA
->m_colour
= colour
;
96 void wxPen::SetDashes(int WXUNUSED(number_of_dashes
), const wxDash
*WXUNUSED(dash
))
98 wxFAIL_MSG( "SetDashes not implemented" );
101 void wxPen::SetColour(unsigned char red
, unsigned char green
, unsigned char blue
)
104 M_PENDATA
->m_colour
.Set(red
, green
, blue
);
107 void wxPen::SetCap(wxPenCap
WXUNUSED(capStyle
))
109 wxFAIL_MSG( "SetCap not implemented" );
112 void wxPen::SetJoin(wxPenJoin
WXUNUSED(joinStyle
))
114 wxFAIL_MSG( "SetJoin not implemented" );
117 void wxPen::SetStyle(wxPenStyle style
)
120 M_PENDATA
->SetStyle(style
);
123 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
125 wxFAIL_MSG( "SetStipple not implemented" );
128 void wxPen::SetWidth(int width
)
130 wxASSERT_MSG( width
<= 1, "only width=0,1 are implemented" );
133 int wxPen::GetDashes(wxDash
**ptr
) const
135 wxFAIL_MSG( "GetDashes not implemented" );
141 int wxPen::GetDashCount() const
143 wxFAIL_MSG( "GetDashCount not implemented" );
148 wxDash
* wxPen::GetDash() const
150 wxFAIL_MSG( "GetDash not implemented" );
155 wxPenCap
wxPen::GetCap() const
157 wxCHECK_MSG( IsOk(), wxCAP_INVALID
, wxT("invalid pen") );
159 wxFAIL_MSG( "GetCap not implemented" );
160 return wxCAP_INVALID
;
163 wxPenJoin
wxPen::GetJoin() const
165 wxCHECK_MSG( IsOk(), wxJOIN_INVALID
, wxT("invalid pen") );
167 wxFAIL_MSG( "GetJoin not implemented" );
168 return wxJOIN_INVALID
;
171 wxPenStyle
wxPen::GetStyle() const
173 wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID
, wxT("invalid pen") );
175 return M_PENDATA
->m_style
;
178 int wxPen::GetWidth() const
180 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
185 wxColour
wxPen::GetColour() const
187 wxCHECK_MSG( IsOk(), wxNullColour
, wxT("invalid pen") );
189 return M_PENDATA
->m_colour
;
192 wxBitmap
*wxPen::GetStipple() const
194 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid pen") );
196 wxFAIL_MSG( "GetStipple not implemented" );
200 wxGDIRefData
*wxPen::CreateGDIRefData() const
202 return new wxPenRefData
;
205 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
207 return new wxPenRefData(*(wxPenRefData
*)data
);