]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/pen.cpp
compile fix
[wxWidgets.git] / src / dfb / pen.cpp
CommitLineData
b3c86150
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/dfb/pen.cpp
3// Purpose: wxPen class implementation
4// Author: Vaclav Slavik
5// Created: 2006-08-04
6// RCS-ID: $Id$
7// Copyright: (c) 2006 REA Elektronik GmbH
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11// For compilers that support precompilation, includes "wx.h".
12#include "wx/wxprec.h"
13
14#ifdef __BORLANDC__
15 #pragma hdrstop
16#endif
17
18#include "wx/pen.h"
19
20#ifndef WX_PRECOMP
21 #include "wx/bitmap.h"
22 #include "wx/colour.h"
23#endif
24
25//-----------------------------------------------------------------------------
26// wxPen
27//-----------------------------------------------------------------------------
28
29class wxPenRefData: public wxObjectRefData
30{
31public:
32 wxPenRefData(const wxColour& clr = wxNullColour, int style = wxSOLID)
33 {
34 m_colour = clr;
35 SetStyle(style);
36 }
37
38 wxPenRefData(const wxPenRefData& data)
39 : m_style(data.m_style), m_colour(data.m_colour) {}
40
41 void SetStyle(int style)
42 {
e17cd59f 43 if ( style != wxSOLID && style != wxTRANSPARENT )
b3c86150 44 {
a5001e93 45 wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" );
b3c86150
VS
46 style = wxSOLID;
47 }
48
49 m_style = style;
50 }
51
52 int m_style;
53 wxColour m_colour;
54};
55
56//-----------------------------------------------------------------------------
57
58#define M_PENDATA ((wxPenRefData *)m_refData)
59
60IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
61
62wxPen::wxPen(const wxColour &colour, int width, int style)
63{
a5001e93 64 wxASSERT_MSG( width <= 1, "only width=0,1 are supported" );
b3c86150
VS
65
66 m_refData = new wxPenRefData(colour, style);
67}
68
69wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
70{
a5001e93 71 wxFAIL_MSG( "stipple pens not supported" );
b3c86150
VS
72
73 m_refData = new wxPenRefData();
74}
75
76bool wxPen::operator==(const wxPen& pen) const
77{
78#warning "this is incorrect (MGL too)"
79 return m_refData == pen.m_refData;
80}
81
82void wxPen::SetColour(const wxColour &colour)
83{
84 AllocExclusive();
85 M_PENDATA->m_colour = colour;
86}
87
88void wxPen::SetDashes(int WXUNUSED(number_of_dashes), const wxDash *WXUNUSED(dash))
89{
a5001e93 90 wxFAIL_MSG( "SetDashes not implemented" );
b3c86150
VS
91}
92
93void wxPen::SetColour(unsigned char red, unsigned char green, unsigned char blue)
94{
95 AllocExclusive();
96 M_PENDATA->m_colour.Set(red, green, blue);
97}
98
99void wxPen::SetCap(int WXUNUSED(capStyle))
100{
a5001e93 101 wxFAIL_MSG( "SetCap not implemented" );
b3c86150
VS
102}
103
104void wxPen::SetJoin(int WXUNUSED(joinStyle))
105{
a5001e93 106 wxFAIL_MSG( "SetJoin not implemented" );
b3c86150
VS
107}
108
109void wxPen::SetStyle(int style)
110{
111 AllocExclusive();
112 M_PENDATA->SetStyle(style);
113}
114
115void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple))
116{
a5001e93 117 wxFAIL_MSG( "SetStipple not implemented" );
b3c86150
VS
118}
119
120void wxPen::SetWidth(int width)
121{
a5001e93 122 wxASSERT_MSG( width <= 1, "only width=0,1 are implemented" );
b3c86150
VS
123}
124
125int wxPen::GetDashes(wxDash **ptr) const
126{
a5001e93 127 wxFAIL_MSG( "GetDashes not implemented" );
b3c86150
VS
128
129 *ptr = NULL;
130 return 0;
131}
132
133int wxPen::GetDashCount() const
134{
a5001e93 135 wxFAIL_MSG( "GetDashCount not implemented" );
b3c86150
VS
136
137 return 0;
138}
139
140wxDash* wxPen::GetDash() const
141{
a5001e93 142 wxFAIL_MSG( "GetDash not implemented" );
b3c86150
VS
143
144 return NULL;
145}
146
147int wxPen::GetCap() const
148{
149 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
150
a5001e93 151 wxFAIL_MSG( "GetCap not implemented" );
b3c86150
VS
152 return -1;
153}
154
155int wxPen::GetJoin() const
156{
157 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
158
a5001e93 159 wxFAIL_MSG( "GetJoin not implemented" );
b3c86150
VS
160 return -1;
161}
162
163int wxPen::GetStyle() const
164{
165 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
166
167 return M_PENDATA->m_style;
168}
169
170int wxPen::GetWidth() const
171{
172 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
173
174 return 1;
175}
176
177wxColour &wxPen::GetColour() const
178{
179 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
180
181 return M_PENDATA->m_colour;
182}
183
184wxBitmap *wxPen::GetStipple() const
185{
186 wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") );
187
a5001e93 188 wxFAIL_MSG( "GetStipple not implemented" );
b3c86150
VS
189 return NULL;
190}
191
b7cacb43 192bool wxPen::IsOk() const
b3c86150
VS
193{
194 return ((m_refData) && M_PENDATA->m_colour.Ok());
195}
196
197wxObjectRefData *wxPen::CreateRefData() const
198{
199 return new wxPenRefData;
200}
201
202wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
203{
204 return new wxPenRefData(*(wxPenRefData *)data);
205}