]> git.saurik.com Git - wxWidgets.git/blob - include/wx/mac/carbon/pen.h
Patch from Hartwig for wxMac implementation
[wxWidgets.git] / include / wx / mac / carbon / pen.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/mac/carbon/pen.h
3 // Purpose: wxPen class
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id$
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_PEN_H_
13 #define _WX_PEN_H_
14
15 #include "wx/gdiobj.h"
16 #include "wx/colour.h"
17 #include "wx/bitmap.h"
18
19 class WXDLLIMPEXP_FWD_CORE wxPen;
20
21 class WXDLLEXPORT wxPenRefData: public wxGDIRefData
22 {
23 friend class WXDLLIMPEXP_FWD_CORE wxPen;
24 public:
25 wxPenRefData();
26 wxPenRefData(const wxPenRefData& data);
27 virtual ~wxPenRefData();
28
29 wxPenRefData& operator=(const wxPenRefData& data);
30
31 bool operator==(const wxPenRefData& data) const
32 {
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));
43 }
44
45 protected:
46 int m_width;
47 int m_style;
48 int m_join ;
49 int m_cap ;
50 wxBitmap m_stipple ;
51 int m_nbDash ;
52 wxDash * m_dash ;
53 wxColour m_colour;
54 /* TODO: implementation
55 WXHPEN m_hPen;
56 */
57 };
58
59 #define M_PENDATA ((wxPenRefData *)m_refData)
60
61 // Pen
62 class WXDLLEXPORT wxPen: public wxGDIObject
63 {
64 DECLARE_DYNAMIC_CLASS(wxPen)
65 public:
66 wxPen();
67 wxPen(const wxColour& col, int width = 1, int style = wxSOLID);
68 wxPen(const wxBitmap& stipple, int width);
69 virtual ~wxPen();
70
71 inline bool operator == (const wxPen& pen) const
72 {
73 const wxPenRefData *penData = (wxPenRefData *)pen.m_refData;
74
75 // an invalid pen is only equal to another invalid pen
76 return m_refData ? penData && *M_PENDATA == *penData : !penData;
77 }
78
79 inline bool operator != (const wxPen& pen) const { return !(*this == pen); }
80
81 virtual bool Ok() const { return IsOk(); }
82 virtual bool IsOk() const { return (m_refData != NULL) ; }
83
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) ;
87
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) ;
94
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);
102 }
103
104 inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
105
106 // Implementation
107
108 // Useful helper: create the brush resource
109 bool RealizeResource();
110
111 private:
112 void Unshare();
113 };
114
115 #endif
116 // _WX_PEN_H_