]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gdiobj.h
Removed SetPropertiesFlag() (high-level function using 'undocumented' wxPGProperty...
[wxWidgets.git] / include / wx / gdiobj.h
... / ...
CommitLineData
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
23class WXDLLIMPEXP_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};
30
31// ----------------------------------------------------------------------------
32// wxGDIObject: base class for bitmaps, pens, brushes, ...
33// ----------------------------------------------------------------------------
34
35class WXDLLIMPEXP_CORE wxGDIObject : public wxObject
36{
37public:
38 // checks if the object can be used
39 virtual 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
47 bool IsNull() const { return m_refData == NULL; }
48
49 // older version, for backwards compatibility only (but not deprecated
50 // because it's still widely used)
51 bool Ok() const { return IsOk(); }
52
53#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXPALMOS__)
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; }
64#endif // defined(__WXMSW__) || defined(__WXPM__)
65
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
83 DECLARE_DYNAMIC_CLASS(wxGDIObject)
84};
85
86#endif // _WX_GDIOBJ_H_BASE_