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:
Vadim Zeitlin
2007-12-15 17:54:20 +00:00
parent d6906a06a2
commit 8f884a0dcc
161 changed files with 1244 additions and 1139 deletions

View File

@@ -64,7 +64,6 @@ protected:
// ========================================================================
class WXDLLEXPORT wxBitmap: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxBitmap)
// ------------------------------------------------------------------------
// initialization
// ------------------------------------------------------------------------
@@ -116,8 +115,6 @@ public:
// get the given part of bitmap
wxBitmap GetSubBitmap( const wxRect& rect ) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;
int GetWidth() const;
int GetHeight() const;
int GetDepth() const;
@@ -140,10 +137,6 @@ public:
int GetBitmapType() const;
// wxObjectRefData
wxObjectRefData *CreateRefData() const;
wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxCocoa
WX_NSBitmapImageRep GetNSBitmapImageRep();
void SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep);
@@ -151,6 +144,12 @@ public:
static void InitStandardHandlers() { }
static void CleanUpHandlers() { }
protected:
wxGDIRefData *CreateGDIRefData() const;
wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
DECLARE_DYNAMIC_CLASS(wxBitmap)
};
class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
@@ -158,5 +157,4 @@ class WXDLLIMPEXP_CORE wxBitmapHandler: public wxBitmapHandlerBase
DECLARE_ABSTRACT_CLASS(wxBitmapHandler)
};
#endif
// __WX_COCOA_BITMAP_H__
#endif // __WX_COCOA_BITMAP_H__

View File

@@ -52,16 +52,12 @@ public:
virtual int GetStyle() const;
wxBitmap *GetStipple() const;
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const
{ return (m_refData != NULL); }
// wxObjectRefData
wxObjectRefData *CreateRefData() const;
wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// wxCocoa
WX_NSColor GetNSColor();
protected:
wxGDIRefData *CreateGDIRefData() const;
wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
};
#endif // __WX_COCOA_BRUSH_H__

View File

@@ -50,7 +50,7 @@ public:
virtual ~wxColour();
// accessors
bool IsOk() const { return m_cocoaNSColor; }
virtual bool IsOk() const { return m_cocoaNSColor; }
WX_NSColor GetNSColor() { return m_cocoaNSColor; }
unsigned char Red() const { return m_red; }

View File

@@ -14,12 +14,8 @@
#include "wx/bitmap.h"
class WXDLLEXPORT wxCursorRefData: public wxObjectRefData
class WXDLLEXPORT wxCursorRefData : public wxGDIRefData
{
DECLARE_NO_COPY_CLASS(wxCursorRefData)
friend class WXDLLIMPEXP_FWD_CORE wxBitmap;
friend class WXDLLIMPEXP_FWD_CORE wxCursor;
public:
wxCursorRefData();
virtual ~wxCursorRefData();
@@ -27,6 +23,11 @@ public:
protected:
int m_width, m_height;
WX_NSCursor m_hCursor;
friend class WXDLLIMPEXP_FWD_CORE wxBitmap;
friend class WXDLLIMPEXP_FWD_CORE wxCursor;
DECLARE_NO_COPY_CLASS(wxCursorRefData)
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
@@ -35,31 +36,26 @@ protected:
// Cursor
class WXDLLEXPORT wxCursor: public wxBitmap
{
DECLARE_DYNAMIC_CLASS(wxCursor)
public:
wxCursor();
wxCursor();
wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const wxString& name, long flags = 0,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(const wxString& name, long flags = 0,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(int cursor_type);
virtual ~wxCursor();
wxCursor(int cursor_type);
virtual ~wxCursor();
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return m_refData ; }
// FIXME: operator==() is wrong!
bool operator==(const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
bool operator!=(const wxCursor& cursor) const { return !(*this == cursor); }
inline bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
inline bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
inline WX_NSCursor GetNSCursor() const
{
return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0);
}
WX_NSCursor GetNSCursor() const { return M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0; }
DECLARE_DYNAMIC_CLASS(wxCursor)
};
extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor);

View File

@@ -110,15 +110,6 @@ public:
virtual bool RealizeResource();
protected:
/*! @abstract Helper method for COW.
@discussion
wxFont can be considered a mutable holder of an immutable opaque implementation object.
All methods that mutate the font should first call Unshare() to ensure that mutating
the implementation object does not cause another wxFont that happened to share the
same ref data to mutate.
*/
void Unshare();
/*! @abstract Internal constructor with ref data
@discussion
Takes ownership of @a refData. That is, it is assumed that refData has either just been
@@ -128,6 +119,10 @@ protected:
explicit wxFont(wxFontRefData *refData)
{ Create(refData); }
bool Create(wxFontRefData *refData);
virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};

View File

@@ -18,9 +18,8 @@
// ========================================================================
// wxIcon
// ========================================================================
class WXDLLEXPORT wxIcon: public wxGDIObject
class WXDLLEXPORT wxIcon : public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxIcon)
public:
wxIcon();
@@ -49,14 +48,18 @@ public:
// ctors, assignment operators...), but it's ok to have such function
void CopyFromBitmap(const wxBitmap& bmp);
bool Ok() const { return IsOk(); }
bool IsOk() const;
int GetWidth() const;
int GetHeight() const;
WX_NSImage GetNSImage() const;
bool CreateFromXpm(const char **bits);
protected:
virtual wxGDIRefData *CreateGDIRefData() const;
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
private:
DECLARE_DYNAMIC_CLASS(wxIcon)
};
#endif
// _WX_COCOA_ICON_H__
#endif // _WX_COCOA_ICON_H__

View File

@@ -23,24 +23,15 @@ class WXDLLIMPEXP_FWD_CORE wxBitmap;
// ========================================================================
class WXDLLEXPORT wxPen: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxPen)
public:
wxPen();
wxPen(const wxColour& col, int width = 1, int style = wxSOLID);
wxPen(const wxBitmap& stipple, int width);
virtual ~wxPen();
// wxObjectRefData
wxObjectRefData *CreateRefData() const;
wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
inline bool operator == (const wxPen& pen) const
{ return m_refData == pen.m_refData; }
inline bool operator != (const wxPen& pen) const
{ return m_refData != pen.m_refData; }
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return (m_refData != NULL) ; }
// FIXME: operator==() is wrong
bool operator==(const wxPen& pen) const { return m_refData == pen.m_refData; }
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
void SetColour(const wxColour& col) ;
void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
@@ -62,6 +53,12 @@ public:
WX_NSColor GetNSColor();
int GetCocoaLineDash(const CGFloat **pattern);
protected:
wxGDIRefData *CreateGDIRefData() const;
wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
DECLARE_DYNAMIC_CLASS(wxPen)
};
#endif // __WX_COCOA_PEN_H__