]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/os2/pen.h | |
3 | // Purpose: wxPen class | |
4 | // Author: David Webster | |
5 | // Modified by: | |
6 | // Created: 10/10/99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) David Webster | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_PEN_H_ | |
13 | #define _WX_PEN_H_ | |
14 | ||
15 | #include "wx/gdiobj.h" | |
16 | #include "wx/bitmap.h" | |
17 | ||
18 | typedef long wxPMDash; | |
19 | ||
20 | class WXDLLEXPORT wxPen; | |
21 | ||
22 | class WXDLLEXPORT wxPenRefData: public wxGDIRefData | |
23 | { | |
24 | friend class WXDLLEXPORT wxPen; | |
25 | public: | |
26 | wxPenRefData(); | |
27 | wxPenRefData(const wxPenRefData& rData); | |
28 | virtual ~wxPenRefData(); | |
29 | ||
30 | protected: | |
31 | int m_nWidth; | |
32 | int m_nStyle; | |
33 | int m_nJoin; | |
34 | int m_nCap; | |
35 | wxBitmap m_vStipple; | |
36 | int m_nbDash; | |
37 | wxDash * m_dash; | |
38 | wxColour m_vColour; | |
39 | WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with | |
40 | }; | |
41 | ||
42 | #define M_PENDATA ((wxPenRefData *)m_refData) | |
43 | ||
44 | // Pen | |
45 | class WXDLLEXPORT wxPen : public wxGDIObject | |
46 | { | |
47 | DECLARE_DYNAMIC_CLASS(wxPen) | |
48 | public: | |
49 | wxPen(); | |
50 | wxPen( const wxColour& rColour | |
51 | ,int nWidth = 1 | |
52 | ,int nStyle = wxSOLID | |
53 | ); | |
54 | wxPen( const wxBitmap& rStipple | |
55 | ,int nWidth | |
56 | ); | |
57 | virtual ~wxPen(); | |
58 | ||
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; } | |
63 | ||
64 | virtual bool Ok(void) const { return (m_refData != NULL); } | |
65 | ||
66 | // | |
67 | // Override in order to recreate the pen | |
68 | // | |
69 | void SetColour(const wxColour& rColour); | |
70 | void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBlue); | |
71 | ||
72 | void SetWidth(int nWidth); | |
73 | void SetStyle(int nStyle); | |
74 | void SetStipple(const wxBitmap& rStipple); | |
75 | void SetDashes( int nNbDashes | |
76 | ,const wxDash* pDash | |
77 | ); | |
78 | void SetJoin(int nJoin); | |
79 | void SetCap(int nCap); | |
80 | void SetPS(HPS hPS); | |
81 | ||
82 | inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_vColour : wxNullColour); }; | |
83 | inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_nWidth : 0); }; | |
84 | inline int GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_nStyle : 0); }; | |
85 | inline int GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_nJoin : 0); }; | |
86 | inline int GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_nCap : 0); }; | |
87 | inline int GetPS(void) const { return (M_PENDATA ? M_PENDATA->m_hPen : 0); }; | |
88 | inline int GetDashes(wxDash **ptr) const | |
89 | { | |
90 | *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL); | |
91 | return (M_PENDATA ? M_PENDATA->m_nbDash : 0); | |
92 | } | |
93 | inline wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); }; | |
94 | inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); }; | |
95 | ||
96 | inline wxBitmap* GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_vStipple) : (wxBitmap*) NULL); }; | |
97 | ||
98 | // | |
99 | // Implementation | |
100 | // | |
101 | ||
102 | // | |
103 | // Useful helper: create the brush resource | |
104 | // | |
105 | bool RealizeResource(void); | |
106 | bool FreeResource(bool bForce = false); | |
107 | WXHANDLE GetResourceHandle(void); | |
108 | bool IsFree(void) const; | |
109 | void Unshare(void); | |
110 | ||
111 | private: | |
112 | LINEBUNDLE m_vLineBundle; | |
113 | AREABUNDLE m_vAreaBundle; | |
114 | }; // end of CLASS wxPen | |
115 | ||
116 | extern int wx2os2PenStyle(int nWxStyle); | |
117 | ||
118 | #endif | |
119 | // _WX_PEN_H_ |