]>
Commit | Line | Data |
---|---|---|
2bda0e17 KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: pen.h | |
3 | // Purpose: wxPen class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
bbcdf8bc JS |
8 | // Copyright: (c) Julian Smart |
9 | // Licence: wxWindows licence | |
2bda0e17 KB |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
bbcdf8bc JS |
12 | #ifndef _WX_PEN_H_ |
13 | #define _WX_PEN_H_ | |
2bda0e17 KB |
14 | |
15 | #ifdef __GNUG__ | |
16 | #pragma interface "pen.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/gdiobj.h" | |
20 | ||
21 | typedef WXDWORD wxDash ; | |
22 | ||
23 | class WXDLLEXPORT wxPen; | |
24 | ||
25 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
26 | { | |
27 | friend class WXDLLEXPORT wxPen; | |
28 | public: | |
e4a81a2e | 29 | wxPenRefData(); |
b823f5a1 | 30 | wxPenRefData(const wxPenRefData& data); |
e4a81a2e | 31 | ~wxPenRefData(); |
2bda0e17 KB |
32 | |
33 | protected: | |
34 | int m_width; | |
35 | int m_style; | |
36 | int m_join ; | |
37 | int m_cap ; | |
38 | wxBitmap m_stipple ; | |
39 | int m_nbDash ; | |
40 | wxDash * m_dash ; | |
41 | wxColour m_colour; | |
42 | WXHPEN m_hPen; | |
43 | }; | |
44 | ||
45 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
46 | ||
47 | // Pen | |
48 | class WXDLLEXPORT wxPen: public wxGDIObject | |
49 | { | |
50 | DECLARE_DYNAMIC_CLASS(wxPen) | |
51 | public: | |
e4a81a2e | 52 | wxPen(); |
debe6624 JS |
53 | wxPen(const wxColour& col, int width, int style); |
54 | wxPen(const wxString& col, int width, int style); | |
55 | wxPen(const wxBitmap& stipple, int width); | |
2bda0e17 | 56 | inline wxPen(const wxPen& pen) { Ref(pen); } |
b823f5a1 | 57 | inline wxPen(const wxPen* pen) { if (pen) Ref(*pen); } |
e4a81a2e | 58 | ~wxPen(); |
2bda0e17 KB |
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 | ||
e4a81a2e | 64 | virtual bool Ok() const { return (m_refData != NULL) ; } |
2bda0e17 KB |
65 | |
66 | // Override in order to recreate the pen | |
67 | void SetColour(const wxColour& col) ; | |
68 | void SetColour(const wxString& col) ; | |
69 | void SetColour(const unsigned char r, const unsigned char g, const unsigned char b) ; | |
70 | ||
debe6624 JS |
71 | void SetWidth(int width) ; |
72 | void SetStyle(int style) ; | |
2bda0e17 | 73 | void SetStipple(const wxBitmap& stipple) ; |
debe6624 JS |
74 | void SetDashes(int nb_dashes, const wxDash *dash) ; |
75 | void SetJoin(int join) ; | |
76 | void SetCap(int cap) ; | |
2bda0e17 | 77 | |
e4a81a2e VZ |
78 | inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; |
79 | inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; | |
80 | inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; | |
81 | inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; | |
82 | inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; | |
2bda0e17 KB |
83 | inline int GetDashes(wxDash **ptr) const { |
84 | *ptr = (M_PENDATA ? M_PENDATA->m_dash : NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
85 | } | |
86 | ||
e4a81a2e | 87 | inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : NULL); }; |
2bda0e17 KB |
88 | |
89 | // Internal | |
e4a81a2e | 90 | bool RealizeResource(); |
2bda0e17 | 91 | bool FreeResource(bool force = FALSE); |
e4a81a2e VZ |
92 | WXHANDLE GetResourceHandle() ; |
93 | bool IsFree() const; | |
b823f5a1 | 94 | void Unshare(); |
2bda0e17 KB |
95 | }; |
96 | ||
97 | int wx2msPenStyle(int wx_style); | |
98 | ||
99 | #endif | |
bbcdf8bc | 100 | // _WX_PEN_H_ |