1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/pen.h
3 // Purpose: wxPen class
4 // Author: William Osborne - minimal working wxPalmOS port
5 // Modified by: Yunhui Fu
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/gdiobj.h"
16 #include "wx/bitmap.h"
17 #include "wx/colour.h"
19 typedef WXDWORD wxMSWDash
;
21 class WXDLLIMPEXP_FWD_CORE wxPen
;
23 // VZ: this class should be made private
24 class WXDLLEXPORT wxPenRefData
: public wxGDIRefData
28 wxPenRefData(const wxPenRefData
& data
);
29 virtual ~wxPenRefData();
31 bool operator==(const wxPenRefData
& data
) const
33 // we intentionally don't compare m_hPen fields here
34 return m_style
== data
.m_style
&&
35 m_width
== data
.m_width
&&
36 m_join
== data
.m_join
&&
37 m_cap
== data
.m_cap
&&
38 m_colour
== data
.m_colour
&&
39 (m_style
!= wxSTIPPLE
|| m_stipple
.IsSameAs(data
.m_stipple
)) &&
40 (m_style
!= wxUSER_DASH
||
41 (m_nbDash
== data
.m_nbDash
&&
42 memcmp(m_dash
, data
.m_dash
, m_nbDash
*sizeof(wxDash
)) == 0));
57 friend class WXDLLIMPEXP_FWD_CORE wxPen
;
60 // DECLARE_NO_COPY_CLASS(wxPenRefData)
61 // because copy constructor is explicitly declared above;
62 // but no copy assignment operator is defined, so declare
63 // it private to prevent the compiler from defining it:
64 wxPenRefData
& operator=(const wxPenRefData
&);
67 #define M_PENDATA ((wxPenRefData *)m_refData)
68 #define wxPENDATA(x) ((wxPenRefData *)(x).m_refData)
70 // ----------------------------------------------------------------------------
72 // ----------------------------------------------------------------------------
74 class WXDLLEXPORT wxPen
: public wxPenBase
78 wxPen(const wxColour
& col
, int width
= 1, wxPenStyle style
= wxPENSTYLE_SOLID
);
79 #if FUTURE_WXWIN_COMPATIBILITY_3_0
80 wxDEPRECATED_FUTURE( wxPen(const wxColour
& col
, int width
, int style
) );
83 wxPen(const wxBitmap
& stipple
, int width
);
86 bool operator==(const wxPen
& pen
) const
88 const wxPenRefData
*penData
= (wxPenRefData
*)pen
.m_refData
;
90 // an invalid pen is only equal to another invalid pen
91 return m_refData
? penData
&& *M_PENDATA
== *penData
: !penData
;
94 bool operator!=(const wxPen
& pen
) const { return !(*this == pen
); }
96 // Override in order to recreate the pen
97 void SetColour(const wxColour
& col
);
98 void SetColour(unsigned char r
, unsigned char g
, unsigned char b
);
100 void SetWidth(int width
);
101 void SetStyle(wxPenStyle style
);
102 void SetStipple(const wxBitmap
& stipple
);
103 void SetDashes(int nb_dashes
, const wxDash
*dash
);
104 void SetJoin(wxPenJoin join
);
105 void SetCap(wxPenCap cap
);
107 wxColour
& GetColour() const { return (M_PENDATA
? M_PENDATA
->m_colour
: wxNullColour
); };
108 int GetWidth() const { return (M_PENDATA
? M_PENDATA
->m_width
: 0); };
109 wxPenStyle
GetStyle() const { return (M_PENDATA
? M_PENDATA
->m_style
: 0); };
110 wxPenJoin
GetJoin() const { return (M_PENDATA
? M_PENDATA
->m_join
: 0); };
111 wxPenCap
GetCap() const { return (M_PENDATA
? M_PENDATA
->m_cap
: 0); };
112 int GetDashes(wxDash
**ptr
) const
114 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
115 return (M_PENDATA
? M_PENDATA
->m_nbDash
: 0);
117 wxDash
* GetDash() const { return (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*)NULL
); };
118 inline int GetDashCount() const { return (M_PENDATA
? M_PENDATA
->m_nbDash
: 0); };
120 inline wxBitmap
*GetStipple() const { return (M_PENDATA
? (& M_PENDATA
->m_stipple
) : (wxBitmap
*) NULL
); };
123 bool RealizeResource();
124 bool FreeResource(bool force
= false);
125 WXHANDLE
GetResourceHandle() const;
129 virtual wxGDIRefData
* CreateGDIRefData() const;
130 virtual wxGDIRefData
* CloneGDIRefData(const wxGDIRefData
* data
) const;
131 // same as FreeResource() + RealizeResource()
135 DECLARE_DYNAMIC_CLASS(wxPen
)