]>
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" | |
2432b92d | 20 | #include "wx/bitmap.h" |
ed39ff57 | 21 | #include "wx/colour.h" |
2bda0e17 | 22 | |
236a9de3 | 23 | typedef WXDWORD wxMSWDash; |
2bda0e17 KB |
24 | |
25 | class WXDLLEXPORT wxPen; | |
26 | ||
27 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
28 | { | |
29 | friend class WXDLLEXPORT wxPen; | |
30 | public: | |
e4a81a2e | 31 | wxPenRefData(); |
b823f5a1 | 32 | wxPenRefData(const wxPenRefData& data); |
e4a81a2e | 33 | ~wxPenRefData(); |
2bda0e17 KB |
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 ; | |
edd97174 | 42 | wxDash * m_dash ; |
2bda0e17 KB |
43 | wxColour m_colour; |
44 | WXHPEN m_hPen; | |
22f3361e VZ |
45 | |
46 | private: | |
47 | // Cannot use | |
48 | // DECLARE_NO_COPY_CLASS(wxPenRefData) | |
49 | // because copy constructor is explicitly declared above; | |
50 | // but no copy assignment operator is defined, so declare | |
51 | // it private to prevent the compiler from defining it: | |
52 | wxPenRefData& operator=(const wxPenRefData&); | |
2bda0e17 KB |
53 | }; |
54 | ||
55 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
56 | ||
57 | // Pen | |
58 | class WXDLLEXPORT wxPen: public wxGDIObject | |
59 | { | |
60 | DECLARE_DYNAMIC_CLASS(wxPen) | |
61 | public: | |
e4a81a2e | 62 | wxPen(); |
debe6624 | 63 | wxPen(const wxColour& col, int width, int style); |
debe6624 | 64 | wxPen(const wxBitmap& stipple, int width); |
2bda0e17 | 65 | inline wxPen(const wxPen& pen) { Ref(pen); } |
e4a81a2e | 66 | ~wxPen(); |
2bda0e17 KB |
67 | |
68 | inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } | |
f6bcfd97 BP |
69 | inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; } |
70 | inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; } | |
2bda0e17 | 71 | |
e4a81a2e | 72 | virtual bool Ok() const { return (m_refData != NULL) ; } |
2bda0e17 KB |
73 | |
74 | // Override in order to recreate the pen | |
75 | void SetColour(const wxColour& col) ; | |
4d947517 | 76 | void SetColour(unsigned char r, unsigned char g, unsigned char b); |
2bda0e17 | 77 | |
debe6624 JS |
78 | void SetWidth(int width) ; |
79 | void SetStyle(int style) ; | |
2bda0e17 | 80 | void SetStipple(const wxBitmap& stipple) ; |
debe6624 JS |
81 | void SetDashes(int nb_dashes, const wxDash *dash) ; |
82 | void SetJoin(int join) ; | |
83 | void SetCap(int cap) ; | |
2bda0e17 | 84 | |
e4a81a2e VZ |
85 | inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; |
86 | inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; | |
87 | inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; | |
88 | inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; | |
89 | inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; | |
236a9de3 RL |
90 | inline int GetDashes(wxDash **ptr) const |
91 | { | |
92 | *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); | |
93 | return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
2bda0e17 KB |
94 | } |
95 | ||
57c208c5 | 96 | inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; |
2bda0e17 KB |
97 | |
98 | // Internal | |
e4a81a2e | 99 | bool RealizeResource(); |
2bda0e17 | 100 | bool FreeResource(bool force = FALSE); |
2b5f62a0 | 101 | WXHANDLE GetResourceHandle() const; |
e4a81a2e | 102 | bool IsFree() const; |
b823f5a1 | 103 | void Unshare(); |
2bda0e17 KB |
104 | }; |
105 | ||
106 | int wx2msPenStyle(int wx_style); | |
107 | ||
108 | #endif | |
bbcdf8bc | 109 | // _WX_PEN_H_ |