]>
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 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 DeleteObject((HPEN
) M_PENDATA
->m_hPen
);
137 M_PENDATA
->m_hPen
= 0;
143 void wxPen::Unshare()
145 // Don't change shared data
148 m_refData
= new wxPenRefData();
152 wxPenRefData
* ref
= new wxPenRefData(*(wxPenRefData
*)m_refData
);
158 void wxPen::SetColour(const wxColour
& col
)
162 M_PENDATA
->m_colour
= col
;
167 void wxPen::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
171 M_PENDATA
->m_colour
.Set(r
, g
, b
);
176 void wxPen::SetWidth(int Width
)
180 M_PENDATA
->m_width
= Width
;
185 void wxPen::SetStyle(int Style
)
189 M_PENDATA
->m_style
= Style
;
194 void wxPen::SetStipple(const wxBitmap
& Stipple
)
198 M_PENDATA
->m_stipple
= Stipple
;
199 M_PENDATA
->m_style
= wxSTIPPLE
;
204 void wxPen::SetDashes(int nb_dashes
, const wxDash
*Dash
)
208 M_PENDATA
->m_nbDash
= nb_dashes
;
209 M_PENDATA
->m_dash
= (wxDash
*)Dash
;
214 void wxPen::SetJoin(int Join
)
218 M_PENDATA
->m_join
= Join
;
223 void wxPen::SetCap(int Cap
)
227 M_PENDATA
->m_cap
= Cap
;
232 void wxPen::SetCap(int Cap
)
236 M_PENDATA
->m_cap
= Cap
;
241 int wx2os2PenStyle(int wx_style
)
267 // Win32s doesn't have PS_USERSTYLE
268 if (wxGetOsVersion()==wxWINDOWS_NT || wxGetOsVersion()==wxWIN95)
269 cstyle = PS_USERSTYLE;
271 cstyle = PS_DOT; // We must make a choice... This is mine!