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