]>
Commit | Line | Data |
---|---|---|
ffecfa5a | 1 | ///////////////////////////////////////////////////////////////////////////// |
e1d63b79 | 2 | // Name: wx/palmos/pen.h |
ffecfa5a | 3 | // Purpose: wxPen class |
e1d63b79 | 4 | // Author: William Osborne - minimal working wxPalmOS port |
6afc1b46 | 5 | // Modified by: Yunhui Fu |
ffecfa5a | 6 | // Created: 10/13/04 |
e1d63b79 | 7 | // RCS-ID: $Id$ |
ffecfa5a JS |
8 | // Copyright: (c) William Osborne |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PEN_H_ | |
13 | #define _WX_PEN_H_ | |
14 | ||
ffecfa5a JS |
15 | #include "wx/gdiobj.h" |
16 | #include "wx/bitmap.h" | |
17 | #include "wx/colour.h" | |
18 | ||
19 | typedef WXDWORD wxMSWDash; | |
20 | ||
b5dbe15d | 21 | class WXDLLIMPEXP_FWD_CORE wxPen; |
ffecfa5a JS |
22 | |
23 | // VZ: this class should be made private | |
53a2db12 | 24 | class WXDLLIMPEXP_CORE wxPenRefData : public wxGDIRefData |
ffecfa5a JS |
25 | { |
26 | public: | |
27 | wxPenRefData(); | |
28 | wxPenRefData(const wxPenRefData& data); | |
29 | virtual ~wxPenRefData(); | |
30 | ||
31 | bool operator==(const wxPenRefData& data) const | |
32 | { | |
33 | // we intentionally don't compare m_hPen fields here | |
34 | return m_style == data.m_style && | |
35 | m_width == data.m_width && | |
36 | m_join == data.m_join && | |
37 | m_cap == data.m_cap && | |
38 | m_colour == data.m_colour && | |
a3ab1c18 | 39 | (m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) && |
ffecfa5a JS |
40 | (m_style != wxUSER_DASH || |
41 | (m_nbDash == data.m_nbDash && | |
42 | memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); | |
43 | } | |
44 | ||
45 | protected: | |
46 | int m_width; | |
82cddbd9 | 47 | wxPenStyle m_style; |
ffecfa5a JS |
48 | int m_join; |
49 | int m_cap; | |
50 | wxBitmap m_stipple; | |
51 | int m_nbDash; | |
52 | wxDash * m_dash; | |
53 | wxColour m_colour; | |
54 | WXHPEN m_hPen; | |
55 | ||
56 | private: | |
b5dbe15d | 57 | friend class WXDLLIMPEXP_FWD_CORE wxPen; |
ffecfa5a JS |
58 | |
59 | // Cannot use | |
60 | // DECLARE_NO_COPY_CLASS(wxPenRefData) | |
61 | // because copy constructor is explicitly declared above; | |
62 | // but no copy assignment operator is defined, so declare | |
63 | // it private to prevent the compiler from defining it: | |
64 | wxPenRefData& operator=(const wxPenRefData&); | |
65 | }; | |
66 | ||
67 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
68 | #define wxPENDATA(x) ((wxPenRefData *)(x).m_refData) | |
69 | ||
70 | // ---------------------------------------------------------------------------- | |
71 | // Pen | |
72 | // ---------------------------------------------------------------------------- | |
73 | ||
53a2db12 | 74 | class WXDLLIMPEXP_CORE wxPen : public wxPenBase |
ffecfa5a JS |
75 | { |
76 | public: | |
77 | wxPen(); | |
82cddbd9 | 78 | wxPen(const wxColour& col, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID); |
ac3688c0 FM |
79 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 |
80 | wxDEPRECATED_FUTURE( wxPen(const wxColour& col, int width, int style) ); | |
82cddbd9 FM |
81 | #endif |
82 | ||
ffecfa5a | 83 | wxPen(const wxBitmap& stipple, int width); |
ffecfa5a JS |
84 | virtual ~wxPen(); |
85 | ||
ffecfa5a JS |
86 | bool operator==(const wxPen& pen) const |
87 | { | |
88 | const wxPenRefData *penData = (wxPenRefData *)pen.m_refData; | |
89 | ||
90 | // an invalid pen is only equal to another invalid pen | |
91 | return m_refData ? penData && *M_PENDATA == *penData : !penData; | |
92 | } | |
93 | ||
94 | bool operator!=(const wxPen& pen) const { return !(*this == pen); } | |
95 | ||
ffecfa5a JS |
96 | // Override in order to recreate the pen |
97 | void SetColour(const wxColour& col); | |
1a1498c0 | 98 | void SetColour(unsigned char r, unsigned char g, unsigned char b); |
ffecfa5a JS |
99 | |
100 | void SetWidth(int width); | |
82cddbd9 | 101 | void SetStyle(wxPenStyle style); |
ffecfa5a JS |
102 | void SetStipple(const wxBitmap& stipple); |
103 | void SetDashes(int nb_dashes, const wxDash *dash); | |
82cddbd9 FM |
104 | void SetJoin(wxPenJoin join); |
105 | void SetCap(wxPenCap cap); | |
ffecfa5a JS |
106 | |
107 | wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); }; | |
108 | int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); }; | |
82cddbd9 FM |
109 | wxPenStyle GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); }; |
110 | wxPenJoin GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); }; | |
111 | wxPenCap GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); }; | |
ffecfa5a JS |
112 | int GetDashes(wxDash **ptr) const |
113 | { | |
114 | *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); | |
115 | return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
116 | } | |
117 | wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); }; | |
118 | inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); }; | |
119 | ||
120 | inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); }; | |
121 | ||
122 | // Internal | |
123 | bool RealizeResource(); | |
46562151 | 124 | bool FreeResource(bool force = false); |
ffecfa5a JS |
125 | WXHANDLE GetResourceHandle() const; |
126 | bool IsFree() const; | |
6afc1b46 | 127 | |
bc735a68 VZ |
128 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 |
129 | wxDEPRECATED_FUTURE( void SetStyle(int style) ) | |
130 | { SetStyle((wxPenStyle)style); } | |
131 | #endif | |
132 | ||
6afc1b46 VZ |
133 | protected: |
134 | virtual wxGDIRefData* CreateGDIRefData() const; | |
135 | virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const; | |
136 | // same as FreeResource() + RealizeResource() | |
137 | bool Recreate(); | |
ffecfa5a JS |
138 | |
139 | private: | |
140 | DECLARE_DYNAMIC_CLASS(wxPen) | |
141 | }; | |
142 | ||
143 | #endif // _WX_PEN_H_ |