]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/dfb/pen.cpp
wx.IconBundle support
[wxWidgets.git] / src / dfb / pen.cpp
... / ...
CommitLineData
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 {
43 if ( style != wxSOLID && style != wxTRANSPARENT )
44 {
45 wxFAIL_MSG( _T("only wxSOLID and wxTRANSPARENT styles are supported") );
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{
64 wxASSERT_MSG( width <= 1, _T("only width=0,1 are supported") );
65
66 m_refData = new wxPenRefData(colour, style);
67}
68
69wxPen::wxPen(const wxBitmap& WXUNUSED(stipple), int WXUNUSED(width))
70{
71 wxFAIL_MSG( _T("stipple pens not supported") );
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{
90 wxFAIL_MSG( _T("SetDashes not implemented") );
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{
101 wxFAIL_MSG( _T("SetCap not implemented") );
102}
103
104void wxPen::SetJoin(int WXUNUSED(joinStyle))
105{
106 wxFAIL_MSG( _T("SetJoin not implemented") );
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{
117 wxFAIL_MSG( _T("SetStipple not implemented") );
118}
119
120void wxPen::SetWidth(int width)
121{
122 wxASSERT_MSG( width <= 1, _T("only width=0,1 are implemented") );
123}
124
125int wxPen::GetDashes(wxDash **ptr) const
126{
127 wxFAIL_MSG( _T("GetDashes not implemented") );
128
129 *ptr = NULL;
130 return 0;
131}
132
133int wxPen::GetDashCount() const
134{
135 wxFAIL_MSG( _T("GetDashCount not implemented") );
136
137 return 0;
138}
139
140wxDash* wxPen::GetDash() const
141{
142 wxFAIL_MSG( _T("GetDash not implemented") );
143
144 return NULL;
145}
146
147int wxPen::GetCap() const
148{
149 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
150
151 wxFAIL_MSG( _T("GetCap not implemented") );
152 return -1;
153}
154
155int wxPen::GetJoin() const
156{
157 wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
158
159 wxFAIL_MSG( _T("GetJoin not implemented") );
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
188 wxFAIL_MSG( _T("GetStipple not implemented") );
189 return NULL;
190}
191
192bool wxPen::IsOk() const
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}