]>
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 #if !USE_SHARED_LIBRARIES
28 IMPLEMENT_DYNAMIC_CLASS(wxPen
, wxGDIObject
)
31 wxPenRefData::wxPenRefData()
35 m_join
= wxJOIN_ROUND
;
42 wxPenRefData::wxPenRefData(const wxPenRefData
& data
)
44 m_style
= data
.m_style
;
45 m_width
= data
.m_width
;
48 m_nbDash
= data
.m_nbDash
;
50 m_colour
= data
.m_colour
;
56 wxPenRefData::~wxPenRefData()
66 wxThePenList
->AddPen(this);
72 wxThePenList
->RemovePen(this);
75 // Should implement Create
76 wxPen::wxPen(const wxColour
& col
, int Width
, int Style
)
78 m_refData
= new wxPenRefData
;
80 M_PENDATA
->m_colour
= col
;
81 // M_PENDATA->m_stipple = NULL;
82 M_PENDATA
->m_width
= Width
;
83 M_PENDATA
->m_style
= Style
;
84 M_PENDATA
->m_join
= wxJOIN_ROUND
;
85 M_PENDATA
->m_cap
= wxCAP_ROUND
;
86 M_PENDATA
->m_nbDash
= 0 ;
87 M_PENDATA
->m_dash
= 0 ;
88 M_PENDATA
->m_hPen
= 0 ;
92 if ((Style == wxDOT) || (Style == wxLONG_DASH) ||
93 (Style == wxSHORT_DASH) || (Style == wxDOT_DASH) ||
94 (Style == wxUSER_DASH))
95 M_PENDATA->m_width = 1;
100 wxThePenList
->AddPen(this);
103 wxPen::wxPen(const wxBitmap
& stipple
, int Width
)
105 m_refData
= new wxPenRefData
;
107 M_PENDATA
->m_stipple
= stipple
;
108 M_PENDATA
->m_width
= Width
;
109 M_PENDATA
->m_style
= wxSTIPPLE
;
110 M_PENDATA
->m_join
= wxJOIN_ROUND
;
111 M_PENDATA
->m_cap
= wxCAP_ROUND
;
112 M_PENDATA
->m_nbDash
= 0 ;
113 M_PENDATA
->m_dash
= 0 ;
114 M_PENDATA
->m_hPen
= 0 ;
119 wxThePenList
->AddPen(this);
122 bool wxPen::RealizeResource()
124 // TODO: create actual pen
128 WXHANDLE
wxPen::GetResourceHandle()
133 return (WXHANDLE
)M_PENDATA
->m_hPen
;
136 bool wxPen::FreeResource(bool force
)
138 if (M_PENDATA
&& (M_PENDATA
->m_hPen
!= 0))
140 // TODO: DeleteObject((HPEN) M_PENDATA->m_hPen);
141 M_PENDATA
->m_hPen
= 0;
147 bool wxPen::IsFree() const
149 return (M_PENDATA
&& M_PENDATA
->m_hPen
== 0);
152 void wxPen::Unshare()
154 // Don't change shared data
157 m_refData
= new wxPenRefData();
161 wxPenRefData
* ref
= new wxPenRefData(*(wxPenRefData
*)m_refData
);
167 void wxPen::SetColour(const wxColour
& col
)
171 M_PENDATA
->m_colour
= col
;
176 void wxPen::SetColour(unsigned char r
, unsigned char g
, unsigned char b
)
180 M_PENDATA
->m_colour
.Set(r
, g
, b
);
185 void wxPen::SetWidth(int Width
)
189 M_PENDATA
->m_width
= Width
;
194 void wxPen::SetStyle(int Style
)
198 M_PENDATA
->m_style
= Style
;
203 void wxPen::SetStipple(const wxBitmap
& Stipple
)
207 M_PENDATA
->m_stipple
= Stipple
;
208 M_PENDATA
->m_style
= wxSTIPPLE
;
213 void wxPen::SetDashes(int nb_dashes
, const wxDash
*Dash
)
217 M_PENDATA
->m_nbDash
= nb_dashes
;
218 M_PENDATA
->m_dash
= (wxDash
*)Dash
;
223 void wxPen::SetJoin(int Join
)
227 M_PENDATA
->m_join
= Join
;
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!