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