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