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
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// 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:
|
|
|
|
// override this in the derived classes to check if this data object is
|
|
|
|
// really fully initialized
|
|
|
|
virtual bool IsOk() const { return true; }
|
|
|
|
};
|
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(); }
|
|
|
|
|
2006-10-21 13:19:11 -04:00
|
|
|
#if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXPALMOS__)
|
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.
|
|
|
|
virtual WXHANDLE GetResourceHandle() const { return 0; }
|
2006-10-21 13:19:11 -04:00
|
|
|
#endif // defined(__WXMSW__) || defined(__WXPM__)
|
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)
|
|
|
|
virtual wxObjectRefData *CreateRefData() const
|
|
|
|
{
|
|
|
|
return CreateGDIRefData();
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const
|
|
|
|
{
|
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;
|
|
|
|
|
2006-04-16 18:33:24 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxGDIObject)
|
|
|
|
};
|
1998-05-20 10:01:55 -04:00
|
|
|
|
2007-12-15 12:54:20 -05:00
|
|
|
#endif // _WX_GDIOBJ_H_BASE_
|