2005-05-04 14:57:50 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/gdiobj.h
|
|
|
|
// Purpose: wxGDIObject base header
|
|
|
|
// Author: Julian Smart
|
|
|
|
// Modified by:
|
|
|
|
// Created:
|
|
|
|
// Copyright: (c) Julian Smart
|
|
|
|
// Licence: wxWindows Licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_GDIOBJ_H_BASE_
|
|
|
|
#define _WX_GDIOBJ_H_BASE_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2006-04-16 18:33:24 -04:00
|
|
|
#include "wx/object.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxGDIRefData is the base class for wxXXXData structures which contain the
|
|
|
|
// real data for the GDI object and are shared among all wxWin objects sharing
|
|
|
|
// the same native GDI object
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-06-12 14:12:55 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxGDIRefData : public wxObjectRefData
|
2007-12-15 12:54:20 -05:00
|
|
|
{
|
|
|
|
public:
|
2010-12-14 13:43:49 -05:00
|
|
|
// Default ctor which needs to be defined just because we use
|
|
|
|
// wxDECLARE_NO_COPY_CLASS() below.
|
|
|
|
wxGDIRefData() { }
|
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
// override this in the derived classes to check if this data object is
|
|
|
|
// really fully initialized
|
|
|
|
virtual bool IsOk() const { return true; }
|
2010-12-14 13:43:49 -05:00
|
|
|
|
|
|
|
private:
|
|
|
|
wxDECLARE_NO_COPY_CLASS(wxGDIRefData);
|
2007-12-15 12:54:20 -05:00
|
|
|
};
|
2006-04-16 18:33:24 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
2007-12-15 12:54:20 -05:00
|
|
|
// wxGDIObject: base class for bitmaps, pens, brushes, ...
|
2006-04-16 18:33:24 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
class WXDLLIMPEXP_CORE wxGDIObject : public wxObject
|
2006-04-16 18:33:24 -04:00
|
|
|
{
|
|
|
|
public:
|
2007-12-15 12:54:20 -05:00
|
|
|
// checks if the object can be used
|
2008-02-18 18:58:09 -05:00
|
|
|
virtual bool IsOk() const
|
2007-12-15 12:54:20 -05:00
|
|
|
{
|
|
|
|
// the cast here is safe because the derived classes always create
|
|
|
|
// wxGDIRefData objects
|
2008-11-01 22:39:52 -04:00
|
|
|
return m_refData && static_cast<wxGDIRefData *>(m_refData)->IsOk();
|
2007-12-15 12:54:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// don't use in the new code, use IsOk() instead
|
2006-04-16 18:33:24 -04:00
|
|
|
bool IsNull() const { return m_refData == NULL; }
|
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
// older version, for backwards compatibility only (but not deprecated
|
|
|
|
// because it's still widely used)
|
2007-12-10 15:07:19 -05:00
|
|
|
bool Ok() const { return IsOk(); }
|
|
|
|
|
2014-05-15 19:56:58 -04:00
|
|
|
#if defined(__WXMSW__)
|
2006-04-16 18:33:24 -04:00
|
|
|
// Creates the resource
|
|
|
|
virtual bool RealizeResource() { return false; }
|
|
|
|
|
|
|
|
// Frees the resource
|
|
|
|
virtual bool FreeResource(bool WXUNUSED(force) = false) { return false; }
|
|
|
|
|
|
|
|
virtual bool IsFree() const { return false; }
|
|
|
|
|
|
|
|
// Returns handle.
|
2020-02-03 02:40:01 -05:00
|
|
|
virtual WXHANDLE GetResourceHandle() const { return NULL; }
|
2014-05-15 19:56:58 -04:00
|
|
|
#endif // defined(__WXMSW__)
|
2006-04-16 18:33:24 -04:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
protected:
|
|
|
|
// replace base class functions using wxObjectRefData with our own which
|
|
|
|
// use wxGDIRefData to ensure that we always work with data objects of the
|
|
|
|
// correct type (i.e. derived from wxGDIRefData)
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxObjectRefData *CreateRefData() const wxOVERRIDE
|
2007-12-15 12:54:20 -05:00
|
|
|
{
|
|
|
|
return CreateGDIRefData();
|
|
|
|
}
|
|
|
|
|
2014-03-29 20:02:23 -04:00
|
|
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const wxOVERRIDE
|
2007-12-15 12:54:20 -05:00
|
|
|
{
|
2008-11-01 22:39:52 -04:00
|
|
|
return CloneGDIRefData(static_cast<const wxGDIRefData *>(data));
|
2007-12-15 12:54:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxGDIRefData *CreateGDIRefData() const = 0;
|
|
|
|
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const = 0;
|
|
|
|
|
2015-04-23 07:49:01 -04:00
|
|
|
wxDECLARE_DYNAMIC_CLASS(wxGDIObject);
|
2006-04-16 18:33:24 -04:00
|
|
|
};
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
#endif // _WX_GDIOBJ_H_BASE_
|