]>
Commit | Line | Data |
---|---|---|
99d80019 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/pen.h | |
3 | // Purpose: Base header for wxPen | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows Licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_PEN_H_BASE_ |
13 | #define _WX_PEN_H_BASE_ | |
c801d85f | 14 | |
04ee05f9 PC |
15 | #include "wx/gdiobj.h" |
16 | #include "wx/gdicmn.h" | |
e45689df | 17 | |
82cddbd9 FM |
18 | enum wxPenStyle |
19 | { | |
ac3688c0 | 20 | wxPENSTYLE_INVALID = -1, |
82cddbd9 FM |
21 | |
22 | wxPENSTYLE_SOLID = wxSOLID, | |
23 | wxPENSTYLE_DOT = wxDOT, | |
24 | wxPENSTYLE_LONG_DASH = wxLONG_DASH, | |
25 | wxPENSTYLE_SHORT_DASH = wxSHORT_DASH, | |
26 | wxPENSTYLE_DOT_DASH = wxDOT_DASH, | |
777819af | 27 | wxPENSTYLE_USER_DASH = wxUSER_DASH, |
82cddbd9 FM |
28 | |
29 | wxPENSTYLE_TRANSPARENT = wxTRANSPARENT, | |
30 | ||
31 | wxPENSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE, | |
32 | wxPENSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK, | |
33 | wxPENSTYLE_STIPPLE = wxSTIPPLE, | |
34 | ||
35 | wxPENSTYLE_BDIAGONAL_HATCH = wxBDIAGONAL_HATCH, | |
36 | wxPENSTYLE_CROSSDIAG_HATCH = wxCROSSDIAG_HATCH, | |
37 | wxPENSTYLE_FDIAGONAL_HATCH = wxFDIAGONAL_HATCH, | |
38 | wxPENSTYLE_CROSS_HATCH = wxCROSS_HATCH, | |
39 | wxPENSTYLE_HORIZONTAL_HATCH = wxHORIZONTAL_HATCH, | |
40 | wxPENSTYLE_VERTICAL_HATCH = wxVERTICAL_HATCH, | |
41 | ||
42 | wxPENSTYLE_FIRST_HATCH = wxFIRST_HATCH, | |
ac3688c0 | 43 | wxPENSTYLE_LAST_HATCH = wxLAST_HATCH |
82cddbd9 FM |
44 | }; |
45 | ||
46 | enum wxPenJoin | |
47 | { | |
48 | wxJOIN_INVALID = -1, | |
49 | ||
50 | wxJOIN_BEVEL = 120, | |
51 | wxJOIN_MITER, | |
1f2e5667 | 52 | wxJOIN_ROUND |
82cddbd9 FM |
53 | }; |
54 | ||
55 | enum wxPenCap | |
56 | { | |
57 | wxCAP_INVALID = -1, | |
58 | ||
59 | wxCAP_ROUND = 130, | |
60 | wxCAP_PROJECTING, | |
61 | wxCAP_BUTT | |
62 | }; | |
63 | ||
64 | ||
53a2db12 | 65 | class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject |
82cddbd9 FM |
66 | { |
67 | public: | |
68 | virtual ~wxPenBase() { } | |
69 | ||
70 | virtual void SetColour(const wxColour& col) = 0; | |
71 | virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0; | |
72 | ||
73 | virtual void SetWidth(int width) = 0; | |
74 | virtual void SetStyle(wxPenStyle style) = 0; | |
75 | virtual void SetStipple(const wxBitmap& stipple) = 0; | |
76 | virtual void SetDashes(int nb_dashes, const wxDash *dash) = 0; | |
77 | virtual void SetJoin(wxPenJoin join) = 0; | |
78 | virtual void SetCap(wxPenCap cap) = 0; | |
79 | ||
231b9591 | 80 | virtual wxColour GetColour() const = 0; |
82cddbd9 FM |
81 | virtual wxBitmap *GetStipple() const = 0; |
82 | virtual wxPenStyle GetStyle() const = 0; | |
83 | virtual wxPenJoin GetJoin() const = 0; | |
84 | virtual wxPenCap GetCap() const = 0; | |
85 | virtual int GetWidth() const = 0; | |
86 | virtual int GetDashes(wxDash **ptr) const = 0; | |
e6777e65 VZ |
87 | |
88 | // Convenient helpers for testing whether the pen is a transparent one: | |
89 | // unlike GetStyle() == wxPENSTYLE_TRANSPARENT, they work correctly even if | |
90 | // the pen is invalid (they both return false in this case). | |
91 | bool IsTransparent() const | |
92 | { | |
93 | return IsOk() && GetStyle() == wxPENSTYLE_TRANSPARENT; | |
94 | } | |
95 | ||
96 | bool IsNonTransparent() const | |
97 | { | |
98 | return IsOk() && GetStyle() != wxPENSTYLE_TRANSPARENT; | |
99 | } | |
82cddbd9 FM |
100 | }; |
101 | ||
4055ed82 | 102 | #if defined(__WXPALMOS__) |
bc735a68 | 103 | #include "wx/palmos/pen.h" |
ffecfa5a | 104 | #elif defined(__WXMSW__) |
bc735a68 | 105 | #include "wx/msw/pen.h" |
4f535231 | 106 | #elif defined(__WXMOTIF__) || defined(__WXX11__) |
bc735a68 | 107 | #include "wx/x11/pen.h" |
1be7a35c | 108 | #elif defined(__WXGTK20__) |
bc735a68 | 109 | #include "wx/gtk/pen.h" |
1be7a35c | 110 | #elif defined(__WXGTK__) |
bc735a68 | 111 | #include "wx/gtk1/pen.h" |
b2a19d94 | 112 | #elif defined(__WXMGL__) |
bc735a68 | 113 | #include "wx/mgl/pen.h" |
b3c86150 | 114 | #elif defined(__WXDFB__) |
bc735a68 | 115 | #include "wx/dfb/pen.h" |
34138703 | 116 | #elif defined(__WXMAC__) |
bc735a68 | 117 | #include "wx/osx/pen.h" |
e64df9bc | 118 | #elif defined(__WXCOCOA__) |
bc735a68 | 119 | #include "wx/cocoa/pen.h" |
1777b9bb | 120 | #elif defined(__WXPM__) |
bc735a68 | 121 | #include "wx/os2/pen.h" |
c801d85f KB |
122 | #endif |
123 | ||
82cddbd9 FM |
124 | class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase |
125 | { | |
126 | public: | |
5d2d8f6a VZ |
127 | wxPen *FindOrCreatePen(const wxColour& colour, |
128 | int width = 1, | |
129 | wxPenStyle style = wxPENSTYLE_SOLID); | |
ac3688c0 FM |
130 | |
131 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
132 | wxPen *FindOrCreatePen(const wxColour& colour, int width, int style) | |
133 | { return FindOrCreatePen(colour, width, (wxPenStyle)style); } | |
134 | #endif | |
82cddbd9 FM |
135 | #if WXWIN_COMPATIBILITY_2_6 |
136 | wxDEPRECATED( void AddPen(wxPen*) ); | |
137 | wxDEPRECATED( void RemovePen(wxPen*) ); | |
138 | #endif | |
139 | }; | |
140 | ||
53a2db12 | 141 | extern WXDLLIMPEXP_DATA_CORE(wxPenList*) wxThePenList; |
82cddbd9 | 142 | |
8907a7e2 VZ |
143 | // provide comparison operators to allow code such as |
144 | // | |
145 | // if ( pen.GetStyle() == wxTRANSPARENT ) | |
146 | // | |
147 | // to compile without warnings which it would otherwise provoke from some | |
148 | // compilers as it compares elements of different enums | |
149 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 | |
150 | ||
25859335 VZ |
151 | // Unfortunately some compilers have ambiguity issues when enum comparisons are |
152 | // overloaded so we have to disable the overloads in this case, see | |
153 | // wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details. | |
154 | #ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM | |
155 | ||
8907a7e2 VZ |
156 | inline bool operator==(wxPenStyle s, wxDeprecatedGUIConstants t) |
157 | { | |
5c33522f | 158 | return static_cast<int>(s) == static_cast<int>(t); |
8907a7e2 VZ |
159 | } |
160 | ||
161 | inline bool operator!=(wxPenStyle s, wxDeprecatedGUIConstants t) | |
162 | { | |
163 | return !(s == t); | |
164 | } | |
165 | ||
25859335 VZ |
166 | #endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM |
167 | ||
8907a7e2 VZ |
168 | #endif // FUTURE_WXWIN_COMPATIBILITY_3_0 |
169 | ||
170 | #endif // _WX_PEN_H_BASE_ |