]>
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 DW |
19 | |
20 | class WXDLLEXPORT wxPen; | |
21 | ||
22 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
23 | { | |
24 | friend class WXDLLEXPORT wxPen; | |
25 | public: | |
26 | wxPenRefData(); | |
fd368161 | 27 | wxPenRefData(const wxPenRefData& rData); |
d3c7fc99 | 28 | virtual ~wxPenRefData(); |
0e320a79 DW |
29 | |
30 | protected: | |
fd368161 DW |
31 | int m_nWidth; |
32 | int m_nStyle; | |
33 | int m_nJoin; | |
34 | int m_nCap; | |
35 | wxBitmap m_vStipple; | |
9e878707 SN |
36 | int m_nbDash; |
37 | wxDash * m_dash; | |
fd368161 DW |
38 | wxColour m_vColour; |
39 | WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with | |
0e320a79 DW |
40 | }; |
41 | ||
42 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
43 | ||
44 | // Pen | |
fd368161 | 45 | class WXDLLEXPORT wxPen : public wxGDIObject |
0e320a79 | 46 | { |
fd368161 | 47 | DECLARE_DYNAMIC_CLASS(wxPen) |
0e320a79 | 48 | public: |
fd368161 DW |
49 | wxPen(); |
50 | wxPen( const wxColour& rColour | |
4f535231 VZ |
51 | ,int nWidth = 1 |
52 | ,int nStyle = wxSOLID | |
fd368161 DW |
53 | ); |
54 | wxPen( const wxBitmap& rStipple | |
55 | ,int nWidth | |
56 | ); | |
d3c7fc99 | 57 | virtual ~wxPen(); |
fd368161 | 58 | |
0e70f525 SN |
59 | inline bool operator == (const wxPen& rPen) const |
60 | { return m_refData == rPen.m_refData; } | |
61 | inline bool operator != (const wxPen& rPen) const | |
62 | { return m_refData != rPen.m_refData; } | |
fd368161 | 63 | |
b7cacb43 VZ |
64 | virtual bool Ok() const { return IsOk(); } |
65 | virtual bool IsOk(void) const { return (m_refData != NULL); } | |
fd368161 DW |
66 | |
67 | // | |
68 | // Override in order to recreate the pen | |
69 | // | |
70 | void SetColour(const wxColour& rColour); | |
1a1498c0 | 71 | void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBlue); |
fd368161 DW |
72 | |
73 | void SetWidth(int nWidth); | |
74 | void SetStyle(int nStyle); | |
75 | void SetStipple(const wxBitmap& rStipple); | |
76 | void SetDashes( int nNbDashes | |
77 | ,const wxDash* pDash | |
78 | ); | |
79 | void SetJoin(int nJoin); | |
80 | void SetCap(int nCap); | |
81 | void SetPS(HPS hPS); | |
82 | ||
83 | inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_vColour : wxNullColour); }; | |
84 | inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_nWidth : 0); }; | |
85 | inline int GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_nStyle : 0); }; | |
86 | inline int GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_nJoin : 0); }; | |
87 | inline int GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_nCap : 0); }; | |
88 | inline int GetPS(void) const { return (M_PENDATA ? M_PENDATA->m_hPen : 0); }; | |
9e878707 SN |
89 | inline int GetDashes(wxDash **ptr) const |
90 | { | |
91 | *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); | |
92 | return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
93 | } | |
94 | inline wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); }; | |
95 | inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); }; | |
c644b82e | 96 | |
fd368161 DW |
97 | inline wxBitmap* GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_vStipple) : (wxBitmap*) NULL); }; |
98 | ||
99 | // | |
100 | // Implementation | |
101 | // | |
102 | ||
103 | // | |
104 | // Useful helper: create the brush resource | |
105 | // | |
106 | bool RealizeResource(void); | |
46562151 | 107 | bool FreeResource(bool bForce = false); |
fd368161 DW |
108 | WXHANDLE GetResourceHandle(void); |
109 | bool IsFree(void) const; | |
110 | void Unshare(void); | |
111 | ||
112 | private: | |
113 | LINEBUNDLE m_vLineBundle; | |
114 | AREABUNDLE m_vAreaBundle; | |
115 | }; // end of CLASS wxPen | |
0e320a79 | 116 | |
bd3e41f6 DW |
117 | extern int wx2os2PenStyle(int nWxStyle); |
118 | ||
0e320a79 DW |
119 | #endif |
120 | // _WX_PEN_H_ |