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