]>
Commit | Line | Data |
---|---|---|
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 | 29 | class wxPenRefData : public wxGDIRefData |
b3c86150 VS |
30 | { |
31 | public: | |
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 | ||
b3c86150 VS |
43 | void SetStyle(int style) |
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 | ||
62 | IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) | |
63 | ||
82cddbd9 | 64 | wxPen::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 |
72 | wxPen::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 |
78 | wxPen::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 | ||
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 | { | |
a5001e93 | 99 | wxFAIL_MSG( "SetDashes not implemented" ); |
b3c86150 VS |
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 | ||
82cddbd9 | 108 | void wxPen::SetCap(wxPenCap WXUNUSED(capStyle)) |
b3c86150 | 109 | { |
a5001e93 | 110 | wxFAIL_MSG( "SetCap not implemented" ); |
b3c86150 VS |
111 | } |
112 | ||
82cddbd9 | 113 | void wxPen::SetJoin(wxPenJoin WXUNUSED(joinStyle)) |
b3c86150 | 114 | { |
a5001e93 | 115 | wxFAIL_MSG( "SetJoin not implemented" ); |
b3c86150 VS |
116 | } |
117 | ||
82cddbd9 | 118 | void wxPen::SetStyle(wxPenStyle style) |
b3c86150 VS |
119 | { |
120 | AllocExclusive(); | |
121 | M_PENDATA->SetStyle(style); | |
122 | } | |
123 | ||
124 | void wxPen::SetStipple(const wxBitmap& WXUNUSED(stipple)) | |
125 | { | |
a5001e93 | 126 | wxFAIL_MSG( "SetStipple not implemented" ); |
b3c86150 VS |
127 | } |
128 | ||
129 | void wxPen::SetWidth(int width) | |
130 | { | |
a5001e93 | 131 | wxASSERT_MSG( width <= 1, "only width=0,1 are implemented" ); |
b3c86150 VS |
132 | } |
133 | ||
134 | int wxPen::GetDashes(wxDash **ptr) const | |
135 | { | |
a5001e93 | 136 | wxFAIL_MSG( "GetDashes not implemented" ); |
b3c86150 VS |
137 | |
138 | *ptr = NULL; | |
139 | return 0; | |
140 | } | |
141 | ||
142 | int wxPen::GetDashCount() const | |
143 | { | |
a5001e93 | 144 | wxFAIL_MSG( "GetDashCount not implemented" ); |
b3c86150 VS |
145 | |
146 | return 0; | |
147 | } | |
148 | ||
149 | wxDash* wxPen::GetDash() const | |
150 | { | |
a5001e93 | 151 | wxFAIL_MSG( "GetDash not implemented" ); |
b3c86150 VS |
152 | |
153 | return NULL; | |
154 | } | |
155 | ||
82cddbd9 | 156 | wxPenCap wxPen::GetCap() const |
b3c86150 | 157 | { |
82cddbd9 | 158 | wxCHECK_MSG( Ok(), wxCAP_INVALID, wxT("invalid pen") ); |
b3c86150 | 159 | |
a5001e93 | 160 | wxFAIL_MSG( "GetCap not implemented" ); |
82cddbd9 | 161 | return wxCAP_INVALID; |
b3c86150 VS |
162 | } |
163 | ||
82cddbd9 | 164 | wxPenJoin wxPen::GetJoin() const |
b3c86150 | 165 | { |
82cddbd9 | 166 | wxCHECK_MSG( Ok(), wxJOIN_INVALID, wxT("invalid pen") ); |
b3c86150 | 167 | |
a5001e93 | 168 | wxFAIL_MSG( "GetJoin not implemented" ); |
82cddbd9 | 169 | return wxJOIN_INVALID; |
b3c86150 VS |
170 | } |
171 | ||
82cddbd9 | 172 | wxPenStyle wxPen::GetStyle() const |
b3c86150 | 173 | { |
ac3688c0 | 174 | wxCHECK_MSG( Ok(), wxPENSTYLE_INVALID, wxT("invalid pen") ); |
b3c86150 VS |
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 | ||
a5001e93 | 197 | wxFAIL_MSG( "GetStipple not implemented" ); |
b3c86150 VS |
198 | return NULL; |
199 | } | |
200 | ||
8f884a0d | 201 | wxGDIRefData *wxPen::CreateGDIRefData() const |
b3c86150 VS |
202 | { |
203 | return new wxPenRefData; | |
204 | } | |
205 | ||
8f884a0d | 206 | wxGDIRefData *wxPen::CloneGDIRefData(const wxGDIRefData *data) const |
b3c86150 VS |
207 | { |
208 | return new wxPenRefData(*(wxPenRefData *)data); | |
209 | } |