]> git.saurik.com Git - wxWidgets.git/blame - src/dfb/pen.cpp
No changes, just fix some typos in wxDFB comments.
[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
4439f88a 43 void SetStyle(wxPenStyle style)
b3c86150 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
ac3688c0
FM
71#if FUTURE_WXWIN_COMPATIBILITY_3_0
72wxPen::wxPen(const wxColour& col, int width, int style)
82cddbd9
FM
73{
74 m_refData = new wxPenRefData(col, (wxPenStyle)style);
75}
ac3688c0 76#endif
82cddbd9 77
b3c86150
VS
78wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
79{
a5001e93 80 wxFAIL_MSG( "stipple pens not supported" );
b3c86150
VS
81
82 m_refData = new wxPenRefData();
83}
84
85bool wxPen::operator==(const wxPen& pen) const
86{
0e1f8ea4 87#warning "this is incorrect"
b3c86150
VS
88 return m_refData == pen.m_refData;
89}
90
91void wxPen::SetColour(const wxColour &colour)
92{
93 AllocExclusive();
94 M_PENDATA->m_colour = colour;
95}
96
97void wxPen::SetDashes(int WXUNUSED(number_of_dashes), const wxDash *WXUNUSED(dash))
98{
a5001e93 99 wxFAIL_MSG( "SetDashes not implemented" );
b3c86150
VS
100}
101
102void wxPen::SetColour(unsigned char red, unsigned char green, unsigned char blue)
103{
104 AllocExclusive();
105 M_PENDATA->m_colour.Set(red, green, blue);
106}
107
82cddbd9 108void wxPen::SetCap(wxPenCap WXUNUSED(capStyle))
b3c86150 109{
a5001e93 110 wxFAIL_MSG( "SetCap not implemented" );
b3c86150
VS
111}
112
82cddbd9 113void wxPen::SetJoin(wxPenJoin WXUNUSED(joinStyle))
b3c86150 114{
a5001e93 115 wxFAIL_MSG( "SetJoin not implemented" );
b3c86150
VS
116}
117
82cddbd9 118void wxPen::SetStyle(wxPenStyle style)
b3c86150
VS
119{
120 AllocExclusive();
121 M_PENDATA->SetStyle(style);
122}
123
124void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple))
125{
a5001e93 126 wxFAIL_MSG( "SetStipple not implemented" );
b3c86150
VS
127}
128
129void wxPen::SetWidth(int width)
130{
a5001e93 131 wxASSERT_MSG( width <= 1, "only width=0,1 are implemented" );
b3c86150
VS
132}
133
134int wxPen::GetDashes(wxDash **ptr) const
135{
a5001e93 136 wxFAIL_MSG( "GetDashes not implemented" );
b3c86150
VS
137
138 *ptr = NULL;
139 return 0;
140}
141
142int wxPen::GetDashCount() const
143{
a5001e93 144 wxFAIL_MSG( "GetDashCount not implemented" );
b3c86150
VS
145
146 return 0;
147}
148
149wxDash* wxPen::GetDash() const
150{
a5001e93 151 wxFAIL_MSG( "GetDash not implemented" );
b3c86150
VS
152
153 return NULL;
154}
155
82cddbd9 156wxPenCap wxPen::GetCap() const
b3c86150 157{
a1b806b9 158 wxCHECK_MSG( IsOk(), wxCAP_INVALID, wxT("invalid pen") );
b3c86150 159
a5001e93 160 wxFAIL_MSG( "GetCap not implemented" );
82cddbd9 161 return wxCAP_INVALID;
b3c86150
VS
162}
163
82cddbd9 164wxPenJoin wxPen::GetJoin() const
b3c86150 165{
a1b806b9 166 wxCHECK_MSG( IsOk(), wxJOIN_INVALID, wxT("invalid pen") );
b3c86150 167
a5001e93 168 wxFAIL_MSG( "GetJoin not implemented" );
82cddbd9 169 return wxJOIN_INVALID;
b3c86150
VS
170}
171
82cddbd9 172wxPenStyle wxPen::GetStyle() const
b3c86150 173{
a1b806b9 174 wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID, wxT("invalid pen") );
b3c86150
VS
175
176 return M_PENDATA->m_style;
177}
178
179int wxPen::GetWidth() const
180{
a1b806b9 181 wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") );
b3c86150
VS
182
183 return 1;
184}
185
231b9591 186wxColour wxPen::GetColour() const
b3c86150 187{
a1b806b9 188 wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid pen") );
b3c86150
VS
189
190 return M_PENDATA->m_colour;
191}
192
193wxBitmap *wxPen::GetStipple() const
194{
a1b806b9 195 wxCHECK_MSG( IsOk(), NULL, wxT("invalid pen") );
b3c86150 196
a5001e93 197 wxFAIL_MSG( "GetStipple not implemented" );
b3c86150
VS
198 return NULL;
199}
200
8f884a0d 201wxGDIRefData *wxPen::CreateGDIRefData() const
b3c86150
VS
202{
203 return new wxPenRefData;
204}
205
8f884a0d 206wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const
b3c86150
VS
207{
208 return new wxPenRefData(*(wxPenRefData *)data);
209}