COW cleanup patch (1583966):

1. perform deep comparison for the classes for which it makes sense in the
   ports where this wasn't done yet
2. remove (shallow) comparison operators for the classes for which it does
   not make sense (such as wxBitmap)
3. makes wxBitmap use COW on all ports
4. adds wxObject::IsRefTo()
5. centralizes and improves COW docs


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@42752 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-10-30 19:26:48 +00:00
parent 8d1517cef2
commit 55ccdb93e4
102 changed files with 310 additions and 639 deletions

View File

@ -85,6 +85,12 @@ initial accelerator table for a window.
<wx/accel.h>
\wxheading{Predefined objects}
Objects:
{\bf wxNullAcceleratorTable}
\wxheading{Example}
{\small%
@ -150,6 +156,7 @@ and cmd values like you would construct wxAcceleratorEntry objects with.}
\func{}{\destruct{wxAcceleratorTable}}{\void}
Destroys the wxAcceleratorTable object.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\membersection{wxAcceleratorTable::IsOk}\label{wxacceleratortableisok}
@ -170,35 +177,3 @@ Assignment operator, using \helpref{reference counting}{trefcount}.
\wxheading{Return value}
Returns reference to this object.
\membersection{wxAcceleratorTable::operator $==$}\label{wxacceleratortableequal}
\func{bool}{operator $==$}{\param{const wxAcceleratorTable\& }{accel}}
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).
\wxheading{Parameters}
\docparam{accel}{Accelerator table to compare with}
\wxheading{Return value}
Returns true if the accelerator tables were effectively equal, false otherwise.
\membersection{wxAcceleratorTable::operator $!=$}\label{wxacceleratortablenotequal}
\func{bool}{operator $!=$}{\param{const wxAcceleratorTable\& }{accel}}
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).
\wxheading{Parameters}
\docparam{accel}{Accelerator table to compare with}
\wxheading{Return value}
Returns true if the accelerator tables were unequal, false otherwise.

View File

@ -44,8 +44,7 @@ Default constructor.
\func{}{wxAnimation}{\param{const wxAnimation\& }{anim}}
Copy constructor.
wxAnimation objects are reference counted so that this operation is very fast.
Copy constructor, uses \helpref{reference counting}{trefcount}.
\func{}{wxAnimation}{\param{const wxString\& }{name}, \param{wxAnimationType}{ type = wxANIMATION\_TYPE\_ANY}}
@ -60,10 +59,8 @@ Loads an animation from a file.
\func{}{\destruct{wxAnimation}}{\void}
Destroys the wxAnimation object and possibly the underlying animation data.
Because reference counting is used, the animation may not actually be
destroyed at this point - only when the reference count is zero will the
data be deleted.
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\membersection{wxAnimation::GetDelay}\label{wxanimationgetdelay}
@ -151,3 +148,10 @@ Loads an animation from a file.
\true if the operation succeeded, \false otherwise.
\membersection{wxAnimation::operator $=$}\label{wxanimationassignment}
\func{wxAnimation\&}{operator $=$}{\param{const wxAnimation\& }{brush}}
Assignment operator, using \helpref{reference counting}{trefcount}.

View File

@ -206,10 +206,8 @@ wxImage to a wxBitmap.}
\func{}{\destruct{wxBitmap}}{\void}
Destroys the wxBitmap object and possibly the underlying bitmap data.
Because reference counting is used, the bitmap may not actually be
destroyed at this point - only when the reference count is zero will the
data be deleted.
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
If the application omits to delete the bitmap explicitly, the bitmap will be
destroyed automatically by wxWidgets when the application exits.
@ -595,33 +593,4 @@ Assignment operator, using \helpref{reference counting}{trefcount}.
Returns 'this' object.
\membersection{wxBitmap::operator $==$}\label{wxbitmapequal}
\func{bool}{operator $==$}{\param{const wxBitmap\& }{bitmap}}
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).
\wxheading{Parameters}
\docparam{bitmap}{Bitmap to compare with 'this'}
\wxheading{Return value}
Returns true if the bitmaps were effectively equal, false otherwise.
\membersection{wxBitmap::operator $!=$}\label{wxbitmapnotequal}
\func{bool}{operator $!=$}{\param{const wxBitmap\& }{bitmap}}
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).
\wxheading{Parameters}
\docparam{bitmap}{Bitmap to compare with 'this'}
\wxheading{Return value}
Returns true if the bitmaps were unequal, false otherwise.

View File

@ -135,12 +135,10 @@ If a stipple brush is created, the brush style will be set to wxSTIPPLE.
\func{}{\destruct{wxBrush}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\wxheading{Remarks}
The destructor may not delete the underlying brush object of the native windowing
system, since wxBrush uses a reference counting system for efficiency.
Although all remaining brushes are deleted when the application exits,
the application should try to clean up all brushes itself. This is because
wxWidgets cannot know if a pointer to the brush object is stored in an
@ -300,18 +298,17 @@ Assignment operator, using \helpref{reference counting}{trefcount}.
\func{bool}{operator $==$}{\param{const wxBrush\& }{brush}}
Equality operator. Two brushes are equal if they contain pointers
to the same underlying brush data. It does not compare each attribute,
so two independently-created brushes using the same parameters will
fail the test.
Equality operator.
See \helpref{reference-counted object comparison}{refcountequality} for more info.
\membersection{wxBrush::operator $!=$}\label{wxbrushnotequals}
\func{bool}{operator $!=$}{\param{const wxBrush\& }{brush}}
Inequality operator. Two brushes are not equal if they contain pointers
to different underlying brush data. It does not compare each attribute.
Inequality operator.
See \helpref{reference-counted object comparison}{refcountequality} for more info.
\section{\class{wxBrushList}}\label{wxbrushlist}

View File

@ -229,7 +229,10 @@ wxCursor down_cursor = wxCursor(down_bits, 32, 32,
\func{}{\destruct{wxCursor}}{\void}
Destroys the cursor. A cursor can be reused for more
Destroys the cursor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
A cursor can be reused for more
than one window, and does not get destroyed when the window is
destroyed. wxWidgets destroys all cursors on application exit, although
it is best to clean them up explicitly.
@ -246,20 +249,3 @@ Returns true if cursor data is present.
Assignment operator, using \helpref{reference counting}{trefcount}.
\membersection{wxCursor::operator $==$}\label{wxcursorequals}
\func{bool}{operator $==$}{\param{const wxCursor\& }{cursor}}
Equality operator. Two cursors are equal if they contain pointers
to the same underlying cursor data. It does not compare each attribute,
so two independently-created cursors using the same parameters will
fail the test.
\membersection{wxCursor::operator $!=$}\label{wxcursornotequals}
\func{bool}{operator $!=$}{\param{const wxCursor\& }{cursor}}
Inequality operator. Two cursors are not equal if they contain pointers
to different underlying cursor data. It does not compare each attribute.

View File

@ -248,12 +248,10 @@ and \helpref{wxDC::GetTextExtent}{wxdcgettextextent}.
\func{}{\destruct{wxFont}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\wxheading{Remarks}
The destructor may not delete the underlying font object of the native windowing
system, since wxFont uses a reference counting system for efficiency.
Although all remaining fonts are deleted when the application exits,
the application should try to clean up all fonts itself. This is because
wxWidgets cannot know if a pointer to the font object is stored in an
@ -589,16 +587,14 @@ Assignment operator, using \helpref{reference counting}{trefcount}.
\func{bool}{operator $==$}{\param{const wxFont\& }{font}}
Equality operator. Two fonts are equal if they contain pointers
to the same underlying font data. It does not compare each attribute,
so two independently-created fonts using the same parameters will
fail the test.
Equality operator.
See \helpref{reference-counted object comparison}{refcountequality} for more info.
\membersection{wxFont::operator $!=$}\label{wxfontnotequals}
\func{bool}{operator $!=$}{\param{const wxFont\& }{font}}
Inequality operator. Two fonts are not equal if they contain pointers
to different underlying font data. It does not compare each attribute.
Inequality operator.
See \helpref{reference-counted object comparison}{refcountequality} for more info.

View File

@ -212,10 +212,8 @@ must have mask colour set.
\func{}{\destruct{wxIcon}}{\void}
Destroys the wxIcon object and possibly the underlying icon data.
Because reference counting is used, the icon may not actually be
destroyed at this point - only when the reference count is zero will the
data be deleted.
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
If the application omits to delete the icon explicitly, the icon will be
destroyed automatically by wxWidgets when the application exits.
@ -355,9 +353,7 @@ Sets the width member (does not affect the icon data).
\func{wxIcon\& }{operator $=$}{\param{const wxIcon\& }{icon}}
Assignment operator. This operator does not copy any data, but instead
passes a pointer to the data in {\it icon} and increments a reference
counter. It is a fast operation.
Assignment operator, using \helpref{reference counting}{trefcount}.
\wxheading{Parameters}
@ -367,34 +363,4 @@ counter. It is a fast operation.
Returns 'this' object.
\membersection{wxIcon::operator $==$}\label{wxiconequal}
\func{bool}{operator $==$}{\param{const wxIcon\& }{icon}}
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).
\wxheading{Parameters}
\docparam{icon}{Icon to compare with 'this'}
\wxheading{Return value}
Returns true if the icons were effectively equal, false otherwise.
\membersection{wxIcon::operator $!=$}\label{wxiconnotequal}
\func{bool}{operator $!=$}{\param{const wxIcon\& }{icon}}
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).
\wxheading{Parameters}
\docparam{icon}{Icon to compare with 'this'}
\wxheading{Return value}
Returns true if the icons were unequal, false otherwise.

View File

@ -224,6 +224,7 @@ platform-dependent bitmap}
\func{}{\destruct{wxImage}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\membersection{wxImage::AddHandler}\label{wximageaddhandler}
@ -1300,36 +1301,6 @@ Assignment operator, using \helpref{reference counting}{trefcount}.
Returns 'this' object.
\membersection{wxImage::operator $==$}\label{wximageequal}
\constfunc{bool}{operator $==$}{\param{const wxImage\& }{image}}
Equality operator. This operator tests whether the internal data pointers are
equal (a fast test).
\wxheading{Parameters}
\docparam{image}{Image to compare with 'this'}
\wxheading{Return value}
Returns true if the images were effectively equal, false otherwise.
\membersection{wxImage::operator $!=$}\label{wximagenotequal}
\constfunc{bool}{operator $!=$}{\param{const wxImage\& }{image}}
Inequality operator. This operator tests whether the internal data pointers are
unequal (a fast test).
\wxheading{Parameters}
\docparam{image}{Image to compare with 'this'}
\wxheading{Return value}
Returns true if the images were unequal, false otherwise.
\section{\class{wxImageHandler}}\label{wximagehandler}

View File

@ -33,6 +33,7 @@ using the \helpref{wxMetafile:IsOk}{wxmetafileisok} member.
\func{}{\destruct{wxMetafile}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\membersection{wxMetafile::IsOk}\label{wxmetafileisok}

View File

@ -116,6 +116,13 @@ this one or is derived from it.
bool tmp = obj->IsKindOf(CLASSINFO(wxFrame));
\end{verbatim}
\membersection{wxObject::IsRefTo}\label{wxobjectisrefto}
\func{bool}{IsRefTo}{\param{const wxObject *}{ obj}}
Returns \true if this object is referencing the \arg{obj}'s data.
Note that this function only does a {\tt shallow} comparison.
\membersection{wxObject::Ref}\label{wxobjectref}
\func{void}{Ref}{\param{const wxObject\& }{clone}}
@ -165,6 +172,17 @@ The {\bf m\_refData} member is set to NULL.
\helpref{wxObject::SetRefData}{wxobjectsetrefdata}, \helpref{wxObject::GetRefData}{wxobjectgetrefdata},\rtfsp
\helpref{wxObjectRefData}{wxobjectrefdata}
\membersection{wxObject::UnShare}\label{wxobjectunshare}
\func{void}{UnShare}{\void}
Ensure that this object's data is not shared with any other object.
if we have no
data, it is created using CreateRefData() below, if we have shared data
it is copied using CloneRefData(), otherwise nothing is done.
\membersection{wxObject::operator new}\label{wxobjectnew}
\func{void *}{new}{\param{size\_t }{size}, \param{const wxString\& }{filename = NULL}, \param{int}{ lineNum = 0}}

View File

@ -86,6 +86,7 @@ red, blue or green component.
\func{}{\destruct{wxPalette}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\membersection{wxPalette::Create}\label{wxpalettecreate}
@ -182,19 +183,3 @@ Returns true if palette data is present.
Assignment operator, using \helpref{reference counting}{trefcount}.
\membersection{wxPalette::operator $==$}\label{wxpaletteequals}
\func{bool}{operator $==$}{\param{const wxPalette\& }{palette}}
Equality operator. Two palettes are equal if they contain pointers
to the same underlying palette data. It does not compare each attribute,
so two independently-created palettes using the same parameters will
fail the test.
\membersection{wxPalette::operator $!=$}\label{wxpalettenotequals}
\func{bool}{operator $!=$}{\param{const wxPalette\& }{palette}}
Inequality operator. Two palettes are not equal if they contain pointers
to different underlying palette data. It does not compare each attribute.

View File

@ -154,12 +154,10 @@ is found in the colour database.
\func{}{\destruct{wxPen}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\wxheading{Remarks}
The destructor may not delete the underlying pen object of the native windowing
system, since wxBrush uses a reference counting system for efficiency.
Although all remaining pens are deleted when the application exits,
the application should try to clean up all pens itself. This is because
wxWidgets cannot know if a pointer to the pen object is stored in an
@ -335,17 +333,15 @@ Assignment operator, using \helpref{reference counting}{trefcount}.
\func{bool}{operator $==$}{\param{const wxPen\& }{pen}}
Equality operator. Two pens are equal if they contain pointers
to the same underlying pen data. It does not compare each attribute,
so two independently-created pens using the same parameters will
fail the test.
Equality operator.
See \helpref{reference-counted object comparison}{refcountequality} for more info.
\membersection{wxPen::operator $!=$}\label{wxpennotequals}
\func{bool}{operator $!=$}{\param{const wxPen\& }{pen}}
Inequality operator. Two pens are not equal if they contain pointers
to different underlying pen data. It does not compare each attribute.
Inequality operator.
See \helpref{reference-counted object comparison}{refcountequality} for more info.
\section{\class{wxPenList}}\label{wxpenlist}

View File

@ -65,6 +65,7 @@ Constructs a region using the non-transparent pixels of a bitmap. See
\func{}{\destruct{wxRegion}}{\void}
Destructor.
See \helpref{reference-counted object destruction}{refcountdestruct} for more info.
\membersection{wxRegion::Clear}\label{wxregionclear}

View File

@ -1,6 +1,6 @@
\section{Reference counting}\label{trefcount}
\subsection{Reference counting and why you shouldn't care about it}\label{refcount}
\subsection{Why you shouldn't care about it}\label{refcount}
Many wxWidgets objects use a technique known as \it{reference counting}, also known
as {\it copy on write} (COW).
@ -19,22 +19,54 @@ is not seen from the outside of the class - in any case, the result of any
operation on it is the same.
\subsection{List of reference-counted wxWidgets classes}\label{refcountlist}
\subsection{Object comparison}\label{refcountequality}
The $==$ and $!=$ operators of \helpref{wxWidgets COW objects}{refcountlist}
always do a {\tt deep} comparison.
This means that the equality operator will return \true if two objects are
identic and not only if they share the same data.
Note that wxWidgets follows the {\it STL philosophy}: when a comparison operator cannot
be implemented efficiently (like for e.g. wxImage's $==$ operator which would need to
compare pixel-by-pixel the entire image's data), it's not implemented at all.
That's why not all reference-counted wxWidgets classes provide comparison operators.
Also note that if you only need to do a {\tt shallow} comparison between two
\helpref{wxObject}{wxobject}-derived classes, you should not use the $==$ and $!=$ operators
but rather the \helpref{wxObject::IsRefTo}{wxobjectisrefto} function.
\subsection{Object destruction}\label{refcountdestruct}
When a COW object destructor is called, it may not delete the data: if it's shared,
the destructor will just decrement the shared data's reference count without destroying it.
Only when the destructor of the last object owning the data is called, the data is really
destroyed. As for all other COW-things, this happens transparently to the class users so
that you shouldn't care about it.
The following classes in wxWidgets have efficient (i.e. fast) assignment operators
and copy constructors since they are reference-counted:
\helpref{wxAcceleratorTable}{wxacceleratortable}\\
\helpref{wxAnimation}{wxanimation}\\
\helpref{wxBitmap}{wxbitmap}\\
\helpref{wxBrush}{wxbrush}\\
\helpref{wxCursor}{wxcursor}\\
\helpref{wxFont}{wxfont}\\
\helpref{wxIcon}{wxicon}\\
\helpref{wxImage}{wximage}\\
\helpref{wxMetafile}{wxmetafile}\\
\helpref{wxPalette}{wxpalette}\\
\helpref{wxPen}{wxpen}\\
\helpref{wxRegion}{wxregion}\\
\helpref{wxRegionIterator}{wxregioniterator}\\
\helpref{wxString}{wxstring}
Note that the list above reports the objects which are reference-counted in all ports of
wxWidgets; some ports may use this tecnique also for other classes.
\subsection{Make your own reference-counted class}\label{wxobjectoverview}
Reference counting can be implemented easily using \helpref{wxObject}{wxobject}

View File

@ -127,8 +127,6 @@ public:
wxBitmap(const char* const* bits);
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM);
wxBitmap(const wxImage& image, int depth = -1);
bool operator == (const wxBitmap& bmp) const;
bool operator != (const wxBitmap& bmp) const;
bool Create(int width, int height, int depth = -1);

View File

@ -132,11 +132,6 @@ public:
int GetBitmapType() const;
inline bool operator == (const wxBitmap& bitmap) const
{ return m_refData == bitmap.m_refData; }
inline bool operator != (const wxBitmap& bitmap) const
{ return m_refData != bitmap.m_refData; }
// wxObjectRefData
wxObjectRefData *CreateRefData() const;
wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;

View File

@ -169,7 +169,7 @@ public:
if (style & wxBUFFER_VIRTUAL_AREA)
window->PrepareDC( m_paintdc );
if( buffer != wxNullBitmap )
if( buffer.IsOk() )
Init(&m_paintdc, buffer, style);
else
Init(&m_paintdc, window->GetClientSize(), style);

View File

@ -39,8 +39,6 @@ public:
bool Ok() const { return IsOk(); }
bool IsOk() const;
bool operator==(const wxBitmap& bmp) const;
bool operator!=(const wxBitmap& bmp) const { return !(*this == bmp); }
bool Create(const wxIDirectFBSurfacePtr& surface);
bool Create(int width, int height, int depth = -1);

View File

@ -34,8 +34,6 @@ public:
bool Ok() const { return IsOk(); }
bool IsOk() const;
bool operator==(const wxCursor& cursor) const;
bool operator!=(const wxCursor& cursor) const { return !(*this == cursor); }
// implementation
wxBitmap GetBitmap() const;

View File

@ -23,13 +23,6 @@ public:
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
virtual ~wxAcceleratorTable();
#if WXWIN_COMPATIBILITY_2_4
bool operator==(const wxAcceleratorTable& accel) const
{ return m_refData == accel.m_refData; }
bool operator!=(const wxAcceleratorTable& accel) const
{ return !(*this == accel); }
#endif
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -23,11 +23,6 @@ WX_DECLARE_LIST_WITH_DECL(wxAnimationDecoder, wxAnimationDecoderList, class WXDL
class WXDLLIMPEXP_ADV wxAnimation : public wxAnimationBase
{
public:
bool operator == (const wxAnimation& anim) const
{ return m_refData == anim.m_refData; }
bool operator != (const wxAnimation& anim) const
{ return m_refData != anim.m_refData; }
virtual bool IsOk() const
{ return m_refData != NULL; }

View File

@ -44,11 +44,6 @@ public:
{
}
bool operator==(const wxIcon& icon) const
{ return m_refData == icon.m_refData; }
bool operator!=(const wxIcon& icon) const
{ return !(*this == icon); }
// create from bitmap (which should have a mask unless it's monochrome):
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
// ctors, assignment operators...), but it's ok to have such function

View File

@ -33,8 +33,6 @@ public:
wxPalette();
wxPalette( int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue );
virtual ~wxPalette();
bool operator == ( const wxPalette& palette ) const;
bool operator != ( const wxPalette& palette ) const;
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const;

View File

@ -33,11 +33,6 @@ public:
wxAnimation& operator= (const wxAnimation&);
bool operator == (const wxAnimation& anim) const
{ return m_pixbuf == anim.m_pixbuf; }
bool operator != (const wxAnimation& anim) const
{ return m_pixbuf != anim.m_pixbuf; }
virtual bool IsOk() const
{ return m_pixbuf != NULL; }

View File

@ -64,8 +64,6 @@ public:
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
virtual ~wxBitmap();
bool operator == ( const wxBitmap& bmp ) const;
bool operator != ( const wxBitmap& bmp ) const { return !(*this == bmp); }
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -32,8 +32,6 @@ public:
int hotSpotX=-1, int hotSpotY=-1,
const char maskBits[] = NULL, const wxColour *fg = NULL, const wxColour *bg = NULL );
virtual ~wxCursor();
bool operator == ( const wxCursor& cursor ) const;
bool operator != ( const wxCursor& cursor ) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -94,6 +94,7 @@ class WXDLLIMPEXP_CORE wxRegionIterator: public wxObject
public:
wxRegionIterator();
wxRegionIterator(const wxRegion& region);
~wxRegionIterator();
void Reset() { m_current = 0u; }
void Reset(const wxRegion& region);
@ -113,9 +114,15 @@ public:
wxRect GetRect() const;
private:
void Init();
void CreateRects( const wxRegion& r );
size_t m_current;
wxRegion m_region;
wxRect *m_rects;
size_t m_numRects;
private:
DECLARE_DYNAMIC_CLASS(wxRegionIterator)
};

View File

@ -78,8 +78,6 @@ public:
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
wxBitmap( const wxImage& image, int depth = -1 ) { (void)CreateFromImage(image, depth); }
virtual ~wxBitmap();
bool operator == ( const wxBitmap& bmp ) const;
bool operator != ( const wxBitmap& bmp ) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -35,8 +35,6 @@ public:
int hotSpotX=-1, int hotSpotY=-1,
const char maskBits[] = NULL, const wxColour *fg = NULL, const wxColour *bg = NULL );
virtual ~wxCursor();
bool operator == ( const wxCursor& cursor ) const;
bool operator != ( const wxCursor& cursor ) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -392,11 +392,6 @@ public:
// -1.0..1.0 where -1.0 is -360 degrees and 1.0 is 360 degrees
void RotateHue(double angle);
bool operator == (const wxImage& image) const
{ return m_refData == image.m_refData; }
bool operator != (const wxImage& image) const
{ return m_refData != image.m_refData; }
static wxList& GetHandlers() { return sm_handlers; }
static void AddHandler( wxImageHandler *handler );
static void InsertHandler( wxImageHandler *handler );

View File

@ -24,11 +24,6 @@ public:
virtual ~wxAcceleratorTable();
bool operator == (const wxAcceleratorTable& accel) const
{ return m_refData == accel.m_refData; }
bool operator != (const wxAcceleratorTable& accel) const
{ return m_refData != accel.m_refData; }
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -157,9 +157,6 @@ public:
wxMask *GetMask() const;
void SetMask(wxMask *mask) ;
inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
static void InitStandardHandlers();
// raw bitmap access support functions, for internal use only

View File

@ -44,10 +44,9 @@ public:
virtual void MacSetTheme(short macThemeBrush) ;
virtual void MacSetThemeBackground(unsigned long macThemeBackground , WXRECTPTR extent) ;
bool operator == (const wxBrush& brush) const
{ return m_refData == brush.m_refData; }
bool operator == (const wxBrush& brush) const;
bool operator != (const wxBrush& brush) const
{ return m_refData != brush.m_refData; }
{ return !(*this == brush); }
wxMacBrushKind MacGetBrushKind() const ;

View File

@ -38,9 +38,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const ;
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; }
void MacInstall() const ;
void SetHCURSOR(WXHCURSOR cursor);

View File

@ -36,8 +36,6 @@ public:
bool LoadFile(const wxString& name ,wxBitmapType flags = wxBITMAP_TYPE_ICON_RESOURCE )
{ return LoadFile( name , flags , -1 , -1 ) ; }
bool operator==(const wxIcon& icon) const { return m_refData == icon.m_refData; }
bool operator!=(const wxIcon& icon) const { return !(*this == icon); }
// create from bitmap (which should have a mask unless it's monochrome):
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no

View File

@ -57,12 +57,6 @@ public:
// Implementation
WXHMETAFILE GetHMETAFILE() const ;
void SetHMETAFILE(WXHMETAFILE mf) ;
// Operators
inline bool operator == (const wxMetafile& metafile) const { return m_refData == metafile.m_refData; }
inline bool operator != (const wxMetafile& metafile) const { return m_refData != metafile.m_refData; }
protected:
};
class WXDLLEXPORT wxMetafileDC: public wxDC

View File

@ -47,9 +47,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return (m_refData != NULL) ; }
inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
virtual int GetColoursCount() const;
private:

View File

@ -28,6 +28,20 @@ public:
wxPenRefData& operator=(const wxPenRefData& data);
bool operator==(const wxPenRefData& data) const
{
// we intentionally don't compare m_hPen fields here
return m_style == data.m_style &&
m_width == data.m_width &&
m_join == data.m_join &&
m_cap == data.m_cap &&
m_colour == data.m_colour &&
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
(m_style != wxUSER_DASH ||
(m_nbDash == data.m_nbDash &&
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
}
protected:
int m_width;
int m_style;
@ -54,8 +68,15 @@ public:
wxPen(const wxBitmap& stipple, int width);
virtual ~wxPen();
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; }
inline bool operator == (const wxPen& pen) const
{
const wxPenRefData *penData = (wxPenRefData *)pen.m_refData;
// an invalid pen is only equal to another invalid pen
return m_refData ? penData && *M_PENDATA == *penData : !penData;
}
inline bool operator != (const wxPen& pen) const { return *(this == pen); }
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return (m_refData != NULL) ; }

View File

@ -190,9 +190,6 @@ public:
int GetBitmapType() const;
inline bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
inline bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
static void InitStandardHandlers();
// raw bitmap access support functions, for internal use only

View File

@ -38,8 +38,6 @@ public:
wxBitmap(const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_RESOURCE);
wxBitmap(const wxImage& image, int depth = -1);
virtual ~wxBitmap() {}
bool operator == (const wxBitmap& bmp) const;
bool operator != (const wxBitmap& bmp) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -33,8 +33,6 @@ public:
long flags = wxBITMAP_TYPE_CUR_RESOURCE,
int hotSpotX = 0, int hotSpotY = 0);
virtual ~wxCursor();
bool operator == (const wxCursor& cursor) const;
bool operator != (const wxCursor& cursor) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -35,8 +35,6 @@ public:
wxPalette();
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
virtual ~wxPalette();
bool operator == (const wxPalette& palette) const;
bool operator != (const wxPalette& palette) const;
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const;

View File

@ -26,9 +26,6 @@ public:
virtual ~wxAcceleratorTable();
bool operator == (const wxAcceleratorTable& accel) const { return m_refData == accel.m_refData; }
bool operator != (const wxAcceleratorTable& accel) const { return m_refData != accel.m_refData; }
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -42,11 +42,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const;
bool operator == (const wxCursor& cursor) const
{ return m_refData == cursor.m_refData; }
bool operator != (const wxCursor& cursor) const
{ return m_refData != cursor.m_refData; }
// Motif-specific.
// Create/get a cursor for the current display
WXCursor GetXCursor(WXDisplay* display) const;

View File

@ -55,11 +55,6 @@ public:
// ctors, assignment operators...), but it's ok to have such function
void CopyFromBitmap(const wxBitmap& bmp);
bool operator == (const wxIcon& icon) const
{ return m_refData == icon.m_refData; }
bool operator != (const wxIcon& icon) const
{ return !(*this == icon); }
DECLARE_DYNAMIC_CLASS(wxIcon)
};

View File

@ -61,9 +61,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return (m_refData != NULL) ; }
bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
// Motif-specific
WXColormap GetXColormap(WXDisplay* display = NULL) const;
bool TransferBitmap(void *data, int depth, int size);

View File

@ -30,10 +30,6 @@ public:
// initialize from array
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]);
bool operator==(const wxAcceleratorTable& accel) const;
bool operator!=(const wxAcceleratorTable& accel) const
{ return !(*this == accel); }
bool Ok() const { return IsOk(); }
bool IsOk() const;
void SetHACCEL(WXHACCEL hAccel);

View File

@ -139,9 +139,6 @@ public:
wxBitmap GetMaskBitmap() const;
void SetMask(wxMask *mask);
bool operator==(const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
bool operator!=(const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
// these functions are internal and shouldn't be used, they risk to
// disappear in the future
bool HasAlpha() const;

View File

@ -32,10 +32,6 @@ public:
wxCursor(int idCursor);
virtual ~wxCursor();
bool operator==(const wxCursor& cursor) const;
bool operator!=(const wxCursor& cursor) const
{ return !(*this == cursor); }
// implementation only
void SetHCURSOR(WXHCURSOR cursor) { SetHandle((WXHANDLE)cursor); }
WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); }

View File

@ -65,11 +65,6 @@ public:
long type = wxBITMAP_TYPE_ICO_RESOURCE,
int desiredWidth = -1, int desiredHeight = -1);
bool operator == (const wxIcon& icon) const
{ return m_refData == icon.m_refData; }
bool operator != (const wxIcon& icon) const
{ return m_refData != icon.m_refData; }
// implementation only from now on
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }

View File

@ -68,12 +68,6 @@ public:
int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
void SetWindowsMappingMode(int mm);
// Operators
bool operator==(const wxMetafile& metafile) const
{ return m_refData == metafile.m_refData; }
bool operator!=(const wxMetafile& metafile) const
{ return m_refData != metafile.m_refData; }
private:
DECLARE_DYNAMIC_CLASS(wxMetafile)
};

View File

@ -44,9 +44,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk(void) const { return (m_refData != NULL) ; }
inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
virtual bool FreeResource(bool force = false);
// implemetation

View File

@ -36,7 +36,7 @@ public:
m_join == data.m_join &&
m_cap == data.m_cap &&
m_colour == data.m_colour &&
(m_style != wxSTIPPLE || m_stipple == data.m_stipple) &&
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
(m_style != wxUSER_DASH ||
(m_nbDash == data.m_nbDash &&
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));

View File

@ -473,6 +473,9 @@ public:
// Make sure this object has only one reference
void UnShare() { AllocExclusive(); }
// Do a shallow comparison of our referenced data with the given object's refdata
bool IsRefTo(const wxObject *p) const { return m_refData == p->m_refData; }
protected:
// ensure that our data is not shared with anybody else: if we have no
// data, it is created using CreateRefData() below, if we have shared data

View File

@ -40,11 +40,6 @@ public:
virtual ~wxAcceleratorTable();
inline bool operator== (const wxAcceleratorTable& rAccel) const
{ return m_refData == rAccel.m_refData; };
inline bool operator!= (const wxAcceleratorTable& rAccel) const
{ return m_refData != rAccel.m_refData; };
bool Ok() const { return IsOk(); }
bool IsOk() const;
void SetHACCEL(WXHACCEL hAccel);

View File

@ -187,12 +187,6 @@ public:
void SetMask(wxMask* pMask) ;
inline bool operator==(const wxBitmap& rBitmap) const
{ return m_refData == rBitmap.m_refData; }
inline bool operator!=(const wxBitmap& rBitmap) const
{ return m_refData != rBitmap.m_refData; }
// Implementation
public:
inline void SetHBITMAP(WXHBITMAP hBmp)

View File

@ -47,8 +47,8 @@ public:
wxBrush(const wxBitmap& rStipple);
virtual ~wxBrush();
inline bool operator == (const wxBrush& rBrush) const { return m_refData == rBrush.m_refData; }
inline bool operator != (const wxBrush& rBrush) const { return m_refData != rBrush.m_refData; }
inline bool operator == (const wxBrush& rBrush) const;
inline bool operator != (const wxBrush& rBrush) const { return !(*this == rBrush); }
virtual void SetColour(const wxColour& rColour);
virtual void SetColour(unsigned char cRed, unsigned char cGreen, unsigned char cBrush);

View File

@ -48,8 +48,6 @@ public:
);
wxCursor(int nCursorType);
inline ~wxCursor() { }
inline bool operator == (const wxCursor& rCursor) const { return m_refData == rCursor.m_refData; }
inline bool operator != (const wxCursor& rCursor) const { return m_refData != rCursor.m_refData; }
inline WXHCURSOR GetHCURSOR(void) const { return (M_CURSORDATA ? M_CURSORDATA->m_hCursor : 0); }
inline void SetHCURSOR(WXHCURSOR hCursor) { SetHandle((WXHANDLE)hCursor); }

View File

@ -64,11 +64,6 @@ public:
,int nDesiredHeight = -1
);
inline bool operator == (const wxIcon& rIcon) const
{ return m_refData == rIcon.m_refData; }
inline bool operator != (const wxIcon& rIcon) const
{ return m_refData != rIcon.m_refData; }
wxIconRefData *GetIconData() const { return (wxIconRefData *)m_refData; }
inline void SetHICON(WXHICON hIcon) { SetHandle((WXHANDLE)hIcon); }

View File

@ -66,12 +66,6 @@ public:
void SetHMETAFILE(WXHANDLE mf) ;
inline int GetWindowsMappingMode(void) { return M_METAFILEDATA->m_windowsMappingMode; }
void SetWindowsMappingMode(int mm);
// Operators
inline bool operator== (const wxMetafile& metafile) const
{ return m_refData == metafile.m_refData; }
inline bool operator!= (const wxMetafile& metafile) const
{ return m_refData != metafile.m_refData; }
};
class WXDLLEXPORT wxMetafileDC: public wxDC

View File

@ -62,11 +62,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk(void) const { return (m_refData != NULL) ; }
inline bool operator == (const wxPalette& rPalette) const
{ return m_refData == rPalette.m_refData; }
inline bool operator != (const wxPalette& rPalette) const
{ return m_refData != rPalette.m_refData; }
virtual bool FreeResource(bool bForce = false);
inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }

View File

@ -27,6 +27,20 @@ public:
wxPenRefData(const wxPenRefData& rData);
virtual ~wxPenRefData();
bool operator==(const wxPenRefData& data) const
{
// we intentionally don't compare m_hPen fields here
return m_nStyle == data.m_nStyle &&
m_nWidth == data.m_nWidth &&
m_nJoin == data.m_nJoin &&
m_nCap == data.m_nCap &&
m_vColour == data.m_vColour &&
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
(m_style != wxUSER_DASH ||
(m_dash == data.m_dash &&
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
}
protected:
int m_nWidth;
int m_nStyle;
@ -57,9 +71,15 @@ public:
virtual ~wxPen();
inline bool operator == (const wxPen& rPen) const
{ return m_refData == rPen.m_refData; }
{
const wxPenRefData *penData = (wxPenRefData *)pen.m_refData;
// an invalid pen is only equal to another invalid pen
return m_refData ? penData && *M_PENDATA == *penData : !penData;
}
inline bool operator != (const wxPen& rPen) const
{ return m_refData != rPen.m_refData; }
{ return !(*this == rPen); }
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk(void) const { return (m_refData != NULL); }

View File

@ -30,13 +30,6 @@ public:
virtual ~wxAcceleratorTable();
#if WXWIN_COMPATIBILITY_2_4
bool operator==(const wxAcceleratorTable& accel) const
{ return m_refData == accel.m_refData; }
bool operator!=(const wxAcceleratorTable& accel) const
{ return !(*this == accel); }
#endif
bool Ok() const { return IsOk(); }
bool IsOk() const;
void SetHACCEL(WXHACCEL hAccel);

View File

@ -132,9 +132,6 @@ public:
wxMask *GetMask() const;
void SetMask(wxMask *mask);
bool operator==(const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
bool operator!=(const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
// these functions are internal and shouldn't be used, they risk to
// disappear in the future
bool HasAlpha() const;

View File

@ -32,10 +32,6 @@ public:
wxCursor(int idCursor);
virtual ~wxCursor();
bool operator==(const wxCursor& cursor) const;
bool operator!=(const wxCursor& cursor) const
{ return !(*this == cursor); }
// implementation only
void SetHCURSOR(WXHCURSOR cursor) { SetHandle((WXHANDLE)cursor); }
WXHCURSOR GetHCURSOR() const { return (WXHCURSOR)GetHandle(); }

View File

@ -68,12 +68,6 @@ public:
int GetWindowsMappingMode() const { return M_METAFILEDATA->m_windowsMappingMode; }
void SetWindowsMappingMode(int mm);
// Operators
bool operator==(const wxMetafile& metafile) const
{ return m_refData == metafile.m_refData; }
bool operator!=(const wxMetafile& metafile) const
{ return m_refData != metafile.m_refData; }
private:
DECLARE_DYNAMIC_CLASS(wxMetafile)
};

View File

@ -44,9 +44,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk(void) const { return (m_refData != NULL) ; }
inline bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
inline bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
virtual bool FreeResource(bool force = false);
inline WXHPALETTE GetHPALETTE(void) const { return (M_PALETTEDATA ? M_PALETTEDATA->m_hPalette : 0); }

View File

@ -36,7 +36,7 @@ public:
m_join == data.m_join &&
m_cap == data.m_cap &&
m_colour == data.m_colour &&
(m_style != wxSTIPPLE || m_stipple == data.m_stipple) &&
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
(m_style != wxUSER_DASH ||
(m_nbDash == data.m_nbDash &&
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));

View File

@ -332,7 +332,7 @@ expdecl wxVariant& operator << ( wxVariant &variant, const classname &object );
#define IMPLEMENT_VARIANT_OBJECT(classname) \
IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,EMPTY_PARAMETER_VALUE)
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,expdecl) \
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
class classname##VariantData: public wxVariantData \
{ \
public:\
@ -355,15 +355,6 @@ private: \
\
IMPLEMENT_CLASS(classname##VariantData, wxVariantData)\
\
bool classname##VariantData::Eq(wxVariantData& data) const \
{\
wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
\
classname##VariantData & otherData = (classname##VariantData &) data;\
\
return (otherData.m_value == m_value);\
}\
\
wxString classname##VariantData::GetType() const\
{\
return m_value.GetClassInfo()->GetClassName();\
@ -390,6 +381,36 @@ expdecl wxVariant& operator << ( wxVariant &variant, const classname &value )\
return variant;\
}
// implements a wxVariantData-derived class using for the Eq() method the operator==
// which must have been provided by "classname"
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED(classname,expdecl) \
IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
\
bool classname##VariantData::Eq(wxVariantData& data) const \
{\
wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
\
classname##VariantData & otherData = (classname##VariantData &) data;\
\
return otherData.m_value == m_value;\
}\
// implements a wxVariantData-derived class using for the Eq() method a shallow
// comparison (through wxObject::IsRefTo function)
#define IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(classname,expdecl) \
IMPLEMENT_VARIANT_OBJECT_EXPORTED_NO_EQ(classname,expdecl) \
\
bool classname##VariantData::Eq(wxVariantData& data) const \
{\
wxASSERT( wxIsKindOf((&data), classname##VariantData) );\
\
classname##VariantData & otherData = (classname##VariantData &) data;\
\
return (otherData.m_value.IsRefTo(&m_value));\
}\
// Since we want type safety wxVariant we need to fetch and dynamic_cast
// in a seemingly safe way so the compiler can check, so we define
// a dynamic_cast /wxDynamicCast analogue.

View File

@ -84,8 +84,6 @@ public:
wxBitmap( const wxString &filename, wxBitmapType type = wxBITMAP_TYPE_XPM );
virtual ~wxBitmap();
bool operator == ( const wxBitmap& bmp ) const;
bool operator != ( const wxBitmap& bmp ) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -35,8 +35,6 @@ public:
int hotSpotX=-1, int hotSpotY=-1,
const char maskBits[]=0, wxColour *fg=0, wxColour *bg=0 );
virtual ~wxCursor();
bool operator == ( const wxCursor& cursor ) const;
bool operator != ( const wxCursor& cursor ) const;
bool Ok() const { return IsOk(); }
bool IsOk() const;

View File

@ -61,9 +61,6 @@ public:
virtual bool Ok() const { return IsOk(); }
virtual bool IsOk() const { return (m_refData != NULL) ; }
bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
// X-specific
WXColormap GetXColormap(WXDisplay* display = NULL) const;
bool TransferBitmap(void *data, int depth, int size);

View File

@ -28,8 +28,8 @@
// ----------------------------------------------------------------------------
#if wxUSE_VARIANT
IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxBitmap,WXDLLEXPORT)
IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxIcon,WXDLLEXPORT)
IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxBitmap,WXDLLEXPORT)
IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxIcon,WXDLLEXPORT)
#endif
// ----------------------------------------------------------------------------

View File

@ -49,7 +49,7 @@
#endif // HAS_FILE_STREAMS
#if wxUSE_VARIANT
IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxImage,WXDLLEXPORT)
IMPLEMENT_VARIANT_OBJECT_EXPORTED_SHALLOWCMP(wxImage,WXDLLEXPORT)
#endif
//-----------------------------------------------------------------------------

View File

@ -1023,7 +1023,7 @@ bool wxWindowBase::SetCursor(const wxCursor& cursor)
{
// setting an invalid cursor is ok, it means that we don't have any special
// cursor
if ( m_cursor == cursor )
if ( m_cursor.IsRefTo(&cursor) )
{
// no change
return false;

View File

@ -194,12 +194,6 @@ bool wxBitmap::IsOk() const
return (m_refData != NULL && M_BITMAP->m_surface);
}
bool wxBitmap::operator==(const wxBitmap& bmp) const
{
// FIXME: is this the right way to compare bitmaps?
return (m_refData == bmp.m_refData);
}
int wxBitmap::GetHeight() const
{
wxCHECK_MSG( Ok(), -1, wxT("invalid bitmap") );
@ -236,6 +230,7 @@ void wxBitmap::SetMask(wxMask *mask)
{
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
AllocExclusive();
delete M_BITMAP->m_mask;
M_BITMAP->m_mask = mask;
}
@ -328,6 +323,7 @@ void wxBitmap::SetPalette(const wxPalette& palette)
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") );
AllocExclusive();
delete M_BITMAP->m_palette;
M_BITMAP->m_palette = NULL;

View File

@ -68,25 +68,6 @@ bool wxCursor::IsOk() const
return m_refData && M_CURSOR->m_bitmap.Ok();
}
bool wxCursor::operator==(const wxCursor& cursor) const
{
if ( Ok() )
{
if ( !cursor.Ok() )
return false;
else if ( M_CURSOR->m_id != M_CURSOR_OF(cursor)->m_id )
return false;
else if ( M_CURSOR->m_id == -1 ) // non-stock cursor
return (m_refData == cursor.m_refData);
else
return true; // IDs != -1 and are the same
}
else
{
return !cursor.Ok();
}
}
wxObjectRefData *wxCursor::CreateRefData() const
{
return new wxCursorRefData;

View File

@ -70,16 +70,6 @@ wxPalette::~wxPalette()
{
}
bool wxPalette::operator == (const wxPalette& palette) const
{
return m_refData == palette.m_refData;
}
bool wxPalette::operator != (const wxPalette& palette) const
{
return m_refData != palette.m_refData;
}
bool wxPalette::IsOk() const
{
return (m_refData != NULL);

View File

@ -631,7 +631,7 @@ bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
if ( !bmpPrev.Ok() )
bmpPrev = m_bitmap;
if ( bmp != bmpPrev )
if ( !bmp.IsRefTo(&bmpPrev) )
m_statbmp->SetBitmap(bmp);
}
#endif // wxUSE_STATBMP

View File

@ -213,7 +213,7 @@ bool wxAnimationCtrl::Create( wxWindow *parent, wxWindowID id,
PostCreation(size);
SetBestSize(size);
if (anim != wxNullAnimation)
if (anim.IsOk())
SetAnimation(anim);
// init the timer used for animation

View File

@ -708,11 +708,6 @@ wxImage wxBitmap::ConvertToImage() const
return image;
}
bool wxBitmap::operator == ( const wxBitmap& bmp ) const
{
return m_refData == bmp.m_refData;
}
bool wxBitmap::IsOk() const
{
return (m_refData != NULL) &&

View File

@ -40,7 +40,7 @@ public:
bool operator == (const wxBrushRefData& data) const
{
return (m_style == data.m_style &&
m_stipple == data.m_stipple &&
m_stipple.IsRefTo(&data.m_stipple) &&
m_colour == data.m_colour);
}

View File

@ -310,16 +310,6 @@ wxCursor::~wxCursor()
{
}
bool wxCursor::operator == ( const wxCursor& cursor ) const
{
return m_refData == cursor.m_refData;
}
bool wxCursor::operator != ( const wxCursor& cursor ) const
{
return m_refData != cursor.m_refData;
}
bool wxCursor::IsOk() const
{
return (m_refData != NULL);

View File

@ -336,30 +336,33 @@ GdkRegion *wxRegion::GetRegion() const
// wxRegionIterator
// ----------------------------------------------------------------------------
class wxRIRefData: public wxObjectRefData
wxRegionIterator::wxRegionIterator()
{
public:
wxRIRefData() { Init(); }
virtual ~wxRIRefData();
void CreateRects( const wxRegion& r );
void Init() { m_rects = NULL; m_numRects = 0; }
wxRect *m_rects;
size_t m_numRects;
};
wxRIRefData::~wxRIRefData()
{
delete [] m_rects;
Init();
Reset();
}
void wxRIRefData::CreateRects( const wxRegion& region )
wxRegionIterator::wxRegionIterator( const wxRegion& region )
{
delete [] m_rects;
Init();
Reset(region);
}
void wxRegionIterator::Init()
{
m_rects = NULL;
m_numRects = 0;
}
wxRegionIterator::~wxRegionIterator()
{
wxDELETEA(m_rects);
}
void wxRegionIterator::CreateRects( const wxRegion& region )
{
wxDELETEA(m_rects);
m_numRects = 0;
GdkRegion *gdkregion = region.GetRegion();
if (!gdkregion)
@ -386,28 +389,16 @@ void wxRIRefData::CreateRects( const wxRegion& region )
g_free( gdkrects );
}
wxRegionIterator::wxRegionIterator()
{
m_refData = new wxRIRefData();
Reset();
}
wxRegionIterator::wxRegionIterator( const wxRegion& region )
{
m_refData = new wxRIRefData();
Reset(region);
}
void wxRegionIterator::Reset( const wxRegion& region )
{
m_region = region;
((wxRIRefData*)m_refData)->CreateRects(region);
CreateRects(region);
Reset();
}
bool wxRegionIterator::HaveRects() const
{
return m_current < ((wxRIRefData*)m_refData)->m_numRects;
return m_current < m_numRects;
}
wxRegionIterator& wxRegionIterator::operator ++ ()
@ -421,6 +412,7 @@ wxRegionIterator& wxRegionIterator::operator ++ ()
wxRegionIterator wxRegionIterator::operator ++ (int)
{
wxRegionIterator tmp = *this;
if (HaveRects())
++m_current;
@ -431,35 +423,35 @@ wxCoord wxRegionIterator::GetX() const
{
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].x;
return m_rects[m_current].x;
}
wxCoord wxRegionIterator::GetY() const
{
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].y;
return m_rects[m_current].y;
}
wxCoord wxRegionIterator::GetW() const
{
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].width;
return m_rects[m_current].width;
}
wxCoord wxRegionIterator::GetH() const
{
wxCHECK_MSG( HaveRects(), 0, _T("invalid wxRegionIterator") );
return ((wxRIRefData*)m_refData)->m_rects[m_current].height;
return m_rects[m_current].height;
}
wxRect wxRegionIterator::GetRect() const
{
wxRect r;
if( HaveRects() )
r = ((wxRIRefData*)m_refData)->m_rects[m_current];
r = m_rects[m_current];
return r;
}

View File

@ -1066,16 +1066,6 @@ wxBitmap::~wxBitmap()
{
}
bool wxBitmap::operator == ( const wxBitmap& bmp ) const
{
return m_refData == bmp.m_refData;
}
bool wxBitmap::operator != ( const wxBitmap& bmp ) const
{
return m_refData != bmp.m_refData;
}
bool wxBitmap::IsOk() const
{
return (m_refData != NULL) &&
@ -1114,6 +1104,7 @@ void wxBitmap::SetMask( wxMask *mask )
{
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
AllocExclusive();
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
M_BMPDATA->m_mask = mask;
@ -1248,25 +1239,19 @@ void wxBitmap::SetPalette(const wxPalette& WXUNUSED(palette))
void wxBitmap::SetHeight( int height )
{
if (!m_refData)
m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_height = height;
}
void wxBitmap::SetWidth( int width )
{
if (!m_refData)
m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_width = width;
}
void wxBitmap::SetDepth( int depth )
{
if (!m_refData)
m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_bpp = depth;
}

View File

@ -41,7 +41,7 @@ public:
bool operator == (const wxBrushRefData& data) const
{
return (m_style == data.m_style &&
m_stipple == data.m_stipple &&
m_stipple.IsRefTo(&data.m_stipple) &&
m_colour == data.m_colour);
}

View File

@ -316,16 +316,6 @@ wxCursor::~wxCursor()
{
}
bool wxCursor::operator == ( const wxCursor& cursor ) const
{
return m_refData == cursor.m_refData;
}
bool wxCursor::operator != ( const wxCursor& cursor ) const
{
return m_refData != cursor.m_refData;
}
bool wxCursor::IsOk() const
{
return (m_refData != NULL);

View File

@ -1281,33 +1281,25 @@ bool wxBitmap::HasAlpha() const
void wxBitmap::SetWidth(int w)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->SetWidth(w);
}
void wxBitmap::SetHeight(int h)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->SetHeight(h);
}
void wxBitmap::SetDepth(int d)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->SetDepth(d);
}
void wxBitmap::SetOk(bool isOk)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->SetOk(isOk);
}
@ -1321,18 +1313,14 @@ wxPalette *wxBitmap::GetPalette() const
void wxBitmap::SetPalette(const wxPalette& palette)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->m_bitmapPalette = palette ;
}
#endif // wxUSE_PALETTE
void wxBitmap::SetMask(wxMask *mask)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
// Remove existing mask if there is one.
delete M_BITMAPDATA->m_bitmapMask;

View File

@ -30,6 +30,18 @@ public:
wxBrushRefData(const wxBrushRefData& data);
virtual ~wxBrushRefData();
bool operator == ( const wxBrushRefData& brush ) const
{
return m_style == brush.m_style &&
m_stipple.IsRefTo(&data.m_stipple) &&
m_colour == brush.m_colour &&
m_macBrushKind == brush.m_macBrushKind &&
m_macThemeBrush == brush.m_macThemeBrush &&
m_macThemeBackground == brush.m_macThemeBackground &&
m_macThemeBackgroundExtent == brush.m_macThemeBackgroundExtent;
}
protected:
wxMacBrushKind m_macBrushKind ;
int m_style;
@ -233,3 +245,12 @@ wxMacBrushKind wxBrush::MacGetBrushKind() const
{
return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
}
bool wxBrush::operator == ( const wxBrush& brush ) const
{
if (m_refData == brush.m_refData) return true;
if (!m_refData || !brush.m_refData) return false;
return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
}

View File

@ -999,25 +999,19 @@ wxMask *wxBitmap::GetMask() const
void wxBitmap::SetWidth(int w)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->m_width = w;
}
void wxBitmap::SetHeight(int h)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->m_height = h;
}
void wxBitmap::SetDepth(int d)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
AllocExclusive();
M_BITMAPDATA->m_depth = d;
}

View File

@ -267,16 +267,6 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
delete bdc;
}
bool wxBitmap::operator == (const wxBitmap& bmp) const
{
return (m_refData == bmp.m_refData);
}
bool wxBitmap::operator != (const wxBitmap& bmp) const
{
return (m_refData != bmp.m_refData);
}
bool wxBitmap::IsOk() const
{
return (m_refData != NULL && M_BMPDATA->m_bitmap != NULL);
@ -314,6 +304,7 @@ void wxBitmap::SetMask(wxMask *mask)
{
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
AllocExclusive();
delete M_BMPDATA->m_mask;
M_BMPDATA->m_mask = mask;
}
@ -357,6 +348,7 @@ void wxBitmap::SetMonoPalette(const wxColour& fg, const wxColour& bg)
{
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
AllocExclusive();
palette_t *mono = M_BMPDATA->m_bitmap->pal;
wxCHECK_RET( M_BMPDATA->m_bpp == 1, wxT("bitmap is not 1bpp") );
@ -482,6 +474,7 @@ void wxBitmap::SetPalette(const wxPalette& palette)
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") );
AllocExclusive();
delete M_BMPDATA->m_palette;
M_BMPDATA->m_palette = NULL;
@ -496,21 +489,21 @@ void wxBitmap::SetPalette(const wxPalette& palette)
void wxBitmap::SetHeight(int height)
{
if (!m_refData) m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_height = height;
}
void wxBitmap::SetWidth(int width)
{
if (!m_refData) m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_width = width;
}
void wxBitmap::SetDepth(int depth)
{
if (!m_refData) m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_bpp = depth;
}

View File

@ -76,6 +76,13 @@ public:
wxBrushRefData();
wxBrushRefData(const wxBrushRefData& data);
bool operator == (const wxBrushRefData& data) const
{
return (m_style == data.m_style &&
m_stipple.IsRefTo(&data.m_stipple) &&
m_colour == data.m_colour);
}
int m_style;
wxColour m_colour;
wxBitmap m_stipple;
@ -145,7 +152,11 @@ wxBrush::wxBrush(const wxBitmap &stippleBitmap)
bool wxBrush::operator == (const wxBrush& brush) const
{
return m_refData == brush.m_refData;
if (m_refData == brush.m_refData) return true;
if (!m_refData || !brush.m_refData) return false;
return *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData;
}
bool wxBrush::operator != (const wxBrush& brush) const

View File

@ -175,16 +175,6 @@ wxCursor::~wxCursor()
// wxObject unrefs data
}
bool wxCursor::operator == (const wxCursor& cursor) const
{
return (m_refData == cursor.m_refData);
}
bool wxCursor::operator != (const wxCursor& cursor) const
{
return (m_refData != cursor.m_refData);
}
bool wxCursor::IsOk() const
{
return (m_refData != NULL);

View File

@ -63,16 +63,6 @@ wxPalette::~wxPalette()
{
}
bool wxPalette::operator == (const wxPalette& palette) const
{
return m_refData == palette.m_refData;
}
bool wxPalette::operator != (const wxPalette& palette) const
{
return m_refData != palette.m_refData;
}
bool wxPalette::IsOk(void) const
{
return (m_refData != NULL);

View File

@ -33,6 +33,21 @@ class wxPenRefData: public wxObjectRefData
wxPenRefData();
wxPenRefData(const wxPenRefData& data);
bool operator==(const wxPenRefData& data) const
{
// we intentionally don't compare m_hPen fields here
return m_style == data.m_style &&
m_width == data.m_width &&
m_pixPattern == data.m_pixPattern &&
m_capStyle == data.m_capStyle &&
m_joinStyle == data.m_joinStyle &&
m_colour == data.m_colour &&
(m_style != wxSTIPPLE || m_stipple.IsRefTo(&data.m_stipple)) &&
(m_style != wxUSER_DASH ||
(m_dash == data.m_dash &&
memcmp(m_dash, data.m_dash, m_countDashes*sizeof(wxDash)) == 0));
}
int m_width;
int m_style;
wxColour m_colour;
@ -109,7 +124,11 @@ wxPen::wxPen(const wxBitmap& stipple, int width)
bool wxPen::operator == (const wxPen& pen) const
{
return m_refData == pen.m_refData;
if (m_refData == pen.m_refData) return true;
if (!m_refData || !pen.m_refData) return false;
return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
}
bool wxPen::operator != (const wxPen& pen) const

View File

@ -130,16 +130,6 @@ wxAcceleratorTable::wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]
M_ACCELDATA->m_ok = (M_ACCELDATA->m_hAccel != 0);
}
bool wxAcceleratorTable::operator==(const wxAcceleratorTable& accel) const
{
const wxAcceleratorRefData *
accelData = (wxAcceleratorRefData *)accel.m_refData;
return m_refData ? (accelData &&
M_ACCELDATA->m_hAccel == accelData->m_hAccel)
: !accelData;
}
bool wxAcceleratorTable::IsOk() const
{
return (M_ACCELDATA && (M_ACCELDATA->m_ok));

View File

@ -124,7 +124,7 @@ bool wxBrushRefData::operator==(const wxBrushRefData& data) const
// don't compare HBRUSHes
return m_style == data.m_style &&
m_colour == data.m_colour &&
m_stipple == data.m_stipple;
m_stipple.IsRefTo(&data.m_stipple);
}
void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)

View File

@ -386,16 +386,6 @@ wxCursor::~wxCursor()
// other wxCursor functions
// ----------------------------------------------------------------------------
bool wxCursor::operator==(const wxCursor& cursor) const
{
if ( !m_refData )
return !cursor.m_refData;
return cursor.m_refData &&
((wxCursorRefData *)m_refData)->m_hCursor ==
((wxCursorRefData *)cursor.m_refData)->m_hCursor;
}
wxGDIImageRefData *wxCursor::CreateData() const
{
return new wxCursorRefData;

View File

@ -108,11 +108,6 @@ wxCursor::~wxCursor()
// other wxCursor functions
// ----------------------------------------------------------------------------
bool wxCursor::operator==(const wxCursor& cursor) const
{
return false;
}
wxGDIImageRefData *wxCursor::CreateData() const
{
return NULL;

View File

@ -917,16 +917,6 @@ wxBitmap::~wxBitmap()
{
}
bool wxBitmap::operator == ( const wxBitmap& bmp ) const
{
return m_refData == bmp.m_refData;
}
bool wxBitmap::operator != ( const wxBitmap& bmp ) const
{
return m_refData != bmp.m_refData;
}
bool wxBitmap::IsOk() const
{
return (m_refData != NULL);
@ -964,6 +954,7 @@ void wxBitmap::SetMask( wxMask *mask )
{
wxCHECK_RET( Ok(), wxT("invalid bitmap") );
AllocExclusive();
if (M_BMPDATA->m_mask) delete M_BMPDATA->m_mask;
M_BMPDATA->m_mask = mask;
@ -1070,6 +1061,7 @@ void wxBitmap::SetPalette(const wxPalette& palette)
wxCHECK_RET(GetDepth() > 1 && GetDepth() <= 8,
wxT("cannot set palette for bitmap of this depth"));
AllocExclusive();
delete M_BMPDATA->m_palette;
M_BMPDATA->m_palette = NULL;
@ -1087,21 +1079,21 @@ wxPalette *wxBitmap::GetPalette() const
void wxBitmap::SetHeight( int height )
{
if (!m_refData) m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_height = height;
}
void wxBitmap::SetWidth( int width )
{
if (!m_refData) m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_width = width;
}
void wxBitmap::SetDepth( int depth )
{
if (!m_refData) m_refData = new wxBitmapRefData();
AllocExclusive();
M_BMPDATA->m_bpp = depth;
}

Some files were not shown because too many files have changed in this diff Show More