]>
Commit | Line | Data |
---|---|---|
9b6dbb09 JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: pen.h | |
3 | // Purpose: wxPen class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PEN_H_ | |
13 | #define _WX_PEN_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "pen.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/gdiobj.h" | |
20 | #include "wx/colour.h" | |
21 | #include "wx/bitmap.h" | |
22 | ||
dfc54541 | 23 | typedef char wxDash ; |
9b6dbb09 JS |
24 | |
25 | class WXDLLEXPORT wxPen; | |
26 | ||
27 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
28 | { | |
29 | friend class WXDLLEXPORT wxPen; | |
30 | public: | |
31 | wxPenRefData(); | |
32 | wxPenRefData(const wxPenRefData& data); | |
33 | ~wxPenRefData(); | |
34 | ||
35 | protected: | |
36 | int m_width; | |
37 | int m_style; | |
38 | int m_join ; | |
39 | int m_cap ; | |
40 | wxBitmap m_stipple ; | |
41 | int m_nbDash ; | |
42 | wxDash * m_dash ; | |
43 | wxColour m_colour; | |
9b6dbb09 JS |
44 | }; |
45 | ||
46 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
47 | ||
48 | // Pen | |
49 | class WXDLLEXPORT wxPen: public wxGDIObject | |
50 | { | |
51 | DECLARE_DYNAMIC_CLASS(wxPen) | |
52 | public: | |
53 | wxPen(); | |
54 | wxPen(const wxColour& col, int width, int style); | |
9b6dbb09 JS |
55 | wxPen(const wxBitmap& stipple, int width); |
56 | inline wxPen(const wxPen& pen) { Ref(pen); } | |
57 | inline wxPen(const wxPen* pen) { if (pen) Ref(*pen); } | |
58 | ~wxPen(); | |
59 | ||
60 | inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } | |
61 | inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; } | |
62 | inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; } | |
63 | ||
64 | virtual bool Ok() const { return (m_refData != NULL) ; } | |
65 | ||
66 | // Override in order to recreate the pen | |
67 | void SetColour(const wxColour& col) ; | |
e4a81a2e | 68 | void SetColour(unsigned char r, unsigned char g, unsigned char b) ; |
9b6dbb09 JS |
69 | |
70 | void SetWidth(int width) ; | |
71 | void SetStyle(int style) ; | |
72 | void SetStipple(const wxBitmap& stipple) ; | |
73 | void SetDashes(int nb_dashes, const wxDash *dash) ; | |
74 | void SetJoin(int join) ; | |
75 | void SetCap(int cap) ; | |
76 | ||
77 | inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; | |
78 | inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; | |
79 | inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; | |
80 | inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; | |
81 | inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; | |
82 | inline int GetDashes(wxDash **ptr) const { | |
83 | *ptr = (M_PENDATA ? M_PENDATA->m_dash : (wxDash*) NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
84 | } | |
16c1f7f3 JS |
85 | inline int GetDashCount() const { return (M_PENDATA->m_nbDash); } |
86 | inline wxDash* GetDash() const { return (M_PENDATA->m_dash); } | |
9b6dbb09 JS |
87 | |
88 | inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; | |
89 | ||
90 | // Implementation | |
91 | ||
92 | // Useful helper: create the brush resource | |
93 | bool RealizeResource(); | |
94 | ||
95 | // When setting properties, we must make sure we're not changing | |
96 | // another object | |
97 | void Unshare(); | |
98 | }; | |
99 | ||
100 | #endif | |
101 | // _WX_PEN_H_ |