]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: pen.h | |
3 | // Purpose: wxPen class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
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 | ||
236a9de3 | 23 | typedef long wxMACDash; |
0dbd6262 SC |
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 ; | |
236a9de3 | 42 | wxMACDash * m_dash ; |
0dbd6262 SC |
43 | wxColour m_colour; |
44 | /* TODO: implementation | |
45 | WXHPEN m_hPen; | |
46 | */ | |
47 | }; | |
48 | ||
49 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
50 | ||
51 | // Pen | |
52 | class WXDLLEXPORT wxPen: public wxGDIObject | |
53 | { | |
54 | DECLARE_DYNAMIC_CLASS(wxPen) | |
55 | public: | |
56 | wxPen(); | |
57 | wxPen(const wxColour& col, int width, int style); | |
58 | wxPen(const wxBitmap& stipple, int width); | |
59 | inline wxPen(const wxPen& pen) { Ref(pen); } | |
60 | ~wxPen(); | |
61 | ||
62 | inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; } | |
63 | inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; } | |
64 | inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; } | |
65 | ||
66 | virtual bool Ok() const { return (m_refData != NULL) ; } | |
67 | ||
68 | // Override in order to recreate the pen | |
69 | void SetColour(const wxColour& col) ; | |
70 | void SetColour(unsigned char r, unsigned char g, unsigned char b) ; | |
71 | ||
72 | void SetWidth(int width) ; | |
73 | void SetStyle(int style) ; | |
74 | void SetStipple(const wxBitmap& stipple) ; | |
75 | void SetDashes(int nb_dashes, const wxDash *dash) ; | |
76 | void SetJoin(int join) ; | |
77 | void SetCap(int cap) ; | |
78 | ||
79 | inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; | |
80 | inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; | |
81 | inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; | |
82 | inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; | |
83 | inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; | |
236a9de3 RL |
84 | inline int GetDashes(wxDash **ptr) const |
85 | { | |
86 | *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); | |
87 | return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
0dbd6262 SC |
88 | } |
89 | ||
90 | inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; | |
91 | ||
92 | // Implementation | |
93 | ||
94 | // Useful helper: create the brush resource | |
95 | bool RealizeResource(); | |
96 | ||
97 | // When setting properties, we must make sure we're not changing | |
98 | // another object | |
99 | void Unshare(); | |
100 | }; | |
101 | ||
102 | #endif | |
103 | // _WX_PEN_H_ |