]> git.saurik.com Git - wxWidgets.git/blob - include/wx/pen.h
adding OnLaunched
[wxWidgets.git] / include / wx / pen.h
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
12 #ifndef _WX_PEN_H_BASE_
13 #define _WX_PEN_H_BASE_
14
15 #include "wx/gdiobj.h"
16 #include "wx/gdicmn.h"
17
18 enum wxPenStyle
19 {
20 wxPENSTYLE_INVALID = -1,
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,
27 wxPENSTYLE_USER_DASH = wxUSER_DASH,
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 = wxHATCHSTYLE_BDIAGONAL,
36 wxPENSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG,
37 wxPENSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL,
38 wxPENSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS,
39 wxPENSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL,
40 wxPENSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL,
41 wxPENSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST,
42 wxPENSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST
43 };
44
45 enum wxPenJoin
46 {
47 wxJOIN_INVALID = -1,
48
49 wxJOIN_BEVEL = 120,
50 wxJOIN_MITER,
51 wxJOIN_ROUND
52 };
53
54 enum wxPenCap
55 {
56 wxCAP_INVALID = -1,
57
58 wxCAP_ROUND = 130,
59 wxCAP_PROJECTING,
60 wxCAP_BUTT
61 };
62
63
64 class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject
65 {
66 public:
67 virtual ~wxPenBase() { }
68
69 virtual void SetColour(const wxColour& col) = 0;
70 virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0;
71
72 virtual void SetWidth(int width) = 0;
73 virtual void SetStyle(wxPenStyle style) = 0;
74 virtual void SetStipple(const wxBitmap& stipple) = 0;
75 virtual void SetDashes(int nb_dashes, const wxDash *dash) = 0;
76 virtual void SetJoin(wxPenJoin join) = 0;
77 virtual void SetCap(wxPenCap cap) = 0;
78
79 virtual wxColour GetColour() const = 0;
80 virtual wxBitmap *GetStipple() const = 0;
81 virtual wxPenStyle GetStyle() const = 0;
82 virtual wxPenJoin GetJoin() const = 0;
83 virtual wxPenCap GetCap() const = 0;
84 virtual int GetWidth() const = 0;
85 virtual int GetDashes(wxDash **ptr) const = 0;
86
87 // Convenient helpers for testing whether the pen is a transparent one:
88 // unlike GetStyle() == wxPENSTYLE_TRANSPARENT, they work correctly even if
89 // the pen is invalid (they both return false in this case).
90 bool IsTransparent() const
91 {
92 return IsOk() && GetStyle() == wxPENSTYLE_TRANSPARENT;
93 }
94
95 bool IsNonTransparent() const
96 {
97 return IsOk() && GetStyle() != wxPENSTYLE_TRANSPARENT;
98 }
99 };
100
101 #if defined(__WXMSW__)
102 #include "wx/msw/pen.h"
103 #elif defined(__WXMOTIF__) || defined(__WXX11__)
104 #include "wx/x11/pen.h"
105 #elif defined(__WXGTK20__)
106 #include "wx/gtk/pen.h"
107 #elif defined(__WXGTK__)
108 #include "wx/gtk1/pen.h"
109 #elif defined(__WXDFB__)
110 #include "wx/dfb/pen.h"
111 #elif defined(__WXMAC__)
112 #include "wx/osx/pen.h"
113 #elif defined(__WXCOCOA__)
114 #include "wx/cocoa/pen.h"
115 #elif defined(__WXPM__)
116 #include "wx/os2/pen.h"
117 #endif
118
119 class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase
120 {
121 public:
122 wxPen *FindOrCreatePen(const wxColour& colour,
123 int width = 1,
124 wxPenStyle style = wxPENSTYLE_SOLID);
125
126 #if FUTURE_WXWIN_COMPATIBILITY_3_0
127 wxPen *FindOrCreatePen(const wxColour& colour, int width, int style)
128 { return FindOrCreatePen(colour, width, (wxPenStyle)style); }
129 #endif
130 #if WXWIN_COMPATIBILITY_2_6
131 wxDEPRECATED( void AddPen(wxPen*) );
132 wxDEPRECATED( void RemovePen(wxPen*) );
133 #endif
134 };
135
136 extern WXDLLIMPEXP_DATA_CORE(wxPenList*) wxThePenList;
137
138 // provide comparison operators to allow code such as
139 //
140 // if ( pen.GetStyle() == wxTRANSPARENT )
141 //
142 // to compile without warnings which it would otherwise provoke from some
143 // compilers as it compares elements of different enums
144 #if FUTURE_WXWIN_COMPATIBILITY_3_0
145
146 // Unfortunately some compilers have ambiguity issues when enum comparisons are
147 // overloaded so we have to disable the overloads in this case, see
148 // wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
149 #ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
150
151 inline bool operator==(wxPenStyle s, wxDeprecatedGUIConstants t)
152 {
153 return static_cast<int>(s) == static_cast<int>(t);
154 }
155
156 inline bool operator!=(wxPenStyle s, wxDeprecatedGUIConstants t)
157 {
158 return !(s == t);
159 }
160
161 #endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
162
163 #endif // FUTURE_WXWIN_COMPATIBILITY_3_0
164
165 #endif // _WX_PEN_H_BASE_