]>
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
, wxPenStyle style
= wxPENSTYLE_SOLID
)
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
, wxPenStyle style
)
66 wxASSERT_MSG( width
<= 1, "only width=0,1 are supported" );
68 m_refData
= new wxPenRefData(colour
, style
);
71 wxPen::wxPen(const wxColour
& col
, int width
, wxBrushStyle style
)
73 m_refData
= new wxPenRefData(col
, (wxPenStyle
)style
);
76 wxPen::wxPen(const wxBitmap
& WXUNUSED(stipple
), int WXUNUSED(width
))
78 wxFAIL_MSG( "stipple pens not supported" );
80 m_refData
= new wxPenRefData();
83 bool wxPen::operator==(const wxPen
& pen
) const
85 #warning "this is incorrect (MGL too)"
86 return m_refData
== pen
.m_refData
;
89 void wxPen::SetColour(const wxColour
&colour
)
92 M_PENDATA
->m_colour
= colour
;
95 void wxPen::SetDashes(int WXUNUSED(number_of_dashes
), const wxDash
*WXUNUSED(dash
))
97 wxFAIL_MSG( "SetDashes not implemented" );
100 void wxPen::SetColour(unsigned char red
, unsigned char green
, unsigned char blue
)
103 M_PENDATA
->m_colour
.Set(red
, green
, blue
);
106 void wxPen::SetCap(wxPenCap
WXUNUSED(capStyle
))
108 wxFAIL_MSG( "SetCap not implemented" );
111 void wxPen::SetJoin(wxPenJoin
WXUNUSED(joinStyle
))
113 wxFAIL_MSG( "SetJoin not implemented" );
116 void wxPen::SetStyle(wxPenStyle style
)
119 M_PENDATA
->SetStyle(style
);
122 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
124 wxFAIL_MSG( "SetStipple not implemented" );
127 void wxPen::SetWidth(int width
)
129 wxASSERT_MSG( width
<= 1, "only width=0,1 are implemented" );
132 int wxPen::GetDashes(wxDash
**ptr
) const
134 wxFAIL_MSG( "GetDashes not implemented" );
140 int wxPen::GetDashCount() const
142 wxFAIL_MSG( "GetDashCount not implemented" );
147 wxDash
* wxPen::GetDash() const
149 wxFAIL_MSG( "GetDash not implemented" );
154 wxPenCap
wxPen::GetCap() const
156 wxCHECK_MSG( Ok(), wxCAP_INVALID
, wxT("invalid pen") );
158 wxFAIL_MSG( "GetCap not implemented" );
159 return wxCAP_INVALID
;
162 wxPenJoin
wxPen::GetJoin() const
164 wxCHECK_MSG( Ok(), wxJOIN_INVALID
, wxT("invalid pen") );
166 wxFAIL_MSG( "GetJoin not implemented" );
167 return wxJOIN_INVALID
;
170 wxPenStyle
wxPen::GetStyle() const
172 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
174 return M_PENDATA
->m_style
;
177 int wxPen::GetWidth() const
179 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
184 wxColour
&wxPen::GetColour() const
186 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
188 return M_PENDATA
->m_colour
;
191 wxBitmap
*wxPen::GetStipple() const
193 wxCHECK_MSG( Ok(), NULL
, wxT("invalid pen") );
195 wxFAIL_MSG( "GetStipple not implemented" );
199 wxGDIRefData
*wxPen::CreateGDIRefData() const
201 return new wxPenRefData
;
204 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
206 return new wxPenRefData(*(wxPenRefData
*)data
);