]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/pen.cpp
don't provide unnecessary (as default) arguments to wxPen ctor, this incidentally...
[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
8f884a0d 29class wxPenRefData : public wxGDIRefData
b3c86150
VS
30{
31public:
82cddbd9 32 wxPenRefData(const wxColour& clr = wxNullColour, wxPenStyle style = wxPENSTYLE_SOLID)
b3c86150
VS
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
8f884a0d
VZ
41 virtual bool IsOk() const { return m_colour.IsOk(); }
42
b3c86150
VS
43 void SetStyle(int style)
44 {
ed7ec76d 45 if ( style != wxPENSTYLE_SOLID && style != wxPENSTYLE_TRANSPARENT )
b3c86150 46 {
a5001e93 47 wxFAIL_MSG( "only wxSOLID and wxTRANSPARENT styles are supported" );
ed7ec76d 48 style = wxPENSTYLE_SOLID;
b3c86150
VS
49 }
50
51 m_style = style;
52 }
53
82cddbd9 54 wxPenStyle m_style;
b3c86150
VS
55 wxColour m_colour;
56};
57
58//-----------------------------------------------------------------------------
59
60#define M_PENDATA ((wxPenRefData *)m_refData)
61
62IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
63
82cddbd9 64wxPen::wxPen(const wxColour &colour, int width, wxPenStyle style)
b3c86150 65{
a5001e93 66 wxASSERT_MSG( width <= 1, "only width=0,1 are supported" );
b3c86150
VS
67
68 m_refData = new wxPenRefData(colour, style);
69}
70
82cddbd9
FM
71wxPen::wxPen(const wxColour& col, int width, wxBrushStyle style)
72{
73 m_refData = new wxPenRefData(col, (wxPenStyle)style);
74}
75
b3c86150
VS
76wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
77{
a5001e93 78 wxFAIL_MSG( "stipple pens not supported" );
b3c86150
VS
79
80 m_refData = new wxPenRefData();
81}
82
83bool wxPen::operator==(const wxPen& pen) const
84{
85#warning "this is incorrect (MGL too)"
86 return m_refData == pen.m_refData;
87}
88
89void wxPen::SetColour(const wxColour &colour)
90{
91 AllocExclusive();
92 M_PENDATA->m_colour = colour;
93}
94
95void wxPen::SetDashes(int WXUNUSED(number_of_dashes), const wxDash *WXUNUSED(dash))
96{
a5001e93 97 wxFAIL_MSG( "SetDashes not implemented" );
b3c86150
VS
98}
99
100void wxPen::SetColour(unsigned char red, unsigned char green, unsigned char blue)
101{
102 AllocExclusive();
103 M_PENDATA->m_colour.Set(red, green, blue);
104}
105
82cddbd9 106void wxPen::SetCap(wxPenCap WXUNUSED(capStyle))
b3c86150 107{
a5001e93 108 wxFAIL_MSG( "SetCap not implemented" );
b3c86150
VS
109}
110
82cddbd9 111void wxPen::SetJoin(wxPenJoin WXUNUSED(joinStyle))
b3c86150 112{
a5001e93 113 wxFAIL_MSG( "SetJoin not implemented" );
b3c86150
VS
114}
115
82cddbd9 116void wxPen::SetStyle(wxPenStyle style)
b3c86150
VS
117{
118 AllocExclusive();
119 M_PENDATA->SetStyle(style);
120}
121
122void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple))
123{
a5001e93 124 wxFAIL_MSG( "SetStipple not implemented" );
b3c86150
VS
125}
126
127void wxPen::SetWidth(int width)
128{
a5001e93 129 wxASSERT_MSG( width <= 1, "only width=0,1 are implemented" );
b3c86150
VS
130}
131
132int wxPen::GetDashes(wxDash **ptr) const
133{
a5001e93 134 wxFAIL_MSG( "GetDashes not implemented" );
b3c86150
VS
135
136 *ptr = NULL;
137 return 0;
138}
139
140int wxPen::GetDashCount() const
141{
a5001e93 142 wxFAIL_MSG( "GetDashCount not implemented" );
b3c86150
VS
143
144 return 0;
145}
146
147wxDash* wxPen::GetDash() const
148{
a5001e93 149 wxFAIL_MSG( "GetDash not implemented" );
b3c86150
VS
150
151 return NULL;
152}
153
82cddbd9 154wxPenCap wxPen::GetCap() const
b3c86150 155{
82cddbd9 156 wxCHECK_MSG( Ok(), wxCAP_INVALID, wxT("invalid pen") );
b3c86150 157
a5001e93 158 wxFAIL_MSG( "GetCap not implemented" );
82cddbd9 159 return wxCAP_INVALID;
b3c86150
VS
160}
161
82cddbd9 162wxPenJoin wxPen::GetJoin() const
b3c86150 163{
82cddbd9 164 wxCHECK_MSG( Ok(), wxJOIN_INVALID, wxT("invalid pen") );
b3c86150 165
a5001e93 166 wxFAIL_MSG( "GetJoin not implemented" );
82cddbd9 167 return wxJOIN_INVALID;
b3c86150
VS
168}
169
82cddbd9 170wxPenStyle wxPen::GetStyle() const
b3c86150 171{
ed7ec76d 172 wxCHECK_MSG( Ok(), wxPENSTYLE_MAX, wxT("invalid pen") );
b3c86150
VS
173
174 return M_PENDATA->m_style;
175}
176
177int wxPen::GetWidth() const
178{
179 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
180
181 return 1;
182}
183
184wxColour &wxPen::GetColour() const
185{
186 wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
187
188 return M_PENDATA->m_colour;
189}
190
191wxBitmap *wxPen::GetStipple() const
192{
193 wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") );
194
a5001e93 195 wxFAIL_MSG( "GetStipple not implemented" );
b3c86150
VS
196 return NULL;
197}
198
8f884a0d 199wxGDIRefData *wxPen::CreateGDIRefData() const
b3c86150
VS
200{
201 return new wxPenRefData;
202}
203
8f884a0d 204wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
205{
206 return new wxPenRefData(*(wxPenRefData *)data);
207}