]>
git.saurik.com Git - wxWidgets.git/blob - src/dfb/pen.cpp
5b70c698bf0afbc17a5c12826f26b411c23b1b7e
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(wxPenStyle style
)
45 if ( style
!= wxPENSTYLE_SOLID
&& style
!= wxPENSTYLE_TRANSPARENT
)
47 wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" );
48 style
= wxPENSTYLE_SOLID
;
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 #if FUTURE_WXWIN_COMPATIBILITY_3_0
72 wxPen::wxPen(const wxColour
& col
, int width
, int style
)
74 m_refData
= new wxPenRefData(col
, (wxPenStyle
)style
);
78 wxPen::wxPen(const wxBitmap
& WXUNUSED(stipple
), int WXUNUSED(width
))
80 wxFAIL_MSG( "stipple pens not supported" );
82 m_refData
= new wxPenRefData();
85 bool wxPen::operator==(const wxPen
& pen
) const
87 #warning "this is incorrect (MGL too)"
88 return m_refData
== pen
.m_refData
;
91 void wxPen::SetColour(const wxColour
&colour
)
94 M_PENDATA
->m_colour
= colour
;
97 void wxPen::SetDashes(int WXUNUSED(number_of_dashes
), const wxDash
*WXUNUSED(dash
))
99 wxFAIL_MSG( "SetDashes not implemented" );
102 void wxPen::SetColour(unsigned char red
, unsigned char green
, unsigned char blue
)
105 M_PENDATA
->m_colour
.Set(red
, green
, blue
);
108 void wxPen::SetCap(wxPenCap
WXUNUSED(capStyle
))
110 wxFAIL_MSG( "SetCap not implemented" );
113 void wxPen::SetJoin(wxPenJoin
WXUNUSED(joinStyle
))
115 wxFAIL_MSG( "SetJoin not implemented" );
118 void wxPen::SetStyle(wxPenStyle style
)
121 M_PENDATA
->SetStyle(style
);
124 void wxPen::SetStipple(const wxBitmap
& WXUNUSED(stipple
))
126 wxFAIL_MSG( "SetStipple not implemented" );
129 void wxPen::SetWidth(int width
)
131 wxASSERT_MSG( width
<= 1, "only width=0,1 are implemented" );
134 int wxPen::GetDashes(wxDash
**ptr
) const
136 wxFAIL_MSG( "GetDashes not implemented" );
142 int wxPen::GetDashCount() const
144 wxFAIL_MSG( "GetDashCount not implemented" );
149 wxDash
* wxPen::GetDash() const
151 wxFAIL_MSG( "GetDash not implemented" );
156 wxPenCap
wxPen::GetCap() const
158 wxCHECK_MSG( Ok(), wxCAP_INVALID
, wxT("invalid pen") );
160 wxFAIL_MSG( "GetCap not implemented" );
161 return wxCAP_INVALID
;
164 wxPenJoin
wxPen::GetJoin() const
166 wxCHECK_MSG( Ok(), wxJOIN_INVALID
, wxT("invalid pen") );
168 wxFAIL_MSG( "GetJoin not implemented" );
169 return wxJOIN_INVALID
;
172 wxPenStyle
wxPen::GetStyle() const
174 wxCHECK_MSG( Ok(), wxPENSTYLE_INVALID
, wxT("invalid pen") );
176 return M_PENDATA
->m_style
;
179 int wxPen::GetWidth() const
181 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
186 wxColour
wxPen::GetColour() const
188 wxCHECK_MSG( Ok(), wxNullColour
, wxT("invalid pen") );
190 return M_PENDATA
->m_colour
;
193 wxBitmap
*wxPen::GetStipple() const
195 wxCHECK_MSG( Ok(), NULL
, wxT("invalid pen") );
197 wxFAIL_MSG( "GetStipple not implemented" );
201 wxGDIRefData
*wxPen::CreateGDIRefData() const
203 return new wxPenRefData
;
206 wxGDIRefData
*wxPen::CloneGDIRefData(const wxGDIRefData
*data
) const
208 return new wxPenRefData(*(wxPenRefData
*)data
);