1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Base header for wxPen
4 // Author: Julian Smart
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows Licence
9 /////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_PEN_H_BASE_
12 #define _WX_PEN_H_BASE_
14 #include "wx/gdiobj.h"
15 #include "wx/gdicmn.h"
19 wxPENSTYLE_INVALID
= -1,
21 wxPENSTYLE_SOLID
= wxSOLID
,
22 wxPENSTYLE_DOT
= wxDOT
,
23 wxPENSTYLE_LONG_DASH
= wxLONG_DASH
,
24 wxPENSTYLE_SHORT_DASH
= wxSHORT_DASH
,
25 wxPENSTYLE_DOT_DASH
= wxDOT_DASH
,
26 wxPENSTYLE_USER_DASH
= wxUSER_DASH
,
28 wxPENSTYLE_TRANSPARENT
= wxTRANSPARENT
,
30 wxPENSTYLE_STIPPLE_MASK_OPAQUE
= wxSTIPPLE_MASK_OPAQUE
,
31 wxPENSTYLE_STIPPLE_MASK
= wxSTIPPLE_MASK
,
32 wxPENSTYLE_STIPPLE
= wxSTIPPLE
,
34 wxPENSTYLE_BDIAGONAL_HATCH
= wxHATCHSTYLE_BDIAGONAL
,
35 wxPENSTYLE_CROSSDIAG_HATCH
= wxHATCHSTYLE_CROSSDIAG
,
36 wxPENSTYLE_FDIAGONAL_HATCH
= wxHATCHSTYLE_FDIAGONAL
,
37 wxPENSTYLE_CROSS_HATCH
= wxHATCHSTYLE_CROSS
,
38 wxPENSTYLE_HORIZONTAL_HATCH
= wxHATCHSTYLE_HORIZONTAL
,
39 wxPENSTYLE_VERTICAL_HATCH
= wxHATCHSTYLE_VERTICAL
,
40 wxPENSTYLE_FIRST_HATCH
= wxHATCHSTYLE_FIRST
,
41 wxPENSTYLE_LAST_HATCH
= wxHATCHSTYLE_LAST
63 class WXDLLIMPEXP_CORE wxPenBase
: public wxGDIObject
66 virtual ~wxPenBase() { }
68 virtual void SetColour(const wxColour
& col
) = 0;
69 virtual void SetColour(unsigned char r
, unsigned char g
, unsigned char b
) = 0;
71 virtual void SetWidth(int width
) = 0;
72 virtual void SetStyle(wxPenStyle style
) = 0;
73 virtual void SetStipple(const wxBitmap
& stipple
) = 0;
74 virtual void SetDashes(int nb_dashes
, const wxDash
*dash
) = 0;
75 virtual void SetJoin(wxPenJoin join
) = 0;
76 virtual void SetCap(wxPenCap cap
) = 0;
78 virtual wxColour
GetColour() const = 0;
79 virtual wxBitmap
*GetStipple() const = 0;
80 virtual wxPenStyle
GetStyle() const = 0;
81 virtual wxPenJoin
GetJoin() const = 0;
82 virtual wxPenCap
GetCap() const = 0;
83 virtual int GetWidth() const = 0;
84 virtual int GetDashes(wxDash
**ptr
) const = 0;
86 // Convenient helpers for testing whether the pen is a transparent one:
87 // unlike GetStyle() == wxPENSTYLE_TRANSPARENT, they work correctly even if
88 // the pen is invalid (they both return false in this case).
89 bool IsTransparent() const
91 return IsOk() && GetStyle() == wxPENSTYLE_TRANSPARENT
;
94 bool IsNonTransparent() const
96 return IsOk() && GetStyle() != wxPENSTYLE_TRANSPARENT
;
100 #if defined(__WXMSW__)
101 #include "wx/msw/pen.h"
102 #elif defined(__WXMOTIF__) || defined(__WXX11__)
103 #include "wx/x11/pen.h"
104 #elif defined(__WXGTK20__)
105 #include "wx/gtk/pen.h"
106 #elif defined(__WXGTK__)
107 #include "wx/gtk1/pen.h"
108 #elif defined(__WXDFB__)
109 #include "wx/dfb/pen.h"
110 #elif defined(__WXMAC__)
111 #include "wx/osx/pen.h"
112 #elif defined(__WXCOCOA__)
113 #include "wx/cocoa/pen.h"
114 #elif defined(__WXPM__)
115 #include "wx/os2/pen.h"
118 class WXDLLIMPEXP_CORE wxPenList
: public wxGDIObjListBase
121 wxPen
*FindOrCreatePen(const wxColour
& colour
,
123 wxPenStyle style
= wxPENSTYLE_SOLID
);
125 #if FUTURE_WXWIN_COMPATIBILITY_3_0
126 wxPen
*FindOrCreatePen(const wxColour
& colour
, int width
, int style
)
127 { return FindOrCreatePen(colour
, width
, (wxPenStyle
)style
); }
129 #if WXWIN_COMPATIBILITY_2_6
130 wxDEPRECATED( void AddPen(wxPen
*) );
131 wxDEPRECATED( void RemovePen(wxPen
*) );
135 extern WXDLLIMPEXP_DATA_CORE(wxPenList
*) wxThePenList
;
137 // provide comparison operators to allow code such as
139 // if ( pen.GetStyle() == wxTRANSPARENT )
141 // to compile without warnings which it would otherwise provoke from some
142 // compilers as it compares elements of different enums
143 #if FUTURE_WXWIN_COMPATIBILITY_3_0
145 // Unfortunately some compilers have ambiguity issues when enum comparisons are
146 // overloaded so we have to disable the overloads in this case, see
147 // wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
148 #ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
150 inline bool operator==(wxPenStyle s
, wxDeprecatedGUIConstants t
)
152 return static_cast<int>(s
) == static_cast<int>(t
);
155 inline bool operator!=(wxPenStyle s
, wxDeprecatedGUIConstants t
)
160 #endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
162 #endif // FUTURE_WXWIN_COMPATIBILITY_3_0
164 #endif // _WX_PEN_H_BASE_