]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gdiobj.h
Add missing lines to setup.h.in. This properly fixes compilation under configure...
[wxWidgets.git] / include / wx / gdiobj.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gdiobj.h
3 // Purpose: wxGDIObject base header
4 // Author: Julian Smart
5 // Modified by:
6 // Created:
7 // Copyright: (c) Julian Smart
8 // RCS-ID: $Id$
9 // Licence: wxWindows Licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_GDIOBJ_H_BASE_
13 #define _WX_GDIOBJ_H_BASE_
14
15 #include "wx/object.h"
16
17 // ----------------------------------------------------------------------------
18 // wxGDIRefData is the base class for wxXXXData structures which contain the
19 // real data for the GDI object and are shared among all wxWin objects sharing
20 // the same native GDI object
21 // ----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_CORE wxGDIRefData : public wxObjectRefData
24 {
25 public:
26 // Default ctor which needs to be defined just because we use
27 // wxDECLARE_NO_COPY_CLASS() below.
28 wxGDIRefData() { }
29
30 // override this in the derived classes to check if this data object is
31 // really fully initialized
32 virtual bool IsOk() const { return true; }
33
34 private:
35 wxDECLARE_NO_COPY_CLASS(wxGDIRefData);
36 };
37
38 // ----------------------------------------------------------------------------
39 // wxGDIObject: base class for bitmaps, pens, brushes, ...
40 // ----------------------------------------------------------------------------
41
42 class WXDLLIMPEXP_CORE wxGDIObject : public wxObject
43 {
44 public:
45 // checks if the object can be used
46 virtual bool IsOk() const
47 {
48 // the cast here is safe because the derived classes always create
49 // wxGDIRefData objects
50 return m_refData && static_cast<wxGDIRefData *>(m_refData)->IsOk();
51 }
52
53 // don't use in the new code, use IsOk() instead
54 bool IsNull() const { return m_refData == NULL; }
55
56 // older version, for backwards compatibility only (but not deprecated
57 // because it's still widely used)
58 bool Ok() const { return IsOk(); }
59
60 #if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXPALMOS__)
61 // Creates the resource
62 virtual bool RealizeResource() { return false; }
63
64 // Frees the resource
65 virtual bool FreeResource(bool WXUNUSED(force) = false) { return false; }
66
67 virtual bool IsFree() const { return false; }
68
69 // Returns handle.
70 virtual WXHANDLE GetResourceHandle() const { return 0; }
71 #endif // defined(__WXMSW__) || defined(__WXPM__)
72
73 protected:
74 // replace base class functions using wxObjectRefData with our own which
75 // use wxGDIRefData to ensure that we always work with data objects of the
76 // correct type (i.e. derived from wxGDIRefData)
77 virtual wxObjectRefData *CreateRefData() const
78 {
79 return CreateGDIRefData();
80 }
81
82 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const
83 {
84 return CloneGDIRefData(static_cast<const wxGDIRefData *>(data));
85 }
86
87 virtual wxGDIRefData *CreateGDIRefData() const = 0;
88 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const = 0;
89
90 DECLARE_DYNAMIC_CLASS(wxGDIObject)
91 };
92
93 #endif // _WX_GDIOBJ_H_BASE_