]> git.saurik.com Git - wxWidgets.git/blob - include/wx/os2/brush.h
fix SetUserData() to delete the correct pointer
[wxWidgets.git] / include / wx / os2 / brush.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/os2/brush.h
3 // Purpose: wxBrush class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/13/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_BRUSH_H_
13 #define _WX_BRUSH_H_
14
15 #include "wx/gdicmn.h"
16 #include "wx/gdiobj.h"
17 #include "wx/bitmap.h"
18
19 class WXDLLEXPORT wxBrush;
20
21 class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
22 {
23 friend class WXDLLEXPORT wxBrush;
24 public:
25 wxBrushRefData();
26 wxBrushRefData(const wxBrushRefData& rData);
27 ~wxBrushRefData();
28
29 protected:
30 int m_nStyle;
31 wxBitmap m_vStipple ;
32 wxColour m_vColour;
33 WXHBRUSH m_hBrush; // in OS/2 GPI this will be the PS the pen is associated with
34 AREABUNDLE m_vBundle;
35 };
36
37 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
38
39 // Brush
40 class WXDLLEXPORT wxBrush: public wxBrushBase
41 {
42 DECLARE_DYNAMIC_CLASS(wxBrush)
43
44 public:
45 wxBrush();
46 wxBrush(const wxColour& rCol, int nStyle = wxSOLID);
47 wxBrush(const wxBitmap& rStipple);
48 inline wxBrush(const wxBrush& rBrush) { Ref(rBrush); }
49 ~wxBrush();
50
51 inline wxBrush& operator = (const wxBrush& rBrush) { if (*this == rBrush) return (*this); Ref(rBrush); return *this; }
52 inline bool operator == (const wxBrush& rBrush) const { return m_refData == rBrush.m_refData; }
53 inline bool operator != (const wxBrush& rBrush) const { return m_refData != rBrush.m_refData; }
54
55 virtual void SetColour(const wxColour& rColour);
56 virtual void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBrush);
57 virtual void SetPS(HPS hPS);
58 virtual void SetStyle(int nStyle) ;
59 virtual void SetStipple(const wxBitmap& rStipple);
60
61 inline wxColour& GetColour(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_vColour : wxNullColour); };
62 virtual int GetStyle(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_nStyle : 0); };
63 inline wxBitmap* GetStipple(void) const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_vStipple : 0); };
64 inline int GetPS(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_hBrush : 0); };
65
66 inline virtual bool Ok(void) const { return (m_refData != NULL) ; }
67
68 //
69 // Implementation
70 //
71
72 //
73 // Useful helper: create the brush resource
74 //
75 bool RealizeResource(void);
76 WXHANDLE GetResourceHandle(void) ;
77 bool FreeResource(bool bForce = false);
78 bool IsFree(void) const;
79 void Unshare(void);
80 }; // end of CLASS wxBrush
81
82 #endif
83 // _WX_BRUSH_H_