]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/pen.h
fixed wxBitmapButton to use focus and hover bitmaps correctly; also fixed tons of...
[wxWidgets.git] / include / wx / os2 / pen.h
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 WXDLLIMPEXP_FWD_CORE wxPen;
21
22 class WXDLLEXPORT wxPenRefData: public wxGDIRefData
23 {
24 friend class WXDLLIMPEXP_FWD_CORE wxPen;
25 public:
26 wxPenRefData();
27 wxPenRefData(const wxPenRefData& rData);
28 virtual ~wxPenRefData();
29
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 &&
38 (m_nStyle != wxSTIPPLE || m_vStipple.IsSameAs(data.m_vStipple)) &&
39 (m_nStyle != wxUSER_DASH ||
40 (m_dash == data.m_dash &&
41 memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
42 }
43
44 protected:
45 int m_nWidth;
46 int m_nStyle;
47 int m_nJoin;
48 int m_nCap;
49 wxBitmap m_vStipple;
50 int m_nbDash;
51 wxDash * m_dash;
52 wxColour m_vColour;
53 WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with
54 };
55
56 #define M_PENDATA ((wxPenRefData *)m_refData)
57
58 // Pen
59 class WXDLLEXPORT wxPen : public wxGDIObject
60 {
61 public:
62 wxPen();
63 wxPen( const wxColour& rColour
64 ,int nWidth = 1
65 ,int nStyle = wxSOLID
66 );
67 wxPen( const wxBitmap& rStipple
68 ,int nWidth
69 );
70 virtual ~wxPen();
71
72 inline bool operator == (const wxPen& rPen) const
73 {
74 const wxPenRefData *penData = (wxPenRefData *)rPen.m_refData;
75
76 // an invalid pen is only equal to another invalid pen
77 return m_refData ? penData && *M_PENDATA == *penData : !penData;
78 }
79
80 inline bool operator != (const wxPen& rPen) const
81 { return !(*this == rPen); }
82
83 //
84 // Override in order to recreate the pen
85 //
86 void SetColour(const wxColour& rColour);
87 void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBlue);
88
89 void SetWidth(int nWidth);
90 void SetStyle(int nStyle);
91 void SetStipple(const wxBitmap& rStipple);
92 void SetDashes( int nNbDashes
93 ,const wxDash* pDash
94 );
95 void SetJoin(int nJoin);
96 void SetCap(int nCap);
97 void SetPS(HPS hPS);
98
99 inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_vColour : wxNullColour); };
100 inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_nWidth : 0); };
101 inline int GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_nStyle : 0); };
102 inline int GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_nJoin : 0); };
103 inline int GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_nCap : 0); };
104 inline int GetPS(void) const { return (M_PENDATA ? M_PENDATA->m_hPen : 0); };
105 inline int GetDashes(wxDash **ptr) const
106 {
107 *ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
108 return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
109 }
110 inline wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); };
111 inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); };
112
113 inline wxBitmap* GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_vStipple) : (wxBitmap*) NULL); };
114
115 //
116 // Implementation
117 //
118
119 //
120 // Useful helper: create the brush resource
121 //
122 bool RealizeResource(void);
123 bool FreeResource(bool bForce = false);
124 virtual WXHANDLE GetResourceHandle(void) const;
125 bool IsFree(void) const;
126
127 private:
128 LINEBUNDLE m_vLineBundle;
129 AREABUNDLE m_vAreaBundle;
130
131 protected:
132 virtual wxGDIRefData* CreateGDIRefData() const;
133 virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
134
135 // same as FreeResource() + RealizeResource()
136 bool Recreate();
137
138 DECLARE_DYNAMIC_CLASS(wxPen)
139 }; // end of CLASS wxPen
140
141 extern int wx2os2PenStyle(int nWxStyle);
142
143 #endif
144 // _WX_PEN_H_