]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/pen.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/pen.h
3 // Purpose: wxPen class
4 // Author: Stefan Csomor
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
15 #include "wx/gdiobj.h"
16 #include "wx/colour.h"
17 #include "wx/bitmap.h"
19 class WXDLLEXPORT wxPen
;
21 class WXDLLEXPORT wxPenRefData
: public wxGDIRefData
23 friend class WXDLLEXPORT wxPen
;
26 wxPenRefData(const wxPenRefData
& data
);
27 virtual ~wxPenRefData();
29 wxPenRefData
& operator=(const wxPenRefData
& data
);
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));
54 /* TODO: implementation
59 #define M_PENDATA ((wxPenRefData *)m_refData)
62 class WXDLLEXPORT wxPen
: public wxGDIObject
64 DECLARE_DYNAMIC_CLASS(wxPen
)
67 wxPen(const wxColour
& col
, int width
= 1, int style
= wxSOLID
);
68 wxPen(const wxBitmap
& stipple
, int width
);
71 inline bool operator == (const wxPen
& pen
) const
73 const wxPenRefData
*penData
= (wxPenRefData
*)pen
.m_refData
;
75 // an invalid pen is only equal to another invalid pen
76 return m_refData
? penData
&& *M_PENDATA
== *penData
: !penData
;
79 inline bool operator != (const wxPen
& pen
) const { return !(*this == pen
); }
81 virtual bool Ok() const { return IsOk(); }
82 virtual bool IsOk() const { return (m_refData
!= NULL
) ; }
84 // Override in order to recreate the pen
85 void SetColour(const wxColour
& col
) ;
86 void SetColour(unsigned char r
, unsigned char g
, unsigned char b
) ;
88 void SetWidth(int width
) ;
89 void SetStyle(int style
) ;
90 void SetStipple(const wxBitmap
& stipple
) ;
91 void SetDashes(int nb_dashes
, const wxDash
*dash
) ;
92 void SetJoin(int join
) ;
93 void SetCap(int cap
) ;
95 inline wxColour
& GetColour() const { return (M_PENDATA
? M_PENDATA
->m_colour
: wxNullColour
); };
96 inline int GetWidth() const { return (M_PENDATA
? M_PENDATA
->m_width
: 0); };
97 inline int GetStyle() const { return (M_PENDATA
? M_PENDATA
->m_style
: 0); };
98 inline int GetJoin() const { return (M_PENDATA
? M_PENDATA
->m_join
: 0); };
99 inline int GetCap() const { return (M_PENDATA
? M_PENDATA
->m_cap
: 0); };
100 inline int GetDashes(wxDash
**ptr
) const {
101 *ptr
= (M_PENDATA
? M_PENDATA
->m_dash
: (wxDash
*) NULL
); return (M_PENDATA
? M_PENDATA
->m_nbDash
: 0);
104 inline wxBitmap
*GetStipple() const { return (M_PENDATA
? (& M_PENDATA
->m_stipple
) : (wxBitmap
*) NULL
); };
108 // Useful helper: create the brush resource
109 bool RealizeResource();