]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdiobj.h
added WX_ASSERT_MESSAGE macro to simply using CPPUNIT_ASSERT_MESSAGE with wxString...
[wxWidgets.git] / include / wx / gdiobj.h
CommitLineData
99d80019
JS
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
34138703
JS
12#ifndef _WX_GDIOBJ_H_BASE_
13#define _WX_GDIOBJ_H_BASE_
c801d85f 14
1de8d512
VZ
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
8f884a0d
VZ
23class WXDLLIMPEXP_FWD_CORE wxGDIRefData : public wxObjectRefData
24{
25public:
26 // override this in the derived classes to check if this data object is
27 // really fully initialized
28 virtual bool IsOk() const { return true; }
29};
1de8d512
VZ
30
31// ----------------------------------------------------------------------------
8f884a0d 32// wxGDIObject: base class for bitmaps, pens, brushes, ...
1de8d512
VZ
33// ----------------------------------------------------------------------------
34
8f884a0d 35class WXDLLIMPEXP_CORE wxGDIObject : public wxObject
1de8d512
VZ
36{
37public:
8f884a0d
VZ
38 // checks if the object can be used
39 bool IsOk() const
40 {
41 // the cast here is safe because the derived classes always create
42 // wxGDIRefData objects
43 return m_refData && wx_static_cast(wxGDIRefData *, m_refData)->IsOk();
44 }
45
46 // don't use in the new code, use IsOk() instead
1de8d512
VZ
47 bool IsNull() const { return m_refData == NULL; }
48
8f884a0d
VZ
49 // older version, for backwards compatibility only (but not deprecated
50 // because it's still widely used)
43cf637f 51 bool Ok() const { return IsOk(); }
43cf637f 52
d9c9196e 53#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXPALMOS__)
1de8d512
VZ
54 // Creates the resource
55 virtual bool RealizeResource() { return false; }
56
57 // Frees the resource
58 virtual bool FreeResource(bool WXUNUSED(force) = false) { return false; }
59
60 virtual bool IsFree() const { return false; }
61
62 // Returns handle.
63 virtual WXHANDLE GetResourceHandle() const { return 0; }
d9c9196e 64#endif // defined(__WXMSW__) || defined(__WXPM__)
1de8d512 65
8f884a0d
VZ
66protected:
67 // replace base class functions using wxObjectRefData with our own which
68 // use wxGDIRefData to ensure that we always work with data objects of the
69 // correct type (i.e. derived from wxGDIRefData)
70 virtual wxObjectRefData *CreateRefData() const
71 {
72 return CreateGDIRefData();
73 }
74
75 virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const
76 {
77 return CloneGDIRefData(wx_static_cast(const wxGDIRefData *, data));
78 }
79
80 virtual wxGDIRefData *CreateGDIRefData() const = 0;
81 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const = 0;
82
1de8d512
VZ
83 DECLARE_DYNAMIC_CLASS(wxGDIObject)
84};
c801d85f 85
8f884a0d 86#endif // _WX_GDIOBJ_H_BASE_