1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/palmos/pen.h
3 // Purpose: wxPen class
4 // Author: William Osborne - minimal working wxPalmOS port
8 // Copyright: (c) William Osborne
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "pen.h"
19 #include "wx/gdiobj.h"
20 #include "wx/bitmap.h"
21 #include "wx/colour.h"
23 typedef WXDWORD wxMSWDash
;
25 class WXDLLEXPORT wxPen
;
27 // VZ: this class should be made private
28 class WXDLLEXPORT wxPenRefData
: public wxGDIRefData
32 wxPenRefData(const wxPenRefData
& data
);
33 virtual ~wxPenRefData();
35 bool operator==(const wxPenRefData
& data
) const
37 // we intentionally don't compare m_hPen fields here
38 return m_style
== data
.m_style
&&
39 m_width
== data
.m_width
&&
40 m_join
== data
.m_join
&&
41 m_cap
== data
.m_cap
&&
42 m_colour
== data
.m_colour
&&
43 (m_style
!= wxSTIPPLE
|| m_stipple
== data
.m_stipple
) &&
44 (m_style
!= wxUSER_DASH
||
45 (m_nbDash
== data
.m_nbDash
&&
46 memcmp(m_dash
, data
.m_dash
, m_nbDash
*sizeof(wxDash
)) == 0));
61 friend class WXDLLEXPORT wxPen
;
64 // DECLARE_NO_COPY_CLASS(wxPenRefData)
65 // because copy constructor is explicitly declared above;
66 // but no copy assignment operator is defined, so declare
67 // it private to prevent the compiler from defining it:
68 wxPenRefData
& operator=(const wxPenRefData
&);
71 #define M_PENDATA ((wxPenRefData *)m_refData)
72 #define wxPENDATA(x) ((wxPenRefData *)(x).m_refData)
74 // ----------------------------------------------------------------------------
76 // ----------------------------------------------------------------------------
78 class WXDLLEXPORT wxPen
: public wxGDIObject
82 wxPen(const wxColour
& col
, int width
= 1, int style
= wxSOLID
);
83 wxPen(const wxBitmap
& stipple
, int width
);
84 wxPen(const wxPen
& pen
) { Ref(pen
); }
87 wxPen
& operator=(const wxPen
& pen
)
95 bool operator==(const wxPen
& pen
) const
97 const wxPenRefData
*penData
= (wxPenRefData
*)pen
.m_refData
;
99 // an invalid pen is only equal to another invalid pen
100 return m_refData
? penData
&& *M_PENDATA
== *penData
: !penData
;
103 bool operator!=(const wxPen
& pen
) const { return !(*this == pen
); }
105 virtual bool Ok() const { return (m_refData
!= NULL
); }
107 // Override in order to recreate the pen
108 void SetColour(const wxColour
& col
);
109 void SetColour(unsigned char r
, unsigned char g
, unsigned char b
);
111 void SetWidth(int width
);
112 void SetStyle(int style
);
113 void SetStipple(const wxBitmap
& stipple
);
114 void SetDashes(int nb_dashes
, const wxDash
*dash
);
115 void SetJoin(int join
);
116 void SetCap(int cap
);
118 wxColour
& GetColour() const { return (M_PENDATA
? M_PENDATA
->m_colour
: wxNullColour
); };
119 int GetWidth() const { return (M_PENDATA
? M_PENDATA
->m_width
: 0); };
120 int GetStyle() const { return (M_PENDATA
? M_PENDATA
->m_style
: 0); };
121 int GetJoin() const { return (M_PENDATA
? M_PENDATA
->m_join
: 0); };
122 int GetCap() const { return (M_PENDATA
? M_PENDATA
->m_cap
: 0); };
123 int GetDashes(wxDash
**ptr
) const
125 *ptr
= (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*) NULL
);
126 return (M_PENDATA
? M_PENDATA
->m_nbDash
: 0);
128 wxDash
* GetDash() const { return (M_PENDATA
? (wxDash
*)M_PENDATA
->m_dash
: (wxDash
*)NULL
); };
129 inline int GetDashCount() const { return (M_PENDATA
? M_PENDATA
->m_nbDash
: 0); };
131 inline wxBitmap
*GetStipple() const { return (M_PENDATA
? (& M_PENDATA
->m_stipple
) : (wxBitmap
*) NULL
); };
134 bool RealizeResource();
135 bool FreeResource(bool force
= FALSE
);
136 WXHANDLE
GetResourceHandle() const;
141 DECLARE_DYNAMIC_CLASS(wxPen
)