Fix Ok/IsOk() mess in wxGDIObject-derived classes; also added
wxGDIObject::Create/CloneGDIRefData() and implemented them for (almost) all ports git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50727 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -176,7 +176,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual wxGDIImageRefData *CreateData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
// creates an uninitialized bitmap, called from Create()s above
|
||||
bool DoCreate(int w, int h, int depth, WXHDC hdc);
|
||||
|
@@ -42,19 +42,15 @@ public:
|
||||
virtual int GetStyle() const;
|
||||
wxBitmap *GetStipple() const;
|
||||
|
||||
bool Ok() const { return IsOk(); }
|
||||
bool IsOk() const { return m_refData != NULL; }
|
||||
|
||||
// return the HBRUSH for this brush
|
||||
virtual WXHANDLE GetResourceHandle() const;
|
||||
|
||||
protected:
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxBrush)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_BRUSH_H_
|
||||
#endif // _WX_BRUSH_H_
|
||||
|
@@ -36,7 +36,7 @@ public:
|
||||
// accessors
|
||||
// ---------
|
||||
|
||||
bool IsOk() const { return m_isInit; }
|
||||
virtual bool IsOk() const { return m_isInit; }
|
||||
|
||||
unsigned char Red() const { return m_red; }
|
||||
unsigned char Green() const { return m_green; }
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#define _WX_MSW_ENHMETA_H_
|
||||
|
||||
#include "wx/dc.h"
|
||||
#include "wx/gdiobj.h"
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
#include "wx/dataobj.h"
|
||||
@@ -22,12 +23,12 @@
|
||||
// wxEnhMetaFile: encapsulation of Win32 HENHMETAFILE
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxEnhMetaFile : public wxObject
|
||||
class WXDLLEXPORT wxEnhMetaFile : public wxGDIObject
|
||||
{
|
||||
public:
|
||||
wxEnhMetaFile(const wxString& file = wxEmptyString) : m_filename(file)
|
||||
{ Init(); }
|
||||
wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxObject()
|
||||
wxEnhMetaFile(const wxEnhMetaFile& metafile) : wxGDIObject()
|
||||
{ Init(); Assign(metafile); }
|
||||
wxEnhMetaFile& operator=(const wxEnhMetaFile& metafile)
|
||||
{ Free(); Assign(metafile); return *this; }
|
||||
@@ -39,8 +40,7 @@ public:
|
||||
bool Play(wxDC *dc, wxRect *rectBound = (wxRect *)NULL);
|
||||
|
||||
// accessors
|
||||
bool Ok() const { return IsOk(); }
|
||||
bool IsOk() const { return m_hMF != 0; }
|
||||
virtual bool IsOk() const { return m_hMF != 0; }
|
||||
|
||||
wxSize GetSize() const;
|
||||
int GetWidth() const { return GetSize().x; }
|
||||
@@ -62,6 +62,11 @@ protected:
|
||||
void Free();
|
||||
void Assign(const wxEnhMetaFile& mf);
|
||||
|
||||
// we don't use these functions (but probably should) but have to implement
|
||||
// them as they're pure virtual in the base class
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
private:
|
||||
wxString m_filename;
|
||||
WXHANDLE m_hMF;
|
||||
|
@@ -135,8 +135,8 @@ protected:
|
||||
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
||||
|
||||
// implement wxObject virtuals which are used by AllocExclusive()
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||
|
@@ -51,7 +51,7 @@ public:
|
||||
}
|
||||
|
||||
// accessors
|
||||
bool IsOk() const { return m_handle != 0; }
|
||||
virtual bool IsOk() const { return m_handle != 0; }
|
||||
|
||||
void SetSize(int w, int h) { m_width = w; m_height = h; }
|
||||
|
||||
@@ -154,9 +154,6 @@ public:
|
||||
void SetHandle(WXHANDLE handle)
|
||||
{ AllocExclusive(); GetGDIImageData()->m_handle = handle; }
|
||||
|
||||
bool Ok() const { return IsOk(); }
|
||||
bool IsOk() const { return GetHandle() != 0; }
|
||||
|
||||
int GetWidth() const { return IsNull() ? 0 : GetGDIImageData()->m_width; }
|
||||
int GetHeight() const { return IsNull() ? 0 : GetGDIImageData()->m_height; }
|
||||
int GetDepth() const { return IsNull() ? 0 : GetGDIImageData()->m_depth; }
|
||||
@@ -180,8 +177,17 @@ protected:
|
||||
// create the data for the derived class here
|
||||
virtual wxGDIImageRefData *CreateData() const = 0;
|
||||
|
||||
// implement the wxObject method in terms of our, more specific, one
|
||||
virtual wxObjectRefData *CreateRefData() const { return CreateData(); }
|
||||
// implement the wxGDIObject method in terms of our, more specific, one
|
||||
virtual wxGDIRefData *CreateGDIRefData() const { return CreateData(); }
|
||||
|
||||
// we can't [efficiently] clone objects of this class
|
||||
virtual wxGDIRefData *
|
||||
CloneGDIRefData(const wxGDIRefData *WXUNUSED(data)) const
|
||||
{
|
||||
wxFAIL_MSG( _T("must be implemented if used") );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static wxGDIImageHandlerList ms_handlers;
|
||||
};
|
||||
|
@@ -27,15 +27,18 @@ class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
||||
|
||||
class WXDLLEXPORT wxMetafileRefData: public wxGDIRefData
|
||||
{
|
||||
friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
||||
public:
|
||||
wxMetafileRefData();
|
||||
virtual ~wxMetafileRefData();
|
||||
|
||||
virtual bool IsOk() const { return m_metafile != 0; }
|
||||
|
||||
public:
|
||||
WXHANDLE m_metafile;
|
||||
int m_windowsMappingMode;
|
||||
int m_width, m_height;
|
||||
|
||||
friend class WXDLLIMPEXP_FWD_CORE wxMetafile;
|
||||
};
|
||||
|
||||
#define M_METAFILEDATA ((wxMetafileRefData *)m_refData)
|
||||
@@ -51,8 +54,6 @@ public:
|
||||
virtual bool SetClipboard(int width = 0, int height = 0);
|
||||
|
||||
virtual bool Play(wxDC *dc);
|
||||
bool Ok() const { return IsOk(); }
|
||||
bool IsOk() const { return (M_METAFILEDATA && (M_METAFILEDATA->m_metafile != 0)); };
|
||||
|
||||
// set/get the size of metafile for clipboard operations
|
||||
wxSize GetSize() const { return wxSize(GetWidth(), GetHeight()); }
|
||||
@@ -96,6 +97,9 @@ public:
|
||||
protected:
|
||||
virtual void DoGetSize(int *width, int *height) const;
|
||||
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
int m_windowsMappingMode;
|
||||
wxMetafile* m_metaFile;
|
||||
|
||||
|
@@ -14,45 +14,38 @@
|
||||
|
||||
#include "wx/gdiobj.h"
|
||||
|
||||
class WXDLLIMPEXP_FWD_CORE wxPalette;
|
||||
|
||||
class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
|
||||
{
|
||||
friend class WXDLLIMPEXP_FWD_CORE wxPalette;
|
||||
public:
|
||||
wxPaletteRefData(void);
|
||||
virtual ~wxPaletteRefData(void);
|
||||
protected:
|
||||
WXHPALETTE m_hPalette;
|
||||
};
|
||||
|
||||
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
|
||||
|
||||
class WXDLLEXPORT wxPalette: public wxPaletteBase
|
||||
class WXDLLEXPORT wxPalette : public wxPaletteBase
|
||||
{
|
||||
public:
|
||||
wxPalette();
|
||||
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
|
||||
virtual ~wxPalette(void);
|
||||
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
|
||||
|
||||
int GetPixel(unsigned char red, unsigned char green, unsigned char blue) const;
|
||||
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
|
||||
wxPalette() { }
|
||||
wxPalette(int n,
|
||||
unsigned char *red, unsigned char *green, unsigned char *blue)
|
||||
{
|
||||
Create(n, red, green, blue);
|
||||
}
|
||||
|
||||
bool Create(int n,
|
||||
unsigned char *red, unsigned char *green, unsigned char *blue);
|
||||
|
||||
virtual int GetColoursCount() const;
|
||||
|
||||
virtual bool Ok() const { return IsOk(); }
|
||||
virtual bool IsOk(void) const { return (m_refData != NULL) ; }
|
||||
int
|
||||
GetPixel(unsigned char red, unsigned char green, unsigned char blue) const;
|
||||
|
||||
virtual bool FreeResource(bool force = false);
|
||||
bool
|
||||
GetRGB(int pixel,
|
||||
unsigned char *red, unsigned char *green, unsigned char *blue) const;
|
||||
|
||||
// implemetation
|
||||
inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }
|
||||
WXHPALETTE GetHPALETTE() const;
|
||||
void SetHPALETTE(WXHPALETTE pal);
|
||||
|
||||
|
||||
protected:
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxPalette)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_PALETTE_H_
|
||||
#endif // _WX_PALETTE_H_
|
||||
|
@@ -30,9 +30,6 @@ public:
|
||||
bool operator==(const wxPen& pen) const;
|
||||
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
||||
|
||||
virtual bool Ok() const { return IsOk(); }
|
||||
virtual bool IsOk() const { return (m_refData != NULL); }
|
||||
|
||||
// Override in order to recreate the pen
|
||||
void SetColour(const wxColour& col);
|
||||
void SetColour(unsigned char r, unsigned char g, unsigned char b);
|
||||
@@ -61,8 +58,8 @@ public:
|
||||
virtual bool IsFree() const;
|
||||
|
||||
protected:
|
||||
virtual wxObjectRefData* CreateRefData() const;
|
||||
virtual wxObjectRefData* CloneRefData(const wxObjectRefData* data) const;
|
||||
virtual wxGDIRefData* CreateGDIRefData() const;
|
||||
virtual wxGDIRefData* CloneGDIRefData(const wxGDIRefData* data) const;
|
||||
|
||||
// same as FreeResource() + RealizeResource()
|
||||
bool Recreate();
|
||||
|
@@ -43,8 +43,8 @@ public:
|
||||
WXHRGN GetHRGN() const;
|
||||
|
||||
protected:
|
||||
virtual wxObjectRefData *CreateRefData() const;
|
||||
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
|
||||
virtual bool DoIsEqual(const wxRegion& region) const;
|
||||
virtual bool DoGetBox(wxCoord& x, wxCoord& y, wxCoord& w, wxCoord& h) const;
|
||||
|
Reference in New Issue
Block a user