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