]> git.saurik.com Git - wxWidgets.git/blame - include/wx/os2/pen.h
changing to wxDC, so that wxGCDC can be used as well
[wxWidgets.git] / include / wx / os2 / pen.h
CommitLineData
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 18typedef long wxPMDash;
0e320a79 19
b5dbe15d 20class WXDLLIMPEXP_FWD_CORE wxPen;
0e320a79
DW
21
22class WXDLLEXPORT wxPenRefData: public wxGDIRefData
23{
b5dbe15d 24 friend class WXDLLIMPEXP_FWD_CORE wxPen;
0e320a79
DW
25public:
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 &&
7aa920b5
VZ
38 (m_nStyle != wxSTIPPLE || m_vStipple.IsSameAs(data.m_vStipple)) &&
39 (m_nStyle != wxUSER_DASH ||
55ccdb93
VZ
40 (m_dash == data.m_dash &&
41 memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
42 }
43
0e320a79 44protected:
fd368161
DW
45 int m_nWidth;
46 int m_nStyle;
47 int m_nJoin;
48 int m_nCap;
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
fd368161 59class WXDLLEXPORT wxPen : public wxGDIObject
0e320a79 60{
fd368161 61 DECLARE_DYNAMIC_CLASS(wxPen)
0e320a79 62public:
fd368161
DW
63 wxPen();
64 wxPen( const wxColour& rColour
4f535231
VZ
65 ,int nWidth = 1
66 ,int nStyle = wxSOLID
fd368161
DW
67 );
68 wxPen( const wxBitmap& rStipple
69 ,int nWidth
70 );
d3c7fc99 71 virtual ~wxPen();
fd368161 72
0e70f525 73 inline bool operator == (const wxPen& rPen) const
55ccdb93 74 {
7aa920b5 75 const wxPenRefData *penData = (wxPenRefData *)rPen.m_refData;
55ccdb93
VZ
76
77 // an invalid pen is only equal to another invalid pen
78 return m_refData ? penData && *M_PENDATA == *penData : !penData;
79 }
80
0e70f525 81 inline bool operator != (const wxPen& rPen) const
55ccdb93 82 { return !(*this == rPen); }
fd368161 83
fd368161
DW
84 //
85 // Override in order to recreate the pen
86 //
87 void SetColour(const wxColour& rColour);
1a1498c0 88 void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBlue);
fd368161
DW
89
90 void SetWidth(int nWidth);
91 void SetStyle(int nStyle);
92 void SetStipple(const wxBitmap& rStipple);
93 void SetDashes( int nNbDashes
94 ,const wxDash* pDash
95 );
96 void SetJoin(int nJoin);
97 void SetCap(int nCap);
98 void SetPS(HPS hPS);
99
100 inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_vColour : wxNullColour); };
101 inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_nWidth : 0); };
102 inline int GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_nStyle : 0); };
103 inline int GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_nJoin : 0); };
104 inline int GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_nCap : 0); };
105 inline int GetPS(void) const { return (M_PENDATA ? M_PENDATA->m_hPen : 0); };
9e878707
SN
106 inline int GetDashes(wxDash **ptr) const
107 {
108 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
109 return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
110 }
111 inline wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); };
112 inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); };
c644b82e 113
fd368161
DW
114 inline wxBitmap* GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_vStipple) : (wxBitmap*) NULL); };
115
116 //
117 // Implementation
118 //
119
120 //
121 // Useful helper: create the brush resource
122 //
123 bool RealizeResource(void);
46562151 124 bool FreeResource(bool bForce = false);
17b1d76b 125 virtual WXHANDLE GetResourceHandle(void) const;
fd368161
DW
126 bool IsFree(void) const;
127 void Unshare(void);
128
129private:
130 LINEBUNDLE m_vLineBundle;
131 AREABUNDLE m_vAreaBundle;
132}; // end of CLASS wxPen
0e320a79 133
bd3e41f6
DW
134extern int wx2os2PenStyle(int nWxStyle);
135
0e320a79
DW
136#endif
137 // _WX_PEN_H_