]>
git.saurik.com Git - wxWidgets.git/blob - src/os2/pen.cpp
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 IMPLEMENT_DYNAMIC_CLASS(wxPen
, wxGDIObject
)
29 wxPenRefData::wxPenRefData()
33 m_join
= wxJOIN_ROUND
;
40 wxPenRefData::wxPenRefData(const wxPenRefData
& data
)
42 m_style
= data
.m_style
;
43 m_width
= data
.m_width
;
46 m_nbDash
= data
.m_nbDash
;
48 m_colour
= data
.m_colour
;
54 wxPenRefData::~wxPenRefData()
64 wxThePenList
->AddPen(this);
70 wxThePenList
->RemovePen(this);
73 // Should implement Create
74 wxPen::wxPen(const wxColour
& col
, int Width
, int Style
)
76 m_refData
= new wxPenRefData
;
78 M_PENDATA
->m_colour
= col
;
79 // M_PENDATA->m_stipple = NULL;
80 M_PENDATA
->m_width
= Width
;
81 M_PENDATA
->m_style
= Style
;
82 M_PENDATA
->m_join
= wxJOIN_ROUND
;
83 M_PENDATA
->m_cap
= wxCAP_ROUND
;
84 M_PENDATA
->m_nbDash
= 0 ;
85 M_PENDATA
->m_dash
= 0 ;
86 M_PENDATA
->m_hPen
= 0 ;
90 if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
91 (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
92 (Style == wxUSER_DASH))
93 M_PENDATA->m_width = 1;
98 wxThePenList
->AddPen(this);
101 wxPen::wxPen(const wxBitmap
& stipple
, int Width
)
103 m_refData
= new wxPenRefData
;
105 M_PENDATA
->m_stipple
= stipple
;
106 M_PENDATA
->m_width
= Width
;
107 M_PENDATA
->m_style
= wxSTIPPLE
;
108 M_PENDATA
->m_join
= wxJOIN_ROUND
;
109 M_PENDATA
->m_cap
= wxCAP_ROUND
;
110 M_PENDATA
->m_nbDash
= 0 ;
111 M_PENDATA
->m_dash
= 0 ;
112 M_PENDATA
->m_hPen
= 0 ;
117 wxThePenList
->AddPen(this);
120 bool wxPen::RealizeResource()
122 // TODO: create actual pen
126 WXHANDLE
wxPen::GetResourceHandle()
131 return (WXHANDLE
)M_PENDATA
->m_hPen
;
134 bool wxPen::FreeResource(bool force
)
136 if (M_PENDATA
&& (M_PENDATA
->m_hPen
!= 0))
138 // TODO: DeleteObject((HPEN) M_PENDATA->m_hPen);
139 M_PENDATA
->m_hPen
= 0;
145 bool wxPen::IsFree() const
147 return (M_PENDATA
&& M_PENDATA
->m_hPen
== 0);
150 void wxPen::Unshare()
152 // Don't change shared data
155 m_refData
= new wxPenRefData();
159 wxPenRefData
* ref
= new wxPenRefData(*(wxPenRefData
*)m_refData
);
165 void wxPen::SetColour(const wxColour
& col
)
169 M_PENDATA
->m_colour
= col
;
174 void wxPen::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
178 M_PENDATA
->m_colour
.Set(r
, g
, b
);
183 void wxPen::SetWidth(int Width
)
187 M_PENDATA
->m_width
= Width
;
192 void wxPen::SetStyle(int Style
)
196 M_PENDATA
->m_style
= Style
;
201 void wxPen::SetStipple(const wxBitmap
& Stipple
)
205 M_PENDATA
->m_stipple
= Stipple
;
206 M_PENDATA
->m_style
= wxSTIPPLE
;
211 void wxPen::SetDashes(int nb_dashes
, const wxDash
*Dash
)
215 M_PENDATA
->m_nbDash
= nb_dashes
;
216 M_PENDATA
->m_dash
= (wxDash
*)Dash
;
221 void wxPen::SetJoin(int Join
)
225 M_PENDATA
->m_join
= Join
;
230 void wxPen::SetCap(int Cap
)
234 M_PENDATA
->m_cap
= Cap
;
239 int wx2os2PenStyle(int wx_style
)
265 // Win32s doesn't have PS_USERSTYLE
266 if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
267 cstyle = PS_USERSTYLE;
269 cstyle = PS_DOT; // We must make a choice... This is mine!