1 /////////////////////////////////////////////////////////////////////////////
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
24 #include "wx/os2/private.h"
27 wxPenRefData
::wxPenRefData()
31 m_join
= wxJOIN_ROUND
;
38 wxPenRefData
::wxPenRefData(const wxPenRefData
& data
)
40 m_style
= data
.m_style
;
41 m_width
= data
.m_width
;
44 m_nbDash
= data
.m_nbDash
;
46 m_colour
= data
.m_colour
;
52 wxPenRefData
::~wxPenRefData()
62 wxThePenList
->AddPen(this);
68 wxThePenList
->RemovePen(this);
71 // Should implement Create
72 wxPen
::wxPen(const wxColour
& col
, int Width
, int Style
)
74 m_refData
= new wxPenRefData
;
76 M_PENDATA
->m_colour
= col
;
77 // M_PENDATA->m_stipple = NULL;
78 M_PENDATA
->m_width
= Width
;
79 M_PENDATA
->m_style
= Style
;
80 M_PENDATA
->m_join
= wxJOIN_ROUND
;
81 M_PENDATA
->m_cap
= wxCAP_ROUND
;
82 M_PENDATA
->m_nbDash
= 0 ;
83 M_PENDATA
->m_dash
= 0 ;
84 M_PENDATA
->m_hPen
= 0 ;
88 if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
89 (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
90 (Style == wxUSER_DASH))
91 M_PENDATA->m_width = 1;
96 wxThePenList
->AddPen(this);
99 wxPen
::wxPen(const wxBitmap
& stipple
, int Width
)
101 m_refData
= new wxPenRefData
;
103 M_PENDATA
->m_stipple
= stipple
;
104 M_PENDATA
->m_width
= Width
;
105 M_PENDATA
->m_style
= wxSTIPPLE
;
106 M_PENDATA
->m_join
= wxJOIN_ROUND
;
107 M_PENDATA
->m_cap
= wxCAP_ROUND
;
108 M_PENDATA
->m_nbDash
= 0 ;
109 M_PENDATA
->m_dash
= 0 ;
110 M_PENDATA
->m_hPen
= 0 ;
115 wxThePenList
->AddPen(this);
118 bool wxPen
::RealizeResource()
120 // TODO: create actual pen
124 WXHANDLE wxPen
::GetResourceHandle()
129 return (WXHANDLE
)M_PENDATA
->m_hPen
;
132 bool wxPen
::FreeResource(bool force
)
134 if (M_PENDATA
&& (M_PENDATA
->m_hPen
!= 0))
136 // TODO: DeleteObject((HPEN) M_PENDATA->m_hPen);
137 M_PENDATA
->m_hPen
= 0;
143 bool wxPen
::IsFree() const
145 return (M_PENDATA
&& M_PENDATA
->m_hPen
== 0);
148 void wxPen
::Unshare()
150 // Don't change shared data
153 m_refData
= new wxPenRefData();
157 wxPenRefData
* ref
= new wxPenRefData(*(wxPenRefData
*)m_refData
);
163 void wxPen
::SetColour(const wxColour
& col
)
167 M_PENDATA
->m_colour
= col
;
172 void wxPen
::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
176 M_PENDATA
->m_colour
.Set(r
, g
, b
);
181 void wxPen
::SetWidth(int Width
)
185 M_PENDATA
->m_width
= Width
;
190 void wxPen
::SetStyle(int Style
)
194 M_PENDATA
->m_style
= Style
;
199 void wxPen
::SetStipple(const wxBitmap
& Stipple
)
203 M_PENDATA
->m_stipple
= Stipple
;
204 M_PENDATA
->m_style
= wxSTIPPLE
;
209 void wxPen
::SetDashes(int nb_dashes
, const wxDash
*Dash
)
213 M_PENDATA
->m_nbDash
= nb_dashes
;
214 M_PENDATA
->m_dash
= (wxDash
*)Dash
;
219 void wxPen
::SetJoin(int Join
)
223 M_PENDATA
->m_join
= Join
;
228 void wxPen
::SetCap(int Cap
)
232 M_PENDATA
->m_cap
= Cap
;
237 int wx2os2PenStyle(int wx_style
)
263 // Win32s doesn't have PS_USERSTYLE
264 if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
265 cstyle = PS_USERSTYLE;
267 cstyle = PS_DOT; // We must make a choice... This is mine!