]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gdiobj.h
Dramatically optimise inserting many items in wxGenericListCtrl.
[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
0042c76f 23class WXDLLIMPEXP_CORE wxGDIRefData : public wxObjectRefData
8f884a0d
VZ
24{
25public:
fd08ccd2
VZ
26 // Default ctor which needs to be defined just because we use
27 // wxDECLARE_NO_COPY_CLASS() below.
28 wxGDIRefData() { }
29
8f884a0d
VZ
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; }
fd08ccd2
VZ
33
34private:
35 wxDECLARE_NO_COPY_CLASS(wxGDIRefData);
8f884a0d 36};
1de8d512
VZ
37
38// ----------------------------------------------------------------------------
8f884a0d 39// wxGDIObject: base class for bitmaps, pens, brushes, ...
1de8d512
VZ
40// ----------------------------------------------------------------------------
41
8f884a0d 42class WXDLLIMPEXP_CORE wxGDIObject : public wxObject
1de8d512
VZ
43{
44public:
8f884a0d 45 // checks if the object can be used
4decd6af 46 virtual bool IsOk() const
8f884a0d
VZ
47 {
48 // the cast here is safe because the derived classes always create
49 // wxGDIRefData objects
5c33522f 50 return m_refData && static_cast<wxGDIRefData *>(m_refData)->IsOk();
8f884a0d
VZ
51 }
52
53 // don't use in the new code, use IsOk() instead
1de8d512
VZ
54 bool IsNull() const { return m_refData == NULL; }
55
8f884a0d
VZ
56 // older version, for backwards compatibility only (but not deprecated
57 // because it's still widely used)
43cf637f 58 bool Ok() const { return IsOk(); }
43cf637f 59
d9c9196e 60#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXPALMOS__)
1de8d512
VZ
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; }
d9c9196e 71#endif // defined(__WXMSW__) || defined(__WXPM__)
1de8d512 72
8f884a0d
VZ
73protected:
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 {
5c33522f 84 return CloneGDIRefData(static_cast<const wxGDIRefData *>(data));
8f884a0d
VZ
85 }
86
87 virtual wxGDIRefData *CreateGDIRefData() const = 0;
88 virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const = 0;
89
1de8d512
VZ
90 DECLARE_DYNAMIC_CLASS(wxGDIObject)
91};
c801d85f 92
8f884a0d 93#endif // _WX_GDIOBJ_H_BASE_