]>
Commit | Line | Data |
---|---|---|
0e320a79 | 1 | ///////////////////////////////////////////////////////////////////////////// |
46562151 | 2 | // Name: src/os2/pen.cpp |
0e320a79 | 3 | // Purpose: wxPen |
cdf1e714 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
cdf1e714 | 6 | // Created: 10/10/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
cdf1e714 | 8 | // Copyright: (c) David Webster |
65571936 | 9 | // Licence: wxWindows licence |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
cdf1e714 DW |
12 | // For compilers that support precompilation, includes "wx.h". |
13 | #include "wx/wxprec.h" | |
0e320a79 | 14 | |
f5590243 WS |
15 | #include "wx/pen.h" |
16 | ||
cdf1e714 | 17 | #ifndef WX_PRECOMP |
521bf4ff WS |
18 | #include <stdio.h> |
19 | #include "wx/list.h" | |
20 | #include "wx/utils.h" | |
21 | #include "wx/app.h" | |
521bf4ff | 22 | #include "wx/log.h" |
0e320a79 DW |
23 | #endif |
24 | ||
cdf1e714 | 25 | #include "wx/os2/private.h" |
cdf1e714 | 26 | |
1aca6611 SN |
27 | class WXDLLIMPEXP_FWD_CORE wxPen; |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
30 | // wxPenRefData: contains information about an HPEN and its handle | |
31 | // ---------------------------------------------------------------------------- | |
32 | ||
33 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
34 | { | |
35 | friend class WXDLLIMPEXP_FWD_CORE wxPen; | |
36 | public: | |
37 | wxPenRefData(); | |
38 | wxPenRefData(const wxPenRefData& rData); | |
39 | wxPenRefData(const wxColour& col, int width, wxPenStyle style); | |
40 | wxPenRefData(const wxBitmap& stipple, int width); | |
41 | virtual ~wxPenRefData(); | |
42 | ||
43 | bool operator==(const wxPenRefData& data) const | |
44 | { | |
45 | // we intentionally don't compare m_hPen fields here | |
46 | return m_nStyle == data.m_nStyle && | |
47 | m_nWidth == data.m_nWidth && | |
48 | m_nJoin == data.m_nJoin && | |
49 | m_nCap == data.m_nCap && | |
50 | m_vColour == data.m_vColour && | |
51 | (m_nStyle != wxPENSTYLE_STIPPLE || m_vStipple.IsSameAs(data.m_vStipple)) && | |
52 | (m_nStyle != wxPENSTYLE_USER_DASH || | |
53 | (m_dash == data.m_dash && | |
54 | memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); | |
55 | } | |
56 | ||
57 | private: | |
58 | // initialize the fields which have reasonable default values | |
59 | // | |
60 | // doesn't initialize m_width and m_style which must be initialize in ctor | |
61 | void Init() | |
62 | { | |
63 | m_nJoin = wxJOIN_ROUND; | |
64 | m_nCap = wxCAP_ROUND; | |
65 | m_nbDash = 0; | |
66 | m_dash = NULL; | |
67 | m_hPen = 0; | |
68 | } | |
69 | ||
70 | int m_nWidth; | |
71 | wxPenStyle m_nStyle; | |
72 | wxPenJoin m_nJoin; | |
73 | wxPenCap m_nCap; | |
74 | wxBitmap m_vStipple; | |
75 | int m_nbDash; | |
76 | wxDash * m_dash; | |
77 | wxColour m_vColour; | |
78 | WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with | |
79 | ||
c0c133e1 | 80 | wxDECLARE_NO_ASSIGN_CLASS(wxPenRefData); |
1aca6611 SN |
81 | }; |
82 | ||
83 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
84 | ||
85 | // ---------------------------------------------------------------------------- | |
86 | // wxPenRefData ctors/dtor | |
87 | // ---------------------------------------------------------------------------- | |
004fd0c8 | 88 | |
0e320a79 DW |
89 | wxPenRefData::wxPenRefData() |
90 | { | |
1aca6611 SN |
91 | Init(); |
92 | ||
ed7ec76d | 93 | m_nStyle = wxPENSTYLE_SOLID; |
26ac77db | 94 | m_nWidth = 1; |
26ac77db DW |
95 | } // end of wxPenRefData::wxPenRefData |
96 | ||
97 | wxPenRefData::wxPenRefData( | |
98 | const wxPenRefData& rData | |
99 | ) | |
0e320a79 | 100 | { |
26ac77db DW |
101 | m_nStyle = rData.m_nStyle; |
102 | m_nWidth = rData.m_nWidth; | |
103 | m_nJoin = rData.m_nJoin; | |
104 | m_nCap = rData.m_nCap; | |
9e878707 SN |
105 | m_nbDash = rData.m_nbDash; |
106 | m_dash = rData.m_dash; | |
26ac77db DW |
107 | m_vColour = rData.m_vColour; |
108 | m_hPen = 0L; | |
109 | } // end of wxPenRefData::wxPenRefData | |
0e320a79 | 110 | |
1aca6611 | 111 | wxPenRefData::wxPenRefData(const wxColour& col, int width, wxPenStyle style) |
0e320a79 | 112 | { |
1aca6611 SN |
113 | Init(); |
114 | ||
115 | m_nStyle = style; | |
116 | m_nWidth = width; | |
0e320a79 | 117 | |
1aca6611 SN |
118 | m_vColour = col; |
119 | } | |
120 | ||
121 | wxPenRefData::wxPenRefData(const wxBitmap& stipple, int width) | |
0e320a79 | 122 | { |
1aca6611 SN |
123 | Init(); |
124 | ||
125 | m_nStyle = wxPENSTYLE_STIPPLE; | |
126 | m_nWidth = width; | |
127 | ||
128 | m_vStipple = stipple; | |
129 | } | |
0e320a79 | 130 | |
1aca6611 | 131 | wxPenRefData::~wxPenRefData() |
0e320a79 | 132 | { |
1aca6611 SN |
133 | } // end of wxPenRefData::~wxPenRefData |
134 | ||
135 | // ---------------------------------------------------------------------------- | |
136 | // wxPen | |
137 | // ---------------------------------------------------------------------------- | |
138 | ||
139 | IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) | |
0e320a79 | 140 | |
26ac77db DW |
141 | wxPen::wxPen( |
142 | const wxColour& rColour | |
143 | , int nWidth | |
82cddbd9 | 144 | , wxPenStyle nStyle |
26ac77db | 145 | ) |
0e320a79 | 146 | { |
1aca6611 | 147 | m_refData = new wxPenRefData(rColour, nWidth, nStyle); |
26ac77db | 148 | |
0e320a79 | 149 | RealizeResource(); |
26ac77db | 150 | } // end of wxPen::wxPen |
0e320a79 | 151 | |
ac3688c0 FM |
152 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 |
153 | wxPen::wxPen(const wxColour& colour, int width, int style) | |
82cddbd9 | 154 | { |
1aca6611 | 155 | m_refData = new wxPenRefData(colour, width, (wxPenStyle)style); |
82cddbd9 FM |
156 | |
157 | RealizeResource(); | |
158 | } | |
ac3688c0 | 159 | #endif |
82cddbd9 | 160 | |
26ac77db DW |
161 | wxPen::wxPen( |
162 | const wxBitmap& rStipple | |
163 | , int nWidth | |
164 | ) | |
0e320a79 | 165 | { |
1aca6611 | 166 | m_refData = new wxPenRefData (rStipple, nWidth); |
0e320a79 DW |
167 | |
168 | RealizeResource(); | |
26ac77db | 169 | } // end of wxPen::wxPen |
0e320a79 | 170 | |
34f00837 SN |
171 | bool wxPen::operator==(const wxPen& pen) const |
172 | { | |
173 | const wxPenRefData * | |
5c33522f | 174 | penData = static_cast<const wxPenRefData *>(pen.m_refData); |
34f00837 SN |
175 | |
176 | // an invalid pen is only equal to another invalid pen | |
177 | return m_refData ? penData && *M_PENDATA == *penData : !penData; | |
178 | } | |
179 | ||
272ebf16 | 180 | int wx2os2PenStyle( |
82cddbd9 | 181 | wxPenStyle nWxStyle |
272ebf16 SN |
182 | ); |
183 | ||
cdf1e714 DW |
184 | bool wxPen::RealizeResource() |
185 | { | |
26ac77db DW |
186 | BOOL bOk; |
187 | ERRORID vError; | |
188 | wxString sError; | |
189 | ||
190 | if (M_PENDATA && M_PENDATA->m_hPen == 0L) | |
191 | { | |
192 | SIZEL vSize = {0, 0}; | |
193 | DEVOPENSTRUC vDop = {0L, "DISPLAY", NULL, 0L, 0L, 0L, 0L, 0L, 0L}; | |
194 | HDC hDC = ::DevOpenDC( vHabmain | |
195 | ,OD_MEMORY | |
196 | ,"*" | |
197 | ,5L | |
198 | ,(PDEVOPENDATA)&vDop | |
199 | ,NULLHANDLE | |
200 | ); | |
201 | M_PENDATA->m_hPen = (WXHPEN)::GpiCreatePS( vHabmain | |
202 | ,hDC | |
203 | ,&vSize | |
204 | ,PU_PELS | GPIT_MICRO | GPIA_ASSOC | |
205 | ); | |
206 | } | |
207 | if (M_PENDATA) | |
208 | { | |
209 | // | |
210 | // Set the color table to RGB mode | |
211 | // | |
212 | if (!::GpiCreateLogColorTable( (HPS)M_PENDATA->m_hPen | |
213 | ,0L | |
214 | ,LCOLF_RGB | |
215 | ,0L | |
216 | ,0L | |
217 | ,NULL | |
218 | )) | |
219 | { | |
220 | vError = ::WinGetLastError(vHabmain); | |
221 | sError = wxPMErrorToStr(vError); | |
9a83f860 | 222 | wxLogError(wxT("Unable to set current color table to RGB mode. Error: %s\n"), sError.c_str()); |
46562151 | 223 | return false; |
26ac77db | 224 | } |
ed7ec76d | 225 | if (M_PENDATA->m_nStyle == wxPENSTYLE_TRANSPARENT) |
26ac77db | 226 | { |
6670f564 | 227 | return true; |
26ac77db DW |
228 | } |
229 | ||
6670f564 WS |
230 | COLORREF vPmColour = 0L; |
231 | USHORT uLineType = (USHORT)wx2os2PenStyle(M_PENDATA->m_nStyle); | |
26ac77db DW |
232 | |
233 | vPmColour = M_PENDATA->m_vColour.GetPixel(); | |
234 | ||
235 | USHORT uJoin = 0L; | |
236 | ||
237 | switch(M_PENDATA->m_nJoin) | |
238 | { | |
239 | case wxJOIN_BEVEL: | |
240 | uJoin = LINEJOIN_BEVEL; | |
241 | break; | |
242 | ||
243 | case wxJOIN_MITER: | |
244 | uJoin = LINEJOIN_MITRE; | |
245 | break; | |
246 | ||
247 | case wxJOIN_ROUND: | |
248 | uJoin = LINEJOIN_ROUND; | |
249 | break; | |
250 | } | |
251 | ||
252 | USHORT uCap = 0L; | |
253 | ||
254 | switch(M_PENDATA->m_nCap) | |
255 | { | |
256 | case wxCAP_PROJECTING: | |
257 | uCap = LINEEND_SQUARE; | |
258 | break; | |
259 | ||
260 | case wxCAP_BUTT: | |
261 | uCap = LINEEND_FLAT; | |
262 | break; | |
263 | ||
264 | case wxCAP_ROUND: | |
265 | uCap = LINEEND_ROUND; | |
266 | break; | |
267 | } | |
268 | m_vLineBundle.lColor = (LONG)vPmColour; | |
269 | m_vLineBundle.usMixMode = FM_OVERPAINT; | |
aa2f364e SN |
270 | if (M_PENDATA->m_nWidth < 1) |
271 | M_PENDATA->m_nWidth = 1; | |
26ac77db DW |
272 | m_vLineBundle.fxWidth = M_PENDATA->m_nWidth; |
273 | m_vLineBundle.lGeomWidth = M_PENDATA->m_nWidth; | |
274 | m_vLineBundle.usType = uLineType; | |
275 | m_vLineBundle.usEnd = uCap; | |
276 | m_vLineBundle.usJoin = uJoin; | |
277 | ||
278 | bOk = ::GpiSetAttrs( M_PENDATA->m_hPen | |
279 | ,PRIM_LINE | |
280 | ,LBB_COLOR | LBB_MIX_MODE | LBB_WIDTH | LBB_GEOM_WIDTH | LBB_TYPE | LBB_END | LBB_JOIN | |
281 | ,0L | |
282 | ,&m_vLineBundle | |
283 | ); | |
284 | if (!bOk) | |
285 | { | |
286 | vError = ::WinGetLastError(vHabmain); | |
287 | sError = wxPMErrorToStr(vError); | |
9a83f860 | 288 | wxLogError(wxT("Can't set Gpi attributes for a LINEBUNDLE. Error: %s\n"), sError.c_str()); |
46562151 | 289 | return false; |
26ac77db DW |
290 | } |
291 | ||
d697657f DW |
292 | ULONG flAttrMask = 0L; |
293 | ULONG flDefMask = 0L; | |
26ac77db DW |
294 | switch(M_PENDATA->m_nStyle) |
295 | { | |
ed7ec76d | 296 | case wxPENSTYLE_STIPPLE: |
26ac77db DW |
297 | ::GpiSetBitmapId( M_PENDATA->m_hPen |
298 | ,(USHORT)M_PENDATA->m_vStipple.GetHBITMAP() | |
299 | ,(USHORT)M_PENDATA->m_vStipple.GetId() | |
300 | ); | |
301 | ::GpiSetPatternSet( M_PENDATA->m_hPen | |
302 | ,(USHORT)M_PENDATA->m_vStipple.GetId() | |
303 | ); | |
d697657f DW |
304 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SET | ABB_SYMBOL; |
305 | flDefMask = ABB_REF_POINT; | |
26ac77db DW |
306 | break; |
307 | ||
ed7ec76d | 308 | case wxPENSTYLE_BDIAGONAL_HATCH: |
26ac77db DW |
309 | m_vAreaBundle.usSymbol = PATSYM_DIAG3; |
310 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
311 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
312 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
313 | break; |
314 | ||
ed7ec76d | 315 | case wxPENSTYLE_CROSSDIAG_HATCH: |
26ac77db DW |
316 | m_vAreaBundle.usSymbol = PATSYM_DIAGHATCH; |
317 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
318 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
319 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
320 | break; |
321 | ||
ed7ec76d | 322 | case wxPENSTYLE_FDIAGONAL_HATCH: |
26ac77db DW |
323 | m_vAreaBundle.usSymbol = PATSYM_DIAG1; |
324 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
325 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
326 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
327 | break; |
328 | ||
ed7ec76d | 329 | case wxPENSTYLE_CROSS_HATCH: |
26ac77db DW |
330 | m_vAreaBundle.usSymbol = PATSYM_HATCH; |
331 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
332 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
333 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
334 | break; |
335 | ||
ed7ec76d | 336 | case wxPENSTYLE_HORIZONTAL_HATCH: |
26ac77db DW |
337 | m_vAreaBundle.usSymbol = PATSYM_HORIZ; |
338 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
339 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
340 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
341 | break; |
342 | ||
ed7ec76d | 343 | case wxPENSTYLE_VERTICAL_HATCH: |
26ac77db DW |
344 | m_vAreaBundle.usSymbol = PATSYM_VERT; |
345 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
346 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
347 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
348 | break; |
349 | ||
350 | default: | |
351 | m_vAreaBundle.usSymbol = PATSYM_SOLID; | |
352 | m_vAreaBundle.usSet = LCID_DEFAULT; | |
d697657f DW |
353 | flAttrMask = ABB_COLOR | ABB_BACK_COLOR | ABB_MIX_MODE | ABB_BACK_MIX_MODE | ABB_SYMBOL; |
354 | flDefMask = ABB_SET | ABB_REF_POINT; | |
26ac77db DW |
355 | break; |
356 | } | |
357 | ||
358 | m_vAreaBundle.lColor = vPmColour; | |
8d854fa9 | 359 | m_vAreaBundle.lBackColor = RGB_WHITE; |
26ac77db DW |
360 | m_vAreaBundle.usMixMode = FM_OVERPAINT; |
361 | m_vAreaBundle.usBackMixMode = BM_OVERPAINT; | |
362 | ||
363 | bOk = ::GpiSetAttrs( M_PENDATA->m_hPen | |
364 | ,PRIM_AREA | |
d697657f DW |
365 | ,flAttrMask |
366 | ,flDefMask | |
26ac77db DW |
367 | ,&m_vAreaBundle |
368 | ); | |
369 | if (!bOk) | |
370 | { | |
371 | vError = ::WinGetLastError(vHabmain); | |
372 | sError = wxPMErrorToStr(vError); | |
9a83f860 | 373 | wxLogError(wxT("Can't set Gpi attributes for an AREABUNDLE. Error: %s\n"), sError.c_str()); |
26ac77db | 374 | } |
6670f564 WS |
375 | |
376 | return (bool)bOk; | |
26ac77db | 377 | } |
6670f564 | 378 | return false; |
26ac77db | 379 | } // end of wxPen::RealizeResource |
cdf1e714 | 380 | |
17b1d76b | 381 | WXHANDLE wxPen::GetResourceHandle() const |
cdf1e714 | 382 | { |
26ac77db | 383 | if (!M_PENDATA) |
cdf1e714 DW |
384 | return 0; |
385 | else | |
386 | return (WXHANDLE)M_PENDATA->m_hPen; | |
26ac77db | 387 | } // end of wxPen::GetResourceHandle |
cdf1e714 | 388 | |
6670f564 | 389 | bool wxPen::FreeResource( bool WXUNUSED(bForce) ) |
cdf1e714 DW |
390 | { |
391 | if (M_PENDATA && (M_PENDATA->m_hPen != 0)) | |
392 | { | |
cdf1e714 | 393 | M_PENDATA->m_hPen = 0; |
6670f564 | 394 | return true; |
cdf1e714 | 395 | } |
6670f564 | 396 | else return false; |
26ac77db | 397 | } // end of wxPen::FreeResource |
cdf1e714 | 398 | |
e6ebb514 DW |
399 | bool wxPen::IsFree() const |
400 | { | |
26ac77db | 401 | return (M_PENDATA && M_PENDATA->m_hPen == 0); |
e6ebb514 DW |
402 | } |
403 | ||
4b3f61d1 | 404 | wxGDIRefData* wxPen::CreateGDIRefData() const |
0e320a79 | 405 | { |
4b3f61d1 SN |
406 | return new wxPenRefData; |
407 | } | |
408 | ||
409 | wxGDIRefData* wxPen::CloneGDIRefData(const wxGDIRefData* data) const | |
410 | { | |
5c33522f | 411 | return new wxPenRefData(*static_cast<const wxPenRefData*>(data)); |
4b3f61d1 | 412 | } |
0e320a79 | 413 | |
46562151 | 414 | void wxPen::SetColour( const wxColour& rColour ) |
0e320a79 | 415 | { |
4b3f61d1 | 416 | AllocExclusive(); |
26ac77db | 417 | M_PENDATA->m_vColour = rColour; |
0e320a79 | 418 | RealizeResource(); |
26ac77db | 419 | } // end of wxPen::SetColour |
0e320a79 | 420 | |
1a1498c0 | 421 | void wxPen::SetColour( unsigned char cRed, unsigned char cGreen, unsigned char cBlue) |
0e320a79 | 422 | { |
4b3f61d1 | 423 | AllocExclusive(); |
26ac77db | 424 | M_PENDATA->m_vColour.Set(cRed, cGreen, cBlue); |
0e320a79 | 425 | RealizeResource(); |
26ac77db | 426 | } // end of wxPen::SetColour |
0e320a79 | 427 | |
46562151 | 428 | void wxPen::SetPS( HPS hPS ) |
0e320a79 | 429 | { |
4b3f61d1 | 430 | AllocExclusive(); |
26ac77db DW |
431 | if (M_PENDATA->m_hPen) |
432 | ::GpiDestroyPS(M_PENDATA->m_hPen); | |
433 | M_PENDATA->m_hPen = hPS; | |
0e320a79 | 434 | RealizeResource(); |
26ac77db | 435 | } // end of WxWinGdi_CPen::SetPS |
0e320a79 | 436 | |
26ac77db DW |
437 | void wxPen::SetWidth( |
438 | int nWidth | |
439 | ) | |
0e320a79 | 440 | { |
4b3f61d1 | 441 | AllocExclusive(); |
26ac77db | 442 | M_PENDATA->m_nWidth = nWidth; |
0e320a79 | 443 | RealizeResource(); |
26ac77db | 444 | } // end of wxPen::SetWidth |
0e320a79 | 445 | |
26ac77db | 446 | void wxPen::SetStyle( |
82cddbd9 | 447 | wxPenStyle nStyle |
26ac77db | 448 | ) |
0e320a79 | 449 | { |
4b3f61d1 | 450 | AllocExclusive(); |
26ac77db | 451 | M_PENDATA->m_nStyle = nStyle; |
0e320a79 | 452 | RealizeResource(); |
26ac77db | 453 | } // end of wxPen::SetStyle |
0e320a79 | 454 | |
26ac77db DW |
455 | void wxPen::SetStipple( |
456 | const wxBitmap& rStipple | |
457 | ) | |
0e320a79 | 458 | { |
4b3f61d1 | 459 | AllocExclusive(); |
26ac77db | 460 | M_PENDATA->m_vStipple = rStipple; |
1aca6611 | 461 | M_PENDATA->m_nStyle = wxPENSTYLE_STIPPLE; |
0e320a79 | 462 | RealizeResource(); |
26ac77db | 463 | } // end of wxPen::SetStipple |
0e320a79 | 464 | |
6670f564 WS |
465 | void wxPen::SetDashes( int WXUNUSED(nNbDashes), |
466 | const wxDash* WXUNUSED(pDash) ) | |
26ac77db DW |
467 | { |
468 | // | |
469 | // Does nothing under OS/2 | |
470 | // | |
471 | } // end of wxPen::SetDashes | |
472 | ||
473 | void wxPen::SetJoin( | |
82cddbd9 | 474 | wxPenJoin nJoin |
26ac77db | 475 | ) |
0e320a79 | 476 | { |
4b3f61d1 | 477 | AllocExclusive(); |
26ac77db | 478 | M_PENDATA->m_nJoin = nJoin; |
0e320a79 | 479 | RealizeResource(); |
26ac77db | 480 | } // end of wxPen::SetJoin |
0e320a79 | 481 | |
26ac77db | 482 | void wxPen::SetCap( |
82cddbd9 | 483 | wxPenCap nCap |
26ac77db | 484 | ) |
0e320a79 | 485 | { |
4b3f61d1 | 486 | AllocExclusive(); |
26ac77db | 487 | M_PENDATA->m_nCap = nCap; |
0e320a79 | 488 | RealizeResource(); |
26ac77db | 489 | } // end of wxPen::SetCap |
0e320a79 | 490 | |
231b9591 | 491 | wxColour wxPen::GetColour() const |
1aca6611 | 492 | { |
a1b806b9 | 493 | wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid pen") ); |
1aca6611 SN |
494 | |
495 | return M_PENDATA->m_vColour; | |
496 | } | |
497 | ||
498 | int wxPen::GetWidth() const | |
499 | { | |
a1b806b9 | 500 | wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") ); |
1aca6611 SN |
501 | |
502 | return M_PENDATA->m_nWidth; | |
503 | } | |
504 | ||
505 | wxPenStyle wxPen::GetStyle() const | |
506 | { | |
a1b806b9 | 507 | wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID, wxT("invalid pen") ); |
1aca6611 SN |
508 | |
509 | return M_PENDATA->m_nStyle; | |
510 | } | |
511 | ||
512 | wxPenJoin wxPen::GetJoin() const | |
513 | { | |
a1b806b9 | 514 | wxCHECK_MSG( IsOk(), wxJOIN_INVALID, wxT("invalid pen") ); |
1aca6611 SN |
515 | |
516 | return M_PENDATA->m_nJoin; | |
517 | } | |
518 | ||
519 | wxPenCap wxPen::GetCap() const | |
520 | { | |
a1b806b9 | 521 | wxCHECK_MSG( IsOk(), wxCAP_INVALID, wxT("invalid pen") ); |
1aca6611 SN |
522 | |
523 | return M_PENDATA->m_nCap; | |
524 | } | |
525 | ||
526 | int wxPen::GetPS() const | |
527 | { | |
a1b806b9 | 528 | wxCHECK_MSG( IsOk(), 0, wxT("invalid pen") ); |
1aca6611 SN |
529 | |
530 | return M_PENDATA->m_hPen; | |
531 | } | |
532 | ||
533 | int wxPen::GetDashes(wxDash** ptr) const | |
534 | { | |
a1b806b9 | 535 | wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") ); |
1aca6611 SN |
536 | |
537 | *ptr = M_PENDATA->m_dash; | |
538 | return M_PENDATA->m_nbDash; | |
539 | } | |
540 | ||
541 | wxDash* wxPen::GetDash() const | |
542 | { | |
a1b806b9 | 543 | wxCHECK_MSG( IsOk(), NULL, wxT("invalid pen") ); |
1aca6611 SN |
544 | |
545 | return M_PENDATA->m_dash; | |
546 | } | |
547 | ||
548 | int wxPen::GetDashCount() const | |
549 | { | |
a1b806b9 | 550 | wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") ); |
1aca6611 SN |
551 | |
552 | return M_PENDATA->m_nbDash; | |
553 | } | |
554 | ||
555 | wxBitmap* wxPen::GetStipple() const | |
556 | { | |
a1b806b9 | 557 | wxCHECK_MSG( IsOk(), NULL, wxT("invalid pen") ); |
1aca6611 SN |
558 | |
559 | return &(M_PENDATA->m_vStipple); | |
560 | } | |
561 | ||
26ac77db | 562 | int wx2os2PenStyle( |
82cddbd9 | 563 | wxPenStyle nWxStyle |
26ac77db | 564 | ) |
cdf1e714 | 565 | { |
26ac77db DW |
566 | int nPMStyle = 0; |
567 | ||
568 | switch (nWxStyle) | |
fb46a9a6 | 569 | { |
ed7ec76d | 570 | case wxPENSTYLE_DOT: |
26ac77db DW |
571 | nPMStyle = LINETYPE_DOT; |
572 | break; | |
573 | ||
ed7ec76d | 574 | case wxPENSTYLE_DOT_DASH: |
26ac77db DW |
575 | nPMStyle = LINETYPE_DASHDOT; |
576 | break; | |
577 | ||
ed7ec76d | 578 | case wxPENSTYLE_SHORT_DASH: |
26ac77db DW |
579 | nPMStyle = LINETYPE_SHORTDASH; |
580 | break; | |
581 | ||
ed7ec76d | 582 | case wxPENSTYLE_LONG_DASH: |
26ac77db DW |
583 | nPMStyle = LINETYPE_LONGDASH; |
584 | break; | |
585 | ||
ed7ec76d | 586 | case wxPENSTYLE_TRANSPARENT: |
26ac77db DW |
587 | nPMStyle = LINETYPE_INVISIBLE; |
588 | break; | |
589 | ||
ed7ec76d | 590 | case wxPENSTYLE_USER_DASH: |
26ac77db DW |
591 | nPMStyle = LINETYPE_DASHDOUBLEDOT; // We must make a choice... This is mine! |
592 | break; | |
593 | ||
ed7ec76d | 594 | case wxPENSTYLE_SOLID: |
26ac77db DW |
595 | default: |
596 | nPMStyle = LINETYPE_SOLID; | |
597 | break; | |
598 | } | |
599 | return nPMStyle; | |
600 | } // end of wx2os2PenStyle |