]>
Commit | Line | Data |
---|---|---|
0e320a79 | 1 | ///////////////////////////////////////////////////////////////////////////// |
4f535231 | 2 | // Name: wx/os2/pen.h |
0e320a79 | 3 | // Purpose: wxPen class |
cdf1e714 | 4 | // Author: David Webster |
0e320a79 | 5 | // Modified by: |
cdf1e714 | 6 | // Created: 10/10/99 |
0e320a79 | 7 | // RCS-ID: $Id$ |
cdf1e714 | 8 | // Copyright: (c) David Webster |
65571936 | 9 | // Licence: wxWindows licence |
0e320a79 DW |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
12 | #ifndef _WX_PEN_H_ | |
13 | #define _WX_PEN_H_ | |
14 | ||
0e320a79 | 15 | #include "wx/gdiobj.h" |
0e320a79 DW |
16 | #include "wx/bitmap.h" |
17 | ||
236a9de3 | 18 | typedef long wxPMDash; |
0e320a79 | 19 | |
b5dbe15d | 20 | class WXDLLIMPEXP_FWD_CORE wxPen; |
0e320a79 DW |
21 | |
22 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
23 | { | |
b5dbe15d | 24 | friend class WXDLLIMPEXP_FWD_CORE wxPen; |
0e320a79 DW |
25 | public: |
26 | wxPenRefData(); | |
fd368161 | 27 | wxPenRefData(const wxPenRefData& rData); |
d3c7fc99 | 28 | virtual ~wxPenRefData(); |
0e320a79 | 29 | |
55ccdb93 VZ |
30 | bool operator==(const wxPenRefData& data) const |
31 | { | |
32 | // we intentionally don't compare m_hPen fields here | |
33 | return m_nStyle == data.m_nStyle && | |
34 | m_nWidth == data.m_nWidth && | |
35 | m_nJoin == data.m_nJoin && | |
36 | m_nCap == data.m_nCap && | |
37 | m_vColour == data.m_vColour && | |
4d98fefc SN |
38 | (m_nStyle != wxPENSTYLE_STIPPLE || m_vStipple.IsSameAs(data.m_vStipple)) && |
39 | (m_nStyle != wxPENSTYLE_USER_DASH || | |
55ccdb93 VZ |
40 | (m_dash == data.m_dash && |
41 | memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); | |
42 | } | |
43 | ||
0e320a79 | 44 | protected: |
fd368161 | 45 | int m_nWidth; |
82cddbd9 FM |
46 | wxPenStyle m_nStyle; |
47 | wxPenJoin m_nJoin; | |
48 | wxPenCap m_nCap; | |
fd368161 | 49 | wxBitmap m_vStipple; |
9e878707 SN |
50 | int m_nbDash; |
51 | wxDash * m_dash; | |
fd368161 DW |
52 | wxColour m_vColour; |
53 | WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with | |
0e320a79 DW |
54 | }; |
55 | ||
56 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
57 | ||
58 | // Pen | |
82cddbd9 | 59 | class WXDLLEXPORT wxPen : public wxPenBase |
0e320a79 | 60 | { |
0e320a79 | 61 | public: |
fd368161 DW |
62 | wxPen(); |
63 | wxPen( const wxColour& rColour | |
4f535231 | 64 | ,int nWidth = 1 |
82cddbd9 | 65 | ,wxPenStyle nStyle = wxPENSTYLE_SOLID |
fd368161 | 66 | ); |
ac3688c0 FM |
67 | #if FUTURE_WXWIN_COMPATIBILITY_3_0 |
68 | wxDEPRECATED_FUTURE( wxPen(const wxColour& col, int width, int style) ); | |
82cddbd9 FM |
69 | #endif |
70 | ||
fd368161 DW |
71 | wxPen( const wxBitmap& rStipple |
72 | ,int nWidth | |
73 | ); | |
d3c7fc99 | 74 | virtual ~wxPen(); |
fd368161 | 75 | |
0e70f525 | 76 | inline bool operator == (const wxPen& rPen) const |
55ccdb93 | 77 | { |
7aa920b5 | 78 | const wxPenRefData *penData = (wxPenRefData *)rPen.m_refData; |
55ccdb93 VZ |
79 | |
80 | // an invalid pen is only equal to another invalid pen | |
81 | return m_refData ? penData && *M_PENDATA == *penData : !penData; | |
82 | } | |
83 | ||
0e70f525 | 84 | inline bool operator != (const wxPen& rPen) const |
55ccdb93 | 85 | { return !(*this == rPen); } |
fd368161 | 86 | |
fd368161 DW |
87 | // |
88 | // Override in order to recreate the pen | |
89 | // | |
90 | void SetColour(const wxColour& rColour); | |
1a1498c0 | 91 | void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBlue); |
fd368161 DW |
92 | |
93 | void SetWidth(int nWidth); | |
82cddbd9 | 94 | void SetStyle(wxPenStyle nStyle); |
fd368161 DW |
95 | void SetStipple(const wxBitmap& rStipple); |
96 | void SetDashes( int nNbDashes | |
97 | ,const wxDash* pDash | |
98 | ); | |
82cddbd9 FM |
99 | void SetJoin(wxPenJoin nJoin); |
100 | void SetCap(wxPenCap nCap); | |
fd368161 DW |
101 | void SetPS(HPS hPS); |
102 | ||
103 | inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_vColour : wxNullColour); }; | |
4d98fefc SN |
104 | inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_nWidth : -1); }; |
105 | inline wxPenStyle GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_nStyle : wxPENSTYLE_INVALID); }; | |
106 | inline wxPenJoin GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_nJoin : wxJOIN_INVALID); }; | |
107 | inline wxPenCap GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_nCap : wxCAP_INVALID); }; | |
fd368161 | 108 | inline int GetPS(void) const { return (M_PENDATA ? M_PENDATA->m_hPen : 0); }; |
9e878707 SN |
109 | inline int GetDashes(wxDash **ptr) const |
110 | { | |
111 | *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); | |
4d98fefc | 112 | return (M_PENDATA ? M_PENDATA->m_nbDash : -1); |
9e878707 SN |
113 | } |
114 | inline wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); }; | |
115 | inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); }; | |
c644b82e | 116 | |
fd368161 DW |
117 | inline wxBitmap* GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_vStipple) : (wxBitmap*) NULL); }; |
118 | ||
119 | // | |
120 | // Implementation | |
121 | // | |
122 | ||
123 | // | |
124 | // Useful helper: create the brush resource | |
125 | // | |
126 | bool RealizeResource(void); | |
46562151 | 127 | bool FreeResource(bool bForce = false); |
17b1d76b | 128 | virtual WXHANDLE GetResourceHandle(void) const; |
fd368161 | 129 | bool IsFree(void) const; |
fd368161 DW |
130 | |
131 | private: | |
132 | LINEBUNDLE m_vLineBundle; | |
133 | AREABUNDLE m_vAreaBundle; | |
4b3f61d1 SN |
134 | |
135 | protected: | |
136 | virtual wxGDIRefData* CreateGDIRefData() const; | |
137 | virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const; | |
138 | ||
139 | // same as FreeResource() + RealizeResource() | |
140 | bool Recreate(); | |
141 | ||
142 | DECLARE_DYNAMIC_CLASS(wxPen) | |
fd368161 | 143 | }; // end of CLASS wxPen |
0e320a79 | 144 | |
82cddbd9 | 145 | extern int wx2os2PenStyle(wxPenStyle nWxStyle); |
bd3e41f6 | 146 | |
0e320a79 DW |
147 | #endif |
148 | // _WX_PEN_H_ |